mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2024-11-24 10:26:11 +03:00
[PepperBridgeAbstract, DealabsBridge, HotUKDealsBridge, MydealsBridge] Streamlining Group Management (#4336)
* [PepperBridgeAbstract, DealabsBridge, HotUKDealsBridge, MydealsBridge] Streamlining Group Management Since groups can change URLs, be created, or removed at the discretion of website administrators, maintaining a valid and functional list of groups is impractical. Users can now enter the part of the URL that defines the group in a text field, rather than searching through a lengthy, likely outdated list. The way the RSS feed title is retrieved had to be adjusted accordingly. Titles are now cached for 15 days to avoid unnecessary website access and to prevent potential bot blocking. Existing feeds will continue to work, as their parameters remain unchanged; only the method for inputting them has been modified. * [PepperBridgeAbstract, DealabsBridge, HotUKDealsBridge, MydealsBridge] Streamlining Group Management Coding policy fixes * [PepperBridgeAbstract, DealabsBridge, HotUKDealsBridge, MydealsBridge] Streamlining Group Management Fix wrong comment * [PepperBridgeAbstract, DealabsBridge, HotUKDealsBridge, MydealsBridge] Streamlining Group Management Add Example values for Group context
This commit is contained in:
parent
a6e8760726
commit
2ee615e588
4 changed files with 69 additions and 6977 deletions
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
@ -263,11 +263,40 @@ HEREDOC;
|
|||
*/
|
||||
private function getTalkTitle()
|
||||
{
|
||||
$cacheKey = $this->getInput('url') . 'TITLE';
|
||||
$title = $this->loadCacheValue($cacheKey);
|
||||
// The cache does not contain the title of the bridge, we must get it and save it in the cache
|
||||
if ($title === null) {
|
||||
$html = getSimpleHTMLDOMCached($this->getInput('url'));
|
||||
$title = $html->find('title', 0)->plaintext;
|
||||
// Save the value in the cache for the next 15 days
|
||||
$this->saveCacheValue($cacheKey, $title, 86400 * 15);
|
||||
}
|
||||
return $title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Title from a Group if it exists
|
||||
* @return string String of the Talk title
|
||||
*/
|
||||
private function getGroupTitle()
|
||||
{
|
||||
$cacheKey = $this->getInput('group') . 'TITLE';
|
||||
$title = $this->loadCacheValue($cacheKey);
|
||||
// The cache does not contain the title of the bridge, we must get it and save it in the cache
|
||||
if ($title == null) {
|
||||
$html = getSimpleHTMLDOMCached($this->getGroupURI());
|
||||
// Search the title in the javascript mess
|
||||
preg_match('/threadGroupName":"([^"]*)","threadGroupUrlName":"' . $this->getInput('group') . '"/m', $html, $matches);
|
||||
$title = $matches[1];
|
||||
// Save the value in the cache for the next 15 days
|
||||
$this->saveCacheValue($cacheKey, $title, 86400 * 15);
|
||||
}
|
||||
|
||||
$order = $this->getKey('order');
|
||||
return $title . ' - ' . $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the HTML Title code from an item
|
||||
* @return string String of the deal title
|
||||
|
@ -429,7 +458,7 @@ HEREDOC;
|
|||
return $this->i8n('bridge-name') . ' - ' . $this->i8n('title-keyword') . ' : ' . $this->getInput('q');
|
||||
break;
|
||||
case $this->i8n('context-group'):
|
||||
return $this->i8n('bridge-name') . ' - ' . $this->i8n('title-group') . ' : ' . $this->getKey('group');
|
||||
return $this->i8n('bridge-name') . ' - ' . $this->i8n('title-group') . ' : ' . $this->getGroupTitle();
|
||||
break;
|
||||
case $this->i8n('context-talk'):
|
||||
return $this->i8n('bridge-name') . ' - ' . $this->i8n('title-talk') . ' : ' . $this->getTalkTitle();
|
||||
|
@ -496,8 +525,15 @@ HEREDOC;
|
|||
$group = $this->getInput('group');
|
||||
$order = $this->getInput('order');
|
||||
|
||||
// This permit to keep the existing Feed to work
|
||||
if ($order == $this->i8n('context-hot')) {
|
||||
$sortBy = 'temp';
|
||||
} else if ($order == $this->i8n('context-new')) {
|
||||
$sortBy = 'new';
|
||||
}
|
||||
|
||||
$url = $this->i8n('bridge-uri')
|
||||
. $this->i8n('uri-group') . $group . $order;
|
||||
. $this->i8n('uri-group') . $group . '?sortBy=' . $sortBy;
|
||||
return $url;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue