mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-24 17:13:27 +02:00
Compare commits
48 Commits
2018-04-20
...
2018-07-17
Author | SHA1 | Date | |
---|---|---|---|
|
6a98293fb3 | ||
|
d79630e3b8 | ||
|
1f2fe25471 | ||
|
87fc9e9156 | ||
|
c7b0c9fd31 | ||
|
fbf874cb29 | ||
|
049ee52fb5 | ||
|
3f41d0593a | ||
|
7126f5e838 | ||
|
ead7b2e8de | ||
|
0d80a19e84 | ||
|
42c699f474 | ||
|
2bc8daa101 | ||
|
bca79d3f88 | ||
|
90dc968fd1 | ||
|
da6b98851c | ||
|
71c29d4192 | ||
|
193ca87afa | ||
|
5ea79ac1fc | ||
|
937ea49271 | ||
|
95686b803c | ||
|
5087f5f79e | ||
|
4a5f190e0e | ||
|
01a2746715 | ||
|
f4a60c1777 | ||
|
1b08bce779 | ||
|
9fa74a36c6 | ||
|
7493e2b5b8 | ||
|
8e468a9ca7 | ||
|
50924b9213 | ||
|
4c5013bc82 | ||
|
7dc09db9ca | ||
|
d92da8f0f7 | ||
|
064ba456e8 | ||
|
8ac8e08abf | ||
|
c4f32c31a8 | ||
|
4369e077c2 | ||
|
1045850043 | ||
|
2d8f4dc3c5 | ||
|
779b638fb4 | ||
|
3ca59392c2 | ||
|
9b34b68180 | ||
|
79ebdc4b39 | ||
|
8770c87389 | ||
|
c1e3352218 | ||
|
00570ce1b4 | ||
|
df33dcff4e | ||
|
e60b5ab193 |
8
.dockerignore
Normal file
8
.dockerignore
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
.git
|
||||||
|
cache/*
|
||||||
|
DEBUG
|
||||||
|
Dockerfile
|
||||||
|
whitelist.txt
|
||||||
|
phpcs.xml
|
||||||
|
CHANGELOG.md
|
||||||
|
CONTRIBUTING.md
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -227,6 +227,7 @@ pip-log.txt
|
|||||||
/cache
|
/cache
|
||||||
/whitelist.txt
|
/whitelist.txt
|
||||||
DEBUG
|
DEBUG
|
||||||
|
config.ini.php
|
||||||
|
|
||||||
######################
|
######################
|
||||||
## VisualStudioCode ##
|
## VisualStudioCode ##
|
||||||
|
5
Dockerfile
Normal file
5
Dockerfile
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
FROM ulsmith/alpine-apache-php7
|
||||||
|
|
||||||
|
COPY ./ /app/public/
|
||||||
|
|
||||||
|
RUN chown -R apache:root /app/public
|
@@ -53,7 +53,7 @@ Requirements
|
|||||||
|
|
||||||
* PHP 5.6, e.g. `AddHandler application/x-httpd-php56 .php` in `.htaccess`
|
* PHP 5.6, e.g. `AddHandler application/x-httpd-php56 .php` in `.htaccess`
|
||||||
* `openssl` extension enabled in PHP config (`php.ini`)
|
* `openssl` extension enabled in PHP config (`php.ini`)
|
||||||
* `allow_url_fopen=1` in `php.ini`
|
* `curl` extension enabled in PHP config (`php.ini`)
|
||||||
|
|
||||||
Enabling/Disabling bridges
|
Enabling/Disabling bridges
|
||||||
===
|
===
|
||||||
|
149
bridges/AmazonPriceTrackerBridge.php
Normal file
149
bridges/AmazonPriceTrackerBridge.php
Normal file
@@ -0,0 +1,149 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
class AmazonPriceTrackerBridge extends BridgeAbstract {
|
||||||
|
const MAINTAINER = 'captn3m0';
|
||||||
|
const NAME = 'Amazon Price Tracker';
|
||||||
|
const URI = 'https://www.amazon.com/';
|
||||||
|
const CACHE_TIMEOUT = 3600; // 1h
|
||||||
|
const DESCRIPTION = 'Tracks price for a single product on Amazon';
|
||||||
|
|
||||||
|
const PARAMETERS = array(
|
||||||
|
array(
|
||||||
|
'asin' => array(
|
||||||
|
'name' => 'ASIN',
|
||||||
|
'required' => true,
|
||||||
|
'exampleValue' => 'B071GB1VMQ',
|
||||||
|
// https://stackoverflow.com/a/12827734
|
||||||
|
'pattern' => 'B[\dA-Z]{9}|\d{9}(X|\d)',
|
||||||
|
),
|
||||||
|
'tld' => array(
|
||||||
|
'name' => 'Country',
|
||||||
|
'type' => 'list',
|
||||||
|
'required' => true,
|
||||||
|
'values' => array(
|
||||||
|
'Australia' => 'com.au',
|
||||||
|
'Brazil' => 'com.br',
|
||||||
|
'Canada' => 'ca',
|
||||||
|
'China' => 'cn',
|
||||||
|
'France' => 'fr',
|
||||||
|
'Germany' => 'de',
|
||||||
|
'India' => 'in',
|
||||||
|
'Italy' => 'it',
|
||||||
|
'Japan' => 'co.jp',
|
||||||
|
'Mexico' => 'com.mx',
|
||||||
|
'Netherlands' => 'nl',
|
||||||
|
'Spain' => 'es',
|
||||||
|
'United Kingdom' => 'co.uk',
|
||||||
|
'United States' => 'com',
|
||||||
|
),
|
||||||
|
'defaultValue' => 'com',
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
protected $title;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates domain name given a amazon TLD
|
||||||
|
*/
|
||||||
|
private function getDomainName() {
|
||||||
|
return 'https://www.amazon.' . $this->getInput('tld');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generates URI for a Amazon product page
|
||||||
|
*/
|
||||||
|
public function getURI() {
|
||||||
|
if (!is_null($this->getInput('asin'))) {
|
||||||
|
return $this->getDomainName() . '/dp/' . $this->getInput('asin') . '/';
|
||||||
|
}
|
||||||
|
return parent::getURI();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scrapes the product title from the html page
|
||||||
|
* returns the default title if scraping fails
|
||||||
|
*/
|
||||||
|
private function getTitle($html) {
|
||||||
|
$titleTag = $html->find('#productTitle', 0);
|
||||||
|
|
||||||
|
if (!$titleTag) {
|
||||||
|
return $this->getDefaultTitle();
|
||||||
|
} else {
|
||||||
|
return trim(html_entity_decode($titleTag->innertext, ENT_QUOTES));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Title used by the feed if none could be found
|
||||||
|
*/
|
||||||
|
private function getDefaultTitle() {
|
||||||
|
return 'Amazon.' . $this->getInput('tld') . ': ' . $this->getInput('asin');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns name for the feed
|
||||||
|
* Uses title (already scraped) if it has one
|
||||||
|
*/
|
||||||
|
public function getName() {
|
||||||
|
if (isset($this->title)) {
|
||||||
|
return $this->title;
|
||||||
|
} else {
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a generated image tag for the product
|
||||||
|
*/
|
||||||
|
private function getImage($html) {
|
||||||
|
$imageSrc = $html->find('#main-image-container img', 0);
|
||||||
|
|
||||||
|
if ($imageSrc) {
|
||||||
|
$imageSrc = $imageSrc ? $imageSrc->getAttribute('data-old-hires') : '';
|
||||||
|
return <<<EOT
|
||||||
|
<img width="300" style="max-width:300;max-height:300" src="$imageSrc" alt="{$this->title}" />
|
||||||
|
EOT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return \simple_html_dom object
|
||||||
|
* for the entire html of the product page
|
||||||
|
*/
|
||||||
|
private function getHtml() {
|
||||||
|
$uri = $this->getURI();
|
||||||
|
|
||||||
|
return getSimpleHTMLDOM($uri) ?: returnServerError('Could not request Amazon.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Scrape method for Amazon product page
|
||||||
|
* @return [type] [description]
|
||||||
|
*/
|
||||||
|
public function collectData() {
|
||||||
|
$html = $this->getHtml();
|
||||||
|
$this->title = $this->getTitle($html);
|
||||||
|
$imageTag = $this->getImage($html);
|
||||||
|
|
||||||
|
$asinData = $html->find('#cerberus-data-metrics', 0);
|
||||||
|
|
||||||
|
// <div id="cerberus-data-metrics" style="display: none;"
|
||||||
|
// data-asin="B00WTHJ5SU" data-asin-price="14.99" data-asin-shipping="0"
|
||||||
|
// data-asin-currency-code="USD" data-substitute-count="-1" ... />
|
||||||
|
$currency = $asinData->getAttribute('data-asin-currency-code');
|
||||||
|
$shipping = $asinData->getAttribute('data-asin-shipping');
|
||||||
|
$price = $asinData->getAttribute('data-asin-price');
|
||||||
|
|
||||||
|
$item = array(
|
||||||
|
'title' => $this->title,
|
||||||
|
'uri' => $this->getURI(),
|
||||||
|
'content' => "$imageTag<br/>Price: $price $currency",
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($shipping !== '0') {
|
||||||
|
$item['content'] .= "<br>Shipping: $shipping $currency</br>";
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
|
}
|
@@ -19,7 +19,7 @@ class BlaguesDeMerdeBridge extends BridgeAbstract {
|
|||||||
$item['content'] = trim($element->find('div.joke_text_contener', 0)->innertext);
|
$item['content'] = trim($element->find('div.joke_text_contener', 0)->innertext);
|
||||||
$uri = $temp[2]->href;
|
$uri = $temp[2]->href;
|
||||||
$item['uri'] = $uri;
|
$item['uri'] = $uri;
|
||||||
$item['title'] = substr($uri, (strrpos($uri, "/") + 1));
|
$item['title'] = substr($uri, (strrpos($uri, '/') + 1));
|
||||||
$date = $element->find('li.bdm_date', 0)->innertext;
|
$date = $element->find('li.bdm_date', 0)->innertext;
|
||||||
$time = mktime(0, 0, 0, substr($date, 3, 2), substr($date, 0, 2), substr($date, 6, 4));
|
$time = mktime(0, 0, 0, substr($date, 3, 2), substr($date, 0, 2), substr($date, 6, 4));
|
||||||
$item['timestamp'] = $time;
|
$item['timestamp'] = $time;
|
||||||
|
@@ -23,14 +23,14 @@ class CADBridge extends FeedExpander {
|
|||||||
if($html3 == false)
|
if($html3 == false)
|
||||||
return 'Daily comic not released yet';
|
return 'Daily comic not released yet';
|
||||||
|
|
||||||
$htmlpart = explode("/", $url);
|
$htmlpart = explode('/', $url);
|
||||||
|
|
||||||
switch ($htmlpart[3]) {
|
switch ($htmlpart[3]) {
|
||||||
case 'cad':
|
case 'cad':
|
||||||
preg_match_all("/http:\/\/cdn2\.cad-comic\.com\/comics\/cad-\S*png/", $html3, $url2);
|
preg_match_all('/http:\/\/cdn2\.cad-comic\.com\/comics\/cad-\S*png/', $html3, $url2);
|
||||||
break;
|
break;
|
||||||
case 'sillies':
|
case 'sillies':
|
||||||
preg_match_all("/http:\/\/cdn2\.cad-comic\.com\/comics\/sillies-\S*gif/", $html3, $url2);
|
preg_match_all('/http:\/\/cdn2\.cad-comic\.com\/comics\/sillies-\S*gif/', $html3, $url2);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return 'Daily comic not released yet';
|
return 'Daily comic not released yet';
|
||||||
|
25
bridges/ChristianDailyReporterBridge.php
Normal file
25
bridges/ChristianDailyReporterBridge.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
class ChristianDailyReporterBridge extends BridgeAbstract {
|
||||||
|
|
||||||
|
const MAINTAINER = 'rogerdc';
|
||||||
|
const NAME = 'Christian Daily Reporter Unofficial RSS';
|
||||||
|
const URI = 'https://www.christiandailyreporter.com/';
|
||||||
|
const DESCRIPTION = 'The Unofficial Christian Daily Reporter RSS';
|
||||||
|
// const CACHE_TIMEOUT = 86400; // 1 day
|
||||||
|
|
||||||
|
|
||||||
|
public function collectData() {
|
||||||
|
$uri = 'https://www.christiandailyreporter.com/';
|
||||||
|
|
||||||
|
$html = getSimpleHTMLDOM($uri)
|
||||||
|
or returnServerError('Could not request Christian Daily Reporter.');
|
||||||
|
foreach($html->find('div.top p a,div.column p a') as $element) {
|
||||||
|
$item = array();
|
||||||
|
// Title
|
||||||
|
$item['title'] = $element->innertext;
|
||||||
|
// URL
|
||||||
|
$item['uri'] = $element->href;
|
||||||
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
93
bridges/ContainerLinuxReleasesBridge.php
Normal file
93
bridges/ContainerLinuxReleasesBridge.php
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
<?php
|
||||||
|
class ContainerLinuxReleasesBridge extends BridgeAbstract {
|
||||||
|
|
||||||
|
const MAINTAINER = 'captn3m0';
|
||||||
|
const NAME = 'Core OS Container Linux Releases Bridge';
|
||||||
|
const URI = 'https://coreos.com/releases/';
|
||||||
|
const DESCRIPTION = 'Returns the releases notes for Container Linux';
|
||||||
|
|
||||||
|
const STABLE = 'stable';
|
||||||
|
const BETA = 'beta';
|
||||||
|
const ALPHA = 'alpha';
|
||||||
|
|
||||||
|
const PARAMETERS = [
|
||||||
|
[
|
||||||
|
'channel' => [
|
||||||
|
'name' => 'Release Channel',
|
||||||
|
'type' => 'list',
|
||||||
|
'required' => true,
|
||||||
|
'defaultValue' => self::STABLE,
|
||||||
|
'values' => [
|
||||||
|
'Stable' => self::STABLE,
|
||||||
|
'Beta' => self::BETA,
|
||||||
|
'Alpha' => self::ALPHA,
|
||||||
|
],
|
||||||
|
]
|
||||||
|
]
|
||||||
|
];
|
||||||
|
|
||||||
|
public function getReleaseFeed($jsonUrl) {
|
||||||
|
$json = getContents($jsonUrl)
|
||||||
|
or returnServerError('Could not request Core OS Website.');
|
||||||
|
return json_decode($json, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function collectData() {
|
||||||
|
$data = $this->getReleaseFeed($this->getJsonUri());
|
||||||
|
|
||||||
|
foreach ($data as $releaseVersion => $release) {
|
||||||
|
$item = [];
|
||||||
|
|
||||||
|
$item['uri'] = "https://coreos.com/releases/#$releaseVersion";
|
||||||
|
$item['title'] = $releaseVersion;
|
||||||
|
|
||||||
|
$content = $release['release_notes'];
|
||||||
|
$content .= <<<EOT
|
||||||
|
|
||||||
|
Major Software:
|
||||||
|
* Kernel: {$release['major_software']['kernel'][0]}
|
||||||
|
* Docker: {$release['major_software']['docker'][0]}
|
||||||
|
* etcd: {$release['major_software']['etcd'][0]}
|
||||||
|
EOT;
|
||||||
|
$item['timestamp'] = strtotime($release['release_date']);
|
||||||
|
|
||||||
|
// Based on https://gist.github.com/jbroadway/2836900
|
||||||
|
// Links
|
||||||
|
$regex = '/\[([^\[]+)\]\(([^\)]+)\)/';
|
||||||
|
$replacement = '<a href=\'\2\'>\1</a>';
|
||||||
|
$item['content'] = preg_replace($regex, $replacement, $content);
|
||||||
|
|
||||||
|
// Headings
|
||||||
|
$regex = '/^(.*)\:\s?$/m';
|
||||||
|
$replacement = '<h3>\1</h3>';
|
||||||
|
$item['content'] = preg_replace($regex, $replacement, $item['content']);
|
||||||
|
|
||||||
|
// Lists
|
||||||
|
$regex = '/\n\s*[\*|\-](.*)/';
|
||||||
|
$item['content'] = preg_replace_callback ($regex, function($regs) {
|
||||||
|
$item = $regs[1];
|
||||||
|
return sprintf ('<ul><li>%s</li></ul>', trim ($item));
|
||||||
|
}, $item['content']);
|
||||||
|
|
||||||
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getJsonUri() {
|
||||||
|
$channel = $this->getInput('channel');
|
||||||
|
|
||||||
|
return "https://coreos.com/releases/releases-$channel.json";
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getURI() {
|
||||||
|
return self::URI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('channel'))) {
|
||||||
|
return 'Container Linux Releases: ' . $this->getInput('channel') . ' Channel';
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
|
}
|
@@ -25,7 +25,7 @@ class CopieDoubleBridge extends BridgeAbstract {
|
|||||||
} elseif(strpos($element->innertext, '/images/suivant.gif') === false) {
|
} elseif(strpos($element->innertext, '/images/suivant.gif') === false) {
|
||||||
$a = $element->find('a', 0);
|
$a = $element->find('a', 0);
|
||||||
$item['uri'] = self::URI . $a->href;
|
$item['uri'] = self::URI . $a->href;
|
||||||
$content = str_replace('src="/', 'src="/' . self::URI, $element->find("td", 0)->innertext);
|
$content = str_replace('src="/', 'src="/' . self::URI, $element->find('td', 0)->innertext);
|
||||||
$content = str_replace('href="/', 'href="' . self::URI, $content);
|
$content = str_replace('href="/', 'href="' . self::URI, $content);
|
||||||
$item['content'] = $content;
|
$item['content'] = $content;
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
|
@@ -11,7 +11,7 @@ class CourrierInternationalBridge extends BridgeAbstract {
|
|||||||
$html = getSimpleHTMLDOM(self::URI)
|
$html = getSimpleHTMLDOM(self::URI)
|
||||||
or returnServerError('Error.');
|
or returnServerError('Error.');
|
||||||
|
|
||||||
$element = $html->find("article");
|
$element = $html->find('article');
|
||||||
$article_count = 1;
|
$article_count = 1;
|
||||||
|
|
||||||
foreach($element as $article) {
|
foreach($element as $article) {
|
||||||
|
@@ -16,7 +16,7 @@ class CpasbienBridge extends BridgeAbstract {
|
|||||||
));
|
));
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
$request = str_replace(" ", "-", trim($this->getInput('q')));
|
$request = str_replace(' ', '-', trim($this->getInput('q')));
|
||||||
$html = getSimpleHTMLDOM(self::URI . '/recherche/' . urlencode($request) . '.html')
|
$html = getSimpleHTMLDOM(self::URI . '/recherche/' . urlencode($request) . '.html')
|
||||||
or returnServerError('No results for this query.');
|
or returnServerError('No results for this query.');
|
||||||
|
|
||||||
|
@@ -41,7 +41,7 @@ class DanbooruBridge extends BridgeAbstract {
|
|||||||
|
|
||||||
$item = array();
|
$item = array();
|
||||||
$item['uri'] = $element->find('a', 0)->href;
|
$item['uri'] = $element->find('a', 0)->href;
|
||||||
$item['postid'] = (int)preg_replace("/[^0-9]/", '', $element->getAttribute(static::IDATTRIBUTE));
|
$item['postid'] = (int)preg_replace('/[^0-9]/', '', $element->getAttribute(static::IDATTRIBUTE));
|
||||||
$item['timestamp'] = time();
|
$item['timestamp'] = time();
|
||||||
$thumbnailUri = $element->find('img', 0)->src;
|
$thumbnailUri = $element->find('img', 0)->src;
|
||||||
$item['tags'] = $this->getTags($element);
|
$item['tags'] = $this->getTags($element);
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
class DealabsBridge extends BridgeAbstract {
|
class DealabsBridge extends PepperBridgeAbstract {
|
||||||
const NAME = 'Dealabs search bridge';
|
|
||||||
|
const NAME = 'Dealabs Bridge';
|
||||||
const URI = 'https://www.dealabs.com/';
|
const URI = 'https://www.dealabs.com/';
|
||||||
const DESCRIPTION = 'Return the Dealabs search result using keywords';
|
const DESCRIPTION = 'Affiche les Deals de Dealabs';
|
||||||
const MAINTAINER = 'sysadminstory';
|
const MAINTAINER = 'sysadminstory';
|
||||||
const PARAMETERS = array(
|
const PARAMETERS = array(
|
||||||
'Recherche par Mot(s) clé(s)' => array (
|
'Recherche par Mot(s) clé(s)' => array (
|
||||||
@@ -39,7 +40,7 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
),
|
),
|
||||||
|
|
||||||
'Deals par groupe' => array(
|
'Deals par groupe' => array(
|
||||||
'groupe' => array(
|
'group' => array(
|
||||||
'name' => 'Groupe',
|
'name' => 'Groupe',
|
||||||
'type' => 'list',
|
'type' => 'list',
|
||||||
'required' => 'true',
|
'required' => 'true',
|
||||||
@@ -61,10 +62,10 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
'Services divers' => 'services-divers',
|
'Services divers' => 'services-divers',
|
||||||
'Sports & plein air' => 'sports-plein-air',
|
'Sports & plein air' => 'sports-plein-air',
|
||||||
'Téléphonie' => 'telephonie',
|
'Téléphonie' => 'telephonie',
|
||||||
'Voyages & sorties' => 'voyages-sorties-restaurants'
|
'Voyages & sorties' => 'voyages-sorties-restaurants',
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'ordre' => array(
|
'order' => array(
|
||||||
'name' => 'Trier par',
|
'name' => 'Trier par',
|
||||||
'type' => 'list',
|
'type' => 'list',
|
||||||
'required' => 'true',
|
'required' => 'true',
|
||||||
@@ -78,37 +79,99 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
public $lang = array(
|
||||||
|
'bridge-uri' => SELF::URI,
|
||||||
|
'bridge-name' => SELF::NAME,
|
||||||
|
'context-keyword' => 'Recherche par Mot(s) clé(s)',
|
||||||
|
'context-group' => 'Deals par groupe',
|
||||||
|
'uri-group' => '/groupe/',
|
||||||
|
'request-error' => 'Could not request Dealabs',
|
||||||
|
'no-results' => 'Il n'y a rien à afficher pour le moment :(',
|
||||||
|
'relative-date-indicator' => array(
|
||||||
|
'il y a',
|
||||||
|
),
|
||||||
|
'price' => 'Prix',
|
||||||
|
'shipping' => 'Livraison',
|
||||||
|
'origin' => 'Origine',
|
||||||
|
'discount' => 'Réduction',
|
||||||
|
'title-keyword' => 'Recherche',
|
||||||
|
'title-group' => 'Groupe',
|
||||||
|
'local-months' => array(
|
||||||
|
'janvier',
|
||||||
|
'février',
|
||||||
|
'mars',
|
||||||
|
'avril',
|
||||||
|
'mai',
|
||||||
|
'juin',
|
||||||
|
'juillet',
|
||||||
|
'août',
|
||||||
|
'septembre',
|
||||||
|
'octobre',
|
||||||
|
'novembre',
|
||||||
|
'décembre'
|
||||||
|
),
|
||||||
|
'local-time-relative' => array(
|
||||||
|
'il y a ',
|
||||||
|
'min',
|
||||||
|
'h',
|
||||||
|
'jour',
|
||||||
|
'jours',
|
||||||
|
'mois',
|
||||||
|
'ans',
|
||||||
|
'et '
|
||||||
|
),
|
||||||
|
'date-prefixes' => array(
|
||||||
|
'Actualisé ',
|
||||||
|
),
|
||||||
|
'relative-date-alt-prefixes' => array(
|
||||||
|
'Actualisé ',
|
||||||
|
),
|
||||||
|
'relative-date-ignore-suffix' => array(
|
||||||
|
),
|
||||||
|
|
||||||
|
'localdeal' => array(
|
||||||
|
'Local',
|
||||||
|
'Pays d\'expédition'
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class PepperBridgeAbstract extends BridgeAbstract {
|
||||||
|
|
||||||
const CACHE_TIMEOUT = 3600;
|
const CACHE_TIMEOUT = 3600;
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
switch($this->queriedContext) {
|
switch($this->queriedContext) {
|
||||||
case 'Recherche par Mot(s) clé(s)':
|
case $this->i8n('context-keyword'):
|
||||||
return $this->collectDataMotsCles();
|
return $this->collectDataKeywords();
|
||||||
break;
|
break;
|
||||||
case 'Deals par groupe':
|
case $this->i8n('context-group'):
|
||||||
return $this->collectDataGroupe();
|
return $this->collectDataGroup();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Deal data from the choosen groupe in the choose order
|
* Get the Deal data from the choosen group in the choosed order
|
||||||
*/
|
*/
|
||||||
public function collectDataGroupe()
|
public function collectDataGroup()
|
||||||
{
|
{
|
||||||
|
|
||||||
$groupe = $this->getInput('groupe');
|
$group = $this->getInput('group');
|
||||||
$ordre = $this->getInput('ordre');
|
$order = $this->getInput('order');
|
||||||
|
|
||||||
$url = self::URI
|
$url = $this->i8n('bridge-uri')
|
||||||
. '/groupe/' . $groupe . $ordre;
|
. $this->i8n('uri-group') . $group . $order;
|
||||||
$this->collectDeals($url);
|
$this->collectDeals($url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Deal data from the choosen keywords and parameters
|
* Get the Deal data from the choosen keywords and parameters
|
||||||
*/
|
*/
|
||||||
public function collectDataMotsCles()
|
public function collectDataKeywords()
|
||||||
{
|
{
|
||||||
$q = $this->getInput('q');
|
$q = $this->getInput('q');
|
||||||
$hide_expired = $this->getInput('hide_expired');
|
$hide_expired = $this->getInput('hide_expired');
|
||||||
@@ -117,7 +180,7 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
$priceTo = $this->getInput('priceFrom');
|
$priceTo = $this->getInput('priceFrom');
|
||||||
|
|
||||||
/* Even if the original website uses POST with the search page, GET works too */
|
/* Even if the original website uses POST with the search page, GET works too */
|
||||||
$url = self::URI
|
$url = $this->i8n('bridge-uri')
|
||||||
. '/search/advanced?q='
|
. '/search/advanced?q='
|
||||||
. urlencode($q)
|
. urlencode($q)
|
||||||
. '&hide_expired='. $hide_expired
|
. '&hide_expired='. $hide_expired
|
||||||
@@ -138,8 +201,8 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
*/
|
*/
|
||||||
public function collectDeals($url){
|
public function collectDeals($url){
|
||||||
$html = getSimpleHTMLDOM($url)
|
$html = getSimpleHTMLDOM($url)
|
||||||
or returnServerError('Could not request Dealabs.');
|
or returnServerError($this->i8n('request-error'));
|
||||||
$list = $html->find('article');
|
$list = $html->find('article[id]');
|
||||||
|
|
||||||
// Deal Image Link CSS Selector
|
// Deal Image Link CSS Selector
|
||||||
$selectorImageLink = implode(
|
$selectorImageLink = implode(
|
||||||
@@ -148,7 +211,6 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
'cept-thread-image-link',
|
'cept-thread-image-link',
|
||||||
'imgFrame',
|
'imgFrame',
|
||||||
'imgFrame--noBorder',
|
'imgFrame--noBorder',
|
||||||
'box--all-i',
|
|
||||||
'thread-listImgCell',
|
'thread-listImgCell',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
@@ -181,7 +243,7 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
'cept-description-container',
|
'cept-description-container',
|
||||||
'overflow--wrap-break',
|
'overflow--wrap-break',
|
||||||
'size--all-s',
|
'size--all-s',
|
||||||
'size--fromW3-m',
|
'size--fromW3-m'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -191,7 +253,6 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
array(
|
array(
|
||||||
'size--all-s',
|
'size--all-s',
|
||||||
'flex',
|
'flex',
|
||||||
'flex--wrap',
|
|
||||||
'flex--justify-e',
|
'flex--justify-e',
|
||||||
'flex--grow-1',
|
'flex--grow-1',
|
||||||
)
|
)
|
||||||
@@ -199,40 +260,44 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
|
|
||||||
// If there is no results, we don't parse the content because it display some random deals
|
// If there is no results, we don't parse the content because it display some random deals
|
||||||
$noresult = $html->find('h3[class=size--all-l size--fromW2-xl size--fromW3-xxl]', 0);
|
$noresult = $html->find('h3[class=size--all-l size--fromW2-xl size--fromW3-xxl]', 0);
|
||||||
if($noresult != null && $noresult->plaintext == 'Il n'y a rien à afficher pour le moment :(') {
|
if ($noresult != null && strpos($noresult->plaintext, $this->i8n('no-results')) !== false) {
|
||||||
$this->items = array();
|
$this->items = array();
|
||||||
} else {
|
} else {
|
||||||
foreach($list as $deal) {
|
foreach ($list as $deal) {
|
||||||
$item = array();
|
$item = array();
|
||||||
$item['uri'] = $deal->find('div[class=threadGrid-title]', 0)->find('a', 0)->href;
|
$item['uri'] = $deal->find('div[class=threadGrid-title]', 0)->find('a', 0)->href;
|
||||||
$item['title'] = $deal->find('a[class*='. $selectorLink .']', 0
|
$item['title'] = $deal->find('a[class*='. $selectorLink .']', 0
|
||||||
)->plaintext;
|
)->plaintext;
|
||||||
$item['author'] = $deal->find('span.thread-username', 0)->plaintext;
|
$item['author'] = $deal->find('span.thread-username', 0)->plaintext;
|
||||||
$item['content'] = '<table><tr><td><a href="'
|
$item['content'] = '<table><tr><td><a href="'
|
||||||
. $deal->find(
|
. $deal->find(
|
||||||
'a[class*='. $selectorImageLink .']', 0)->href
|
'a[class*='. $selectorImageLink .']', 0)->href
|
||||||
. '"><img src="'
|
. '"><img src="'
|
||||||
. $this->getImage($deal)
|
. $this->getImage($deal)
|
||||||
. '"/></td><td><h2><a href="'
|
. '"/></td><td><h2><a href="'
|
||||||
. $deal->find('a[class*='. $selectorLink .']', 0)->href
|
. $deal->find('a[class*='. $selectorLink .']', 0)->href
|
||||||
. '">'
|
. '">'
|
||||||
. $deal->find('a[class*='. $selectorLink .']', 0)->innertext
|
. $deal->find('a[class*='. $selectorLink .']', 0)->innertext
|
||||||
. '</a></h2>'
|
. '</a></h2>'
|
||||||
. $this->getPrix($deal)
|
. $this->getPrice($deal)
|
||||||
. $this->getReduction($deal)
|
. $this->getDiscount($deal)
|
||||||
. $this->getExpedition($deal)
|
. $this->getShipsFrom($deal)
|
||||||
. $this->getLivraison($deal)
|
. $this->getShippingCost($deal)
|
||||||
. $this->getOrigine($deal)
|
. $this->GetSource($deal)
|
||||||
. $deal->find('div[class='. $selectorDescription .']', 0)->innertext
|
. $deal->find('div[class*='. $selectorDescription .']', 0)->innertext
|
||||||
. '</td><td>'
|
. '</td><td>'
|
||||||
. $deal->find('div[class='. $selectorHot .']', 0)->children(0)->outertext
|
. $deal->find('div[class='. $selectorHot .']', 0)->children(0)->outertext
|
||||||
. '</td></table>';
|
. '</td></table>';
|
||||||
$dealDateDiv = $deal->find('div[class='. $selectorDate .']', 0)
|
$dealDateDiv = $deal->find('div[class*='. $selectorDate .']', 0)
|
||||||
->find('span[class=hide--toW3]');
|
->find('span[class=hide--toW3]');
|
||||||
$itemDate = end($dealDateDiv)->plaintext;
|
$itemDate = end($dealDateDiv)->plaintext;
|
||||||
if(substr( $itemDate, 0, 6 ) === 'il y a') {
|
// In case of a Local deal, there is no date, but we can use
|
||||||
|
// this case for other reason (like date not in the last field)
|
||||||
|
if ($this->contains($itemDate, $this->i8n('localdeal'))) {
|
||||||
|
$item['timestamp'] = time();
|
||||||
|
} else if ($this->contains($itemDate, $this->i8n('relative-date-indicator'))) {
|
||||||
$item['timestamp'] = $this->relativeDateToTimestamp($itemDate);
|
$item['timestamp'] = $this->relativeDateToTimestamp($itemDate);
|
||||||
} else {
|
} else {
|
||||||
$item['timestamp'] = $this->parseDate($itemDate);
|
$item['timestamp'] = $this->parseDate($itemDate);
|
||||||
}
|
}
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
@@ -240,15 +305,29 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the string $str contains any of the string of the array $arr
|
||||||
|
* @return boolean true if the string matched anything otherwise false
|
||||||
|
*/
|
||||||
|
private function contains($str, array $arr)
|
||||||
|
{
|
||||||
|
foreach ($arr as $a) {
|
||||||
|
if (stripos($str, $a) !== false) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Price from a Deal if it exists
|
* Get the Price from a Deal if it exists
|
||||||
* @return string String of the deal price
|
* @return string String of the deal price
|
||||||
*/
|
*/
|
||||||
private function getPrix($deal)
|
private function getPrice($deal)
|
||||||
{
|
{
|
||||||
if($deal->find(
|
if ($deal->find(
|
||||||
'span[class*=thread-price]', 0) != null) {
|
'span[class*=thread-price]', 0) != null) {
|
||||||
return '<div>Prix : '
|
return '<div>'.$this->i8n('price') .' : '
|
||||||
. $deal->find(
|
. $deal->find(
|
||||||
'span[class*=thread-price]', 0
|
'span[class*=thread-price]', 0
|
||||||
)->plaintext
|
)->plaintext
|
||||||
@@ -263,17 +342,17 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
* Get the Shipping costs from a Deal if it exists
|
* Get the Shipping costs from a Deal if it exists
|
||||||
* @return string String of the deal shipping Cost
|
* @return string String of the deal shipping Cost
|
||||||
*/
|
*/
|
||||||
private function getLivraison($deal)
|
private function getShippingCost($deal)
|
||||||
{
|
{
|
||||||
if($deal->find('span[class*=cept-shipping-price]', 0) != null) {
|
if ($deal->find('span[class*=cept-shipping-price]', 0) != null) {
|
||||||
if($deal->find('span[class*=cept-shipping-price]', 0)->children(0) != null) {
|
if ($deal->find('span[class*=cept-shipping-price]', 0)->children(0) != null) {
|
||||||
return '<div>Livraison : '
|
return '<div>'. $this->i8n('shipping') .' : '
|
||||||
. $deal->find('span[class*=cept-shipping-price]', 0)->children(0)->innertext
|
. $deal->find('span[class*=cept-shipping-price]', 0)->children(0)->innertext
|
||||||
. '</div>';
|
. '</div>';
|
||||||
} else {
|
} else {
|
||||||
return '<div>Livraison : '
|
return '<div>'. $this->i8n('shipping') .' : '
|
||||||
. $deal->find('span[class*=cept-shipping-price]', 0)->innertext
|
. $deal->find('span[class*=cept-shipping-price]', 0)->innertext
|
||||||
. '</div>';
|
. '</div>';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
@@ -284,10 +363,10 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
* Get the source of a Deal if it exists
|
* Get the source of a Deal if it exists
|
||||||
* @return string String of the deal source
|
* @return string String of the deal source
|
||||||
*/
|
*/
|
||||||
private function getOrigine($deal)
|
private function GetSource($deal)
|
||||||
{
|
{
|
||||||
if($deal->find('a[class=text--color-greyShade]', 0) != null) {
|
if ($deal->find('a[class=text--color-greyShade]', 0) != null) {
|
||||||
return '<div>Origine : '
|
return '<div>'. $this->i8n('origin') .' : '
|
||||||
. $deal->find('a[class=text--color-greyShade]', 0)->outertext
|
. $deal->find('a[class=text--color-greyShade]', 0)->outertext
|
||||||
. '</div>';
|
. '</div>';
|
||||||
} else {
|
} else {
|
||||||
@@ -299,15 +378,21 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
* Get the original Price and discout from a Deal if it exists
|
* Get the original Price and discout from a Deal if it exists
|
||||||
* @return string String of the deal original price and discount
|
* @return string String of the deal original price and discount
|
||||||
*/
|
*/
|
||||||
private function getReduction($deal)
|
private function getDiscount($deal)
|
||||||
{
|
{
|
||||||
if($deal->find('span[class*=mute--text text--lineThrough]', 0) != null) {
|
if ($deal->find('span[class*=mute--text text--lineThrough]', 0) != null) {
|
||||||
return '<div>Réduction : <span style="text-decoration: line-through;">'
|
$discountHtml = $deal->find('span[class=space--ml-1 size--all-l size--fromW3-xl]', 0);
|
||||||
|
if ($discountHtml != null) {
|
||||||
|
$discount = $discountHtml->plaintext;
|
||||||
|
} else {
|
||||||
|
$discount = '';
|
||||||
|
}
|
||||||
|
return '<div>'. $this->i8n('discount') .' : <span style="text-decoration: line-through;">'
|
||||||
. $deal->find(
|
. $deal->find(
|
||||||
'span[class*=mute--text text--lineThrough]', 0
|
'span[class*=mute--text text--lineThrough]', 0
|
||||||
)->plaintext
|
)->plaintext
|
||||||
. '</span> '
|
. '</span> '
|
||||||
. $deal->find('span[class=space--ml-1 size--all-l size--fromW3-xl]', 0)->plaintext
|
. $discount
|
||||||
. '</div>';
|
. '</div>';
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
@@ -320,7 +405,6 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
*/
|
*/
|
||||||
private function getImage($deal)
|
private function getImage($deal)
|
||||||
{
|
{
|
||||||
|
|
||||||
$selectorLazy = implode(
|
$selectorLazy = implode(
|
||||||
' ', /* Notice this is a space! */
|
' ', /* Notice this is a space! */
|
||||||
array(
|
array(
|
||||||
@@ -334,7 +418,7 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
$selectorPlain = implode(
|
$selectorPlain = implode(
|
||||||
' ', /* Notice this is a space! */
|
' ', /* Notice this is a space! */
|
||||||
array(
|
array(
|
||||||
'thread-image',
|
'thread-image',
|
||||||
@@ -344,21 +428,21 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
'cept-thread-img'
|
'cept-thread-img'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if($deal->find('img[class='. $selectorLazy .']', 0) != null) {
|
if ($deal->find('img[class='. $selectorLazy .']', 0) != null) {
|
||||||
return json_decode(
|
return json_decode(
|
||||||
html_entity_decode(
|
html_entity_decode(
|
||||||
$deal->find('img[class='. $selectorLazy .']', 0)
|
$deal->find('img[class='. $selectorLazy .']', 0)
|
||||||
->getAttribute('data-lazy-img')))->{'src'};
|
->getAttribute('data-lazy-img')))->{'src'};
|
||||||
} else {
|
} else {
|
||||||
return $deal->find('img[class='. $selectorPlain .']', 0 )->src;
|
return $deal->find('img[class*='. $selectorPlain .']', 0 )->src;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the originating country from a Deal if it existsa
|
* Get the originating country from a Deal if it exists
|
||||||
* @return string String of the deal originating country
|
* @return string String of the deal originating country
|
||||||
*/
|
*/
|
||||||
private function getExpedition($deal)
|
private function getShipsFrom($deal)
|
||||||
{
|
{
|
||||||
$selector = implode(
|
$selector = implode(
|
||||||
' ', /* Notice this is a space! */
|
' ', /* Notice this is a space! */
|
||||||
@@ -369,7 +453,7 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
'text--color-greyShade'
|
'text--color-greyShade'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
if($deal->find('span[class='. $selector .']', 0) != null) {
|
if ($deal->find('span[class='. $selector .']', 0) != null) {
|
||||||
return '<div>'
|
return '<div>'
|
||||||
. $deal->find('span[class='. $selector .']', 0)->children(2)->plaintext
|
. $deal->find('span[class='. $selector .']', 0)->children(2)->plaintext
|
||||||
. '</div>';
|
. '</div>';
|
||||||
@@ -379,25 +463,12 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms a French date into a timestam
|
* Transforms a local date into a timestamp
|
||||||
* @return int timestamp of the input date
|
* @return int timestamp of the input date
|
||||||
*/
|
*/
|
||||||
private function parseDate($string)
|
private function parseDate($string)
|
||||||
{
|
{
|
||||||
$month_fr = array(
|
$month_local = $this->i8n('local-months');
|
||||||
'janvier',
|
|
||||||
'février',
|
|
||||||
'mars',
|
|
||||||
'avril',
|
|
||||||
'mai',
|
|
||||||
'juin',
|
|
||||||
'juillet',
|
|
||||||
'août',
|
|
||||||
'septembre',
|
|
||||||
'octobre',
|
|
||||||
'novembre',
|
|
||||||
'décembre'
|
|
||||||
);
|
|
||||||
$month_en = array(
|
$month_en = array(
|
||||||
'January',
|
'January',
|
||||||
'February',
|
'February',
|
||||||
@@ -412,11 +483,18 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
'November',
|
'November',
|
||||||
'December'
|
'December'
|
||||||
);
|
);
|
||||||
$date_str = trim(str_replace($month_fr, $month_en, $string));
|
|
||||||
|
|
||||||
if(!preg_match('/[0-9]{4}/', $string)) {
|
// A date can be prfixed with some words, we remove theme
|
||||||
|
$string = $this->removeDatePrefixes($string);
|
||||||
|
// We translate the local months name in the english one
|
||||||
|
$date_str = trim(str_replace($month_local, $month_en, $string));
|
||||||
|
|
||||||
|
// If the date does not contain any year, we add the current year
|
||||||
|
if (!preg_match('/[0-9]{4}/', $string)) {
|
||||||
$date_str .= ' ' . date('Y');
|
$date_str .= ' ' . date('Y');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add the Hour and minutes
|
||||||
$date_str .= ' 00:00';
|
$date_str .= ' 00:00';
|
||||||
|
|
||||||
$date = DateTime::createFromFormat('j F Y H:i', $date_str);
|
$date = DateTime::createFromFormat('j F Y H:i', $date_str);
|
||||||
@@ -424,21 +502,41 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Transforms a relate French date into a timestam
|
* Remove the prefix of a date if it has one
|
||||||
|
* @return the date without prefiux
|
||||||
|
*/
|
||||||
|
private function removeDatePrefixes($string)
|
||||||
|
{
|
||||||
|
$string = str_replace($this->i8n('date-prefixes'), array(), $string);
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Remove the suffix of a relative date if it has one
|
||||||
|
* @return the relative date without suffixes
|
||||||
|
*/
|
||||||
|
private function removeRelativeDateSuffixes($string)
|
||||||
|
{
|
||||||
|
if (count($this->i8n('relative-date-ignore-suffix')) > 0) {
|
||||||
|
$string = preg_replace($this->i8n('relative-date-ignore-suffix'), '', $string);
|
||||||
|
}
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transforms a relative local date into a timestamp
|
||||||
* @return int timestamp of the input date
|
* @return int timestamp of the input date
|
||||||
*/
|
*/
|
||||||
private function relativeDateToTimestamp($str) {
|
private function relativeDateToTimestamp($str) {
|
||||||
$date = new DateTime();
|
$date = new DateTime();
|
||||||
$search = array(
|
|
||||||
'il y a ',
|
// In case of update date, replace it by the regular relative date first word
|
||||||
'min',
|
$str = str_replace($this->i8n('relative-date-alt-prefixes'), $this->i8n('local-time-relative')[0], $str);
|
||||||
'h',
|
|
||||||
'jour',
|
$str = $this->removeRelativeDateSuffixes($str);
|
||||||
'jours',
|
|
||||||
'mois',
|
$search = $this->i8n('local-time-relative');
|
||||||
'ans',
|
|
||||||
'et '
|
|
||||||
);
|
|
||||||
$replace = array(
|
$replace = array(
|
||||||
'-',
|
'-',
|
||||||
'minute',
|
'minute',
|
||||||
@@ -453,18 +551,38 @@ class DealabsBridge extends BridgeAbstract {
|
|||||||
return $date->getTimestamp();
|
return $date->getTimestamp();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the RSS Feed title according to the parameters
|
||||||
|
* @return string the RSS feed Tiyle
|
||||||
|
*/
|
||||||
public function getName(){
|
public function getName(){
|
||||||
switch($this->queriedContext) {
|
switch($this->queriedContext) {
|
||||||
case 'Recherche par Mot(s) clé(s)':
|
case $this->i8n('context-keyword'):
|
||||||
return self::NAME . ' - Recherche : '. $this->getInput('q');
|
return $this->i8n('bridge-name') . ' - '. $this->i8n('title-keyword') .' : '. $this->getInput('q');
|
||||||
break;
|
break;
|
||||||
case 'Deals par groupe':
|
case $this->i8n('context-group'):
|
||||||
$values = self::PARAMETERS['Deals par groupe']['groupe']['values'];
|
$values = $this->getParameters()[$this->i8n('context-group')]['group']['values'];
|
||||||
$groupe = array_search($this->getInput('groupe'), $values);
|
$group = array_search($this->getInput('group'), $values);
|
||||||
return self::NAME . ' - Groupe : '. $groupe;
|
return $this->i8n('bridge-name') . ' - '. $this->i8n('title-group'). ' : '. $group;
|
||||||
break;
|
break;
|
||||||
default: // Return default value
|
default: // Return default value
|
||||||
return self::NAME;
|
return static::NAME;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This is some "localisation" function that returns the needed content using
|
||||||
|
* the "$lang" class variable in the local class
|
||||||
|
* @return various the local content needed
|
||||||
|
*/
|
||||||
|
public function i8n($key)
|
||||||
|
{
|
||||||
|
if (array_key_exists($key, $this->lang)) {
|
||||||
|
return $this->lang[$key];
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -35,11 +35,11 @@ class DemoBridge extends BridgeAbstract {
|
|||||||
public function collectData(){
|
public function collectData(){
|
||||||
|
|
||||||
$item = array();
|
$item = array();
|
||||||
$item['author'] = "Me!";
|
$item['author'] = 'Me!';
|
||||||
$item['title'] = "Test";
|
$item['title'] = 'Test';
|
||||||
$item['content'] = "Awesome content !";
|
$item['content'] = 'Awesome content !';
|
||||||
$item['id'] = "Lalala";
|
$item['id'] = 'Lalala';
|
||||||
$item['uri'] = "http://example.com/test";
|
$item['uri'] = 'http://example.com/test';
|
||||||
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
|
@@ -42,59 +42,59 @@ class DiscogsBridge extends BridgeAbstract {
|
|||||||
if(!empty($this->getInput('artistid')) || !empty($this->getInput('labelid'))) {
|
if(!empty($this->getInput('artistid')) || !empty($this->getInput('labelid'))) {
|
||||||
|
|
||||||
if(!empty($this->getInput('artistid'))) {
|
if(!empty($this->getInput('artistid'))) {
|
||||||
$data = getContents("https://api.discogs.com/artists/"
|
$data = getContents('https://api.discogs.com/artists/'
|
||||||
. $this->getInput('artistid')
|
. $this->getInput('artistid')
|
||||||
. "/releases?sort=year&sort_order=desc")
|
. '/releases?sort=year&sort_order=desc')
|
||||||
or returnServerError("Unable to query discogs !");
|
or returnServerError('Unable to query discogs !');
|
||||||
} elseif(!empty($this->getInput('labelid'))) {
|
} elseif(!empty($this->getInput('labelid'))) {
|
||||||
$data = getContents("https://api.discogs.com/labels/"
|
$data = getContents('https://api.discogs.com/labels/'
|
||||||
. $this->getInput('labelid')
|
. $this->getInput('labelid')
|
||||||
. "/releases?sort=year&sort_order=desc")
|
. '/releases?sort=year&sort_order=desc')
|
||||||
or returnServerError("Unable to query discogs !");
|
or returnServerError('Unable to query discogs !');
|
||||||
}
|
}
|
||||||
|
|
||||||
$jsonData = json_decode($data, true);
|
$jsonData = json_decode($data, true);
|
||||||
foreach($jsonData["releases"] as $release) {
|
foreach($jsonData['releases'] as $release) {
|
||||||
|
|
||||||
$item = array();
|
$item = array();
|
||||||
$item["author"] = $release["artist"];
|
$item['author'] = $release['artist'];
|
||||||
$item["title"] = $release["title"];
|
$item['title'] = $release['title'];
|
||||||
$item["id"] = $release["id"];
|
$item['id'] = $release['id'];
|
||||||
$resId = array_key_exists("main_release", $release) ? $release["main_release"] : $release["id"];
|
$resId = array_key_exists('main_release', $release) ? $release['main_release'] : $release['id'];
|
||||||
$item["uri"] = self::URI . $this->getInput('artistid') . "/release/" . $resId;
|
$item['uri'] = self::URI . $this->getInput('artistid') . '/release/' . $resId;
|
||||||
$item["timestamp"] = DateTime::createFromFormat("Y", $release["year"])->getTimestamp();
|
$item['timestamp'] = DateTime::createFromFormat('Y', $release['year'])->getTimestamp();
|
||||||
$item["content"] = $item["author"] . " - " . $item["title"];
|
$item['content'] = $item['author'] . ' - ' . $item['title'];
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
} elseif(!empty($this->getInput("username_wantlist")) || !empty($this->getInput("username_folder"))) {
|
} elseif(!empty($this->getInput('username_wantlist')) || !empty($this->getInput('username_folder'))) {
|
||||||
|
|
||||||
if(!empty($this->getInput("username_wantlist"))) {
|
if(!empty($this->getInput('username_wantlist'))) {
|
||||||
$data = getContents("https://api.discogs.com/users/"
|
$data = getContents('https://api.discogs.com/users/'
|
||||||
. $this->getInput('username_wantlist')
|
. $this->getInput('username_wantlist')
|
||||||
. "/wants?sort=added&sort_order=desc")
|
. '/wants?sort=added&sort_order=desc')
|
||||||
or returnServerError("Unable to query discogs !");
|
or returnServerError('Unable to query discogs !');
|
||||||
$jsonData = json_decode($data, true)["wants"];
|
$jsonData = json_decode($data, true)['wants'];
|
||||||
|
|
||||||
} elseif(!empty($this->getInput("username_folder"))) {
|
} elseif(!empty($this->getInput('username_folder'))) {
|
||||||
$data = getContents("https://api.discogs.com/users/"
|
$data = getContents('https://api.discogs.com/users/'
|
||||||
. $this->getInput('username_folder')
|
. $this->getInput('username_folder')
|
||||||
. "/collection/folders/"
|
. '/collection/folders/'
|
||||||
. $this->getInput("folderid")
|
. $this->getInput('folderid')
|
||||||
."/releases?sort=added&sort_order=desc")
|
.'/releases?sort=added&sort_order=desc')
|
||||||
or returnServerError("Unable to query discogs !");
|
or returnServerError('Unable to query discogs !');
|
||||||
$jsonData = json_decode($data, true)["releases"];
|
$jsonData = json_decode($data, true)['releases'];
|
||||||
}
|
}
|
||||||
foreach($jsonData as $element) {
|
foreach($jsonData as $element) {
|
||||||
|
|
||||||
$infos = $element["basic_information"];
|
$infos = $element['basic_information'];
|
||||||
$item = array();
|
$item = array();
|
||||||
$item["title"] = $infos["title"];
|
$item['title'] = $infos['title'];
|
||||||
$item["author"] = $infos["artists"][0]["name"];
|
$item['author'] = $infos['artists'][0]['name'];
|
||||||
$item["id"] = $infos["artists"][0]["id"];
|
$item['id'] = $infos['artists'][0]['id'];
|
||||||
$item["uri"] = self::URI . $infos["artists"][0]["id"] . "/release/" . $infos["id"];
|
$item['uri'] = self::URI . $infos['artists'][0]['id'] . '/release/' . $infos['id'];
|
||||||
$item["timestamp"] = strtotime($element["date_added"]);
|
$item['timestamp'] = strtotime($element['date_added']);
|
||||||
$item["content"] = $item["author"] . " - " . $item["title"];
|
$item['content'] = $item['author'] . ' - ' . $item['title'];
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
142
bridges/ETTVBridge.php
Normal file
142
bridges/ETTVBridge.php
Normal file
@@ -0,0 +1,142 @@
|
|||||||
|
<?php
|
||||||
|
class ETTVBridge extends BridgeAbstract {
|
||||||
|
|
||||||
|
const MAINTAINER = 'GregThib';
|
||||||
|
const NAME = 'ETTV';
|
||||||
|
const URI = 'https://www.ettv.tv/';
|
||||||
|
const DESCRIPTION = 'Returns list of 20 latest torrents for a specific search.';
|
||||||
|
const CACHE_TIMEOUT = 14400; // 4 hours
|
||||||
|
|
||||||
|
const PARAMETERS = array( array(
|
||||||
|
'query' => array(
|
||||||
|
'name' => 'Keywords',
|
||||||
|
'required' => true
|
||||||
|
),
|
||||||
|
'cat' => array(
|
||||||
|
'type' => 'list',
|
||||||
|
'name' => 'Category',
|
||||||
|
'values' => array(
|
||||||
|
'(ALL TYPES)' => '0',
|
||||||
|
'Anime: Movies' => '73',
|
||||||
|
'Anime: Dubbed/Subbed' => '74',
|
||||||
|
'Anime: Others' => '75',
|
||||||
|
'Books: Ebooks' => '53',
|
||||||
|
'Books: Magazines' => '54',
|
||||||
|
'Books: Comics' => '55',
|
||||||
|
'Books: Audio' => '56',
|
||||||
|
'Books: Others' => '68',
|
||||||
|
'Games: Windows' => '57',
|
||||||
|
'Games: Android' => '58',
|
||||||
|
'Games: Others' => '71',
|
||||||
|
'Movies: HD 1080p' => '1',
|
||||||
|
'Movies: HD 720p' => '2',
|
||||||
|
'Movies: UltraHD/4K' => '3',
|
||||||
|
'Movies: XviD' => '42',
|
||||||
|
'Movies: X264/H264' => '47',
|
||||||
|
'Movies: 3D' => '49',
|
||||||
|
'Movies: Dubs/Dual Audio' => '51',
|
||||||
|
'Movies: CAM/TS' => '65',
|
||||||
|
'Movies: BluRay Disc/Remux' => '66',
|
||||||
|
'Movies: DVDR' => '67',
|
||||||
|
'Movies: HEVC/x265' => '76',
|
||||||
|
'Music: MP3' => '59',
|
||||||
|
'Music: FLAC' => '60',
|
||||||
|
'Music: Music Videos' => '61',
|
||||||
|
'Music: Others' => '69',
|
||||||
|
'Software: Windows' => '62',
|
||||||
|
'Software: Android' => '63',
|
||||||
|
'Software: Mac' => '64',
|
||||||
|
'Software: Others' => '70',
|
||||||
|
'TV: HD/X264/H264' => '41',
|
||||||
|
'TV: SD/X264/H264' => '5',
|
||||||
|
'TV: TV Packs' => '7',
|
||||||
|
'TV: SD/XVID' => '50',
|
||||||
|
'TV: Sport' => '72',
|
||||||
|
'TV: HEVC/x265' => '77',
|
||||||
|
'Unsorted: Unsorted' => '78'
|
||||||
|
),
|
||||||
|
'defaultValue' => '(ALL TYPES)'
|
||||||
|
),
|
||||||
|
'status' => array(
|
||||||
|
'type' => 'list',
|
||||||
|
'name' => 'Status',
|
||||||
|
'values' => array(
|
||||||
|
'Active Transfers' => '0',
|
||||||
|
'Included Dead' => '1',
|
||||||
|
'Only Dead' => '2'
|
||||||
|
),
|
||||||
|
'defaultValue' => 'Included Dead'
|
||||||
|
),
|
||||||
|
'lang' => array(
|
||||||
|
'type' => 'list',
|
||||||
|
'name' => 'Lang',
|
||||||
|
'values' => array(
|
||||||
|
'(ALL)' => '0',
|
||||||
|
'Arabic' => '17',
|
||||||
|
'Chinese ' => '10',
|
||||||
|
'Danish' => '13',
|
||||||
|
'Dutch' => '11',
|
||||||
|
'English' => '1',
|
||||||
|
'Finnish' => '18',
|
||||||
|
'French' => '2',
|
||||||
|
'German' => '3',
|
||||||
|
'Greek' => '15',
|
||||||
|
'Hindi' => '8',
|
||||||
|
'Italian' => '4',
|
||||||
|
'Japanese' => '5',
|
||||||
|
'Korean' => '9',
|
||||||
|
'Polish' => '14',
|
||||||
|
'Russian' => '7',
|
||||||
|
'Spanish' => '6',
|
||||||
|
'Turkish' => '16'
|
||||||
|
),
|
||||||
|
'defaultValue' => '(ALL)'
|
||||||
|
)
|
||||||
|
));
|
||||||
|
|
||||||
|
public function collectData(){
|
||||||
|
// No control on inputs, because all have defaultValue set
|
||||||
|
$query_str = 'torrents-search.php';
|
||||||
|
$query_str .= '?search=' . urlencode('+'.str_replace(' ', ' +', $this->getInput('query')));
|
||||||
|
$query_str .= '&cat=' . $this->getInput('cat');
|
||||||
|
$query_str .= 'incldead&=' . $this->getInput('status');
|
||||||
|
$query_str .= '&lang=' . $this->getInput('lang');
|
||||||
|
$query_str .= '&sort=id&order=desc';
|
||||||
|
|
||||||
|
// Get results page
|
||||||
|
$html = getSimpleHTMLDOM(self::URI . $query_str)
|
||||||
|
or returnServerError('Could not request ' . $this->getName());
|
||||||
|
|
||||||
|
// Loop on each entry
|
||||||
|
foreach($html->find('table.table tr') as $element) {
|
||||||
|
if($element->parent->tag == 'thead') continue;
|
||||||
|
$entry = $element->find('td', 1)->find('a', 0);
|
||||||
|
|
||||||
|
// retrieve result page to get more details
|
||||||
|
$link = rtrim(self::URI, '/') . $entry->href;
|
||||||
|
$page = getSimpleHTMLDOM($link)
|
||||||
|
or returnServerError('Could not request page ' . $link);
|
||||||
|
|
||||||
|
// get details & download links
|
||||||
|
$details = $page->find('fieldset.download table', 0); // WHAT?? It should be the second one…
|
||||||
|
$dllinks = $page->find('div#downloadbox table', 0);
|
||||||
|
|
||||||
|
// fill item
|
||||||
|
$item = array();
|
||||||
|
$item['author'] = $details->children(6)->children(1)->plaintext;
|
||||||
|
$item['title'] = $entry->title;
|
||||||
|
$item['uri'] = $dllinks->children(0)->children(0)->children(0)->href;
|
||||||
|
$item['timestamp'] = strtotime($details->children(7)->children(1)->plaintext);
|
||||||
|
$item['content'] = '';
|
||||||
|
$item['content'] .= '<br/><b>Name: </b>' . $details->children(0)->children(1)->innertext;
|
||||||
|
$item['content'] .= '<br/><b>Lang: </b>' . $details->children(3)->children(1)->innertext;
|
||||||
|
$item['content'] .= '<br/><b>Size: </b>' . $details->children(4)->children(1)->innertext;
|
||||||
|
$item['content'] .= '<br/><b>Hash: </b>' . $details->children(5)->children(1)->innertext;
|
||||||
|
foreach($dllinks->children(0)->children(1)->find('a') as $dl) {
|
||||||
|
$item['content'] .= '<br/>' . $dl->outertext;
|
||||||
|
}
|
||||||
|
$item['content'] .= '<br/><br/>' . $details->children(1)->children(0)->innertext;
|
||||||
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,7 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
class EZTVBridge extends BridgeAbstract {
|
class EZTVBridge extends BridgeAbstract {
|
||||||
|
|
||||||
const MAINTAINER = "alexAubin";
|
const MAINTAINER = 'alexAubin';
|
||||||
const NAME = 'EZTV';
|
const NAME = 'EZTV';
|
||||||
const URI = 'https://eztv.ch/';
|
const URI = 'https://eztv.ch/';
|
||||||
const DESCRIPTION = 'Returns list of *recent* torrents for a specific show
|
const DESCRIPTION = 'Returns list of *recent* torrents for a specific show
|
||||||
@@ -23,15 +23,15 @@ on EZTV. Get showID from URLs in https://eztv.ch/shows/showID/show-full-name.';
|
|||||||
$relativeDays = 0;
|
$relativeDays = 0;
|
||||||
$relativeHours = 0;
|
$relativeHours = 0;
|
||||||
|
|
||||||
foreach(explode(" ", $relativeReleaseTime) as $relativeTimeElement) {
|
foreach(explode(' ', $relativeReleaseTime) as $relativeTimeElement) {
|
||||||
if(substr($relativeTimeElement, -1) == "d") $relativeDays = substr($relativeTimeElement, 0, -1);
|
if(substr($relativeTimeElement, -1) == 'd') $relativeDays = substr($relativeTimeElement, 0, -1);
|
||||||
if(substr($relativeTimeElement, -1) == "h") $relativeHours = substr($relativeTimeElement, 0, -1);
|
if(substr($relativeTimeElement, -1) == 'h') $relativeHours = substr($relativeTimeElement, 0, -1);
|
||||||
}
|
}
|
||||||
return mktime(date('h') - $relativeHours, 0, 0, date('m'), date('d') - $relativeDays, date('Y'));
|
return mktime(date('h') - $relativeHours, 0, 0, date('m'), date('d') - $relativeDays, date('Y'));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Loop on show ids
|
// Loop on show ids
|
||||||
$showList = explode(",", $this->getInput('i'));
|
$showList = explode(',', $this->getInput('i'));
|
||||||
foreach($showList as $showID) {
|
foreach($showList as $showID) {
|
||||||
|
|
||||||
// Get show page
|
// Get show page
|
||||||
|
146
bridges/ElloBridge.php
Normal file
146
bridges/ElloBridge.php
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
<?php
|
||||||
|
class ElloBridge extends BridgeAbstract {
|
||||||
|
|
||||||
|
const MAINTAINER = 'teromene';
|
||||||
|
const NAME = 'Ello Bridge';
|
||||||
|
const URI = 'https://ello.co/';
|
||||||
|
const CACHE_TIMEOUT = 4800; //2hours
|
||||||
|
const DESCRIPTION = 'Returns the newest posts for Ello';
|
||||||
|
|
||||||
|
const PARAMETERS = array(
|
||||||
|
'By User' => array(
|
||||||
|
'u' => array(
|
||||||
|
'name' => 'Username',
|
||||||
|
'required' => true,
|
||||||
|
'title' => 'Username'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'Search' => array(
|
||||||
|
's' => array(
|
||||||
|
'name' => 'Search',
|
||||||
|
'required' => true,
|
||||||
|
'title' => 'Search'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
public function collectData() {
|
||||||
|
|
||||||
|
$header = array(
|
||||||
|
'Authorization: Bearer ' . $this->getAPIKey()
|
||||||
|
);
|
||||||
|
|
||||||
|
if(!empty($this->getInput('u'))) {
|
||||||
|
$postData = getContents(self::URI . 'api/v2/users/~' . urlencode($this->getInput('u')) . '/posts', $header) or
|
||||||
|
returnServerError('Unable to query Ello API.');
|
||||||
|
} else {
|
||||||
|
$postData = getContents(self::URI . 'api/v2/posts?terms=' . urlencode($this->getInput('s')), $header) or
|
||||||
|
returnServerError('Unable to query Ello API.');
|
||||||
|
}
|
||||||
|
|
||||||
|
$postData = json_decode($postData);
|
||||||
|
$count = 0;
|
||||||
|
foreach($postData->posts as $post) {
|
||||||
|
|
||||||
|
$item = array();
|
||||||
|
$item['author'] = $this->getUsername($post, $postData);
|
||||||
|
$item['timestamp'] = strtotime($post->created_at);
|
||||||
|
$item['title'] = $this->findText($post->summary);
|
||||||
|
$item['content'] = $this->getPostContent($post->body);
|
||||||
|
$item['enclosures'] = $this->getEnclosures($post, $postData);
|
||||||
|
$content = $post->body;
|
||||||
|
|
||||||
|
$this->items[] = $item;
|
||||||
|
$count += 1;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function findText($path) {
|
||||||
|
|
||||||
|
foreach($path as $summaryElement) {
|
||||||
|
|
||||||
|
if($summaryElement->kind == 'text') {
|
||||||
|
return $summaryElement->data;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getPostContent($path) {
|
||||||
|
|
||||||
|
$content = '';
|
||||||
|
foreach($path as $summaryElement) {
|
||||||
|
|
||||||
|
if($summaryElement->kind == 'text') {
|
||||||
|
$content .= $summaryElement->data;
|
||||||
|
} elseif ($summaryElement->kind == 'image') {
|
||||||
|
$alt = '';
|
||||||
|
if(property_exists($summaryElement->data, 'alt')) {
|
||||||
|
$alt = $summaryElement->data->alt;
|
||||||
|
}
|
||||||
|
$content .= '<img src="' . $summaryElement->data->url . '" alt="' . $alt . '" />';
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $content;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getEnclosures($post, $postData) {
|
||||||
|
|
||||||
|
$assets = [];
|
||||||
|
foreach($post->links->assets as $asset) {
|
||||||
|
foreach($postData->linked->assets as $assetLink) {
|
||||||
|
if($asset == $assetLink->id) {
|
||||||
|
$assets[] = $assetLink->attachment->original->url;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $assets;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getUsername($post, $postData) {
|
||||||
|
|
||||||
|
foreach($postData->linked->users as $user) {
|
||||||
|
if($user->id == $post->links->author->id) {
|
||||||
|
return $user->username;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getAPIKey() {
|
||||||
|
$cache = Cache::create('FileCache');
|
||||||
|
$cache->setPath(CACHE_DIR);
|
||||||
|
$cache->setParameters(['key']);
|
||||||
|
$key = $cache->loadData();
|
||||||
|
|
||||||
|
if($key == null) {
|
||||||
|
$keyInfo = getContents(self::URI . 'api/webapp-token') or
|
||||||
|
returnServerError('Unable to get token.');
|
||||||
|
$key = json_decode($keyInfo)->token->access_token;
|
||||||
|
$cache->saveData($key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $key;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName(){
|
||||||
|
if(!is_null($this->getInput('u'))) {
|
||||||
|
return $this->getInput('u') . ' - Ello Bridge';
|
||||||
|
}
|
||||||
|
|
||||||
|
return parent::getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -95,7 +95,7 @@ EOD;
|
|||||||
. $pageID
|
. $pageID
|
||||||
. '&cursor={"card_id"%3A"videos"%2C"has_next_page"%3Atrue}&surface=mobile_page_home&unit_count=8';
|
. '&cursor={"card_id"%3A"videos"%2C"has_next_page"%3Atrue}&surface=mobile_page_home&unit_count=8';
|
||||||
|
|
||||||
$fileContent = file_get_contents($requestString);
|
$fileContent = getContents($requestString);
|
||||||
|
|
||||||
$articleIndex = 0;
|
$articleIndex = 0;
|
||||||
$maxArticle = 3;
|
$maxArticle = 3;
|
||||||
@@ -103,19 +103,19 @@ EOD;
|
|||||||
$html = $this->buildContent($fileContent);
|
$html = $this->buildContent($fileContent);
|
||||||
$author = $this->getInput('u');
|
$author = $this->getInput('u');
|
||||||
|
|
||||||
foreach($html->find("article") as $content) {
|
foreach($html->find('article') as $content) {
|
||||||
|
|
||||||
$item = array();
|
$item = array();
|
||||||
|
|
||||||
$item['uri'] = "http://touch.facebook.com"
|
$item['uri'] = 'http://touch.facebook.com'
|
||||||
. $content->find("div[class='_52jc _5qc4 _24u0 _36xo']", 0)->find("a", 0)->getAttribute("href");
|
. $content->find("div[class='_52jc _5qc4 _24u0 _36xo']", 0)->find('a', 0)->getAttribute('href');
|
||||||
|
|
||||||
if($content->find("header", 0) !== null) {
|
if($content->find('header', 0) !== null) {
|
||||||
$content->find("header", 0)->innertext = "";
|
$content->find('header', 0)->innertext = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if($content->find("footer", 0) !== null) {
|
if($content->find('footer', 0) !== null) {
|
||||||
$content->find("footer", 0)->innertext = "";
|
$content->find('footer', 0)->innertext = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
//Remove html nodes, keep only img, links, basic formatting
|
//Remove html nodes, keep only img, links, basic formatting
|
||||||
@@ -168,7 +168,7 @@ EOD;
|
|||||||
$regex = implode(
|
$regex = implode(
|
||||||
'',
|
'',
|
||||||
array(
|
array(
|
||||||
"/timeline_unit",
|
'/timeline_unit',
|
||||||
"\\\\\\\\u00253A1",
|
"\\\\\\\\u00253A1",
|
||||||
"\\\\\\\\u00253A([0-9]*)",
|
"\\\\\\\\u00253A([0-9]*)",
|
||||||
"\\\\\\\\u00253A([0-9]*)",
|
"\\\\\\\\u00253A([0-9]*)",
|
||||||
@@ -182,29 +182,29 @@ EOD;
|
|||||||
return implode(
|
return implode(
|
||||||
'',
|
'',
|
||||||
array(
|
array(
|
||||||
"https://touch.facebook.com/pages_reaction_units/more/?page_id=",
|
'https://touch.facebook.com/pages_reaction_units/more/?page_id=',
|
||||||
$pageID,
|
$pageID,
|
||||||
"&cursor=%7B%22timeline_cursor%22%3A%22timeline_unit%3A1%3A",
|
'&cursor=%7B%22timeline_cursor%22%3A%22timeline_unit%3A1%3A',
|
||||||
$result[1],
|
$result[1],
|
||||||
"%3A",
|
'%3A',
|
||||||
$result[2],
|
$result[2],
|
||||||
"%3A",
|
'%3A',
|
||||||
$result[3],
|
$result[3],
|
||||||
"%3A",
|
'%3A',
|
||||||
$result[4],
|
$result[4],
|
||||||
"%22%2C%22timeline_section_cursor%22%3A%7B%7D%2C%22",
|
'%22%2C%22timeline_section_cursor%22%3A%7B%7D%2C%22',
|
||||||
"has_next_page%22%3Atrue%7D&surface=mobile_page_home&unit_count=3"
|
'has_next_page%22%3Atrue%7D&surface=mobile_page_home&unit_count=3'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Builds the HTML from the encoded JS that Facebook provides.
|
//Builds the HTML from the encoded JS that Facebook provides.
|
||||||
private function buildContent($pageContent){
|
private function buildContent($pageContent){
|
||||||
|
// The html ends with:
|
||||||
$regex = "/\\\"html\\\":\\\"(.*?)\\\",\\\"replace/";
|
// /div>","replaceifexists
|
||||||
|
$regex = '/\\"html\\":(\".+\/div>"),"replace/';
|
||||||
preg_match($regex, $pageContent, $result);
|
preg_match($regex, $pageContent, $result);
|
||||||
|
return str_get_html(html_entity_decode(json_decode($result[1])));
|
||||||
return str_get_html(html_entity_decode(json_decode('"' . $result[1] . '"')));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ EOD;
|
|||||||
|
|
||||||
$ctx = stream_context_create(array(
|
$ctx = stream_context_create(array(
|
||||||
'http' => array(
|
'http' => array(
|
||||||
'user_agent' => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0",
|
'user_agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0',
|
||||||
'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
|
'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -222,12 +222,12 @@ EOD;
|
|||||||
$a = file_get_contents($pageURL, 0, $ctx);
|
$a = file_get_contents($pageURL, 0, $ctx);
|
||||||
|
|
||||||
//First request to get the cookie
|
//First request to get the cookie
|
||||||
$cookies = "";
|
$cookies = '';
|
||||||
foreach($http_response_header as $hdr) {
|
foreach($http_response_header as $hdr) {
|
||||||
if(strpos($hdr, "Set-Cookie") !== false) {
|
if(strpos($hdr, 'Set-Cookie') !== false) {
|
||||||
$cLine = explode(":", $hdr)[1];
|
$cLine = explode(':', $hdr)[1];
|
||||||
$cLine = explode(";", $cLine)[0];
|
$cLine = explode(';', $cLine)[0];
|
||||||
$cookies .= ";" . $cLine;
|
$cookies .= ';' . $cLine;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,7 +239,7 @@ EOD;
|
|||||||
|
|
||||||
$context = stream_context_create(array(
|
$context = stream_context_create(array(
|
||||||
'http' => array(
|
'http' => array(
|
||||||
'user_agent' => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0",
|
'user_agent' => 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:46.0) Gecko/20100101 Firefox/46.0',
|
||||||
'header' => 'Cookie: ' . $cookies
|
'header' => 'Cookie: ' . $cookies
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -247,12 +247,12 @@ EOD;
|
|||||||
|
|
||||||
$pageContent = file_get_contents($page, 0, $context);
|
$pageContent = file_get_contents($page, 0, $context);
|
||||||
|
|
||||||
if(strpos($pageContent, "signup-button") != false) {
|
if(strpos($pageContent, 'signup-button') != false) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Get the page ID if we don't have a captcha
|
//Get the page ID if we don't have a captcha
|
||||||
$regex = "/page_id=([0-9]*)&/";
|
$regex = '/page_id=([0-9]*)&/';
|
||||||
preg_match($regex, $pageContent, $matches);
|
preg_match($regex, $pageContent, $matches);
|
||||||
|
|
||||||
if(count($matches) > 0) {
|
if(count($matches) > 0) {
|
||||||
@@ -260,7 +260,7 @@ EOD;
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Get the page ID if we do have a captcha
|
//Get the page ID if we do have a captcha
|
||||||
$regex = "/\"pageID\":\"([0-9]*)\"/";
|
$regex = '/"pageID":"([0-9]*)"/';
|
||||||
preg_match($regex, $pageContent, $matches);
|
preg_match($regex, $pageContent, $matches);
|
||||||
|
|
||||||
return $matches[1];
|
return $matches[1];
|
||||||
|
@@ -1,34 +1,257 @@
|
|||||||
<?php
|
<?php
|
||||||
class FacebookBridge extends BridgeAbstract {
|
class FacebookBridge extends BridgeAbstract {
|
||||||
|
|
||||||
const MAINTAINER = 'teromene';
|
const MAINTAINER = 'teromene, logmanoriginal';
|
||||||
const NAME = 'Facebook';
|
const NAME = 'Facebook';
|
||||||
const URI = 'https://www.facebook.com/';
|
const URI = 'https://www.facebook.com/';
|
||||||
const CACHE_TIMEOUT = 300; // 5min
|
const CACHE_TIMEOUT = 300; // 5min
|
||||||
const DESCRIPTION = 'Input a page title or a profile log. For a profile log,
|
const DESCRIPTION = 'Input a page title or a profile log. For a profile log,
|
||||||
please insert the parameter as follow : myExamplePage/132621766841117';
|
please insert the parameter as follow : myExamplePage/132621766841117';
|
||||||
|
|
||||||
const PARAMETERS = array( array(
|
const PARAMETERS = array(
|
||||||
'u' => array(
|
'User' => array(
|
||||||
'name' => 'Username',
|
'u' => array(
|
||||||
'required' => true
|
'name' => 'Username',
|
||||||
),
|
'required' => true
|
||||||
'media_type' => array(
|
|
||||||
'name' => 'Media type',
|
|
||||||
'type' => 'list',
|
|
||||||
'required' => false,
|
|
||||||
'values' => array(
|
|
||||||
'All' => 'all',
|
|
||||||
'Video' => 'video',
|
|
||||||
'No Video' => 'novideo'
|
|
||||||
),
|
),
|
||||||
'defaultValue' => 'all'
|
'media_type' => array(
|
||||||
|
'name' => 'Media type',
|
||||||
|
'type' => 'list',
|
||||||
|
'required' => false,
|
||||||
|
'values' => array(
|
||||||
|
'All' => 'all',
|
||||||
|
'Video' => 'video',
|
||||||
|
'No Video' => 'novideo'
|
||||||
|
),
|
||||||
|
'defaultValue' => 'all'
|
||||||
|
),
|
||||||
|
'skip_reviews' => array(
|
||||||
|
'name' => 'Skip reviews',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'required' => false,
|
||||||
|
'defaultValue' => false,
|
||||||
|
'title' => 'Feed includes reviews when checked'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'Group' => array(
|
||||||
|
'g' => array(
|
||||||
|
'name' => 'Group',
|
||||||
|
'type' => 'text',
|
||||||
|
'required' => true,
|
||||||
|
'exampleValue' => 'https://www.facebook.com/groups/743149642484225',
|
||||||
|
'title' => 'Insert group name or facebook group URL'
|
||||||
|
)
|
||||||
)
|
)
|
||||||
));
|
);
|
||||||
|
|
||||||
private $authorName = '';
|
private $authorName = '';
|
||||||
|
private $groupName = '';
|
||||||
|
|
||||||
public function collectData(){
|
public function getURI() {
|
||||||
|
$uri = self::URI;
|
||||||
|
|
||||||
|
switch($this->queriedContext) {
|
||||||
|
|
||||||
|
case 'Group':
|
||||||
|
$uri .= 'groups/' . $this->sanitizeGroup(filter_var($this->getInput('g'), FILTER_SANITIZE_URL));
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $uri .= '?_fb_noscript=1';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function collectData() {
|
||||||
|
|
||||||
|
switch($this->queriedContext) {
|
||||||
|
|
||||||
|
case 'Group':
|
||||||
|
$this->collectGroupData();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'User':
|
||||||
|
$this->collectUserData();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
returnClientError('Unknown context: "' . $this->queriedContext . '"!');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Group
|
||||||
|
|
||||||
|
private function collectGroupData() {
|
||||||
|
|
||||||
|
$header = array('Accept-Language: ' . getEnv('HTTP_ACCEPT_LANGUAGE') . "\r\n");
|
||||||
|
|
||||||
|
$html = getSimpleHTMLDOM($this->getURI(), $header)
|
||||||
|
or returnServerError('Failed loading facebook page: ' . $this->getURI());
|
||||||
|
|
||||||
|
if(!$this->isPublicGroup($html)) {
|
||||||
|
returnClientError('This group is not public! RSS-Bridge only supports public groups!');
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultLinkTo($html, substr(self::URI, 0, strlen(self::URI) - 1));
|
||||||
|
|
||||||
|
$this->groupName = $this->extractGroupName($html);
|
||||||
|
|
||||||
|
$posts = $html->find('div.userContentWrapper')
|
||||||
|
or returnServerError('Failed finding posts!');
|
||||||
|
|
||||||
|
foreach($posts as $post) {
|
||||||
|
|
||||||
|
$item = array();
|
||||||
|
|
||||||
|
$item['uri'] = $this->extractGroupURI($post);
|
||||||
|
$item['title'] = $this->extractGroupTitle($post);
|
||||||
|
$item['author'] = $this->extractGroupAuthor($post);
|
||||||
|
$item['content'] = $this->extractGroupContent($post);
|
||||||
|
$item['timestamp'] = $this->extractGroupTimestamp($post);
|
||||||
|
$item['enclosures'] = $this->extractGroupEnclosures($post);
|
||||||
|
|
||||||
|
$this->items[] = $item;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sanitizeGroup($group) {
|
||||||
|
|
||||||
|
if(filter_var(
|
||||||
|
$group,
|
||||||
|
FILTER_VALIDATE_URL,
|
||||||
|
FILTER_FLAG_HOST_REQUIRED | FILTER_FLAG_PATH_REQUIRED)) {
|
||||||
|
// User provided a URL
|
||||||
|
|
||||||
|
$urlparts = parse_url($group);
|
||||||
|
|
||||||
|
if($urlparts['host'] !== parse_url(self::URI)['host']
|
||||||
|
&& 'www.' . $urlparts['host'] !== parse_url(self::URI)['host']) {
|
||||||
|
|
||||||
|
returnClientError('The host you provided is invalid! Received "'
|
||||||
|
. $urlparts['host']
|
||||||
|
. '", expected "'
|
||||||
|
. parse_url(self::URI)['host']
|
||||||
|
. '"!');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return explode('/', $urlparts['path'])[2];
|
||||||
|
|
||||||
|
} elseif(strpos($group, '/') !== false) {
|
||||||
|
returnClientError('The group you provided is invalid: ' . $group);
|
||||||
|
} else {
|
||||||
|
return $group;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function isPublicGroup($html) {
|
||||||
|
|
||||||
|
// Facebook redirects to the groups about page for non-public groups
|
||||||
|
$about = $html->find('#pagelet_group_about', 0);
|
||||||
|
|
||||||
|
return !($about);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractGroupName($html) {
|
||||||
|
|
||||||
|
$ogtitle = $html->find('meta[property="og:title"]', 0)
|
||||||
|
or returnServerError('Unable to find group title!');
|
||||||
|
|
||||||
|
return htmlspecialchars_decode($ogtitle->content, ENT_QUOTES);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractGroupURI($post) {
|
||||||
|
|
||||||
|
$elements = $post->find('a')
|
||||||
|
or returnServerError('Unable to find URI!');
|
||||||
|
|
||||||
|
foreach($elements as $anchor) {
|
||||||
|
|
||||||
|
// Find the one that is a permalink
|
||||||
|
if(strpos($anchor->href, 'permalink') !== false) {
|
||||||
|
return $anchor->href;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractGroupContent($post) {
|
||||||
|
|
||||||
|
$content = $post->find('div.userContent', 0)
|
||||||
|
or returnServerError('Unable to find user content!');
|
||||||
|
|
||||||
|
return $content->innertext . $content->next_sibling()->innertext;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractGroupTimestamp($post) {
|
||||||
|
|
||||||
|
$element = $post->find('abbr[data-utime]', 0)
|
||||||
|
or returnServerError('Unable to find timestamp!');
|
||||||
|
|
||||||
|
return $element->getAttribute('data-utime');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractGroupAuthor($post) {
|
||||||
|
|
||||||
|
$element = $post->find('img', 0)
|
||||||
|
or returnServerError('Unable to find author information!');
|
||||||
|
|
||||||
|
return $element->{'aria-label'};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractGroupEnclosures($post) {
|
||||||
|
|
||||||
|
$elements = $post->find('div.userContent', 0)->next_sibling()->find('img');
|
||||||
|
|
||||||
|
$enclosures = array();
|
||||||
|
|
||||||
|
foreach($elements as $enclosure) {
|
||||||
|
$enclosures[] = $enclosure->src;
|
||||||
|
}
|
||||||
|
|
||||||
|
return empty($enclosures) ? null : $enclosures;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractGroupTitle($post) {
|
||||||
|
|
||||||
|
$element = $post->find('h5', 0)
|
||||||
|
or returnServerError('Unable to find title!');
|
||||||
|
|
||||||
|
if(strpos($element->plaintext, 'shared') === false) {
|
||||||
|
|
||||||
|
$content = strip_tags($this->extractGroupContent($post));
|
||||||
|
|
||||||
|
return $this->extractGroupAuthor($post)
|
||||||
|
. ' posted: '
|
||||||
|
. substr(
|
||||||
|
$content,
|
||||||
|
0,
|
||||||
|
strpos(wordwrap($content, 64), "\n")
|
||||||
|
)
|
||||||
|
. '...';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $element->plaintext;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
private function collectUserData(){
|
||||||
|
|
||||||
//Extract a string using start and end delimiters
|
//Extract a string using start and end delimiters
|
||||||
function extractFromDelimiters($string, $start, $end){
|
function extractFromDelimiters($string, $start, $end){
|
||||||
@@ -95,7 +318,7 @@ class FacebookBridge extends BridgeAbstract {
|
|||||||
if (isset($_SESSION['captcha_fields'], $_SESSION['captcha_action'])) {
|
if (isset($_SESSION['captcha_fields'], $_SESSION['captcha_action'])) {
|
||||||
$captcha_action = $_SESSION['captcha_action'];
|
$captcha_action = $_SESSION['captcha_action'];
|
||||||
$captcha_fields = $_SESSION['captcha_fields'];
|
$captcha_fields = $_SESSION['captcha_fields'];
|
||||||
$captcha_fields['captcha_response'] = preg_replace("/[^a-zA-Z0-9]+/", "", $_POST['captcha_response']);
|
$captcha_fields['captcha_response'] = preg_replace('/[^a-zA-Z0-9]+/', '', $_POST['captcha_response']);
|
||||||
|
|
||||||
$header = array("Content-type:
|
$header = array("Content-type:
|
||||||
application/x-www-form-urlencoded\r\nReferer: $captcha_action\r\nCookie: noscript=1\r\n");
|
application/x-www-form-urlencoded\r\nReferer: $captcha_action\r\nCookie: noscript=1\r\n");
|
||||||
@@ -120,17 +343,44 @@ application/x-www-form-urlencoded\r\nReferer: $captcha_action\r\nCookie: noscrip
|
|||||||
if(is_null($html)) {
|
if(is_null($html)) {
|
||||||
$header = array('Accept-Language: ' . getEnv('HTTP_ACCEPT_LANGUAGE') . "\r\n");
|
$header = array('Accept-Language: ' . getEnv('HTTP_ACCEPT_LANGUAGE') . "\r\n");
|
||||||
|
|
||||||
// First character cannot be a forward slash
|
// Check if the user provided a fully qualified URL
|
||||||
if(strpos($this->getInput('u'), "/") === 0) {
|
if (filter_var($this->getInput('u'), FILTER_VALIDATE_URL)) {
|
||||||
returnClientError('Remove leading slash "/" from the username!');
|
|
||||||
}
|
$urlparts = parse_url($this->getInput('u'));
|
||||||
|
|
||||||
|
if($urlparts['host'] !== parse_url(self::URI)['host']) {
|
||||||
|
returnClientError('The host you provided is invalid! Received "'
|
||||||
|
. $urlparts['host']
|
||||||
|
. '", expected "'
|
||||||
|
. parse_url(self::URI)['host']
|
||||||
|
. '"!');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!array_key_exists('path', $urlparts)
|
||||||
|
|| $urlparts['path'] === '/') {
|
||||||
|
returnClientError('The URL you provided doesn\'t contain the user name!');
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = explode('/', $urlparts['path'])[1];
|
||||||
|
|
||||||
|
$html = getSimpleHTMLDOM(self::URI . urlencode($user) . '?_fb_noscript=1', $header)
|
||||||
|
or returnServerError('No results for this query.');
|
||||||
|
|
||||||
if(!strpos($this->getInput('u'), "/")) {
|
|
||||||
$html = getSimpleHTMLDOM(self::URI . urlencode($this->getInput('u')) . '?_fb_noscript=1', $header)
|
|
||||||
or returnServerError('No results for this query.');
|
|
||||||
} else {
|
} else {
|
||||||
$html = getSimpleHTMLDOM(self::URI . 'pages/' . $this->getInput('u') . '?_fb_noscript=1', $header)
|
|
||||||
or returnServerError('No results for this query.');
|
// First character cannot be a forward slash
|
||||||
|
if(strpos($this->getInput('u'), '/') === 0) {
|
||||||
|
returnClientError('Remove leading slash "/" from the username!');
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!strpos($this->getInput('u'), '/')) {
|
||||||
|
$html = getSimpleHTMLDOM(self::URI . urlencode($this->getInput('u')) . '?_fb_noscript=1', $header)
|
||||||
|
or returnServerError('No results for this query.');
|
||||||
|
} else {
|
||||||
|
$html = getSimpleHTMLDOM(self::URI . 'pages/' . $this->getInput('u') . '?_fb_noscript=1', $header)
|
||||||
|
or returnServerError('No results for this query.');
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,6 +414,12 @@ EOD;
|
|||||||
}
|
}
|
||||||
|
|
||||||
//No captcha? We can carry on retrieving page contents :)
|
//No captcha? We can carry on retrieving page contents :)
|
||||||
|
//First, we check wether the page is public or not
|
||||||
|
$loginForm = $html->find('._585r', 0);
|
||||||
|
if($loginForm != null) {
|
||||||
|
returnServerError('You must be logged in to view this page. This is not supported by RSS-Bridge.');
|
||||||
|
}
|
||||||
|
|
||||||
$element = $html
|
$element = $html
|
||||||
->find('#pagelet_timeline_main_column')[0]
|
->find('#pagelet_timeline_main_column')[0]
|
||||||
->children(0)
|
->children(0)
|
||||||
@@ -189,6 +445,12 @@ EOD;
|
|||||||
$posts = array($cell);
|
$posts = array($cell);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Optionally skip reviews
|
||||||
|
if($this->getInput('skip_reviews')
|
||||||
|
&& !is_null($cell->find('#review_composer_container', 0))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
foreach($posts as $post) {
|
foreach($posts as $post) {
|
||||||
// Check media type
|
// Check media type
|
||||||
switch($this->getInput('media_type')) {
|
switch($this->getInput('media_type')) {
|
||||||
@@ -259,7 +521,7 @@ EOD;
|
|||||||
);
|
);
|
||||||
|
|
||||||
//Retrieve date of the post
|
//Retrieve date of the post
|
||||||
$date = $post->find("abbr")[0];
|
$date = $post->find('abbr')[0];
|
||||||
if(isset($date) && $date->hasAttribute('data-utime')) {
|
if(isset($date) && $date->hasAttribute('data-utime')) {
|
||||||
$date = $date->getAttribute('data-utime');
|
$date = $date->getAttribute('data-utime');
|
||||||
} else {
|
} else {
|
||||||
@@ -290,9 +552,22 @@ EOD;
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
if(!empty($this->authorName)) {
|
|
||||||
return isset($this->extraInfos['name']) ? $this->extraInfos['name'] : $this->authorName
|
switch($this->queriedContext) {
|
||||||
. ' - Facebook Bridge';
|
|
||||||
|
case 'User':
|
||||||
|
if(!empty($this->authorName)) {
|
||||||
|
return isset($this->extraInfos['name']) ? $this->extraInfos['name'] : $this->authorName
|
||||||
|
. ' - Facebook Bridge';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case 'Group':
|
||||||
|
if(!empty($this->groupName)) {
|
||||||
|
return $this->groupName . ' - Facebook Bridge';
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getName();
|
return parent::getName();
|
||||||
|
@@ -15,47 +15,47 @@ class FootitoBridge extends BridgeAbstract {
|
|||||||
|
|
||||||
$content = trim($element->innertext);
|
$content = trim($element->innertext);
|
||||||
$content = str_replace(
|
$content = str_replace(
|
||||||
"<img",
|
'<img',
|
||||||
"<img style='float : left;'",
|
"<img style='float : left;'",
|
||||||
$content );
|
$content );
|
||||||
|
|
||||||
$content = str_replace(
|
$content = str_replace(
|
||||||
"class=\"logo\"",
|
'class="logo"',
|
||||||
"style='float : left;'",
|
"style='float : left;'",
|
||||||
$content );
|
$content );
|
||||||
|
|
||||||
$content = str_replace(
|
$content = str_replace(
|
||||||
"class=\"contenu\"",
|
'class="contenu"',
|
||||||
"style='margin-left : 60px;'",
|
"style='margin-left : 60px;'",
|
||||||
$content );
|
$content );
|
||||||
|
|
||||||
$content = str_replace(
|
$content = str_replace(
|
||||||
"class=\"responsive-comment\"",
|
'class="responsive-comment"',
|
||||||
"style='border-top : 1px #DDD solid; background-color : white; padding : 10px;'",
|
"style='border-top : 1px #DDD solid; background-color : white; padding : 10px;'",
|
||||||
$content );
|
$content );
|
||||||
|
|
||||||
$content = str_replace(
|
$content = str_replace(
|
||||||
"class=\"jaime\"",
|
'class="jaime"',
|
||||||
"style='display : none;'",
|
"style='display : none;'",
|
||||||
$content );
|
$content );
|
||||||
|
|
||||||
$content = str_replace(
|
$content = str_replace(
|
||||||
"class=\"auteur-event responsive\"",
|
'class="auteur-event responsive"',
|
||||||
"style='display : none;'",
|
"style='display : none;'",
|
||||||
$content );
|
$content );
|
||||||
|
|
||||||
$content = str_replace(
|
$content = str_replace(
|
||||||
"class=\"report-abuse-button\"",
|
'class="report-abuse-button"',
|
||||||
"style='display : none;'",
|
"style='display : none;'",
|
||||||
$content );
|
$content );
|
||||||
|
|
||||||
$content = str_replace(
|
$content = str_replace(
|
||||||
"class=\"reaction clearfix\"",
|
'class="reaction clearfix"',
|
||||||
"style='margin : 10px 0px; padding : 5px; border-bottom : 1px #DDD solid;'",
|
"style='margin : 10px 0px; padding : 5px; border-bottom : 1px #DDD solid;'",
|
||||||
$content );
|
$content );
|
||||||
|
|
||||||
$content = str_replace(
|
$content = str_replace(
|
||||||
"class=\"infos\"",
|
'class="infos"',
|
||||||
"style='font-size : 0.7em;'",
|
"style='font-size : 0.7em;'",
|
||||||
$content );
|
$content );
|
||||||
|
|
||||||
|
@@ -30,7 +30,7 @@ class FourchanBridge extends BridgeAbstract {
|
|||||||
public function collectData(){
|
public function collectData(){
|
||||||
|
|
||||||
$html = getSimpleHTMLDOM($this->getURI())
|
$html = getSimpleHTMLDOM($this->getURI())
|
||||||
or returnServerError("Could not request 4chan, thread not found");
|
or returnServerError('Could not request 4chan, thread not found');
|
||||||
|
|
||||||
foreach($html->find('div.postContainer') as $element) {
|
foreach($html->find('div.postContainer') as $element) {
|
||||||
$item = array();
|
$item = array();
|
||||||
|
@@ -106,7 +106,7 @@ class GithubIssueBridge extends BridgeAbstract {
|
|||||||
$content = $comment->parent()->innertext;
|
$content = $comment->parent()->innertext;
|
||||||
} else {
|
} else {
|
||||||
$title .= ' / ' . trim($comment->firstChild()->plaintext);
|
$title .= ' / ' . trim($comment->firstChild()->plaintext);
|
||||||
$content = "<pre>" . $comment->find('.comment-body', 0)->innertext . "</pre>";
|
$content = '<pre>' . $comment->find('.comment-body', 0)->innertext . '</pre>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$item = array();
|
$item = array();
|
||||||
|
@@ -19,26 +19,26 @@ class GoComicsBridge extends BridgeAbstract {
|
|||||||
or returnServerError('Could not request GoComics: ' . $this->getURI());
|
or returnServerError('Could not request GoComics: ' . $this->getURI());
|
||||||
|
|
||||||
//Get info from first page
|
//Get info from first page
|
||||||
$author = preg_replace('/By /', '', $html->find(".media-subheading", 0)->plaintext);
|
$author = preg_replace('/By /', '', $html->find('.media-subheading', 0)->plaintext);
|
||||||
|
|
||||||
$link = self::URI . $html->find(".gc-deck--cta-0", 0)->find('a', 0)->href;
|
$link = self::URI . $html->find('.gc-deck--cta-0', 0)->find('a', 0)->href;
|
||||||
for($i = 0; $i < 5; $i++) {
|
for($i = 0; $i < 5; $i++) {
|
||||||
|
|
||||||
$item = array();
|
$item = array();
|
||||||
|
|
||||||
$page = getSimpleHTMLDOM($link)
|
$page = getSimpleHTMLDOM($link)
|
||||||
or returnServerError('Could not request GoComics: ' . $link);
|
or returnServerError('Could not request GoComics: ' . $link);
|
||||||
$imagelink = $page->find(".img-fluid", 1)->src;
|
$imagelink = $page->find('.img-fluid', 1)->src;
|
||||||
$date = explode("/", $link);
|
$date = explode('/', $link);
|
||||||
|
|
||||||
$item['id'] = $imagelink;
|
$item['id'] = $imagelink;
|
||||||
$item['uri'] = $link;
|
$item['uri'] = $link;
|
||||||
$item['author'] = $author;
|
$item['author'] = $author;
|
||||||
$item['title'] = 'GoComics ' . $this->getInput('comicname');
|
$item['title'] = 'GoComics ' . $this->getInput('comicname');
|
||||||
$item['timestamp'] = DateTime::createFromFormat("Ymd", $date[5] . $date[6] . $date[7])->getTimestamp();
|
$item['timestamp'] = DateTime::createFromFormat('Ymd', $date[5] . $date[6] . $date[7])->getTimestamp();
|
||||||
$item['content'] = '<img src="' . $imagelink . '" />';
|
$item['content'] = '<img src="' . $imagelink . '" />';
|
||||||
|
|
||||||
$link = self::URI . $page->find(".js-previous-comic", 0)->href;
|
$link = self::URI . $page->find('.js-previous-comic', 0)->href;
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -17,7 +17,7 @@ class GoogleSearchBridge extends BridgeAbstract {
|
|||||||
|
|
||||||
const PARAMETERS = array(array(
|
const PARAMETERS = array(array(
|
||||||
'q' => array(
|
'q' => array(
|
||||||
'name' => "keyword",
|
'name' => 'keyword',
|
||||||
'required' => true
|
'required' => true
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
61
bridges/GrandComicsDatabaseBridge.php
Normal file
61
bridges/GrandComicsDatabaseBridge.php
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
<?php
|
||||||
|
class GrandComicsDatabaseBridge extends BridgeAbstract {
|
||||||
|
|
||||||
|
const MAINTAINER = 'corenting';
|
||||||
|
const NAME = 'Grand Comics Database Bridge';
|
||||||
|
const URI = 'https://www.comics.org/';
|
||||||
|
const CACHE_TIMEOUT = 7200; // 2h
|
||||||
|
const DESCRIPTION = 'Returns the latest comics added to a series timeline';
|
||||||
|
const PARAMETERS = array( array(
|
||||||
|
'series' => array(
|
||||||
|
'name' => 'Series id (from the timeline URL)',
|
||||||
|
'required' => true,
|
||||||
|
'exampleValue' => '63051',
|
||||||
|
),
|
||||||
|
));
|
||||||
|
|
||||||
|
public function collectData(){
|
||||||
|
|
||||||
|
$url = self::URI . 'series/' . $this->getInput('series') . '/details/timeline/';
|
||||||
|
$html = getSimpleHTMLDOM($url)
|
||||||
|
or returnServerError('Error while downloading the website content');
|
||||||
|
|
||||||
|
$table = $html->find('table', 0);
|
||||||
|
$list = array_reverse($table->find('[class^=row_even]'));
|
||||||
|
$seriesName = $html->find('span[id=series_name]', 0)->innertext;
|
||||||
|
|
||||||
|
// Get row headers
|
||||||
|
$rowHeaders = $table->find('th');
|
||||||
|
foreach($list as $article) {
|
||||||
|
|
||||||
|
// Skip empty rows
|
||||||
|
$emptyRow = $article->find('td.empty_month');
|
||||||
|
if (count($emptyRow) != 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$rows = $article->find('td');
|
||||||
|
$key_date = $rows[0]->innertext;
|
||||||
|
|
||||||
|
// Get URL too
|
||||||
|
$uri = 'https://www.comics.org' . $article->find('a')[0]->href;
|
||||||
|
|
||||||
|
// Build content
|
||||||
|
$content = '';
|
||||||
|
for($i = 0; $i < count($rowHeaders); $i++) {
|
||||||
|
$headerItem = $rowHeaders[$i]->innertext;
|
||||||
|
$rowItem = $rows[$i]->innertext;
|
||||||
|
$content = $content . $headerItem . ': ' . $rowItem . '<br/>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Build final item
|
||||||
|
$item = array();
|
||||||
|
$item['title'] = $seriesName . ' - ' . $key_date;
|
||||||
|
$item['timestamp'] = strtotime($key_date);
|
||||||
|
$item['content'] = str_get_html($content);
|
||||||
|
$item['uri'] = $uri;
|
||||||
|
|
||||||
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1397
bridges/HotUKDealsBridge.php
Normal file
1397
bridges/HotUKDealsBridge.php
Normal file
File diff suppressed because it is too large
Load Diff
@@ -11,60 +11,38 @@ class InstagramBridge extends BridgeAbstract {
|
|||||||
'u' => array(
|
'u' => array(
|
||||||
'name' => 'username',
|
'name' => 'username',
|
||||||
'required' => true
|
'required' => true
|
||||||
),
|
|
||||||
'media_type' => array(
|
|
||||||
'name' => 'Media type',
|
|
||||||
'type' => 'list',
|
|
||||||
'required' => false,
|
|
||||||
'values' => array(
|
|
||||||
'Both' => 'all',
|
|
||||||
'Video' => 'video',
|
|
||||||
'Picture' => 'picture'
|
|
||||||
),
|
|
||||||
'defaultValue' => 'all'
|
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
array(
|
array(
|
||||||
'h' => array(
|
'h' => array(
|
||||||
'name' => 'hashtag',
|
'name' => 'hashtag',
|
||||||
'required' => true
|
'required' => true
|
||||||
),
|
)
|
||||||
|
),
|
||||||
|
'global' => array(
|
||||||
'media_type' => array(
|
'media_type' => array(
|
||||||
'name' => 'Media type',
|
'name' => 'Media type',
|
||||||
'type' => 'list',
|
'type' => 'list',
|
||||||
'required' => false,
|
'required' => false,
|
||||||
'values' => array(
|
'values' => array(
|
||||||
'Both' => 'all',
|
'All' => 'all',
|
||||||
|
'Story' => 'story',
|
||||||
'Video' => 'video',
|
'Video' => 'video',
|
||||||
'Picture' => 'picture'
|
'Picture' => 'picture',
|
||||||
),
|
),
|
||||||
'defaultValue' => 'all'
|
'defaultValue' => 'all'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
$html = getSimpleHTMLDOM($this->getURI())
|
|
||||||
or returnServerError('Could not request Instagram.');
|
|
||||||
|
|
||||||
$innertext = null;
|
if(!is_null($this->getInput('h')) && $this->getInput('media_type') == 'story') {
|
||||||
|
returnClientError('Stories are not supported for hashtags!');
|
||||||
foreach($html->find('script') as $script) {
|
|
||||||
if('' === $script->innertext) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$pos = strpos(trim($script->innertext), 'window._sharedData');
|
|
||||||
if(0 !== $pos) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
$innertext = $script->innertext;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$json = trim(substr($innertext, $pos + 18), ' =;');
|
$data = $this->getInstagramJSON($this->getURI());
|
||||||
$data = json_decode($json);
|
|
||||||
|
|
||||||
if(!is_null($this->getInput('u'))) {
|
if(!is_null($this->getInput('u'))) {
|
||||||
$userMedia = $data->entry_data->ProfilePage[0]->graphql->user->edge_owner_to_timeline_media->edges;
|
$userMedia = $data->entry_data->ProfilePage[0]->graphql->user->edge_owner_to_timeline_media->edges;
|
||||||
@@ -74,32 +52,83 @@ class InstagramBridge extends BridgeAbstract {
|
|||||||
|
|
||||||
foreach($userMedia as $media) {
|
foreach($userMedia as $media) {
|
||||||
$media = $media->node;
|
$media = $media->node;
|
||||||
// Check media type
|
|
||||||
switch($this->getInput('media_type')) {
|
if(!is_null($this->getInput('u'))) {
|
||||||
case 'all': break;
|
switch($this->getInput('media_type')) {
|
||||||
case 'video':
|
case 'all': break;
|
||||||
if($media->is_video === false) continue 2;
|
case 'video':
|
||||||
break;
|
if($media->__typename != 'GraphVideo') continue 2;
|
||||||
case 'picture':
|
break;
|
||||||
if($media->is_video === true) continue 2;
|
case 'picture':
|
||||||
break;
|
if($media->__typename != 'GraphImage') continue 2;
|
||||||
default: break;
|
break;
|
||||||
|
case 'story':
|
||||||
|
if($media->__typename != 'GraphSidecar') continue 2;
|
||||||
|
break;
|
||||||
|
default: break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if($this->getInput('media_type') == 'video' && !$media->is_video) continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$item = array();
|
$item = array();
|
||||||
$item['uri'] = self::URI . 'p/' . $media->shortcode . '/';
|
$item['uri'] = self::URI . 'p/' . $media->shortcode . '/';
|
||||||
$item['content'] = '<img src="' . htmlentities($media->display_url) . '" />';
|
|
||||||
if (isset($media->edge_media_to_caption->edges[0]->node->text)) {
|
if (isset($media->edge_media_to_caption->edges[0]->node->text)) {
|
||||||
$item['title'] = $media->edge_media_to_caption->edges[0]->node->text;
|
$item['title'] = $media->edge_media_to_caption->edges[0]->node->text;
|
||||||
} else {
|
} else {
|
||||||
$item['title'] = basename($media->display_url);
|
$item['title'] = basename($media->display_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!is_null($this->getInput('u')) && $media->__typename == 'GraphSidecar') {
|
||||||
|
$data = $this->getInstagramStory($item['uri']);
|
||||||
|
$item['content'] = $data[0];
|
||||||
|
$item['enclosures'] = $data[1];
|
||||||
|
} else {
|
||||||
|
$item['content'] = '<img src="' . htmlentities($media->display_url) . '" alt="'. $item['title'] . '" />';
|
||||||
|
$item['enclosures'] = array($media->display_url);
|
||||||
|
}
|
||||||
|
|
||||||
$item['timestamp'] = $media->taken_at_timestamp;
|
$item['timestamp'] = $media->taken_at_timestamp;
|
||||||
$item['enclosures'] = array($media->display_url);
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function getInstagramStory($uri) {
|
||||||
|
|
||||||
|
$data = $this->getInstagramJSON($uri);
|
||||||
|
$mediaInfo = $data->entry_data->PostPage[0]->graphql->shortcode_media;
|
||||||
|
|
||||||
|
//Process the first element, that isn't in the node graph
|
||||||
|
$caption = $mediaInfo->edge_media_to_caption->edges[0]->node->text;
|
||||||
|
|
||||||
|
$enclosures = [$mediaInfo->display_url];
|
||||||
|
$content = '<img src="' . htmlentities($mediaInfo->display_url) . '" alt="'. $caption . '" />';
|
||||||
|
|
||||||
|
foreach($mediaInfo->edge_sidecar_to_children->edges as $media) {
|
||||||
|
|
||||||
|
$content .= '<img src="' . htmlentities($media->node->display_url) . '" alt="'. $caption . '" />';
|
||||||
|
$enclosures[] = $media->node->display_url;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return [$content, $enclosures];
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function getInstagramJSON($uri) {
|
||||||
|
|
||||||
|
$html = getContents($uri)
|
||||||
|
or returnServerError('Could not request Instagram.');
|
||||||
|
$scriptRegex = '/window\._sharedData = (.*);<\/script>/';
|
||||||
|
|
||||||
|
preg_match($scriptRegex, $html, $matches, PREG_OFFSET_CAPTURE, 0);
|
||||||
|
|
||||||
|
return json_decode($matches[1][0]);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
public function getName(){
|
public function getName(){
|
||||||
if(!is_null($this->getInput('u'))) {
|
if(!is_null($this->getInput('u'))) {
|
||||||
return $this->getInput('u') . ' - Instagram Bridge';
|
return $this->getInput('u') . ' - Instagram Bridge';
|
||||||
|
@@ -1,465 +0,0 @@
|
|||||||
<?php
|
|
||||||
class IsoHuntBridge extends BridgeAbstract {
|
|
||||||
const MAINTAINER = 'logmanoriginal';
|
|
||||||
const NAME = 'isoHunt Bridge';
|
|
||||||
const URI = 'https://isohunt.to/';
|
|
||||||
const CACHE_TIMEOUT = 300; //5min
|
|
||||||
const DESCRIPTION = 'Returns the latest results by category or search result';
|
|
||||||
|
|
||||||
const PARAMETERS = array(
|
|
||||||
/*
|
|
||||||
* Get feeds for one of the "latest" categories
|
|
||||||
* Notice: The categories "News" and "Top Searches" are received from the main page
|
|
||||||
* Elements are sorted by name ascending!
|
|
||||||
*/
|
|
||||||
'By "Latest" category' => array(
|
|
||||||
'latest_category' => array(
|
|
||||||
'name' => 'Latest category',
|
|
||||||
'type' => 'list',
|
|
||||||
'required' => true,
|
|
||||||
'title' => 'Select your category',
|
|
||||||
'defaultValue' => 'news',
|
|
||||||
'values' => array(
|
|
||||||
'Hot Torrents' => 'hot_torrents',
|
|
||||||
'News' => 'news',
|
|
||||||
'Releases' => 'releases',
|
|
||||||
'Torrents' => 'torrents'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get feeds for one of the "torrent" categories
|
|
||||||
* Make sure to add new categories also to get_torrent_category_index($)!
|
|
||||||
* Elements are sorted by name ascending!
|
|
||||||
*/
|
|
||||||
'By "Torrent" category' => array(
|
|
||||||
'torrent_category' => array(
|
|
||||||
'name' => 'Torrent category',
|
|
||||||
'type' => 'list',
|
|
||||||
'required' => true,
|
|
||||||
'title' => 'Select your category',
|
|
||||||
'defaultValue' => 'anime',
|
|
||||||
'values' => array(
|
|
||||||
'Adult' => 'adult',
|
|
||||||
'Anime' => 'anime',
|
|
||||||
'Books' => 'books',
|
|
||||||
'Games' => 'games',
|
|
||||||
'Movies' => 'movies',
|
|
||||||
'Music' => 'music',
|
|
||||||
'Other' => 'other',
|
|
||||||
'Series & TV' => 'series_tv',
|
|
||||||
'Software' => 'software'
|
|
||||||
)
|
|
||||||
),
|
|
||||||
'torrent_popularity' => array(
|
|
||||||
'name' => 'Sort by popularity',
|
|
||||||
'type' => 'checkbox',
|
|
||||||
'title' => 'Activate to receive results by popularity'
|
|
||||||
)
|
|
||||||
),
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Get feeds for a specific search request
|
|
||||||
*/
|
|
||||||
'Search torrent by name' => array(
|
|
||||||
'search_name' => array(
|
|
||||||
'name' => 'Name',
|
|
||||||
'required' => true,
|
|
||||||
'title' => 'Insert your search query',
|
|
||||||
'exampleValue' => 'Bridge'
|
|
||||||
),
|
|
||||||
'search_category' => array(
|
|
||||||
'name' => 'Category',
|
|
||||||
'type' => 'list',
|
|
||||||
'title' => 'Select your category',
|
|
||||||
'defaultValue' => 'all',
|
|
||||||
'values' => array(
|
|
||||||
'Adult' => 'adult',
|
|
||||||
'All' => 'all',
|
|
||||||
'Anime' => 'anime',
|
|
||||||
'Books' => 'books',
|
|
||||||
'Games' => 'games',
|
|
||||||
'Movies' => 'movies',
|
|
||||||
'Music' => 'music',
|
|
||||||
'Other' => 'other',
|
|
||||||
'Series & TV' => 'series_tv',
|
|
||||||
'Software' => 'software'
|
|
||||||
)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
public function getURI(){
|
|
||||||
$uri = self::URI;
|
|
||||||
switch($this->queriedContext) {
|
|
||||||
case 'By "Latest" category':
|
|
||||||
switch($this->getInput('latest_category')) {
|
|
||||||
case 'hot_torrents':
|
|
||||||
$uri .= 'statistic/hot/torrents';
|
|
||||||
break;
|
|
||||||
case 'news':
|
|
||||||
break;
|
|
||||||
case 'releases':
|
|
||||||
$uri .= 'releases.php';
|
|
||||||
break;
|
|
||||||
case 'torrents':
|
|
||||||
$uri .= 'latest.php';
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'By "Torrent" category':
|
|
||||||
$uri .= $this->buildCategoryUri(
|
|
||||||
$this->getInput('torrent_category'),
|
|
||||||
$this->getInput('torrent_popularity')
|
|
||||||
);
|
|
||||||
break;
|
|
||||||
case 'Search torrent by name':
|
|
||||||
$category = $this->getInput('search_category');
|
|
||||||
$uri .= $this->buildCategoryUri($category);
|
|
||||||
if($category !== 'movies')
|
|
||||||
$uri .= '&ihq=' . urlencode($this->getInput('search_name'));
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: parent::getURI();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $uri;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function getName(){
|
|
||||||
switch($this->queriedContext) {
|
|
||||||
case 'By "Latest" category':
|
|
||||||
$categoryName = array_search(
|
|
||||||
$this->getInput('latest_category'),
|
|
||||||
self::PARAMETERS['By "Latest" category']['latest_category']['values']
|
|
||||||
);
|
|
||||||
$name = 'Latest ' . $categoryName . ' - ' . self::NAME;
|
|
||||||
break;
|
|
||||||
case 'By "Torrent" category':
|
|
||||||
$categoryName = array_search(
|
|
||||||
$this->getInput('torrent_category'),
|
|
||||||
self::PARAMETERS['By "Torrent" category']['torrent_category']['values']
|
|
||||||
);
|
|
||||||
$name = 'Category: ' . $categoryName . ' - ' . self::NAME;
|
|
||||||
break;
|
|
||||||
case 'Search torrent by name':
|
|
||||||
$categoryName = array_search(
|
|
||||||
$this->getInput('search_category'),
|
|
||||||
self::PARAMETERS['Search torrent by name']['search_category']['values']
|
|
||||||
);
|
|
||||||
$name = 'Search: "'
|
|
||||||
. $this->getInput('search_name')
|
|
||||||
. '" in category: '
|
|
||||||
. $categoryName . ' - '
|
|
||||||
. self::NAME;
|
|
||||||
break;
|
|
||||||
default: return parent::getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
return $name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public function collectData(){
|
|
||||||
$html = $this->loadHtml($this->getURI());
|
|
||||||
|
|
||||||
switch($this->queriedContext) {
|
|
||||||
case 'By "Latest" category':
|
|
||||||
switch($this->getInput('latest_category')) {
|
|
||||||
case 'hot_torrents':
|
|
||||||
$this->getLatestHotTorrents($html);
|
|
||||||
break;
|
|
||||||
case 'news':
|
|
||||||
$this->getLatestNews($html);
|
|
||||||
break;
|
|
||||||
case 'releases':
|
|
||||||
case 'torrents':
|
|
||||||
$this->getLatestTorrents($html);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'By "Torrent" category':
|
|
||||||
if($this->getInput('torrent_category') === 'movies') {
|
|
||||||
// This one is special (content wise)
|
|
||||||
$this->getMovieTorrents($html);
|
|
||||||
} else {
|
|
||||||
$this->getLatestTorrents($html);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 'Search torrent by name':
|
|
||||||
if($this->getInput('search_category') === 'movies') {
|
|
||||||
// This one is special (content wise)
|
|
||||||
$this->getMovieTorrents($html);
|
|
||||||
} else {
|
|
||||||
$this->getLatestTorrents($html);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#region Helper functions for "Movie Torrents"
|
|
||||||
|
|
||||||
private function getMovieTorrents($html){
|
|
||||||
$container = $html->find('div#w0', 0);
|
|
||||||
if(!$container)
|
|
||||||
returnServerError('Unable to find torrent container!');
|
|
||||||
|
|
||||||
$torrents = $container->find('article');
|
|
||||||
if(!$torrents)
|
|
||||||
returnServerError('Unable to find torrents!');
|
|
||||||
|
|
||||||
foreach($torrents as $torrent) {
|
|
||||||
|
|
||||||
$anchor = $torrent->find('a', 0);
|
|
||||||
if(!$anchor)
|
|
||||||
returnServerError('Unable to find anchor!');
|
|
||||||
|
|
||||||
$date = $torrent->find('small', 0);
|
|
||||||
if(!$date)
|
|
||||||
returnServerError('Unable to find date!');
|
|
||||||
|
|
||||||
$item = array();
|
|
||||||
|
|
||||||
$item['uri'] = $this->fixRelativeUri($anchor->href);
|
|
||||||
$item['title'] = $anchor->title;
|
|
||||||
// $item['author'] =
|
|
||||||
$item['timestamp'] = strtotime($date->plaintext);
|
|
||||||
$item['content'] = $this->fixRelativeUri($torrent->innertext);
|
|
||||||
|
|
||||||
$this->items[] = $item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Helper functions for "Latest Hot Torrents"
|
|
||||||
|
|
||||||
private function getLatestHotTorrents($html){
|
|
||||||
$container = $html->find('div#serps', 0);
|
|
||||||
if(!$container)
|
|
||||||
returnServerError('Unable to find torrent container!');
|
|
||||||
|
|
||||||
$torrents = $container->find('tr');
|
|
||||||
if(!$torrents)
|
|
||||||
returnServerError('Unable to find torrents!');
|
|
||||||
|
|
||||||
// Remove first element (header row)
|
|
||||||
$torrents = array_slice($torrents, 1);
|
|
||||||
|
|
||||||
foreach($torrents as $torrent) {
|
|
||||||
|
|
||||||
$cell = $torrent->find('td', 0);
|
|
||||||
if(!$cell)
|
|
||||||
returnServerError('Unable to find cell!');
|
|
||||||
|
|
||||||
$element = $cell->find('a', 0);
|
|
||||||
if(!$element)
|
|
||||||
returnServerError('Unable to find element!');
|
|
||||||
|
|
||||||
$item = array();
|
|
||||||
|
|
||||||
$item['uri'] = $element->href;
|
|
||||||
$item['title'] = $element->plaintext;
|
|
||||||
// $item['author'] =
|
|
||||||
// $item['timestamp'] =
|
|
||||||
// $item['content'] =
|
|
||||||
|
|
||||||
$this->items[] = $item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Helper functions for "Latest News"
|
|
||||||
|
|
||||||
private function getLatestNews($html){
|
|
||||||
$container = $html->find('div#postcontainer', 0);
|
|
||||||
if(!$container)
|
|
||||||
returnServerError('Unable to find post container!');
|
|
||||||
|
|
||||||
$posts = $container->find('div.index-post');
|
|
||||||
if(!$posts)
|
|
||||||
returnServerError('Unable to find posts!');
|
|
||||||
|
|
||||||
foreach($posts as $post) {
|
|
||||||
$item = array();
|
|
||||||
|
|
||||||
$item['uri'] = $this->latestNewsExtractUri($post);
|
|
||||||
$item['title'] = $this->latestNewsExtractTitle($post);
|
|
||||||
$item['author'] = $this->latestNewsExtractAuthor($post);
|
|
||||||
$item['timestamp'] = $this->latestNewsExtractTimestamp($post);
|
|
||||||
$item['content'] = $this->latestNewsExtractContent($post);
|
|
||||||
|
|
||||||
$this->items[] = $item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function latestNewsExtractAuthor($post){
|
|
||||||
$author = $post->find('small', 0);
|
|
||||||
if(!$author)
|
|
||||||
returnServerError('Unable to find author!');
|
|
||||||
|
|
||||||
// The author is hidden within a string like: 'Posted by {author} on {date}'
|
|
||||||
preg_match('/Posted\sby\s(.*)\son/i', $author->innertext, $matches);
|
|
||||||
|
|
||||||
return $matches[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function latestNewsExtractTimestamp($post){
|
|
||||||
$date = $post->find('small', 0);
|
|
||||||
if(!$date)
|
|
||||||
returnServerError('Unable to find date!');
|
|
||||||
|
|
||||||
// The date is hidden within a string like: 'Posted by {author} on {date}'
|
|
||||||
preg_match('/Posted\sby\s.*\son\s(.*)/i', $date->innertext, $matches);
|
|
||||||
|
|
||||||
$timestamp = strtotime($matches[1]);
|
|
||||||
|
|
||||||
// Make sure date is not in the future (dates are given like 'Nov. 20' without year)
|
|
||||||
if($timestamp > time()) {
|
|
||||||
$timestamp = strtotime('-1 year', $timestamp);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $timestamp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function latestNewsExtractTitle($post){
|
|
||||||
$title = $post->find('a', 0);
|
|
||||||
if(!$title)
|
|
||||||
returnServerError('Unable to find title!');
|
|
||||||
|
|
||||||
return $title->plaintext;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function latestNewsExtractUri($post){
|
|
||||||
$uri = $post->find('a', 0);
|
|
||||||
if(!$uri)
|
|
||||||
returnServerError('Unable to find uri!');
|
|
||||||
|
|
||||||
return $uri->href;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function latestNewsExtractContent($post){
|
|
||||||
$content = $post->find('div', 0);
|
|
||||||
if(!$content)
|
|
||||||
returnServerError('Unable to find content!');
|
|
||||||
|
|
||||||
// Remove <h2>...</h2> (title)
|
|
||||||
foreach($content->find('h2') as $element) {
|
|
||||||
$element->outertext = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Remove <small>...</small> (author)
|
|
||||||
foreach($content->find('small') as $element) {
|
|
||||||
$element->outertext = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
return $content->innertext;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Helper functions for "Latest Torrents", "Latest Releases" and "Torrent Category"
|
|
||||||
|
|
||||||
private function getLatestTorrents($html){
|
|
||||||
$container = $html->find('div#serps', 0);
|
|
||||||
if(!$container)
|
|
||||||
returnServerError('Unable to find torrent container!');
|
|
||||||
|
|
||||||
$torrents = $container->find('tr[data-key]');
|
|
||||||
if(!$torrents)
|
|
||||||
returnServerError('Unable to find torrents!');
|
|
||||||
|
|
||||||
foreach($torrents as $torrent) {
|
|
||||||
$item = array();
|
|
||||||
|
|
||||||
$item['uri'] = $this->latestTorrentsExtractUri($torrent);
|
|
||||||
$item['title'] = $this->latestTorrentsExtractTitle($torrent);
|
|
||||||
$item['author'] = $this->latestTorrentsExtractAuthor($torrent);
|
|
||||||
$item['timestamp'] = $this->latestTorrentsExtractTimestamp($torrent);
|
|
||||||
$item['content'] = ''; // There is no valuable content
|
|
||||||
|
|
||||||
$this->items[] = $item;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function latestTorrentsExtractTitle($torrent){
|
|
||||||
$cell = $torrent->find('td.title-row', 0);
|
|
||||||
if(!$cell)
|
|
||||||
returnServerError('Unable to find title cell!');
|
|
||||||
|
|
||||||
$title = $cell->find('span', 0);
|
|
||||||
if(!$title)
|
|
||||||
returnServerError('Unable to find title!');
|
|
||||||
|
|
||||||
return $title->plaintext;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function latestTorrentsExtractUri($torrent){
|
|
||||||
$cell = $torrent->find('td.title-row', 0);
|
|
||||||
if(!$cell)
|
|
||||||
returnServerError('Unable to find title cell!');
|
|
||||||
|
|
||||||
$uri = $cell->find('a', 0);
|
|
||||||
if(!$uri)
|
|
||||||
returnServerError('Unable to find uri!');
|
|
||||||
|
|
||||||
return $this->fixRelativeUri($uri->href);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function latestTorrentsExtractAuthor($torrent){
|
|
||||||
$cell = $torrent->find('td.user-row', 0);
|
|
||||||
if(!$cell)
|
|
||||||
return; // No author
|
|
||||||
|
|
||||||
$user = $cell->find('a', 0);
|
|
||||||
if(!$user)
|
|
||||||
returnServerError('Unable to find user!');
|
|
||||||
|
|
||||||
return $user->plaintext;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function latestTorrentsExtractTimestamp($torrent){
|
|
||||||
$cell = $torrent->find('td.date-row', 0);
|
|
||||||
if(!$cell)
|
|
||||||
returnServerError('Unable to find date cell!');
|
|
||||||
|
|
||||||
return strtotime('-' . $cell->plaintext, time());
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Generic helper functions
|
|
||||||
|
|
||||||
private function loadHtml($uri){
|
|
||||||
$html = getSimpleHTMLDOM($uri);
|
|
||||||
if(!$html)
|
|
||||||
returnServerError('Unable to load ' . $uri . '!');
|
|
||||||
|
|
||||||
return $html;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function fixRelativeUri($uri){
|
|
||||||
return preg_replace('/\//i', self::URI, $uri, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function buildCategoryUri($category, $order_popularity = false){
|
|
||||||
switch($category) {
|
|
||||||
case 'anime': $index = 1; break;
|
|
||||||
case 'software' : $index = 2; break;
|
|
||||||
case 'games' : $index = 3; break;
|
|
||||||
case 'adult' : $index = 4; break;
|
|
||||||
case 'movies' : $index = 5; break;
|
|
||||||
case 'music' : $index = 6; break;
|
|
||||||
case 'other' : $index = 7; break;
|
|
||||||
case 'series_tv' : $index = 8; break;
|
|
||||||
case 'books': $index = 9; break;
|
|
||||||
case 'all':
|
|
||||||
default: $index = 0; break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 'torrents/?iht=' . $index . '&ihs=' . ($order_popularity ? 1 : 0) . '&age=0';
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
353
bridges/JustETFBridge.php
Normal file
353
bridges/JustETFBridge.php
Normal file
@@ -0,0 +1,353 @@
|
|||||||
|
<?php
|
||||||
|
class JustETFBridge extends BridgeAbstract {
|
||||||
|
const NAME = 'justETF Bridge';
|
||||||
|
const URI = 'https://www.justetf.com';
|
||||||
|
const DESCRIPTION = 'Currently only supports the news feed';
|
||||||
|
const MAINTAINER = 'logmanoriginal';
|
||||||
|
const PARAMETERS = array(
|
||||||
|
'News' => array(
|
||||||
|
'full' => array(
|
||||||
|
'name' => 'Full Article',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'title' => 'Enable to load full articles'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'Profile' => array(
|
||||||
|
'isin' => array(
|
||||||
|
'name' => 'ISIN',
|
||||||
|
'type' => 'text',
|
||||||
|
'required' => true,
|
||||||
|
'pattern' => '[a-zA-Z]{2}[a-zA-Z0-9]{10}',
|
||||||
|
'title' => 'ISIN, consisting of 2-letter country code, 9-character identifier, check character'
|
||||||
|
),
|
||||||
|
'strategy' => array(
|
||||||
|
'name' => 'Include Strategy',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'defaultValue' => 'checked'
|
||||||
|
),
|
||||||
|
'description' => array(
|
||||||
|
'name' => 'Include Description',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'defaultValue' => 'checked'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'global' => array(
|
||||||
|
'lang' => array(
|
||||||
|
'name' => 'Language',
|
||||||
|
'required' => true,
|
||||||
|
'type' => 'list',
|
||||||
|
'values' => array(
|
||||||
|
'Englisch' => 'en',
|
||||||
|
'Deutsch' => 'de',
|
||||||
|
'Italiano' => 'it'
|
||||||
|
),
|
||||||
|
'defaultValue' => 'Englisch'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
public function collectData() {
|
||||||
|
$html = getSimpleHTMLDOM($this->getURI())
|
||||||
|
or returnServerError('Failed loading contents from ' . $this->getURI());
|
||||||
|
|
||||||
|
defaultLinkTo($html, static::URI);
|
||||||
|
|
||||||
|
switch($this->queriedContext) {
|
||||||
|
case 'News':
|
||||||
|
$this->collectNews($html);
|
||||||
|
break;
|
||||||
|
case 'Profile':
|
||||||
|
$this->collectProfile($html);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getURI() {
|
||||||
|
$uri = static::URI;
|
||||||
|
|
||||||
|
if($this->getInput('lang')) {
|
||||||
|
$uri .= '/' . $this->getInput('lang');
|
||||||
|
}
|
||||||
|
|
||||||
|
switch($this->queriedContext) {
|
||||||
|
case 'News':
|
||||||
|
$uri .= '/news';
|
||||||
|
break;
|
||||||
|
case 'Profile':
|
||||||
|
$uri .= '/etf-profile.html?' . http_build_query(array(
|
||||||
|
'isin' => strtoupper($this->getInput('isin'))
|
||||||
|
));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $uri;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getName() {
|
||||||
|
$name = static::NAME;
|
||||||
|
|
||||||
|
$name .= ($this->queriedContext) ? ' - ' . $this->queriedContext : '';
|
||||||
|
|
||||||
|
switch($this->queriedContext) {
|
||||||
|
case 'News': break;
|
||||||
|
case 'Profile':
|
||||||
|
if($this->getInput('isin')) {
|
||||||
|
$name .= ' ISIN ' . strtoupper($this->getInput('isin'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->getInput('lang')) {
|
||||||
|
$name .= ' (' . strtoupper($this->getInput('lang')) . ')';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region Common
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fixes dates depending on the choosen language:
|
||||||
|
*
|
||||||
|
* de : dd.mm.yy
|
||||||
|
* en : dd.mm.yy
|
||||||
|
* it : dd/mm/yy
|
||||||
|
*
|
||||||
|
* Basically strtotime doesn't convert dates correctly due to formats
|
||||||
|
* being hard to interpret. So we use the DateTime object, manually
|
||||||
|
* fixing dates and times (set to 00:00:00.000).
|
||||||
|
*
|
||||||
|
* We don't know the timezone, so just assume +00:00 (or whatever
|
||||||
|
* DateTime chooses)
|
||||||
|
*/
|
||||||
|
private function fixDate($date) {
|
||||||
|
switch($this->getInput('lang')) {
|
||||||
|
case 'en':
|
||||||
|
case 'de':
|
||||||
|
$df = date_create_from_format('d.m.y', $date);
|
||||||
|
break;
|
||||||
|
case 'it':
|
||||||
|
$df = date_create_from_format('d/m/y', $date);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
date_time_set($df, 0, 0);
|
||||||
|
|
||||||
|
// debugMessage(date_format($df, 'U'));
|
||||||
|
|
||||||
|
return date_format($df, 'U');
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractImages($article) {
|
||||||
|
// Notice: We can have zero or more images (though it should mostly be 1)
|
||||||
|
$elements = $article->find('img');
|
||||||
|
|
||||||
|
$images = array();
|
||||||
|
|
||||||
|
foreach($elements as $img) {
|
||||||
|
// Skip the logo (mostly provided part of a hidden div)
|
||||||
|
if(substr($img->src, strrpos($img->src, '/') + 1) === 'logo.png')
|
||||||
|
continue;
|
||||||
|
|
||||||
|
$images[] = $img->src;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $images;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region News
|
||||||
|
|
||||||
|
private function collectNews($html) {
|
||||||
|
$articles = $html->find('div.newsTopArticle')
|
||||||
|
or returnServerError('No articles found! Layout might have changed!');
|
||||||
|
|
||||||
|
foreach($articles as $article) {
|
||||||
|
|
||||||
|
$item = array();
|
||||||
|
|
||||||
|
// Common data
|
||||||
|
|
||||||
|
$item['uri'] = $this->extractNewsUri($article);
|
||||||
|
$item['timestamp'] = $this->extractNewsDate($article);
|
||||||
|
$item['title'] = $this->extractNewsTitle($article);
|
||||||
|
|
||||||
|
if($this->getInput('full')) {
|
||||||
|
|
||||||
|
$uri = $this->extractNewsUri($article);
|
||||||
|
|
||||||
|
$html = getSimpleHTMLDOMCached($uri)
|
||||||
|
or returnServerError('Failed loading full article from ' . $uri);
|
||||||
|
|
||||||
|
$fullArticle = $html->find('div.article', 0)
|
||||||
|
or returnServerError('No content found! Layout might have changed!');
|
||||||
|
|
||||||
|
defaultLinkTo($fullArticle, static::URI);
|
||||||
|
|
||||||
|
$item['author'] = $this->extractFullArticleAuthor($fullArticle);
|
||||||
|
$item['content'] = $this->extractFullArticleContent($fullArticle);
|
||||||
|
$item['enclosures'] = $this->extractImages($fullArticle);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
$item['content'] = $this->extractNewsDescription($article);
|
||||||
|
$item['enclosures'] = $this->extractImages($article);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractNewsUri($article) {
|
||||||
|
$element = $article->find('a', 0)
|
||||||
|
or returnServerError('Anchor not found!');
|
||||||
|
|
||||||
|
return $element->href;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractNewsDate($article) {
|
||||||
|
$element = $article->find('div.subheadline', 0)
|
||||||
|
or returnServerError('Date not found!');
|
||||||
|
|
||||||
|
// debugMessage($element->plaintext);
|
||||||
|
|
||||||
|
$date = trim(explode('|', $element->plaintext)[0]);
|
||||||
|
|
||||||
|
return $this->fixDate($date);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractNewsDescription($article) {
|
||||||
|
$element = $article->find('span.newsText', 0)
|
||||||
|
or returnServerError('Description not found!');
|
||||||
|
|
||||||
|
$element->find('a', 0)->onclick = '';
|
||||||
|
|
||||||
|
// debugMessage($element->innertext);
|
||||||
|
|
||||||
|
return $element->innertext;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractNewsTitle($article) {
|
||||||
|
$element = $article->find('h3', 0)
|
||||||
|
or returnServerError('Title not found!');
|
||||||
|
|
||||||
|
return $element->plaintext;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractFullArticleContent($article) {
|
||||||
|
$element = $article->find('div.article_body', 0)
|
||||||
|
or returnServerError('Article body not found!');
|
||||||
|
|
||||||
|
// Remove teaser image
|
||||||
|
$element->find('img.teaser-img', 0)->outertext = '';
|
||||||
|
|
||||||
|
// Remove self advertisements
|
||||||
|
foreach($element->find('.call-action') as $adv) {
|
||||||
|
$adv->outertext = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove tips
|
||||||
|
foreach($element->find('.panel-edu') as $tip) {
|
||||||
|
$tip->outertext = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove inline scripts (used for i.e. interactive graphs) as they are
|
||||||
|
// rendered as a long series of strings
|
||||||
|
foreach($element->find('script') as $script) {
|
||||||
|
$script->outertext = '[Content removed! Visit site to see full contents!]';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $element->innertext;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractFullArticleAuthor($article) {
|
||||||
|
$element = $article->find('span[itemprop=name]', 0)
|
||||||
|
or returnServerError('Author not found!');
|
||||||
|
|
||||||
|
return $element->plaintext;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Profile
|
||||||
|
|
||||||
|
private function collectProfile($html) {
|
||||||
|
$item = array();
|
||||||
|
|
||||||
|
$item['uri'] = $this->getURI();
|
||||||
|
$item['timestamp'] = $this->extractProfileDate($html);
|
||||||
|
$item['title'] = $this->extractProfiletitle($html);
|
||||||
|
$item['author'] = $this->extractProfileAuthor($html);
|
||||||
|
$item['content'] = $this->extractProfileContent($html);
|
||||||
|
|
||||||
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractProfileDate($html) {
|
||||||
|
$element = $html->find('div.infobox div.vallabel', 0)
|
||||||
|
or returnServerError('Date not found!');
|
||||||
|
|
||||||
|
// debugMessage($element->plaintext);
|
||||||
|
|
||||||
|
$date = trim(explode("\r\n", $element->plaintext)[1]);
|
||||||
|
|
||||||
|
return $this->fixDate($date);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractProfileTitle($html) {
|
||||||
|
$element = $html->find('span.h1', 0)
|
||||||
|
or returnServerError('Title not found!');
|
||||||
|
|
||||||
|
return $element->plaintext;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractProfileContent($html) {
|
||||||
|
// There are a few thins we are interested:
|
||||||
|
// - Investment Strategy
|
||||||
|
// - Description
|
||||||
|
// - Quote
|
||||||
|
|
||||||
|
$strategy = $html->find('div.tab-container div.col-sm-6 p', 0)
|
||||||
|
or returnServerError('Investment Strategy not found!');
|
||||||
|
|
||||||
|
// Description requires a bit of cleanup due to lack of propper identification
|
||||||
|
|
||||||
|
$description = $html->find('div.headline', 5)
|
||||||
|
or returnServerError('Description container not found!');
|
||||||
|
|
||||||
|
$description = $description->parent();
|
||||||
|
|
||||||
|
foreach($description->find('div') as $div) {
|
||||||
|
$div->outertext = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$quote = $html->find('div.infobox div.val', 0)
|
||||||
|
or returnServerError('Quote not found!');
|
||||||
|
|
||||||
|
$quote_html = '<strong>Quote</strong><br><p>' . $quote . '</p>';
|
||||||
|
$strategy_html = '';
|
||||||
|
$description_html = '';
|
||||||
|
|
||||||
|
if($this->getInput('strategy') === true) {
|
||||||
|
$strategy_html = '<strong>Strategy</strong><br><p>' . $strategy . '</p><br>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if($this->getInput('description') === true) {
|
||||||
|
$description_html = '<strong>Description</strong><br><p>' . $description . '</p><br>';
|
||||||
|
}
|
||||||
|
|
||||||
|
return $strategy_html . $description_html . $quote_html;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function extractProfileAuthor($html) {
|
||||||
|
// Use ISIN + WKN as author
|
||||||
|
// Notice: "identfier" is not a typo [sic]!
|
||||||
|
$element = $html->find('span.identfier', 0)
|
||||||
|
or returnServerError('Author not found!');
|
||||||
|
|
||||||
|
return $element->plaintext;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
@@ -58,7 +58,7 @@ class KununuBridge extends BridgeAbstract {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return self::URI . $site . '/' . $company . '/' . $section;
|
return self::URI . $site . '/' . $company . '/' . $section . '?sort=update_time_desc';
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getURI();
|
return parent::getURI();
|
||||||
@@ -135,8 +135,8 @@ class KununuBridge extends BridgeAbstract {
|
|||||||
* Encodes unmlauts in the given text
|
* Encodes unmlauts in the given text
|
||||||
*/
|
*/
|
||||||
private function encodeUmlauts($text){
|
private function encodeUmlauts($text){
|
||||||
$umlauts = Array("/ä/","/ö/","/ü/","/Ä/","/Ö/","/Ü/","/ß/");
|
$umlauts = Array('/ä/','/ö/','/ü/','/Ä/','/Ö/','/Ü/','/ß/');
|
||||||
$replace = Array("ae","oe","ue","Ae","Oe","Ue","ss");
|
$replace = Array('ae','oe','ue','Ae','Oe','Ue','ss');
|
||||||
|
|
||||||
return preg_replace($umlauts, $replace, $text);
|
return preg_replace($umlauts, $replace, $text);
|
||||||
}
|
}
|
||||||
@@ -190,11 +190,11 @@ class KununuBridge extends BridgeAbstract {
|
|||||||
* Returns the URI from a given article
|
* Returns the URI from a given article
|
||||||
*/
|
*/
|
||||||
private function extractArticleUri($article){
|
private function extractArticleUri($article){
|
||||||
$anchor = $article->find('ku-company-review-more', 0);
|
$anchor = $article->find('h1.review-title a', 0);
|
||||||
if(is_null($anchor))
|
if(is_null($anchor))
|
||||||
returnServerError('Cannot find article URI!');
|
returnServerError('Cannot find article URI!');
|
||||||
|
|
||||||
return self::URI . $anchor->{'review-url'};
|
return self::URI . $anchor->href;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@@ -1,11 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
class LeBonCoinBridge extends BridgeAbstract {
|
class LeBonCoinBridge extends BridgeAbstract {
|
||||||
|
|
||||||
const MAINTAINER = '16mhz';
|
const MAINTAINER = 'jacknumber';
|
||||||
const NAME = 'LeBonCoin';
|
const NAME = 'LeBonCoin';
|
||||||
const URI = 'https://www.leboncoin.fr/';
|
const URI = 'https://www.leboncoin.fr/';
|
||||||
const DESCRIPTION = 'Returns most recent results from LeBonCoin for a
|
const DESCRIPTION = 'Returns most recent results from LeBonCoin';
|
||||||
region, and optionally a category and a keyword .';
|
|
||||||
|
|
||||||
const PARAMETERS = array(
|
const PARAMETERS = array(
|
||||||
array(
|
array(
|
||||||
@@ -14,125 +13,137 @@ region, and optionally a category and a keyword .';
|
|||||||
'name' => 'Région',
|
'name' => 'Région',
|
||||||
'type' => 'list',
|
'type' => 'list',
|
||||||
'values' => array(
|
'values' => array(
|
||||||
'Toute la France' => 'ile_de_france/occasions',
|
'Toute la France' => '',
|
||||||
'Alsace' => 'alsace',
|
'Alsace' => '1',
|
||||||
'Aquitaine' => 'aquitaine',
|
'Aquitaine' => '2',
|
||||||
'Auvergne' => 'auvergne',
|
'Auvergne' => '3',
|
||||||
'Basse Normandie' => 'basse_normandie',
|
'Basse Normandie' => '4',
|
||||||
'Bourgogne' => 'bourgogne',
|
'Bourgogne' => '5',
|
||||||
'Bretagne' => 'bretagne',
|
'Bretagne' => '6',
|
||||||
'Centre' => 'centre',
|
'Centre' => '7',
|
||||||
'Champagne Ardenne' => 'champagne_ardenne',
|
'Champagne Ardenne' => '8',
|
||||||
'Corse' => 'corse',
|
'Corse' => '9',
|
||||||
'Franche Comté' => 'franche_comte',
|
'Franche Comté' => '10',
|
||||||
'Haute Normandie' => 'haute_normandie',
|
'Haute Normandie' => '11',
|
||||||
'Ile de France' => 'ile_de_france',
|
'Ile de France' => '12',
|
||||||
'Languedoc Roussillon' => 'languedoc_roussillon',
|
'Languedoc Roussillon' => '13',
|
||||||
'Limousin' => 'limousin',
|
'Limousin' => '14',
|
||||||
'Lorraine' => 'lorraine',
|
'Lorraine' => '15',
|
||||||
'Midi Pyrénées' => 'midi_pyrenees',
|
'Midi Pyrénées' => '16',
|
||||||
'Nord Pas De Calais' => 'nord_pas_de_calais',
|
'Nord Pas De Calais' => '17',
|
||||||
'Pays de la Loire' => 'pays_de_la_loire',
|
'Pays de la Loire' => '18',
|
||||||
'Picardie' => 'picardie',
|
'Picardie' => '19',
|
||||||
'Poitou Charentes' => 'poitou_charentes',
|
'Poitou Charentes' => '20',
|
||||||
'Provence Alpes Côte d\'Azur' => 'provence_alpes_cote_d_azur',
|
'Provence Alpes Côte d\'Azur' => '21',
|
||||||
'Rhône-Alpes' => 'rhone_alpes',
|
'Rhône-Alpes' => '22',
|
||||||
'Guadeloupe' => 'guadeloupe',
|
'Guadeloupe' => '23',
|
||||||
'Martinique' => 'martinique',
|
'Martinique' => '24',
|
||||||
'Guyane' => 'guyane',
|
'Guyane' => '25',
|
||||||
'Réunion' => 'reunion'
|
'Réunion' => '26'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'c' => array(
|
'c' => array(
|
||||||
'name' => 'Catégorie',
|
'name' => 'Catégorie',
|
||||||
'type' => 'list',
|
'type' => 'list',
|
||||||
'values' => array(
|
'values' => array(
|
||||||
'TOUS' => '',
|
'Toutes catégories' => '',
|
||||||
'EMPLOI' => '_emploi_',
|
'EMPLOI' => array(
|
||||||
|
'Emploi et recrutement' => '71',
|
||||||
|
'Offres d\'emploi et jobs' => '33'
|
||||||
|
),
|
||||||
'VEHICULES' => array(
|
'VEHICULES' => array(
|
||||||
'Tous' => '_vehicules_',
|
'Tous' => '1',
|
||||||
'Voitures' => 'voitures',
|
'Voitures' => '2',
|
||||||
'Motos' => 'motos',
|
'Motos' => '3',
|
||||||
'Caravaning' => 'caravaning',
|
'Caravaning' => '4',
|
||||||
'Utilitaires' => 'utilitaires',
|
'Utilitaires' => '5',
|
||||||
'Équipement Auto' => 'equipement_auto',
|
'Equipement Auto' => '6',
|
||||||
'Équipement Moto' => 'equipement_moto',
|
'Equipement Moto' => '44',
|
||||||
'Équipement Caravaning' => 'equipement_caravaning',
|
'Equipement Caravaning' => '50',
|
||||||
'Nautisme' => 'nautisme',
|
'Nautisme' => '7',
|
||||||
'Équipement Nautisme' => 'equipement_nautisme'
|
'Equipement Nautisme' => '51'
|
||||||
),
|
),
|
||||||
'IMMOBILIER' => array(
|
'IMMOBILIER' => array(
|
||||||
'Tous' => '_immobilier_',
|
'Tous' => '8',
|
||||||
'Ventes immobilières' => 'ventes_immobilieres',
|
'Ventes immobilières' => '9',
|
||||||
'Locations' => 'locations',
|
'Locations' => '10',
|
||||||
'Colocations' => 'colocations',
|
'Colocations' => '11',
|
||||||
'Bureaux & Commerces' => 'bureaux_commerces'
|
'Bureaux & Commerces' => '13'
|
||||||
),
|
),
|
||||||
'VACANCES' => array(
|
'VACANCES' => array(
|
||||||
'Tous' => '_vacances_',
|
'Tous' => '66',
|
||||||
'Location gîtes' => 'locations_gites',
|
'Locations & Gîtes' => '12',
|
||||||
'Chambres d\'hôtes' => 'chambres_d_hotes',
|
'Chambres d\'hôtes' => '67',
|
||||||
'Campings' => 'campings',
|
'Campings' => '68',
|
||||||
'Hôtels' => 'hotels',
|
'Hôtels' => '69',
|
||||||
'Hébergements insolites' => 'hebergements_insolites'
|
'Hébergements insolites' => '70'
|
||||||
),
|
),
|
||||||
'MULTIMEDIA' => array(
|
'MULTIMEDIA' => array(
|
||||||
'Tous' => '_multimedia_',
|
'Tous' => '14',
|
||||||
'Informatique' => 'informatique',
|
'Informatique' => '15',
|
||||||
'Consoles & Jeux vidéo' => 'consoles_jeux_video',
|
'Consoles & Jeux vidéo' => '43',
|
||||||
'Image & Son' => 'image_son',
|
'Image & Son' => '16',
|
||||||
'Téléphonie' => 'telephonie'
|
'Téléphonie' => '17'
|
||||||
),
|
),
|
||||||
'LOISIRS' => array(
|
'LOISIRS' => array(
|
||||||
'Tous' => '_loisirs_',
|
'Tous' => '24',
|
||||||
'DVD / Films' => 'dvd_films',
|
'DVD / Films' => '25',
|
||||||
'CD / Musique' => 'cd_musique',
|
'CD / Musique' => '26',
|
||||||
'Livres' => 'livres',
|
'Livres' => '27',
|
||||||
'Animaux' => 'animaux',
|
'Animaux' => '28',
|
||||||
'Vélos' => 'velos',
|
'Vélos' => '55',
|
||||||
'Sports & Hobbies' => 'sports_hobbies',
|
'Sports & Hobbies' => '29',
|
||||||
'Instruments de musique' => 'instruments_de_musique',
|
'Instruments de musique' => '30',
|
||||||
'Collection' => 'collection',
|
'Collection' => '40',
|
||||||
'Jeux & Jouets' => 'jeux_jouets',
|
'Jeux & Jouets' => '41',
|
||||||
'Vins & Gastronomie' => 'vins_gastronomie'
|
'Vins & Gastronomie' => '48'
|
||||||
),
|
),
|
||||||
'MATÉRIEL PROFESSIONNEL' => array(
|
'MATERIEL PROFESSIONNEL' => array(
|
||||||
'Tous' => '_materiel_professionnel_',
|
'Tous' => '56',
|
||||||
'Matériel Agricole' => 'mateiel_agricole',
|
'Matériel Agricole' => '57',
|
||||||
'Transport - Manutention' => 'transport_manutention',
|
'Transport - Manutention' => '58',
|
||||||
'BTP - Chantier - Gros-œuvre' => 'btp_chantier_gros_oeuvre',
|
'BTP - Chantier Gros-oeuvre' => '59',
|
||||||
'Outillage - Matériaux 2nd-œuvre' => 'outillage_materiaux_2nd_oeuvre',
|
'Outillage - Matériaux 2nd-oeuvre' => '60',
|
||||||
'Équipements Industriels' => 'equipement_industriels',
|
'Équipements Industriels' => '32',
|
||||||
'Restauration - Hôtellerie' => 'restauration_hotellerie',
|
'Restauration - Hôtellerie' => '61',
|
||||||
'Fournitures de Bureau' => 'fournitures_de_bureau',
|
'Fournitures de Bureau' => '62',
|
||||||
'Commerces & Marchés' => 'commerces_marches',
|
'Commerces & Marchés' => '63',
|
||||||
'Matériel médical' => 'materiel_medical'
|
'Matériel Médical' => '64'
|
||||||
),
|
),
|
||||||
'SERVICES' => array(
|
'SERVICES' => array(
|
||||||
'Tous' => '_services_',
|
'Tous' => '31',
|
||||||
'Prestations de services' => 'prestations_de_services',
|
'Prestations de services' => '34',
|
||||||
'Billetterie' => 'billetterie',
|
'Billetterie' => '35',
|
||||||
'Évènements' => 'evenements',
|
'Evénements' => '49',
|
||||||
'Cours particuliers' => 'cours_particuliers',
|
'Cours particuliers' => '36',
|
||||||
'Covoiturage' => 'covoiturage'
|
'Covoiturage' => '65'
|
||||||
),
|
),
|
||||||
'MAISON' => array(
|
'MAISON' => array(
|
||||||
'Tous' => '_maison_',
|
'Tous' => '18',
|
||||||
'Ameublement' => 'ameublement',
|
'Ameublement' => '19',
|
||||||
'Électroménager' => 'electromenager',
|
'Electroménager' => '20',
|
||||||
'Arts de la table' => 'arts_de_la_table',
|
'Arts de la table' => '45',
|
||||||
'Décoration' => 'decoration',
|
'Décoration' => '39',
|
||||||
'Linge de maison' => 'linge_de_maison',
|
'Linge de maison' => '46',
|
||||||
'Bricolage' => 'bricolage',
|
'Bricolage' => '21',
|
||||||
'Jardinage' => 'jardinage',
|
'Jardinage' => '52',
|
||||||
'Vêtements' => 'vetements',
|
'Vêtements' => '22',
|
||||||
'Chaussures' => 'chaussures',
|
'Chaussures' => '53',
|
||||||
'Accessoires & Bagagerie' => 'accessoires_bagagerie',
|
'Accessoires & Bagagerie' => '47',
|
||||||
'Montres & Bijoux' => 'montres_bijoux',
|
'Montres & Bijoux' => '42',
|
||||||
'Équipement bébé' => 'equipement_bebe',
|
'Equipement bébé' => '23',
|
||||||
'Vêtements bébé' => 'vetements_bebe'
|
'Vêtements bébé' => '54',
|
||||||
),
|
),
|
||||||
'AUTRES' => 'autres'
|
'AUTRES' => '37'
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'o' => array(
|
||||||
|
'name' => 'Vendeur',
|
||||||
|
'type' => 'list',
|
||||||
|
'values' => array(
|
||||||
|
'Tous' => '',
|
||||||
|
'Particuliers' => 'private',
|
||||||
|
'Professionnels' => 'pro',
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -140,50 +151,71 @@ region, and optionally a category and a keyword .';
|
|||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
|
|
||||||
$category = $this->getInput('c');
|
$params = array(
|
||||||
if(empty($category)) {
|
'text' => $this->getInput('k'),
|
||||||
$category = 'annonces';
|
'region' => $this->getInput('r'),
|
||||||
|
'category' => $this->getInput('c'),
|
||||||
|
'owner_type' => $this->getInput('o'),
|
||||||
|
);
|
||||||
|
|
||||||
|
$url = self::URI . 'recherche/?' . http_build_query($params);
|
||||||
|
$html = getContents($url)
|
||||||
|
or returnServerError('Could not request LeBonCoin. Tried: ' . $url);
|
||||||
|
|
||||||
|
if(!preg_match('/^<script>window.FLUX_STATE[^\r\n]*/m', $html, $matches)) {
|
||||||
|
returnServerError('Could not parse JSON in page content.');
|
||||||
}
|
}
|
||||||
|
|
||||||
$html = getSimpleHTMLDOM(self::URI
|
$clean_match = str_replace(
|
||||||
. $category
|
array('</script>', '<script>window.FLUX_STATE = '),
|
||||||
. '/offres/'
|
array('', ''),
|
||||||
. $this->getInput('r')
|
$matches[0]
|
||||||
. '/?f=a&th=1&q='
|
);
|
||||||
. urlencode($this->getInput('k')))
|
$json = json_decode($clean_match);
|
||||||
or returnServerError('Could not request LeBonCoin.');
|
|
||||||
|
|
||||||
$list = $html->find('.tabsContent', 0);
|
if($json->adSearch->data->total === 0) {
|
||||||
if($list === null) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$tags = $list->find('li');
|
foreach($json->adSearch->data->ads as $element) {
|
||||||
|
|
||||||
foreach($tags as $element) {
|
$item['title'] = $element->subject;
|
||||||
|
$item['content'] = $element->body;
|
||||||
|
$item['date'] = $element->index_date;
|
||||||
|
$item['timestamp'] = strtotime($element->index_date);
|
||||||
|
$item['uri'] = $element->url;
|
||||||
|
$item['ad_type'] = $element->ad_type;
|
||||||
|
$item['author'] = $element->owner->name;
|
||||||
|
|
||||||
$element = $element->find('a', 0);
|
if(isset($element->location->city)) {
|
||||||
|
|
||||||
$item = array();
|
$item['city'] = $element->location->city;
|
||||||
$item['uri'] = $element->href;
|
$item['content'] .= ' -- ' . $element->location->city;
|
||||||
$title = html_entity_decode($element->getAttribute('title'));
|
|
||||||
$content_image = $element->find('div.item_image', 0)->find('.lazyload', 0);
|
|
||||||
|
|
||||||
if($content_image !== null) {
|
|
||||||
$content = '<img src="' . $content_image->getAttribute('data-imgsrc') . '" alt="thumbnail">';
|
|
||||||
} else {
|
|
||||||
$content = "";
|
|
||||||
}
|
}
|
||||||
$date = $element->find('aside.item_absolute', 0)->find('p.item_sup', 0);
|
|
||||||
|
|
||||||
$detailsList = $element->find('section.item_infos', 0);
|
if(isset($element->location->zipcode)) {
|
||||||
|
$item['zipcode'] = $element->location->zipcode;
|
||||||
|
}
|
||||||
|
|
||||||
for($i = 0; $i <= 1; $i++) $content .= $detailsList->find('p.item_supp', $i)->plaintext;
|
if(isset($element->price)) {
|
||||||
$price = $detailsList->find('h3.item_price', 0);
|
|
||||||
$content .= $price === null ? '' : $price->plaintext;
|
$item['price'] = $element->price[0];
|
||||||
|
$item['content'] .= ' -- ' . current($element->price) . '€';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($element->images->urls)) {
|
||||||
|
|
||||||
|
$item['thumbnail'] = $element->images->thumb_url;
|
||||||
|
$item['enclosures'] = array();
|
||||||
|
|
||||||
|
foreach($element->images->urls as $image) {
|
||||||
|
$item['enclosures'][] = $image;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$item['title'] = $title;
|
|
||||||
$item['content'] = $content . $date;
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -22,16 +22,16 @@ class LesJoiesDuCodeBridge extends BridgeAbstract {
|
|||||||
// retrieve .gif instead of static .jpg
|
// retrieve .gif instead of static .jpg
|
||||||
$images = $temp->find('p img');
|
$images = $temp->find('p img');
|
||||||
foreach($images as $image) {
|
foreach($images as $image) {
|
||||||
$img_src = str_replace(".jpg", ".gif", $image->src);
|
$img_src = str_replace('.jpg', '.gif', $image->src);
|
||||||
$image->src = $img_src;
|
$image->src = $img_src;
|
||||||
}
|
}
|
||||||
$content = $temp->innertext;
|
$content = $temp->innertext;
|
||||||
|
|
||||||
$auteur = $temp->find('i', 0);
|
$auteur = $temp->find('i', 0);
|
||||||
$pos = strpos($auteur->innertext, "by");
|
$pos = strpos($auteur->innertext, 'by');
|
||||||
|
|
||||||
if($pos > 0) {
|
if($pos > 0) {
|
||||||
$auteur = trim(str_replace("*/", "", substr($auteur->innertext, ($pos + 2))));
|
$auteur = trim(str_replace('*/', '', substr($auteur->innertext, ($pos + 2))));
|
||||||
$item['author'] = $auteur;
|
$item['author'] = $auteur;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -100,7 +100,7 @@ class MangareaderBridge extends BridgeAbstract {
|
|||||||
case 'Get popular mangas':
|
case 'Get popular mangas':
|
||||||
// Find manga name within "Popular mangas for ..."
|
// Find manga name within "Popular mangas for ..."
|
||||||
$pagetitle = $xpath->query(".//*[@id='bodyalt']/h1")->item(0)->nodeValue;
|
$pagetitle = $xpath->query(".//*[@id='bodyalt']/h1")->item(0)->nodeValue;
|
||||||
$this->request = substr($pagetitle, 0, strrpos($pagetitle, " -"));
|
$this->request = substr($pagetitle, 0, strrpos($pagetitle, ' -'));
|
||||||
$this->getPopularMangas($xpath);
|
$this->getPopularMangas($xpath);
|
||||||
break;
|
break;
|
||||||
case 'Get manga updates':
|
case 'Get manga updates':
|
||||||
@@ -120,7 +120,7 @@ class MangareaderBridge extends BridgeAbstract {
|
|||||||
// Return some dummy-data if no content available
|
// Return some dummy-data if no content available
|
||||||
if(empty($this->items)) {
|
if(empty($this->items)) {
|
||||||
$item = array();
|
$item = array();
|
||||||
$item['content'] = "<p>No updates available</p>";
|
$item['content'] = '<p>No updates available</p>';
|
||||||
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
@@ -143,18 +143,18 @@ class MangareaderBridge extends BridgeAbstract {
|
|||||||
$item['title'] = htmlspecialchars($manga->nodeValue);
|
$item['title'] = htmlspecialchars($manga->nodeValue);
|
||||||
|
|
||||||
// Add each chapter to the feed
|
// Add each chapter to the feed
|
||||||
$item['content'] = "";
|
$item['content'] = '';
|
||||||
|
|
||||||
foreach ($chapters as $chapter) {
|
foreach ($chapters as $chapter) {
|
||||||
if($item['content'] <> "") {
|
if($item['content'] <> '') {
|
||||||
$item['content'] .= "<br>";
|
$item['content'] .= '<br>';
|
||||||
}
|
}
|
||||||
$item['content'] .= "<a href='"
|
$item['content'] .= "<a href='"
|
||||||
. self::URI
|
. self::URI
|
||||||
. htmlspecialchars($chapter->getAttribute('href'))
|
. htmlspecialchars($chapter->getAttribute('href'))
|
||||||
. "'>"
|
. "'>"
|
||||||
. htmlspecialchars($chapter->nodeValue)
|
. htmlspecialchars($chapter->nodeValue)
|
||||||
. "</a>";
|
. '</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
@@ -211,13 +211,13 @@ EOD;
|
|||||||
|
|
||||||
foreach ($chapters as $chapter) {
|
foreach ($chapters as $chapter) {
|
||||||
$item = array();
|
$item = array();
|
||||||
$item['title'] = htmlspecialchars($xpath->query("td[1]", $chapter)
|
$item['title'] = htmlspecialchars($xpath->query('td[1]', $chapter)
|
||||||
->item(0)
|
->item(0)
|
||||||
->nodeValue);
|
->nodeValue);
|
||||||
$item['uri'] = self::URI . $xpath->query("td[1]/a", $chapter)
|
$item['uri'] = self::URI . $xpath->query('td[1]/a', $chapter)
|
||||||
->item(0)
|
->item(0)
|
||||||
->getAttribute('href');
|
->getAttribute('href');
|
||||||
$item['timestamp'] = strtotime($xpath->query("td[2]", $chapter)
|
$item['timestamp'] = strtotime($xpath->query('td[2]', $chapter)
|
||||||
->item(0)
|
->item(0)
|
||||||
->nodeValue);
|
->nodeValue);
|
||||||
array_unshift($this->items, $item);
|
array_unshift($this->items, $item);
|
||||||
@@ -227,12 +227,12 @@ EOD;
|
|||||||
public function getURI(){
|
public function getURI(){
|
||||||
switch($this->queriedContext) {
|
switch($this->queriedContext) {
|
||||||
case 'Get latest updates':
|
case 'Get latest updates':
|
||||||
$path = "latest";
|
$path = 'latest';
|
||||||
break;
|
break;
|
||||||
case 'Get popular mangas':
|
case 'Get popular mangas':
|
||||||
$path = "popular";
|
$path = 'popular';
|
||||||
if($this->getInput('category') !== "all") {
|
if($this->getInput('category') !== 'all') {
|
||||||
$path .= "/" . $this->getInput('category');
|
$path .= '/' . $this->getInput('category');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'Get manga updates':
|
case 'Get manga updates':
|
||||||
|
144
bridges/MydealsBridge.php
Normal file
144
bridges/MydealsBridge.php
Normal file
@@ -0,0 +1,144 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
require_once(__DIR__ . '/DealabsBridge.php');
|
||||||
|
class MydealsBridge extends PepperBridgeAbstract {
|
||||||
|
|
||||||
|
const NAME = 'Mydeals bridge';
|
||||||
|
const URI = 'https://www.mydealz.de/';
|
||||||
|
const DESCRIPTION = 'Zeigt die Deals von mydeals.de';
|
||||||
|
const MAINTAINER = 'sysadminstory';
|
||||||
|
const PARAMETERS = array(
|
||||||
|
'Suche nach Stichworten' => array (
|
||||||
|
'q' => array(
|
||||||
|
'name' => 'Stichworten',
|
||||||
|
'type' => 'text',
|
||||||
|
'required' => true
|
||||||
|
),
|
||||||
|
'hide_expired' => array(
|
||||||
|
'name' => 'Abgelaufenes ausblenden',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'required' => 'true'
|
||||||
|
),
|
||||||
|
'hide_local' => array(
|
||||||
|
'name' => 'Lokales ausblenden',
|
||||||
|
'type' => 'checkbox',
|
||||||
|
'title' => 'Deals im physischen Geschäft ausblenden',
|
||||||
|
'required' => 'true'
|
||||||
|
),
|
||||||
|
'priceFrom' => array(
|
||||||
|
'name' => 'Minimaler Preis',
|
||||||
|
'type' => 'text',
|
||||||
|
'title' => 'Minmaler Preis in Euros',
|
||||||
|
'required' => 'false',
|
||||||
|
'defaultValue' => ''
|
||||||
|
),
|
||||||
|
'priceTo' => array(
|
||||||
|
'name' => 'Maximaler Preis',
|
||||||
|
'type' => 'text',
|
||||||
|
'title' => 'maximaler Preis in Euro',
|
||||||
|
'required' => 'false',
|
||||||
|
'defaultValue' => ''
|
||||||
|
),
|
||||||
|
),
|
||||||
|
|
||||||
|
'Deals pro Gruppen' => array(
|
||||||
|
'group' => array(
|
||||||
|
'name' => 'Gruppen',
|
||||||
|
'type' => 'list',
|
||||||
|
'required' => 'true',
|
||||||
|
'title' => 'Gruppe, deren Deals angezeigt werden müssen',
|
||||||
|
'values' => array(
|
||||||
|
'Elektronik' => 'elektronik',
|
||||||
|
'Handy & Smartphone' => 'smartphone',
|
||||||
|
'Gaming' => 'gaming',
|
||||||
|
'Software' => 'apps-software',
|
||||||
|
'Fashion Frauen' => 'fashion-frauen',
|
||||||
|
'Fashion Männer' => 'fashion-accessoires',
|
||||||
|
'Beauty & Gesundheit' => 'beauty',
|
||||||
|
'Family & Kids' => 'family-kids',
|
||||||
|
'Essen & Trinken' => 'food',
|
||||||
|
'Freizeit & Reisen' => 'reisen',
|
||||||
|
'Haushalt & Garten' => 'home-living',
|
||||||
|
'Entertainment' => 'entertainment',
|
||||||
|
'Verträge & Finanzen' => 'vertraege-finanzen',
|
||||||
|
'Coupons' => 'coupons',
|
||||||
|
|
||||||
|
)
|
||||||
|
),
|
||||||
|
'order' => array(
|
||||||
|
'name' => 'sortieren nach',
|
||||||
|
'type' => 'list',
|
||||||
|
'required' => 'true',
|
||||||
|
'title' => 'Sortierung der deals',
|
||||||
|
'values' => array(
|
||||||
|
'Vom heißesten zum kältesten Deal' => '',
|
||||||
|
'Vom jüngsten Deal zum ältesten' => '-new',
|
||||||
|
'Vom am meisten kommentierten Deal zum am wenigsten kommentierten Deal' => '-discussed'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
public $lang = array(
|
||||||
|
'bridge-uri' => SELF::URI,
|
||||||
|
'bridge-name' => SELF::NAME,
|
||||||
|
'context-keyword' => 'Suche nach Stichworten',
|
||||||
|
'context-group' => 'Deals pro Gruppen',
|
||||||
|
'uri-group' => '/gruppe/',
|
||||||
|
'request-error' => 'Could not request mydeals',
|
||||||
|
'no-results' => 'Ups, wir konnten keine Deals zu',
|
||||||
|
'relative-date-indicator' => array(
|
||||||
|
'vor',
|
||||||
|
'seit'
|
||||||
|
),
|
||||||
|
'price' => 'Preis',
|
||||||
|
'shipping' => 'Versand',
|
||||||
|
'origin' => 'Ursprung',
|
||||||
|
'discount' => 'Rabatte',
|
||||||
|
'title-keyword' => 'Suche',
|
||||||
|
'title-group' => 'Gruppe',
|
||||||
|
'local-months' => array(
|
||||||
|
'Jan',
|
||||||
|
'Feb',
|
||||||
|
'Mär',
|
||||||
|
'Apr',
|
||||||
|
'Mai',
|
||||||
|
'Jun',
|
||||||
|
'Jul',
|
||||||
|
'Aug',
|
||||||
|
'Sep',
|
||||||
|
'Okt',
|
||||||
|
'Nov',
|
||||||
|
'Dez',
|
||||||
|
'.'
|
||||||
|
),
|
||||||
|
'local-time-relative' => array(
|
||||||
|
'eingestellt vor ',
|
||||||
|
'm',
|
||||||
|
'h,',
|
||||||
|
'day',
|
||||||
|
'days',
|
||||||
|
'month',
|
||||||
|
'year',
|
||||||
|
'and '
|
||||||
|
),
|
||||||
|
'date-prefixes' => array(
|
||||||
|
'eingestellt am ',
|
||||||
|
'lokal ',
|
||||||
|
'aktualisiert ',
|
||||||
|
),
|
||||||
|
'relative-date-alt-prefixes' => array(
|
||||||
|
'aktualisiert vor ',
|
||||||
|
'kommentiert vor ',
|
||||||
|
'heiß seit '
|
||||||
|
),
|
||||||
|
'relative-date-ignore-suffix' => array(
|
||||||
|
'/von.*$/'
|
||||||
|
),
|
||||||
|
'localdeal' => array(
|
||||||
|
'Lokal ',
|
||||||
|
'Läuft bis '
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
}
|
@@ -12,7 +12,7 @@ class NasaApodBridge extends BridgeAbstract {
|
|||||||
$html = getSimpleHTMLDOM(self::URI . 'archivepix.html')
|
$html = getSimpleHTMLDOM(self::URI . 'archivepix.html')
|
||||||
or returnServerError('Error while downloading the website content');
|
or returnServerError('Error while downloading the website content');
|
||||||
|
|
||||||
$list = explode("<br>", $html->find('b', 0)->innertext);
|
$list = explode('<br>', $html->find('b', 0)->innertext);
|
||||||
|
|
||||||
for($i = 0; $i < 3; $i++) {
|
for($i = 0; $i < 3; $i++) {
|
||||||
$line = $list[$i];
|
$line = $list[$i];
|
||||||
@@ -32,7 +32,7 @@ class NasaApodBridge extends BridgeAbstract {
|
|||||||
$explanation = $picture_html->find('p', 2)->innertext;
|
$explanation = $picture_html->find('p', 2)->innertext;
|
||||||
|
|
||||||
//Extract date from the picture page
|
//Extract date from the picture page
|
||||||
$date = explode(" ", $picture_html->find('p', 1)->innertext);
|
$date = explode(' ', $picture_html->find('p', 1)->innertext);
|
||||||
$item['timestamp'] = strtotime($date[4] . $date[3] . $date[2]);
|
$item['timestamp'] = strtotime($date[4] . $date[3] . $date[2]);
|
||||||
|
|
||||||
//Other informations
|
//Other informations
|
||||||
|
@@ -49,7 +49,7 @@ class NotAlwaysBridge extends BridgeAbstract {
|
|||||||
|
|
||||||
public function getURI(){
|
public function getURI(){
|
||||||
if(!is_null($this->getInput('filter'))) {
|
if(!is_null($this->getInput('filter'))) {
|
||||||
return self::URI . $this->getInput('filter') . "/";
|
return self::URI . $this->getInput('filter') . '/';
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getURI();
|
return parent::getURI();
|
||||||
|
@@ -44,7 +44,7 @@ class PinterestBridge extends FeedExpander {
|
|||||||
$pattern = '/https\:\/\/i\.pinimg\.com\/[a-zA-Z0-9]*x\//';
|
$pattern = '/https\:\/\/i\.pinimg\.com\/[a-zA-Z0-9]*x\//';
|
||||||
foreach($this->items as $item) {
|
foreach($this->items as $item) {
|
||||||
|
|
||||||
$item["content"] = preg_replace($pattern, 'https://i.pinimg.com/originals/', $item["content"]);
|
$item['content'] = preg_replace($pattern, 'https://i.pinimg.com/originals/', $item['content']);
|
||||||
$newitems[] = $item;
|
$newitems[] = $item;
|
||||||
}
|
}
|
||||||
$this->items = $newitems;
|
$this->items = $newitems;
|
||||||
@@ -64,10 +64,10 @@ class PinterestBridge extends FeedExpander {
|
|||||||
// provide even less info. Thus we attempt multiple options.
|
// provide even less info. Thus we attempt multiple options.
|
||||||
$item['title'] = trim($result['title']);
|
$item['title'] = trim($result['title']);
|
||||||
|
|
||||||
if($item['title'] === "")
|
if($item['title'] === '')
|
||||||
$item['title'] = trim($result['rich_summary']['display_name']);
|
$item['title'] = trim($result['rich_summary']['display_name']);
|
||||||
|
|
||||||
if($item['title'] === "")
|
if($item['title'] === '')
|
||||||
$item['title'] = trim($result['grid_description']);
|
$item['title'] = trim($result['grid_description']);
|
||||||
|
|
||||||
$item['timestamp'] = strtotime($result['created_at']);
|
$item['timestamp'] = strtotime($result['created_at']);
|
||||||
|
@@ -33,40 +33,40 @@ class PixivBridge extends BridgeAbstract {
|
|||||||
$count++;
|
$count++;
|
||||||
|
|
||||||
$item = array();
|
$item = array();
|
||||||
$item["id"] = $result["illustId"];
|
$item['id'] = $result['illustId'];
|
||||||
$item["uri"] = "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=" . $result["illustId"];
|
$item['uri'] = 'https://www.pixiv.net/member_illust.php?mode=medium&illust_id=' . $result['illustId'];
|
||||||
$item["title"] = $result["illustTitle"];
|
$item['title'] = $result['illustTitle'];
|
||||||
$item["author"] = $result["userName"];
|
$item['author'] = $result['userName'];
|
||||||
|
|
||||||
preg_match_all($timeRegex, $result["url"], $dt, PREG_SET_ORDER, 0);
|
preg_match_all($timeRegex, $result['url'], $dt, PREG_SET_ORDER, 0);
|
||||||
$elementDate = DateTime::createFromFormat("YmdHis",
|
$elementDate = DateTime::createFromFormat('YmdHis',
|
||||||
$dt[0][1] . $dt[0][2] . $dt[0][3] . $dt[0][4] . $dt[0][5] . $dt[0][6]);
|
$dt[0][1] . $dt[0][2] . $dt[0][3] . $dt[0][4] . $dt[0][5] . $dt[0][6]);
|
||||||
$item["timestamp"] = $elementDate->getTimestamp();
|
$item['timestamp'] = $elementDate->getTimestamp();
|
||||||
|
|
||||||
$item["content"] = "<img src='" . $this->cacheImage($result['url'], $item["id"]) . "' />";
|
$item['content'] = "<img src='" . $this->cacheImage($result['url'], $item['id']) . "' />";
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function cacheImage($url, $illustId) {
|
public function cacheImage($url, $illustId) {
|
||||||
|
|
||||||
$url = str_replace("_master1200", "", $url);
|
$url = str_replace('_master1200', '', $url);
|
||||||
$url = str_replace("c/240x240/img-master/", "img-original/", $url);
|
$url = str_replace('c/240x240/img-master/', 'img-original/', $url);
|
||||||
$path = CACHE_DIR . '/pixiv_img';
|
$path = CACHE_DIR . '/pixiv_img';
|
||||||
|
|
||||||
if(!is_dir($path))
|
if(!is_dir($path))
|
||||||
mkdir($path, 0755, true);
|
mkdir($path, 0755, true);
|
||||||
|
|
||||||
if(!is_file($path . '/' . $illustId . '.jpeg')) {
|
if(!is_file($path . '/' . $illustId . '.jpeg')) {
|
||||||
$headers = array("Referer: https://www.pixiv.net/member_illust.php?mode=medium&illust_id=" . $illustId);
|
$headers = array('Referer: https://www.pixiv.net/member_illust.php?mode=medium&illust_id=' . $illustId);
|
||||||
$illust = getContents($url, $headers);
|
$illust = getContents($url, $headers);
|
||||||
if(strpos($illust, "404 Not Found") !== false) {
|
if(strpos($illust, '404 Not Found') !== false) {
|
||||||
$illust = getContents(str_replace("jpg", "png", $url), $headers);
|
$illust = getContents(str_replace('jpg', 'png', $url), $headers);
|
||||||
}
|
}
|
||||||
file_put_contents($path . '/' . $illustId . '.jpeg', $illust);
|
file_put_contents($path . '/' . $illustId . '.jpeg', $illust);
|
||||||
}
|
}
|
||||||
|
|
||||||
return 'cache/pixiv_img/' . $illustId . ".jpeg";
|
return 'cache/pixiv_img/' . $illustId . '.jpeg';
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -8,9 +8,9 @@ class RainbowSixSiegeBridge extends BridgeAbstract {
|
|||||||
const DESCRIPTION = 'Latest articles from the Rainbow Six Siege blog';
|
const DESCRIPTION = 'Latest articles from the Rainbow Six Siege blog';
|
||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
$dlUrl = "https://prod-tridionservice.ubisoft.com/live/v1/News/Latest?templateId=tcm%3A152-7677";
|
$dlUrl = 'https://prod-tridionservice.ubisoft.com/live/v1/News/Latest?templateId=tcm%3A152-7677';
|
||||||
$dlUrl .= "8-32&pageIndex=0&pageSize=10&language=en-US&detailPageId=tcm%3A152-194572-64";
|
$dlUrl .= '8-32&pageIndex=0&pageSize=10&language=en-US&detailPageId=tcm%3A152-194572-64';
|
||||||
$dlUrl .= "&keywordList=175426&siteId=undefined&useSeoFriendlyUrl=true";
|
$dlUrl .= '&keywordList=175426&siteId=undefined&useSeoFriendlyUrl=true';
|
||||||
$jsonString = getContents($dlUrl) or returnServerError('Error while downloading the website content');
|
$jsonString = getContents($dlUrl) or returnServerError('Error while downloading the website content');
|
||||||
|
|
||||||
$json = json_decode($jsonString, true);
|
$json = json_decode($jsonString, true);
|
||||||
|
@@ -25,7 +25,7 @@ class ReadComicsBridge extends BridgeAbstract {
|
|||||||
return $timestamp;
|
return $timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
$keywordsList = explode(";", $this->getInput('q'));
|
$keywordsList = explode(';', $this->getInput('q'));
|
||||||
foreach($keywordsList as $keywords) {
|
foreach($keywordsList as $keywords) {
|
||||||
$html = $this->getSimpleHTMLDOM(self::URI . 'comic/' . rawurlencode($keywords))
|
$html = $this->getSimpleHTMLDOM(self::URI . 'comic/' . rawurlencode($keywords))
|
||||||
or $this->returnServerError('Could not request readcomics.tv.');
|
or $this->returnServerError('Could not request readcomics.tv.');
|
||||||
|
@@ -19,7 +19,7 @@ class ReporterreBridge extends BridgeAbstract {
|
|||||||
// Replace all relative urls with absolute ones
|
// Replace all relative urls with absolute ones
|
||||||
$text = preg_replace(
|
$text = preg_replace(
|
||||||
'/(href|src)(\=[\"\'])(?!http)([^"\']+)/ims',
|
'/(href|src)(\=[\"\'])(?!http)([^"\']+)/ims',
|
||||||
"$1$2" . self::URI . "$3",
|
'$1$2' . self::URI . '$3',
|
||||||
$text
|
$text
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@@ -9,9 +9,9 @@ class Rue89Bridge extends FeedExpander {
|
|||||||
protected function parseItem($item){
|
protected function parseItem($item){
|
||||||
$item = parent::parseItem($item);
|
$item = parent::parseItem($item);
|
||||||
|
|
||||||
$url = "http://api.rue89.nouvelobs.com/export/mobile2/node/"
|
$url = 'http://api.rue89.nouvelobs.com/export/mobile2/node/'
|
||||||
. str_replace(" ", "", substr($item['uri'], -8))
|
. str_replace(' ', '', substr($item['uri'], -8))
|
||||||
. "/full";
|
. '/full';
|
||||||
|
|
||||||
$datas = json_decode(getContents($url), true);
|
$datas = json_decode(getContents($url), true);
|
||||||
$item['content'] = $datas['node']['body'];
|
$item['content'] = $datas['node']['body'];
|
||||||
|
@@ -32,7 +32,7 @@ class SexactuBridge extends BridgeAbstract {
|
|||||||
$item = array();
|
$item = array();
|
||||||
$item['author'] = self::AUTHOR;
|
$item['author'] = self::AUTHOR;
|
||||||
$item['title'] = $title->plaintext;
|
$item['title'] = $title->plaintext;
|
||||||
$urlAttribute = "data-href";
|
$urlAttribute = 'data-href';
|
||||||
$uri = $title->$urlAttribute;
|
$uri = $title->$urlAttribute;
|
||||||
if($uri === false)
|
if($uri === false)
|
||||||
continue;
|
continue;
|
||||||
|
@@ -73,7 +73,7 @@ class ShanaprojectBridge extends BridgeAbstract {
|
|||||||
// Getting the picture is a little bit tricky as it is part of the style.
|
// Getting the picture is a little bit tricky as it is part of the style.
|
||||||
// Luckily the style is part of the parent div :)
|
// Luckily the style is part of the parent div :)
|
||||||
|
|
||||||
if(preg_match("/url\(\/\/([^\)]+)\)/i", $anime->parent->style, $matches))
|
if(preg_match('/url\(\/\/([^\)]+)\)/i', $anime->parent->style, $matches))
|
||||||
return $matches[1];
|
return $matches[1];
|
||||||
|
|
||||||
returnServerError('Could not extract background image!');
|
returnServerError('Could not extract background image!');
|
||||||
|
@@ -21,7 +21,7 @@ class Shimmie2Bridge extends DanbooruBridge {
|
|||||||
protected function getItemFromElement($element){
|
protected function getItemFromElement($element){
|
||||||
$item = array();
|
$item = array();
|
||||||
$item['uri'] = $this->getURI() . $element->href;
|
$item['uri'] = $this->getURI() . $element->href;
|
||||||
$item['id'] = (int)preg_replace("/[^0-9]/", '', $element->getAttribute(static::IDATTRIBUTE));
|
$item['id'] = (int)preg_replace('/[^0-9]/', '', $element->getAttribute(static::IDATTRIBUTE));
|
||||||
$item['timestamp'] = time();
|
$item['timestamp'] = time();
|
||||||
$thumbnailUri = $this->getURI() . $element->find('img', 0)->src;
|
$thumbnailUri = $this->getURI() . $element->find('img', 0)->src;
|
||||||
$item['tags'] = $element->getAttribute('data-tags');
|
$item['tags'] = $element->getAttribute('data-tags');
|
||||||
|
45
bridges/SuperSmashBlogBridge.php
Normal file
45
bridges/SuperSmashBlogBridge.php
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
class SuperSmashBlogBridge extends BridgeAbstract {
|
||||||
|
|
||||||
|
const MAINTAINER = 'corenting';
|
||||||
|
const NAME = 'Super Smash Blog';
|
||||||
|
const URI = 'https://www.smashbros.com/en_US/blog/index.html';
|
||||||
|
const CACHE_TIMEOUT = 7200; // 2h
|
||||||
|
const DESCRIPTION = 'Latest articles from the Super Smash Blog blog';
|
||||||
|
|
||||||
|
public function collectData(){
|
||||||
|
$dlUrl = 'https://www.smashbros.com/data/bs/en_US/json/en_US.json';
|
||||||
|
|
||||||
|
$jsonString = getContents($dlUrl) or returnServerError('Error while downloading the website content');
|
||||||
|
$json = json_decode($jsonString, true);
|
||||||
|
|
||||||
|
foreach($json as $article) {
|
||||||
|
|
||||||
|
// Build content
|
||||||
|
$picture = $article['acf']['image1']['url'];
|
||||||
|
if (strlen($picture) != 0) {
|
||||||
|
$picture = str_get_html('<img src="https://www.smashbros.com/' . substr($picture, 8) . '"/>');
|
||||||
|
} else {
|
||||||
|
$picture = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
$video = $article['acf']['link_url'];
|
||||||
|
if (strlen($video) != 0) {
|
||||||
|
$video = str_get_html('<a href="' . $video .'">Youtube video</a>');
|
||||||
|
} else {
|
||||||
|
$video = '';
|
||||||
|
}
|
||||||
|
$text = str_get_html($article['acf']['editor']);
|
||||||
|
$content = $picture . $video . $text;
|
||||||
|
|
||||||
|
// Build final item
|
||||||
|
$item = array();
|
||||||
|
$item['title'] = $article['title']['rendered'];
|
||||||
|
$item['timestamp'] = strtotime($article['date']);
|
||||||
|
$item['content'] = $content;
|
||||||
|
$item['uri'] = self::URI . '?post=' . $article['id'];
|
||||||
|
|
||||||
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -66,7 +66,7 @@ class VkBridge extends BridgeAbstract
|
|||||||
$post->find('a.wall_post_more', 0)->outertext = '';
|
$post->find('a.wall_post_more', 0)->outertext = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$content_suffix = "";
|
$content_suffix = '';
|
||||||
|
|
||||||
// looking for external links
|
// looking for external links
|
||||||
$external_link_selectors = array(
|
$external_link_selectors = array(
|
||||||
@@ -81,8 +81,8 @@ class VkBridge extends BridgeAbstract
|
|||||||
$innertext = $a->innertext;
|
$innertext = $a->innertext;
|
||||||
$parsed_url = parse_url($a->getAttribute('href'));
|
$parsed_url = parse_url($a->getAttribute('href'));
|
||||||
if (strpos($parsed_url['path'], '/away.php') !== 0) continue;
|
if (strpos($parsed_url['path'], '/away.php') !== 0) continue;
|
||||||
parse_str($parsed_url["query"], $parsed_query);
|
parse_str($parsed_url['query'], $parsed_query);
|
||||||
$content_suffix .= "<br>External link: <a href='" . $parsed_query["to"] . "'>$innertext</a>";
|
$content_suffix .= "<br>External link: <a href='" . $parsed_query['to'] . "'>$innertext</a>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,12 +100,22 @@ class VkBridge extends BridgeAbstract
|
|||||||
}
|
}
|
||||||
|
|
||||||
// looking for article
|
// looking for article
|
||||||
$article = $post->find("a.article_snippet", 0);
|
$article = $post->find('a.article_snippet', 0);
|
||||||
if (is_object($article)) {
|
if (is_object($article)) {
|
||||||
$article_title = $article->find("div.article_snippet__title", 0)->innertext;
|
if (strpos($article->getAttribute('class'), 'article_snippet_mini') !== false) {
|
||||||
$article_author = $article->find("div.article_snippet__author", 0)->innertext;
|
$article_title_selector = 'div.article_snippet_mini_title';
|
||||||
|
$article_author_selector = 'div.article_snippet_mini_info > .mem_link,
|
||||||
|
div.article_snippet_mini_info > .group_link';
|
||||||
|
$article_thumb_selector = 'div.article_snippet_mini_thumb';
|
||||||
|
} else {
|
||||||
|
$article_title_selector = 'div.article_snippet__title';
|
||||||
|
$article_author_selector = 'div.article_snippet__author';
|
||||||
|
$article_thumb_selector = 'div.article_snippet__image';
|
||||||
|
}
|
||||||
|
$article_title = $article->find($article_title_selector, 0)->innertext;
|
||||||
|
$article_author = $article->find($article_author_selector, 0)->innertext;
|
||||||
$article_link = self::URI . ltrim($article->getAttribute('href'), '/');
|
$article_link = self::URI . ltrim($article->getAttribute('href'), '/');
|
||||||
$article_img_element_style = $article->find("div.article_snippet__image", 0)->getAttribute('style');
|
$article_img_element_style = $article->find($article_thumb_selector, 0)->getAttribute('style');
|
||||||
preg_match('/background-image: url\((.*)\)/', $article_img_element_style, $matches);
|
preg_match('/background-image: url\((.*)\)/', $article_img_element_style, $matches);
|
||||||
if (count($matches) > 0) {
|
if (count($matches) > 0) {
|
||||||
$content_suffix .= "<br><img src='" . $matches[1] . "'>";
|
$content_suffix .= "<br><img src='" . $matches[1] . "'>";
|
||||||
@@ -123,6 +133,16 @@ class VkBridge extends BridgeAbstract
|
|||||||
$video->outertext = '';
|
$video->outertext = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get all other videos
|
||||||
|
foreach($post->find('a.page_post_thumb_video') as $a) {
|
||||||
|
$video_title = $a->getAttribute('aria-label');
|
||||||
|
$temp = explode(' ', $video_title, 2);
|
||||||
|
if (count($temp) > 1) $video_title = $temp[1];
|
||||||
|
$video_link = self::URI . ltrim( $a->getAttribute('href'), '/' );
|
||||||
|
$content_suffix .= "<br>Video: <a href='$video_link'>$video_title</a>";
|
||||||
|
$a->outertext = '';
|
||||||
|
}
|
||||||
|
|
||||||
// get all photos
|
// get all photos
|
||||||
foreach($post->find('div.wall_text > a.page_post_thumb_wrap') as $a) {
|
foreach($post->find('div.wall_text > a.page_post_thumb_wrap') as $a) {
|
||||||
$result = $this->getPhoto($a);
|
$result = $this->getPhoto($a);
|
||||||
@@ -143,8 +163,8 @@ class VkBridge extends BridgeAbstract
|
|||||||
// get photo documents
|
// get photo documents
|
||||||
foreach($post->find('a.page_doc_photo_href') as $a) {
|
foreach($post->find('a.page_doc_photo_href') as $a) {
|
||||||
$doc_link = self::URI . ltrim($a->getAttribute('href'), '/');
|
$doc_link = self::URI . ltrim($a->getAttribute('href'), '/');
|
||||||
$doc_gif_label_element = $a->find(".page_gif_label", 0);
|
$doc_gif_label_element = $a->find('.page_gif_label', 0);
|
||||||
$doc_title_element = $a->find(".doc_label", 0);
|
$doc_title_element = $a->find('.doc_label', 0);
|
||||||
|
|
||||||
if (is_object($doc_gif_label_element)) {
|
if (is_object($doc_gif_label_element)) {
|
||||||
$gif_preview_img = backgroundToImg($a->find('.page_doc_photo', 0));
|
$gif_preview_img = backgroundToImg($a->find('.page_doc_photo', 0));
|
||||||
@@ -164,7 +184,7 @@ class VkBridge extends BridgeAbstract
|
|||||||
|
|
||||||
// get other documents
|
// get other documents
|
||||||
foreach($post->find('div.page_doc_row') as $div) {
|
foreach($post->find('div.page_doc_row') as $div) {
|
||||||
$doc_title_element = $div->find("a.page_doc_title", 0);
|
$doc_title_element = $div->find('a.page_doc_title', 0);
|
||||||
|
|
||||||
if (is_object($doc_title_element)) {
|
if (is_object($doc_title_element)) {
|
||||||
$doc_title = $doc_title_element->innertext;
|
$doc_title = $doc_title_element->innertext;
|
||||||
@@ -179,6 +199,16 @@ class VkBridge extends BridgeAbstract
|
|||||||
$div->outertext = '';
|
$div->outertext = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// get polls
|
||||||
|
foreach($post->find('div.page_media_poll_wrap') as $div) {
|
||||||
|
$poll_title = $div->find('.page_media_poll_title', 0)->innertext;
|
||||||
|
$content_suffix .= "<br>Poll: $poll_title";
|
||||||
|
foreach($div->find('div.page_poll_text') as $poll_stat_title) {
|
||||||
|
$content_suffix .= '<br>- ' . $poll_stat_title->innertext;
|
||||||
|
}
|
||||||
|
$div->outertext = '';
|
||||||
|
}
|
||||||
|
|
||||||
// get sign
|
// get sign
|
||||||
$post_author = $pageName;
|
$post_author = $pageName;
|
||||||
foreach($post->find('a.wall_signed_by') as $a) {
|
foreach($post->find('a.wall_signed_by') as $a) {
|
||||||
@@ -201,10 +231,10 @@ class VkBridge extends BridgeAbstract
|
|||||||
|
|
||||||
// get post link
|
// get post link
|
||||||
$post_link = $post->find('a.post_link', 0)->getAttribute('href');
|
$post_link = $post->find('a.post_link', 0)->getAttribute('href');
|
||||||
preg_match("/wall-?\d+_(\d+)/", $post_link, $preg_match_result);
|
preg_match('/wall-?\d+_(\d+)/', $post_link, $preg_match_result);
|
||||||
$item['post_id'] = intval($preg_match_result[1]);
|
$item['post_id'] = intval($preg_match_result[1]);
|
||||||
if (substr(self::URI, -1) == '/') {
|
if (substr(self::URI, -1) == '/') {
|
||||||
$post_link = self::URI . ltrim($post_link, "/");
|
$post_link = self::URI . ltrim($post_link, '/');
|
||||||
} else {
|
} else {
|
||||||
$post_link = self::URI . $post_link;
|
$post_link = self::URI . $post_link;
|
||||||
}
|
}
|
||||||
@@ -243,11 +273,17 @@ class VkBridge extends BridgeAbstract
|
|||||||
$data = json_decode($arg, true);
|
$data = json_decode($arg, true);
|
||||||
if ($data == null) return;
|
if ($data == null) return;
|
||||||
|
|
||||||
$thumb = $data['temp']['base'] . $data['temp']['x_'][0] . ".jpg";
|
$thumb = $data['temp']['base'] . $data['temp']['x_'][0] . '.jpg';
|
||||||
$original = '';
|
$original = '';
|
||||||
foreach(array('y_', 'z_', 'w_') as $key) {
|
foreach(array('y_', 'z_', 'w_') as $key) {
|
||||||
if (!isset($data['temp'][$key])) continue;
|
if (!isset($data['temp'][$key])) continue;
|
||||||
$original = $data['temp']['base'] . $data['temp'][$key][0] . ".jpg";
|
if (!isset($data['temp'][$key][0])) continue;
|
||||||
|
if (substr($data['temp'][$key][0], 0, 4) == 'http') {
|
||||||
|
$base = '';
|
||||||
|
} else {
|
||||||
|
$base = $data['temp']['base'];
|
||||||
|
}
|
||||||
|
$original = $base . $data['temp'][$key][0] . '.jpg';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($original) {
|
if ($original) {
|
||||||
@@ -260,7 +296,7 @@ class VkBridge extends BridgeAbstract
|
|||||||
private function getTitle($content)
|
private function getTitle($content)
|
||||||
{
|
{
|
||||||
preg_match('/^["\w\ \p{Cyrillic}\(\)\?#«»-]+/mu', htmlspecialchars_decode($content), $result);
|
preg_match('/^["\w\ \p{Cyrillic}\(\)\?#«»-]+/mu', htmlspecialchars_decode($content), $result);
|
||||||
if (count($result) == 0) return "untitled";
|
if (count($result) == 0) return 'untitled';
|
||||||
return $result[0];
|
return $result[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -18,10 +18,10 @@ class WhydBridge extends BridgeAbstract {
|
|||||||
|
|
||||||
public function collectData(){
|
public function collectData(){
|
||||||
$html = '';
|
$html = '';
|
||||||
if(strlen(preg_replace("/[^0-9a-f]/", '', $this->getInput('u'))) == 24) {
|
if(strlen(preg_replace('/[^0-9a-f]/', '', $this->getInput('u'))) == 24) {
|
||||||
// is input the userid ?
|
// is input the userid ?
|
||||||
$html = getSimpleHTMLDOM(
|
$html = getSimpleHTMLDOM(
|
||||||
self::URI . 'u/' . preg_replace("/[^0-9a-f]/", '', $this->getInput('u'))
|
self::URI . 'u/' . preg_replace('/[^0-9a-f]/', '', $this->getInput('u'))
|
||||||
) or returnServerError('No results for this query.');
|
) or returnServerError('No results for this query.');
|
||||||
} else { // input may be the username
|
} else { // input may be the username
|
||||||
$html = getSimpleHTMLDOM(
|
$html = getSimpleHTMLDOM(
|
||||||
|
@@ -1,16 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
class WorldOfTanksBridge extends BridgeAbstract {
|
class WorldOfTanksBridge extends FeedExpander {
|
||||||
|
|
||||||
const MAINTAINER = 'mitsukarenai';
|
const MAINTAINER = 'Riduidel';
|
||||||
const NAME = 'World of Tanks';
|
const NAME = 'World of Tanks';
|
||||||
const URI = 'http://worldoftanks.eu/';
|
const URI = 'http://worldoftanks.eu/';
|
||||||
const DESCRIPTION = 'News about the tank slaughter game.';
|
const DESCRIPTION = 'News about the tank slaughter game.';
|
||||||
|
|
||||||
const PARAMETERS = array( array(
|
const PARAMETERS = array( array(
|
||||||
'category' => array(
|
|
||||||
// TODO: should be a list
|
|
||||||
'name' => 'nom de la catégorie'
|
|
||||||
),
|
|
||||||
'lang' => array(
|
'lang' => array(
|
||||||
'name' => 'Langue',
|
'name' => 'Langue',
|
||||||
'type' => 'list',
|
'type' => 'list',
|
||||||
@@ -26,47 +22,31 @@ class WorldOfTanksBridge extends BridgeAbstract {
|
|||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
private $title = '';
|
public function collectData() {
|
||||||
|
$this->collectExpandableDatas(sprintf('https://worldoftanks.eu/%s/rss/news/', $this->getInput('lang')));
|
||||||
|
}
|
||||||
|
|
||||||
public function getURI(){
|
protected function parseItem($newsItem){
|
||||||
if(!is_null($this->getInput('lang'))) {
|
$item = parent::parseItem($newsItem);
|
||||||
$lang = $this->getInput('lang');
|
$item['content'] = $this->loadFullArticle($item['uri']);
|
||||||
$uri = self::URI . $lang . '/news/';
|
return $item;
|
||||||
if(!empty($this->getInput('category'))) {
|
}
|
||||||
$uri .= 'pc-browser/' . $this->getInput('category') . '/';
|
|
||||||
}
|
/**
|
||||||
return $uri;
|
* Loads the full article and returns the contents
|
||||||
|
* @param $uri The article URI
|
||||||
|
* @return The article content
|
||||||
|
*/
|
||||||
|
private function loadFullArticle($uri){
|
||||||
|
$html = getSimpleHTMLDOMCached($uri);
|
||||||
|
|
||||||
|
$content = $html->find('article', 0);
|
||||||
|
|
||||||
|
// Remove the scripts, please
|
||||||
|
foreach($content->find('script') as $script) {
|
||||||
|
$script->outertext = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
return parent::getURI();
|
return $content->innertext;
|
||||||
}
|
|
||||||
|
|
||||||
public function getName(){
|
|
||||||
return $this->title ?: parent::getName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public function collectData(){
|
|
||||||
$html = getSimpleHTMLDOM($this->getURI())
|
|
||||||
or returnServerError('Could not request ' . $this->getURI());
|
|
||||||
debugMessage("loaded HTML from " . $this->getURI());
|
|
||||||
// customize name
|
|
||||||
$this->title = $html->find('title', 0)->innertext;
|
|
||||||
foreach($html->find('.b-imgblock_ico') as $infoLink) {
|
|
||||||
$this->parseLine($infoLink);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function parseLine($infoLink){
|
|
||||||
$item = array();
|
|
||||||
$item['uri'] = self::URI . $infoLink->href;
|
|
||||||
// now load that uri from cache
|
|
||||||
debugMessage('loading page ' . $item['uri']);
|
|
||||||
$articlePage = getSimpleHTMLDOMCached($item['uri']);
|
|
||||||
$content = $articlePage->find('.l-content', 0);
|
|
||||||
defaultLinkTo($content, self::URI);
|
|
||||||
$item['title'] = $content->find('h1', 0)->innertext;
|
|
||||||
$item['content'] = $content->find('.b-content', 0)->innertext;
|
|
||||||
$item['timestamp'] = $content->find('.b-statistic_time', 0)->getAttribute("data-timestamp");
|
|
||||||
$this->items[] = $item;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -12,72 +12,72 @@ class YGGTorrentBridge extends BridgeAbstract {
|
|||||||
|
|
||||||
const PARAMETERS = array(
|
const PARAMETERS = array(
|
||||||
array(
|
array(
|
||||||
"cat" => array(
|
'cat' => array(
|
||||||
"name" => "category",
|
'name' => 'category',
|
||||||
"type" => "list",
|
'type' => 'list',
|
||||||
"values" => array(
|
'values' => array(
|
||||||
"Toute les catégories" => "all.all",
|
'Toute les catégories' => 'all.all',
|
||||||
"Film/Vidéo - Toutes les sous-catégories" => "2145.all",
|
'Film/Vidéo - Toutes les sous-catégories' => '2145.all',
|
||||||
"Film/Vidéo - Animation" => "2145.2178",
|
'Film/Vidéo - Animation' => '2145.2178',
|
||||||
"Film/Vidéo - Animation Série" => "2145.2179",
|
'Film/Vidéo - Animation Série' => '2145.2179',
|
||||||
"Film/Vidéo - Concert" => "2145.2180",
|
'Film/Vidéo - Concert' => '2145.2180',
|
||||||
"Film/Vidéo - Documentaire" => "2145.2181",
|
'Film/Vidéo - Documentaire' => '2145.2181',
|
||||||
"Film/Vidéo - Émission TV" => "2145.2182",
|
'Film/Vidéo - Émission TV' => '2145.2182',
|
||||||
"Film/Vidéo - Film" => "2145.2183",
|
'Film/Vidéo - Film' => '2145.2183',
|
||||||
"Film/Vidéo - Série TV" => "2145.2184",
|
'Film/Vidéo - Série TV' => '2145.2184',
|
||||||
"Film/Vidéo - Spectacle" => "2145.2185",
|
'Film/Vidéo - Spectacle' => '2145.2185',
|
||||||
"Film/Vidéo - Sport" => "2145.2186",
|
'Film/Vidéo - Sport' => '2145.2186',
|
||||||
"Film/Vidéo - Vidéo-clips" => "2145.2186",
|
'Film/Vidéo - Vidéo-clips' => '2145.2186',
|
||||||
"Audio - Toutes les sous-catégories" => "2139.all",
|
'Audio - Toutes les sous-catégories' => '2139.all',
|
||||||
"Audio - Karaoké" => "2139.2147",
|
'Audio - Karaoké' => '2139.2147',
|
||||||
"Audio - Musique" => "2139.2148",
|
'Audio - Musique' => '2139.2148',
|
||||||
"Audio - Podcast Radio" => "2139.2150",
|
'Audio - Podcast Radio' => '2139.2150',
|
||||||
"Audio - Samples" => "2139.2149",
|
'Audio - Samples' => '2139.2149',
|
||||||
"Jeu vidéo - Toutes les sous-catégories" => "2142.all",
|
'Jeu vidéo - Toutes les sous-catégories' => '2142.all',
|
||||||
"Jeu vidéo - Autre" => "2142.2167",
|
'Jeu vidéo - Autre' => '2142.2167',
|
||||||
"Jeu vidéo - Linux" => "2142.2159",
|
'Jeu vidéo - Linux' => '2142.2159',
|
||||||
"Jeu vidéo - MacOS" => "2142.2160",
|
'Jeu vidéo - MacOS' => '2142.2160',
|
||||||
"Jeu vidéo - Microsoft" => "2142.2162",
|
'Jeu vidéo - Microsoft' => '2142.2162',
|
||||||
"Jeu vidéo - Nintendo" => "2142.2163",
|
'Jeu vidéo - Nintendo' => '2142.2163',
|
||||||
"Jeu vidéo - Smartphone" => "2142.2165",
|
'Jeu vidéo - Smartphone' => '2142.2165',
|
||||||
"Jeu vidéo - Sony" => "2142.2164",
|
'Jeu vidéo - Sony' => '2142.2164',
|
||||||
"Jeu vidéo - Tablette" => "2142.2166",
|
'Jeu vidéo - Tablette' => '2142.2166',
|
||||||
"Jeu vidéo - Windows" => "2142.2161",
|
'Jeu vidéo - Windows' => '2142.2161',
|
||||||
"eBook - Toutes les sous-catégories" => "2140.all",
|
'eBook - Toutes les sous-catégories' => '2140.all',
|
||||||
"eBook - Audio" => "2140.2151",
|
'eBook - Audio' => '2140.2151',
|
||||||
"eBook - Bds" => "2140.2152",
|
'eBook - Bds' => '2140.2152',
|
||||||
"eBook - Comics" => "2140.2153",
|
'eBook - Comics' => '2140.2153',
|
||||||
"eBook - Livres" => "2140.2154",
|
'eBook - Livres' => '2140.2154',
|
||||||
"eBook - Mangas" => "2140.2155",
|
'eBook - Mangas' => '2140.2155',
|
||||||
"eBook - Presse" => "2140.2156",
|
'eBook - Presse' => '2140.2156',
|
||||||
"Emulation - Toutes les sous-catégories" => "2141.all",
|
'Emulation - Toutes les sous-catégories' => '2141.all',
|
||||||
"Emulation - Emulateurs" => "2141.2157",
|
'Emulation - Emulateurs' => '2141.2157',
|
||||||
"Emulation - Roms" => "2141.2158",
|
'Emulation - Roms' => '2141.2158',
|
||||||
"GPS - Toutes les sous-catégories" => "2141.all",
|
'GPS - Toutes les sous-catégories' => '2141.all',
|
||||||
"GPS - Applications" => "2141.2168",
|
'GPS - Applications' => '2141.2168',
|
||||||
"GPS - Cartes" => "2141.2169",
|
'GPS - Cartes' => '2141.2169',
|
||||||
"GPS - Divers" => "2141.2170"
|
'GPS - Divers' => '2141.2170'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
"nom" => array(
|
'nom' => array(
|
||||||
"name" => "Nom",
|
'name' => 'Nom',
|
||||||
"description" => "Nom du torrent",
|
'description' => 'Nom du torrent',
|
||||||
"type" => "text"
|
'type' => 'text'
|
||||||
),
|
),
|
||||||
"description" => array(
|
'description' => array(
|
||||||
"name" => "Description",
|
'name' => 'Description',
|
||||||
"description" => "Description du torrent",
|
'description' => 'Description du torrent',
|
||||||
"type" => "text"
|
'type' => 'text'
|
||||||
),
|
),
|
||||||
"fichier" => array(
|
'fichier' => array(
|
||||||
"name" => "Fichier",
|
'name' => 'Fichier',
|
||||||
"description" => "Fichier du torrent",
|
'description' => 'Fichier du torrent',
|
||||||
"type" => "text"
|
'type' => 'text'
|
||||||
),
|
),
|
||||||
"uploader" => array(
|
'uploader' => array(
|
||||||
"name" => "Uploader",
|
'name' => 'Uploader',
|
||||||
"description" => "Uploader du torrent",
|
'description' => 'Uploader du torrent',
|
||||||
"type" => "text"
|
'type' => 'text'
|
||||||
),
|
),
|
||||||
|
|
||||||
)
|
)
|
||||||
@@ -85,39 +85,43 @@ class YGGTorrentBridge extends BridgeAbstract {
|
|||||||
|
|
||||||
public function collectData() {
|
public function collectData() {
|
||||||
|
|
||||||
$catInfo = explode(".", $this->getInput("cat"));
|
$catInfo = explode('.', $this->getInput('cat'));
|
||||||
$category = $catInfo[0];
|
$category = $catInfo[0];
|
||||||
$subcategory = $catInfo[1];
|
$subcategory = $catInfo[1];
|
||||||
|
|
||||||
$html = getSimpleHTMLDOM(self::URI . "/engine/search?name="
|
$html = getSimpleHTMLDOM(self::URI . '/engine/search?name='
|
||||||
. $this->getInput("nom")
|
. $this->getInput('nom')
|
||||||
. "&description="
|
. '&description='
|
||||||
. $this->getInput("description")
|
. $this->getInput('description')
|
||||||
. "&fichier="
|
. '&fichier='
|
||||||
. $this->getInput("fichier")
|
. $this->getInput('fichier')
|
||||||
. "&file="
|
. '&file='
|
||||||
. $this->getInput("uploader")
|
. $this->getInput('uploader')
|
||||||
. "&category="
|
. '&category='
|
||||||
. $category
|
. $category
|
||||||
. "&sub_category="
|
. '&sub_category='
|
||||||
. $subcategory
|
. $subcategory
|
||||||
. "&do=search")
|
. '&do=search')
|
||||||
or returnServerError("Unable to query Yggtorrent !");
|
or returnServerError('Unable to query Yggtorrent !');
|
||||||
|
|
||||||
$count = 0;
|
$count = 0;
|
||||||
foreach($html->find(".results", 0)->find("tr") as $row) {
|
$results = $html->find('.results', 0);
|
||||||
|
if(!$results) return;
|
||||||
|
|
||||||
|
foreach($results->find('tr') as $row) {
|
||||||
$count++;
|
$count++;
|
||||||
if($count == 1) continue;
|
if($count == 1) continue;
|
||||||
if($count == 12) break;
|
if($count == 12) break;
|
||||||
$item = array();
|
$item = array();
|
||||||
$item["timestamp"] = $row->find(".hidden", 1)->plaintext;
|
$item['timestamp'] = $row->find('.hidden', 1)->plaintext;
|
||||||
$item["title"] = $row->find("a", 1)->plaintext;
|
$item['title'] = $row->find('a', 1)->plaintext;
|
||||||
$torrentData = $this->collectTorrentData($row->find("a", 1)->href);
|
$torrentData = $this->collectTorrentData($row->find('a', 1)->href);
|
||||||
$item["author"] = $torrentData["author"];
|
$item['author'] = $torrentData['author'];
|
||||||
$item["content"] = $torrentData["content"];
|
$item['content'] = $torrentData['content'];
|
||||||
$item["seeders"] = $row->find("td", 7)->plaintext;
|
$item['seeders'] = $row->find('td', 7)->plaintext;
|
||||||
$item["leechers"] = $row->find("td", 8)->plaintext;
|
$item['leechers'] = $row->find('td', 8)->plaintext;
|
||||||
$item["size"] = $row->find("td", 5)->plaintext;
|
$item['size'] = $row->find('td', 5)->plaintext;
|
||||||
|
|
||||||
$this->items[] = $item;
|
$this->items[] = $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -126,13 +130,14 @@ class YGGTorrentBridge extends BridgeAbstract {
|
|||||||
public function collectTorrentData($url) {
|
public function collectTorrentData($url) {
|
||||||
|
|
||||||
//For weird reason, the link we get can be invalid, we fix it.
|
//For weird reason, the link we get can be invalid, we fix it.
|
||||||
$url_full = explode("/", $url);
|
$url_full = explode('/', $url);
|
||||||
|
$url_full[4] = urlencode($url_full[4]);
|
||||||
|
$url_full[5] = urlencode($url_full[5]);
|
||||||
$url_full[6] = urlencode($url_full[6]);
|
$url_full[6] = urlencode($url_full[6]);
|
||||||
$url = implode("/", $url_full);
|
$url = implode('/', $url_full);
|
||||||
|
$page = getSimpleHTMLDOM($url) or returnServerError('Unable to query Yggtorrent page !');
|
||||||
$page = getSimpleHTMLDOM($url) or returnServerError("Unable to query Yggtorrent page !");
|
$author = $page->find('.informations', 0)->find('a', 4)->plaintext;
|
||||||
$author = $page->find(".informations", 0)->find("a", 4)->plaintext;
|
$content = $page->find('.default', 1);
|
||||||
$content = $page->find(".default", 1);
|
return array('author' => $author, 'content' => $content);
|
||||||
return array("author" => $author, "content" => $content);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -25,14 +25,14 @@ class YoutubeBridge extends BridgeAbstract {
|
|||||||
'By channel id' => array(
|
'By channel id' => array(
|
||||||
'c' => array(
|
'c' => array(
|
||||||
'name' => 'channel id',
|
'name' => 'channel id',
|
||||||
'exampleValue' => "15",
|
'exampleValue' => '15',
|
||||||
'required' => true
|
'required' => true
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'By playlist Id' => array(
|
'By playlist Id' => array(
|
||||||
'p' => array(
|
'p' => array(
|
||||||
'name' => 'playlist id',
|
'name' => 'playlist id',
|
||||||
'exampleValue' => "15"
|
'exampleValue' => '15'
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
'Search result' => array(
|
'Search result' => array(
|
||||||
@@ -195,7 +195,7 @@ class YoutubeBridge extends BridgeAbstract {
|
|||||||
$this->request = $this->getInput('s');
|
$this->request = $this->getInput('s');
|
||||||
$page = 1;
|
$page = 1;
|
||||||
if($this->getInput('pa'))
|
if($this->getInput('pa'))
|
||||||
$page = (int)preg_replace("/[^0-9]/", '', $this->getInput('pa'));
|
$page = (int)preg_replace('/[^0-9]/', '', $this->getInput('pa'));
|
||||||
|
|
||||||
$url_listing = self::URI
|
$url_listing = self::URI
|
||||||
. 'results?search_query='
|
. 'results?search_query='
|
||||||
@@ -226,5 +226,5 @@ class YoutubeBridge extends BridgeAbstract {
|
|||||||
default:
|
default:
|
||||||
return parent::getName();
|
return parent::getName();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
55
bridges/ZenodoBridge.php
Normal file
55
bridges/ZenodoBridge.php
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
<?php
|
||||||
|
class ZenodoBridge extends BridgeAbstract {
|
||||||
|
const MAINTAINER = 'theradialactive';
|
||||||
|
const NAME = 'Zenodo';
|
||||||
|
const URI = 'https://zenodo.org';
|
||||||
|
const CACHE_TIMEOUT = 10;
|
||||||
|
const DESCRIPTION = 'Returns the newest content of Zenodo';
|
||||||
|
|
||||||
|
public function collectData(){
|
||||||
|
$html = getSimpleHTMLDOM($this->getURI())
|
||||||
|
or returnServerError('zenodo.org not reachable.');
|
||||||
|
|
||||||
|
foreach($html->find('div.record-elem') as $element) {
|
||||||
|
$item = array();
|
||||||
|
$item['uri'] = self::URI . $element->find('h4', 0)->find('a', 0)->href;
|
||||||
|
$item['title'] = trim(
|
||||||
|
htmlspecialchars_decode($element->find('h4', 0)->find('a', 0)->innertext,
|
||||||
|
ENT_QUOTES
|
||||||
|
)
|
||||||
|
);
|
||||||
|
foreach($element->find('p', 0)->find('span') as $authors) {
|
||||||
|
$item['author'] = $item['author'] . $authors . '; ';
|
||||||
|
}
|
||||||
|
$content = $element->find('p.hidden-xs', 0)->find('a', 0)->innertext . '<br>';
|
||||||
|
$type = '<br>Type: ' . $element->find('span.label-default', 0)->innertext;
|
||||||
|
|
||||||
|
$raw_date = $element->find('small.text-muted', 0)->innertext;
|
||||||
|
$clean_date = date_parse(str_replace('Uploaded on ', '', $raw_date));
|
||||||
|
|
||||||
|
$content = $content . date_parse($clean_date);
|
||||||
|
|
||||||
|
$item['timestamp'] = mktime(
|
||||||
|
$clean_date['hour'],
|
||||||
|
$clean_date['minute'],
|
||||||
|
$clean_date['second'],
|
||||||
|
$clean_date['month'],
|
||||||
|
$clean_date['day'],
|
||||||
|
$clean_date['year']
|
||||||
|
);
|
||||||
|
|
||||||
|
$access = '';
|
||||||
|
if ($element->find('span.label-success', 0)->innertext) {
|
||||||
|
$access = 'Open Access';
|
||||||
|
} elseif ($element->find('span.label-warning', 0)->innertext) {
|
||||||
|
$access = 'Embargoed Access';
|
||||||
|
} else {
|
||||||
|
$access = $element->find('span.label-error', 0)->innertext;
|
||||||
|
}
|
||||||
|
$access = '<br>Access: ' . $access;
|
||||||
|
$publication = '<br>Publication Date: ' . $element->find('span.label-info', 0)->innertext;
|
||||||
|
$item['content'] = $content . $type . $access . $publication;
|
||||||
|
$this->items[] = $item;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -8,7 +8,9 @@ class FileCache implements CacheInterface {
|
|||||||
protected $param;
|
protected $param;
|
||||||
|
|
||||||
public function loadData(){
|
public function loadData(){
|
||||||
return unserialize(file_get_contents($this->getCacheFile()));
|
if(file_exists($this->getCacheFile())) {
|
||||||
|
return unserialize(file_get_contents($this->getCacheFile()));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function saveData($datas){
|
public function saveData($datas){
|
||||||
@@ -17,7 +19,7 @@ class FileCache implements CacheInterface {
|
|||||||
$writeStream = file_put_contents($this->getCacheFile(), serialize($datas));
|
$writeStream = file_put_contents($this->getCacheFile(), serialize($datas));
|
||||||
|
|
||||||
if($writeStream === false) {
|
if($writeStream === false) {
|
||||||
throw new \Exception("Cannot write the cache... Do you have the right permissions ?");
|
throw new \Exception('Cannot write the cache... Do you have the right permissions ?');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
|
44
config.default.ini.php
Normal file
44
config.default.ini.php
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
; <?php exit; ?> DO NOT REMOVE THIS LINE
|
||||||
|
|
||||||
|
; This file contains the default settings for RSS-Bridge. Do not change this
|
||||||
|
; file, it will be replaced on the next update of RSS-Bridge! You can specify
|
||||||
|
; your own configuration in 'config.ini.php' (copy this file).
|
||||||
|
|
||||||
|
[cache]
|
||||||
|
|
||||||
|
; Allow users to specify custom timeout for specific requests.
|
||||||
|
; true = enabled
|
||||||
|
; false = disabled (default)
|
||||||
|
custom_timeout = false
|
||||||
|
|
||||||
|
[proxy]
|
||||||
|
|
||||||
|
; Sets the proxy url (i.e. "tcp://192.168.0.0:32")
|
||||||
|
; "" = Proxy disabled (default)
|
||||||
|
url = ""
|
||||||
|
|
||||||
|
; Sets the proxy name that is shown on the bridge instead of the proxy url.
|
||||||
|
; "" = Show proxy url
|
||||||
|
name = "Hidden proxy name"
|
||||||
|
|
||||||
|
; Allow users to disable proxy usage for specific requests.
|
||||||
|
; true = enabled
|
||||||
|
; false = disabled (default)
|
||||||
|
by_bridge = false
|
||||||
|
|
||||||
|
[authentication]
|
||||||
|
|
||||||
|
; Enables authentication for all requests to this RSS-Bridge instance.
|
||||||
|
;
|
||||||
|
; Warning: You'll have to upgrade existing feeds after enabling this option!
|
||||||
|
;
|
||||||
|
; true = enabled
|
||||||
|
; false = disabled (default)
|
||||||
|
enable = false
|
||||||
|
|
||||||
|
; The username for authentication. Insert this name when prompted for login.
|
||||||
|
username = ""
|
||||||
|
|
||||||
|
; The password for authentication. Insert this password when prompted for login.
|
||||||
|
; Use a strong password to prevent others from guessing your login!
|
||||||
|
password = ""
|
@@ -15,8 +15,11 @@ class AtomFormat extends FormatAbstract{
|
|||||||
|
|
||||||
$extraInfos = $this->getExtraInfos();
|
$extraInfos = $this->getExtraInfos();
|
||||||
$title = $this->xml_encode($extraInfos['name']);
|
$title = $this->xml_encode($extraInfos['name']);
|
||||||
$uri = !empty($extraInfos['uri']) ? $extraInfos['uri'] : 'https://github.com/sebsauvage/rss-bridge';
|
$uri = !empty($extraInfos['uri']) ? $extraInfos['uri'] : 'https://github.com/RSS-Bridge/rss-bridge';
|
||||||
$icon = $this->xml_encode('http://icons.better-idea.org/icon?url='. $uri .'&size=64');
|
|
||||||
|
$uriparts = parse_url($uri);
|
||||||
|
$icon = $this->xml_encode($uriparts['scheme'] . '://' . $uriparts['host'] .'/favicon.ico');
|
||||||
|
|
||||||
$uri = $this->xml_encode($uri);
|
$uri = $this->xml_encode($uri);
|
||||||
|
|
||||||
$entries = '';
|
$entries = '';
|
||||||
@@ -37,6 +40,16 @@ class AtomFormat extends FormatAbstract{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$entryCategories = '';
|
||||||
|
if(isset($item['categories'])) {
|
||||||
|
foreach($item['categories'] as $category) {
|
||||||
|
$entryCategories .= '<category term="'
|
||||||
|
. $this->xml_encode($category)
|
||||||
|
. '"/>'
|
||||||
|
. PHP_EOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$entries .= <<<EOD
|
$entries .= <<<EOD
|
||||||
|
|
||||||
<entry>
|
<entry>
|
||||||
@@ -49,6 +62,7 @@ class AtomFormat extends FormatAbstract{
|
|||||||
<updated>{$entryTimestamp}</updated>
|
<updated>{$entryTimestamp}</updated>
|
||||||
<content type="html">{$entryContent}</content>
|
<content type="html">{$entryContent}</content>
|
||||||
{$entryEnclosures}
|
{$entryEnclosures}
|
||||||
|
{$entryCategories}
|
||||||
</entry>
|
</entry>
|
||||||
|
|
||||||
EOD;
|
EOD;
|
||||||
|
@@ -47,6 +47,20 @@ class HtmlFormat extends FormatAbstract {
|
|||||||
$entryEnclosures .= '</div>';
|
$entryEnclosures .= '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$entryCategories = '';
|
||||||
|
if(isset($item['categories'])) {
|
||||||
|
$entryCategories = '<div class="categories"><p>Categories:</p>';
|
||||||
|
|
||||||
|
foreach($item['categories'] as $category) {
|
||||||
|
|
||||||
|
$entryCategories .= '<li class="category">'
|
||||||
|
. $this->sanitizeHtml($category)
|
||||||
|
. '</li>';
|
||||||
|
}
|
||||||
|
|
||||||
|
$entryCategories .= '</div>';
|
||||||
|
}
|
||||||
|
|
||||||
$entries .= <<<EOD
|
$entries .= <<<EOD
|
||||||
|
|
||||||
<section class="feeditem">
|
<section class="feeditem">
|
||||||
@@ -55,6 +69,7 @@ class HtmlFormat extends FormatAbstract {
|
|||||||
{$entryAuthor}
|
{$entryAuthor}
|
||||||
{$entryContent}
|
{$entryContent}
|
||||||
{$entryEnclosures}
|
{$entryEnclosures}
|
||||||
|
{$entryCategories}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
EOD;
|
EOD;
|
||||||
|
@@ -18,10 +18,11 @@ class MrssFormat extends FormatAbstract {
|
|||||||
if(!empty($extraInfos['uri'])) {
|
if(!empty($extraInfos['uri'])) {
|
||||||
$uri = $this->xml_encode($extraInfos['uri']);
|
$uri = $this->xml_encode($extraInfos['uri']);
|
||||||
} else {
|
} else {
|
||||||
$uri = 'https://github.com/sebsauvage/rss-bridge';
|
$uri = 'https://github.com/RSS-Bridge/rss-bridge';
|
||||||
}
|
}
|
||||||
|
|
||||||
$icon = $this->xml_encode('http://icons.better-idea.org/icon?url='. $uri .'&size=64');
|
$uriparts = parse_url($uri);
|
||||||
|
$icon = $this->xml_encode($uriparts['scheme'] . '://' . $uriparts['host'] .'/favicon.ico');
|
||||||
|
|
||||||
$items = '';
|
$items = '';
|
||||||
foreach($this->getItems() as $item) {
|
foreach($this->getItems() as $item) {
|
||||||
@@ -50,6 +51,16 @@ Some media files might not be shown to you. Consider using the ATOM format inste
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$entryCategories = '';
|
||||||
|
if(isset($item['categories'])) {
|
||||||
|
|
||||||
|
foreach($item['categories'] as $category) {
|
||||||
|
$entryCategories .= '<category>'
|
||||||
|
. $category . '</category>'
|
||||||
|
. PHP_EOL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$items .= <<<EOD
|
$items .= <<<EOD
|
||||||
|
|
||||||
<item>
|
<item>
|
||||||
@@ -60,6 +71,7 @@ Some media files might not be shown to you. Consider using the ATOM format inste
|
|||||||
<description>{$itemContent}{$entryEnclosuresWarning}</description>
|
<description>{$itemContent}{$entryEnclosuresWarning}</description>
|
||||||
<author>{$itemAuthor}</author>
|
<author>{$itemAuthor}</author>
|
||||||
{$entryEnclosures}
|
{$entryEnclosures}
|
||||||
|
{$entryCategories}
|
||||||
</item>
|
</item>
|
||||||
|
|
||||||
EOD;
|
EOD;
|
||||||
|
69
index.php
69
index.php
@@ -1,37 +1,21 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
require_once __DIR__ . '/lib/RssBridge.php';
|
||||||
TODO :
|
|
||||||
- factorize the annotation system
|
|
||||||
- factorize to adapter : Format, Bridge, Cache(actually code is almost the same)
|
|
||||||
- implement annotation cache for entrance page
|
|
||||||
- Cache : I think logic must be change as least to avoid to reconvert object from json in FileCache case.
|
|
||||||
- add namespace to avoid futur problem ?
|
|
||||||
- see FIXME mentions in the code
|
|
||||||
- implement header('X-Cached-Version: '.date(DATE_ATOM, filemtime($cachefile)));
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Defines the minimum required PHP version for RSS-Bridge
|
|
||||||
define('PHP_VERSION_REQUIRED', '5.6.0');
|
define('PHP_VERSION_REQUIRED', '5.6.0');
|
||||||
|
|
||||||
//define('PROXY_URL', 'tcp://192.168.0.0:28');
|
|
||||||
// Set to true if you allow users to disable proxy usage for specific bridges
|
|
||||||
define('PROXY_BYBRIDGE', false);
|
|
||||||
// Comment this line or keep PROXY_NAME empty to display PROXY_URL instead
|
|
||||||
define('PROXY_NAME', 'Hidden Proxy Name');
|
|
||||||
|
|
||||||
// Allows the operator to specify custom cache timeouts via '&_cache_timeout=3600'
|
|
||||||
// true: enabled, false: disabled (default)
|
|
||||||
define('CUSTOM_CACHE_TIMEOUT', false);
|
|
||||||
|
|
||||||
date_default_timezone_set('UTC');
|
|
||||||
error_reporting(0);
|
|
||||||
|
|
||||||
// Specify directory for cached files (using FileCache)
|
// Specify directory for cached files (using FileCache)
|
||||||
define('CACHE_DIR', __DIR__ . '/cache');
|
define('CACHE_DIR', __DIR__ . '/cache');
|
||||||
|
|
||||||
// Specify path for whitelist file
|
// Specify path for whitelist file
|
||||||
define('WHITELIST_FILE', __DIR__ . '/whitelist.txt');
|
define('WHITELIST_FILE', __DIR__ . '/whitelist.txt');
|
||||||
|
|
||||||
|
Configuration::verifyInstallation();
|
||||||
|
Configuration::loadConfiguration();
|
||||||
|
|
||||||
|
Authentication::showPromptIfNeeded();
|
||||||
|
|
||||||
|
date_default_timezone_set('UTC');
|
||||||
|
error_reporting(0);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Move the CLI arguments to the $_GET array, in order to be able to use
|
Move the CLI arguments to the $_GET array, in order to be able to use
|
||||||
@@ -61,40 +45,6 @@ if(file_exists('DEBUG')) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
require_once __DIR__ . '/lib/RssBridge.php';
|
|
||||||
|
|
||||||
// Check PHP version
|
|
||||||
if(version_compare(PHP_VERSION, PHP_VERSION_REQUIRED) === -1)
|
|
||||||
die('RSS-Bridge requires at least PHP version ' . PHP_VERSION_REQUIRED . '!');
|
|
||||||
|
|
||||||
// extensions check
|
|
||||||
if(!extension_loaded('openssl'))
|
|
||||||
die('"openssl" extension not loaded. Please check "php.ini"');
|
|
||||||
|
|
||||||
if(!extension_loaded('libxml'))
|
|
||||||
die('"libxml" extension not loaded. Please check "php.ini"');
|
|
||||||
|
|
||||||
if(!extension_loaded('mbstring'))
|
|
||||||
die('"mbstring" extension not loaded. Please check "php.ini"');
|
|
||||||
|
|
||||||
if(!extension_loaded('simplexml'))
|
|
||||||
die('"simplexml" extension not loaded. Please check "php.ini"');
|
|
||||||
|
|
||||||
if(!extension_loaded('curl'))
|
|
||||||
die('"curl" extension not loaded. Please check "php.ini"');
|
|
||||||
|
|
||||||
// configuration checks
|
|
||||||
if(ini_get('allow_url_fopen') !== "1")
|
|
||||||
die('"allow_url_fopen" is not set to "1". Please check "php.ini');
|
|
||||||
|
|
||||||
// Check cache folder permissions (write permissions required)
|
|
||||||
if(!is_writable(CACHE_DIR))
|
|
||||||
die('RSS-Bridge does not have write permissions for ' . CACHE_DIR . '!');
|
|
||||||
|
|
||||||
// Check whitelist file permissions (only in DEBUG mode)
|
|
||||||
if(!file_exists(WHITELIST_FILE) && !is_writable(dirname(WHITELIST_FILE)))
|
|
||||||
die('RSS-Bridge does not have write permissions for ' . WHITELIST_FILE . '!');
|
|
||||||
|
|
||||||
// FIXME : beta test UA spoofing, please report any blacklisting by PHP-fopen-unfriendly websites
|
// FIXME : beta test UA spoofing, please report any blacklisting by PHP-fopen-unfriendly websites
|
||||||
|
|
||||||
$userAgent = 'Mozilla/5.0(X11; Linux x86_64; rv:30.0)';
|
$userAgent = 'Mozilla/5.0(X11; Linux x86_64; rv:30.0)';
|
||||||
@@ -303,7 +253,8 @@ EOD;
|
|||||||
echo $inactiveBridges;
|
echo $inactiveBridges;
|
||||||
?>
|
?>
|
||||||
<section class="footer">
|
<section class="footer">
|
||||||
<a href="https://github.com/RSS-Bridge/rss-bridge">RSS-Bridge 2018-04-20 ~ Public Domain</a><br />
|
<a href="https://github.com/RSS-Bridge/rss-bridge">RSS-Bridge ~ Public Domain</a><br />
|
||||||
|
<p class="version"> <?= Configuration::getVersion() ?> </p>
|
||||||
<?= $activeFoundBridgeCount; ?>/<?= count($bridgeList) ?> active bridges. <br />
|
<?= $activeFoundBridgeCount; ?>/<?= count($bridgeList) ?> active bridges. <br />
|
||||||
<?php
|
<?php
|
||||||
if($activeFoundBridgeCount !== count($bridgeList)) {
|
if($activeFoundBridgeCount !== count($bridgeList)) {
|
||||||
|
31
lib/Authentication.php
Normal file
31
lib/Authentication.php
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
<?php
|
||||||
|
class Authentication {
|
||||||
|
|
||||||
|
public static function showPromptIfNeeded() {
|
||||||
|
|
||||||
|
if(Configuration::getConfig('authentication', 'enable') === true) {
|
||||||
|
if(!Authentication::verifyPrompt()) {
|
||||||
|
header('WWW-Authenticate: Basic realm="RSS-Bridge"');
|
||||||
|
header('HTTP/1.0 401 Unauthorized');
|
||||||
|
die('Please authenticate in order to access this instance !');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function verifyPrompt() {
|
||||||
|
|
||||||
|
if(isset($_SERVER['PHP_AUTH_USER']) && isset($_SERVER['PHP_AUTH_PW'])) {
|
||||||
|
if(Configuration::getConfig('authentication', 'username') === $_SERVER['PHP_AUTH_USER']
|
||||||
|
&& Configuration::getConfig('authentication', 'password') === $_SERVER['PHP_AUTH_PW']) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
error_log('[RSS-Bridge] Failed authentication attempt from ' . $_SERVER['REMOTE_ADDR']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
120
lib/Configuration.php
Normal file
120
lib/Configuration.php
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
<?php
|
||||||
|
class Configuration {
|
||||||
|
|
||||||
|
public static $VERSION = '2018-07-17';
|
||||||
|
|
||||||
|
public static $config = null;
|
||||||
|
|
||||||
|
public static function verifyInstallation() {
|
||||||
|
|
||||||
|
// Check PHP version
|
||||||
|
if(version_compare(PHP_VERSION, PHP_VERSION_REQUIRED) === -1)
|
||||||
|
die('RSS-Bridge requires at least PHP version ' . PHP_VERSION_REQUIRED . '!');
|
||||||
|
|
||||||
|
// extensions check
|
||||||
|
if(!extension_loaded('openssl'))
|
||||||
|
die('"openssl" extension not loaded. Please check "php.ini"');
|
||||||
|
|
||||||
|
if(!extension_loaded('libxml'))
|
||||||
|
die('"libxml" extension not loaded. Please check "php.ini"');
|
||||||
|
|
||||||
|
if(!extension_loaded('mbstring'))
|
||||||
|
die('"mbstring" extension not loaded. Please check "php.ini"');
|
||||||
|
|
||||||
|
if(!extension_loaded('simplexml'))
|
||||||
|
die('"simplexml" extension not loaded. Please check "php.ini"');
|
||||||
|
|
||||||
|
if(!extension_loaded('curl'))
|
||||||
|
die('"curl" extension not loaded. Please check "php.ini"');
|
||||||
|
|
||||||
|
// Check cache folder permissions (write permissions required)
|
||||||
|
if(!is_writable(CACHE_DIR))
|
||||||
|
die('RSS-Bridge does not have write permissions for ' . CACHE_DIR . '!');
|
||||||
|
|
||||||
|
// Check whitelist file permissions (only in DEBUG mode)
|
||||||
|
if(!file_exists(WHITELIST_FILE) && !is_writable(dirname(WHITELIST_FILE)))
|
||||||
|
die('RSS-Bridge does not have write permissions for ' . WHITELIST_FILE . '!');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function loadConfiguration() {
|
||||||
|
|
||||||
|
if(!file_exists('config.default.ini.php'))
|
||||||
|
die('The default configuration file "config.default.ini.php" is missing!');
|
||||||
|
|
||||||
|
Configuration::$config = parse_ini_file('config.default.ini.php', true, INI_SCANNER_TYPED);
|
||||||
|
if(!Configuration::$config)
|
||||||
|
die('Error parsing config.default.ini.php');
|
||||||
|
|
||||||
|
if(file_exists('config.ini.php')) {
|
||||||
|
// Replace default configuration with custom settings
|
||||||
|
foreach(parse_ini_file('config.ini.php', true, INI_SCANNER_TYPED) as $header => $section) {
|
||||||
|
foreach($section as $key => $value) {
|
||||||
|
// Skip unknown sections and keys
|
||||||
|
if(array_key_exists($header, Configuration::$config) && array_key_exists($key, Configuration::$config[$header])) {
|
||||||
|
Configuration::$config[$header][$key] = $value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!is_string(self::getConfig('proxy', 'url')))
|
||||||
|
die('Parameter [proxy] => "url" is not a valid string! Please check "config.ini.php"!');
|
||||||
|
|
||||||
|
if(!empty(self::getConfig('proxy', 'url')))
|
||||||
|
define('PROXY_URL', self::getConfig('proxy', 'url'));
|
||||||
|
|
||||||
|
if(!is_bool(self::getConfig('proxy', 'by_bridge')))
|
||||||
|
die('Parameter [proxy] => "by_bridge" is not a valid Boolean! Please check "config.ini.php"!');
|
||||||
|
|
||||||
|
define('PROXY_BYBRIDGE', self::getConfig('proxy', 'by_bridge'));
|
||||||
|
|
||||||
|
if(!is_string(self::getConfig('proxy', 'name')))
|
||||||
|
die('Parameter [proxy] => "name" is not a valid string! Please check "config.ini.php"!');
|
||||||
|
|
||||||
|
define('PROXY_NAME', self::getConfig('proxy', 'name'));
|
||||||
|
|
||||||
|
if(!is_bool(self::getConfig('cache', 'custom_timeout')))
|
||||||
|
die('Parameter [cache] => "custom_timeout" is not a valid Boolean! Please check "config.ini.php"!');
|
||||||
|
|
||||||
|
define('CUSTOM_CACHE_TIMEOUT', self::getConfig('cache', 'custom_timeout'));
|
||||||
|
|
||||||
|
if(!is_bool(self::getConfig('authentication', 'enable')))
|
||||||
|
die('Parameter [authentication] => "enable" is not a valid Boolean! Please check "config.ini.php"!');
|
||||||
|
|
||||||
|
if(!is_string(self::getConfig('authentication', 'username')))
|
||||||
|
die('Parameter [authentication] => "username" is not a valid string! Please check "config.ini.php"!');
|
||||||
|
|
||||||
|
if(!is_string(self::getConfig('authentication', 'password')))
|
||||||
|
die('Parameter [authentication] => "password" is not a valid string! Please check "config.ini.php"!');
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getConfig($category, $key) {
|
||||||
|
|
||||||
|
if(array_key_exists($category, self::$config) && array_key_exists($key, self::$config[$category])) {
|
||||||
|
return self::$config[$category][$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function getVersion() {
|
||||||
|
|
||||||
|
$headFile = '.git/HEAD';
|
||||||
|
|
||||||
|
if(file_exists($headFile)) {
|
||||||
|
|
||||||
|
$revisionHashFile = '.git/' . substr(file_get_contents($headFile), 5, -1);
|
||||||
|
$branchName = explode('/', $revisionHashFile)[3];
|
||||||
|
if(file_exists($revisionHashFile)) {
|
||||||
|
return 'git.' . $branchName . '.' . substr(file_get_contents($revisionHashFile), 0, 7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Configuration::$VERSION;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@@ -64,7 +64,10 @@ function buildBridgeException($e, $bridge){
|
|||||||
$body = 'Error message: `'
|
$body = 'Error message: `'
|
||||||
. $e->getMessage()
|
. $e->getMessage()
|
||||||
. "`\nQuery string: `"
|
. "`\nQuery string: `"
|
||||||
. $_SERVER['QUERY_STRING'] . '`';
|
. $_SERVER['QUERY_STRING']
|
||||||
|
. "`\nVersion: `"
|
||||||
|
. Configuration::getVersion()
|
||||||
|
. '`';
|
||||||
|
|
||||||
$link = buildGitHubIssueQuery($title, $body, 'bug report', $bridge->getMaintainer());
|
$link = buildGitHubIssueQuery($title, $body, 'bug report', $bridge->getMaintainer());
|
||||||
|
|
||||||
|
@@ -24,15 +24,15 @@ abstract class FeedExpander extends BridgeAbstract {
|
|||||||
switch(true) {
|
switch(true) {
|
||||||
case isset($rssContent->item[0]):
|
case isset($rssContent->item[0]):
|
||||||
debugMessage('Detected RSS 1.0 format');
|
debugMessage('Detected RSS 1.0 format');
|
||||||
$this->feedType = "RSS_1_0";
|
$this->feedType = 'RSS_1_0';
|
||||||
break;
|
break;
|
||||||
case isset($rssContent->channel[0]):
|
case isset($rssContent->channel[0]):
|
||||||
debugMessage('Detected RSS 0.9x or 2.0 format');
|
debugMessage('Detected RSS 0.9x or 2.0 format');
|
||||||
$this->feedType = "RSS_2_0";
|
$this->feedType = 'RSS_2_0';
|
||||||
break;
|
break;
|
||||||
case isset($rssContent->entry[0]):
|
case isset($rssContent->entry[0]):
|
||||||
debugMessage('Detected ATOM format');
|
debugMessage('Detected ATOM format');
|
||||||
$this->feedType = "ATOM_1_0";
|
$this->feedType = 'ATOM_1_0';
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
debugMessage('Unknown feed format/version');
|
debugMessage('Unknown feed format/version');
|
||||||
|
@@ -14,6 +14,8 @@ require __DIR__ . '/Bridge.php';
|
|||||||
require __DIR__ . '/BridgeAbstract.php';
|
require __DIR__ . '/BridgeAbstract.php';
|
||||||
require __DIR__ . '/FeedExpander.php';
|
require __DIR__ . '/FeedExpander.php';
|
||||||
require __DIR__ . '/Cache.php';
|
require __DIR__ . '/Cache.php';
|
||||||
|
require __DIR__ . '/Authentication.php';
|
||||||
|
require __DIR__ . '/Configuration.php';
|
||||||
|
|
||||||
require __DIR__ . '/validation.php';
|
require __DIR__ . '/validation.php';
|
||||||
require __DIR__ . '/html.php';
|
require __DIR__ . '/html.php';
|
||||||
|
@@ -22,10 +22,12 @@ function getContents($url, $header = array(), $opts = array()){
|
|||||||
}
|
}
|
||||||
|
|
||||||
$content = curl_exec($ch);
|
$content = curl_exec($ch);
|
||||||
|
$curlError = curl_error($ch);
|
||||||
|
$curlErrno = curl_errno($ch);
|
||||||
curl_close($ch);
|
curl_close($ch);
|
||||||
|
|
||||||
if($content === false)
|
if($content === false)
|
||||||
debugMessage('Cant\'t download ' . $url);
|
debugMessage('Cant\'t download ' . $url . ' cUrl error: ' . $curlError . ' (' . $curlErrno . ')');
|
||||||
|
|
||||||
return $content;
|
return $content;
|
||||||
}
|
}
|
||||||
|
@@ -26,7 +26,7 @@ EOD;
|
|||||||
$bridge = Bridge::create($bridgeName);
|
$bridge = Bridge::create($bridgeName);
|
||||||
|
|
||||||
if($bridge == false)
|
if($bridge == false)
|
||||||
return "";
|
return '';
|
||||||
|
|
||||||
$HTTPSWarning = '';
|
$HTTPSWarning = '';
|
||||||
if(strpos($bridge->getURI(), 'https') !== 0) {
|
if(strpos($bridge->getURI(), 'https') !== 0) {
|
||||||
|
@@ -70,4 +70,8 @@
|
|||||||
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
|
<rule ref="Squiz.WhiteSpace.SemicolonSpacing"/>
|
||||||
<!-- Do not add whitespace at start or end of a file or end of a line -->
|
<!-- Do not add whitespace at start or end of a file or end of a line -->
|
||||||
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
|
<rule ref="Squiz.WhiteSpace.SuperfluousWhitespace"/>
|
||||||
|
<!-- Whenever possible use single quote strings -->
|
||||||
|
<rule ref="Squiz.Strings.DoubleQuoteUsage">
|
||||||
|
<exclude name="Squiz.Strings.DoubleQuoteUsage.ContainsVar" />
|
||||||
|
</rule>
|
||||||
</ruleset>
|
</ruleset>
|
||||||
|
@@ -69,12 +69,14 @@ a.backlink, a.backlink:link, a.backlink:visited, a.itemtitle, a.itemtitle:link,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
section > div.content, section > div.categories,
|
||||||
section > div.content, section > div.attachments {
|
section > div.content, section > div.attachments {
|
||||||
|
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
section > div.categories > li.category,
|
||||||
section > div.attachments > li.enclosure {
|
section > div.attachments > li.enclosure {
|
||||||
|
|
||||||
list-style-type: circle;
|
list-style-type: circle;
|
||||||
|
@@ -143,6 +143,11 @@ section.footer:hover {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
section.footer .version {
|
||||||
|
|
||||||
|
font-size: 80%;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
section > h2 {
|
section > h2 {
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user