added the option for a sessioncookie in heiseBridge (#3596)

* added the option for a sessioncookie

with a valid cookie you can get full heise+ (paywall) articles

* formating

* lint

---------

Co-authored-by: Dag <me@dvikan.no>
This commit is contained in:
Tone 2023-08-03 22:43:55 +02:00 committed by GitHub
parent 7661a78a43
commit d32419ffcf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 2 deletions

View File

@ -103,6 +103,16 @@ class HeiseBridge extends FeedExpander
'required' => false,
'title' => 'Specify number of full articles to return',
'defaultValue' => 5
],
'sessioncookie' => [
'name' => 'Session Cookie',
'required' => false,
'title' => <<<'TITLE'
If you have a heise+ subscription,
you can enter your cookie (ssohls) here to
have heise+ articles displayed in full.
By default the cookie is 1 year valid.
TITLE,
]
]];
const LIMIT = 5;
@ -118,6 +128,7 @@ class HeiseBridge extends FeedExpander
protected function parseItem($feedItem)
{
$item = parent::parseItem($feedItem);
$sessioncookie = $this->getInput('sessioncookie');
// strip rss parameter
$item['uri'] = explode('?', $item['uri'])[0];
@ -128,13 +139,15 @@ class HeiseBridge extends FeedExpander
}
// abort on heise+ articles and link to archive.ph for full-text content
if (str_starts_with($item['title'], 'heise+ |')) {
if ($sessioncookie == '' && str_starts_with($item['title'], 'heise+ |')) {
$item['uri'] = 'https://archive.ph/?run=1&url=' . urlencode($item['uri']);
return $item;
}
$item['uri'] .= '?seite=all';
$article = getSimpleHTMLDOMCached($item['uri']);
$article = getSimpleHTMLDOM($item['uri'], [
'cookie: ssohls=' . $sessioncookie
]);
if ($article) {
$article = defaultLinkTo($article, $item['uri']);