mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-08-30 11:30:11 +02:00
Compare commits
22 Commits
2018-04-06
...
2018-04-20
Author | SHA1 | Date | |
---|---|---|---|
|
b0c7a62f74 | ||
|
57b15a089e | ||
|
4b7fbe4188 | ||
|
2390fb58b3 | ||
|
1e8d29f6ec | ||
|
644d13686c | ||
|
aa0ff1c9b1 | ||
|
539d9f1f06 | ||
|
5ece801ce7 | ||
|
4dcea6d9c9 | ||
|
d69e2521f1 | ||
|
7927d73719 | ||
|
0620f30ae0 | ||
|
795494cfce | ||
|
ba8542156c | ||
|
55f112e034 | ||
|
208fff801d | ||
|
3c9860de43 | ||
|
a16ec196c5 | ||
|
887fc7b037 | ||
|
1bd4a40f71 | ||
|
494169f959 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -231,4 +231,7 @@ DEBUG
|
||||
######################
|
||||
## VisualStudioCode ##
|
||||
######################
|
||||
.vscode/*
|
||||
.vscode/*
|
||||
|
||||
#Builder
|
||||
.buildconfig
|
||||
|
@@ -15,8 +15,13 @@ class DansTonChatBridge extends BridgeAbstract {
|
||||
foreach($html->find('div.item') as $element) {
|
||||
$item = array();
|
||||
$item['uri'] = $element->find('a', 0)->href;
|
||||
$item['title'] = 'DansTonChat ' . $element->find('a', 1)->plaintext;
|
||||
$item['content'] = $element->find('a', 0)->innertext;
|
||||
$titleContent = $element->find('h3 a', 0);
|
||||
if($titleContent) {
|
||||
$item['title'] = 'DansTonChat ' . html_entity_decode($titleContent->plaintext, ENT_QUOTES);
|
||||
} else {
|
||||
$item['title'] = 'DansTonChat';
|
||||
}
|
||||
$item['content'] = $element->find('div.item-content a', 0)->innertext;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
@@ -4,143 +4,163 @@ class DemonoidBridge extends BridgeAbstract {
|
||||
const MAINTAINER = 'metaMMA';
|
||||
const NAME = 'Demonoid';
|
||||
const URI = 'https://www.demonoid.pw/';
|
||||
const DESCRIPTION = 'Returns results for the keywords (in all categories or
|
||||
a specific category). You can put several keywords separated by a semicolon
|
||||
(e.g. "one show;another show"). Searches can by done in a specific category;
|
||||
category number must be specified. (All=0, Movies=1, Music=2, TV=3, Games=4,
|
||||
Applications=5, Pictures=8, Anime=9, Comics=10, Books=11 Music Videos=8,
|
||||
Audio Books=17). User feed takes the Uploader ID number (not uploader name)
|
||||
as keyword. Uploader ID is found by clicking on uploader, clicking on
|
||||
"View this user\'s torrents", and copying the number after "uid=". An entire
|
||||
category feed is accomplished by leaving "keywords" box blank and using the
|
||||
corresponding category number.';
|
||||
const DESCRIPTION = 'Returns results from search';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
const PARAMETERS = array(array(
|
||||
'q' => array(
|
||||
'name' => 'keywords/user ID/category, separated by semicolons',
|
||||
'exampleValue' => 'first list;second list;…',
|
||||
'required' => true
|
||||
),
|
||||
'crit' => array(
|
||||
'name' => 'keywords',
|
||||
'exampleValue' => 'keyword1 keyword2…',
|
||||
'required' => true,
|
||||
),
|
||||
'category' => array(
|
||||
'name' => 'Category',
|
||||
'type' => 'list',
|
||||
'name' => 'Feed type',
|
||||
'values' => array(
|
||||
'search' => 'search',
|
||||
'category' => 'cat',
|
||||
'user' => 'usr'
|
||||
'All' => 0,
|
||||
'Movies' => 1,
|
||||
'Music' => 2,
|
||||
'TV' => 3,
|
||||
'Games' => 4,
|
||||
'Applications' => 5,
|
||||
'Pictures' => 8,
|
||||
'Anime' => 9,
|
||||
'Comics' => 10,
|
||||
'Books' => 11,
|
||||
'Audiobooks' => 17
|
||||
)
|
||||
)
|
||||
),
|
||||
'catCheck' => array(
|
||||
'type' => 'checkbox',
|
||||
'name' => 'Specify category for keyword search ?',
|
||||
),
|
||||
'cat' => array(
|
||||
'name' => 'Category number',
|
||||
),
|
||||
));
|
||||
), array(
|
||||
'catOnly' => array(
|
||||
'name' => 'Category',
|
||||
'type' => 'list',
|
||||
'values' => array(
|
||||
'All' => 0,
|
||||
'Movies' => 1,
|
||||
'Music' => 2,
|
||||
'TV' => 3,
|
||||
'Games' => 4,
|
||||
'Applications' => 5,
|
||||
'Pictures' => 8,
|
||||
'Anime' => 9,
|
||||
'Comics' => 10,
|
||||
'Books' => 11,
|
||||
'Audiobooks' => 17
|
||||
)
|
||||
)
|
||||
), array(
|
||||
'userid' => array(
|
||||
'name' => 'user id',
|
||||
'exampleValue' => '00000',
|
||||
'required' => true,
|
||||
'type' => 'number'
|
||||
),
|
||||
'category' => array(
|
||||
'name' => 'Category',
|
||||
'type' => 'list',
|
||||
'values' => array(
|
||||
'All' => 0,
|
||||
'Movies' => 1,
|
||||
'Music' => 2,
|
||||
'TV' => 3,
|
||||
'Games' => 4,
|
||||
'Applications' => 5,
|
||||
'Pictures' => 8,
|
||||
'Anime' => 9,
|
||||
'Comics' => 10,
|
||||
'Books' => 11,
|
||||
'Audiobooks' => 17
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
public function collectData() {
|
||||
|
||||
$catBool = $this->getInput('catCheck');
|
||||
if($catBool) {
|
||||
$catNum = $this->getInput('cat');
|
||||
if(!empty($this->getInput('q'))) {
|
||||
|
||||
$html = getSimpleHTMLDOM(
|
||||
self::URI .
|
||||
'files/?category=' .
|
||||
rawurlencode($this->getInput('category')) .
|
||||
'&subcategory=All&quality=All&seeded=2&external=2&query=' .
|
||||
urlencode($this->getInput('q')) .
|
||||
'&uid=0&sort='
|
||||
) or returnServerError('Could not request Demonoid.');
|
||||
|
||||
} elseif(!empty($this->getInput('catOnly'))) {
|
||||
|
||||
$html = getSimpleHTMLDOM(
|
||||
self::URI .
|
||||
'files/?uid=0&category=' .
|
||||
rawurlencode($this->getInput('catOnly')) .
|
||||
'&subcategory=0&language=0&seeded=2&quality=0&query=&sort='
|
||||
) or returnServerError('Could not request Demonoid.');
|
||||
|
||||
} elseif(!empty($this->getInput('userid'))) {
|
||||
|
||||
$html = getSimpleHTMLDOM(
|
||||
self::URI .
|
||||
'files/?uid=' .
|
||||
rawurlencode($this->getInput('userid')) .
|
||||
'&seeded=2'
|
||||
) or returnServerError('Could not request Demonoid.');
|
||||
|
||||
} else {
|
||||
returnServerError('Invalid parameters !');
|
||||
}
|
||||
$critList = $this->getInput('crit');
|
||||
|
||||
$keywordsList = explode(';', $this->getInput('q'));
|
||||
foreach($keywordsList as $keywords) {
|
||||
switch($critList) {
|
||||
case 'search':
|
||||
if($catBool == false) {
|
||||
$html = file_get_contents(
|
||||
self::URI .
|
||||
'files/?category=0&subcategory=All&quality=All&seeded=2&external=2&query=' .
|
||||
urlencode($keywords) . #not rawurlencode so space -> '+'
|
||||
'&uid=0&sort='
|
||||
) or returnServerError('Could not request Demonoid.');
|
||||
} else {
|
||||
$html = file_get_contents(
|
||||
self::URI .
|
||||
'files/?category=' .
|
||||
rawurlencode($catNum) .
|
||||
'&subcategory=All&quality=All&seeded=2&external=2&query=' .
|
||||
urlencode($keywords) . #not rawurlencode so space -> '+'
|
||||
'&uid=0&sort='
|
||||
) or returnServerError('Could not request Demonoid.');
|
||||
}
|
||||
break;
|
||||
case 'usr':
|
||||
$html = file_get_contents(
|
||||
self::URI .
|
||||
'files/?uid=' .
|
||||
rawurlencode($keywords) .
|
||||
'&seeded=2'
|
||||
) or returnServerError('Could not request Demonoid.');
|
||||
break;
|
||||
case 'cat':
|
||||
$html = file_get_contents(
|
||||
self::URI .
|
||||
'files/?uid=0&category=' .
|
||||
rawurlencode($keywords) .
|
||||
'&subcategory=0&language=0&seeded=2&quality=0&query=&sort='
|
||||
) or returnServerError('Could not request Demonoid.');
|
||||
break;
|
||||
if(preg_match('~No torrents found~', $html)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$table = $html->find('td[class=ctable_content_no_pad]', 0);
|
||||
$cursorCount = 4;
|
||||
$elementCount = 0;
|
||||
while($elementCount != 40) {
|
||||
$elementCount++;
|
||||
$currentElement = $table->find('tr', $cursorCount);
|
||||
if(preg_match('~items total~', $currentElement)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(preg_match('~No torrents found~', $html)) {
|
||||
returnServerError('No result for query ' . $keywords);
|
||||
}
|
||||
|
||||
$bigTable = explode('<!-- start torrent list -->', $html)[1];
|
||||
$last50 = explode('<!-- end torrent list -->', $bigTable)[0];
|
||||
$dateChunk = explode('added_today', $last50);
|
||||
$item = array ();
|
||||
|
||||
for($block = 1;$block < count($dateChunk);$block++) {
|
||||
preg_match('~(?<=>Add).*?(?=<)~', $dateChunk[$block], $dateStr);
|
||||
$item = array();
|
||||
//Do we have a date ?
|
||||
if(preg_match('~Added.*?(.*)~', $currentElement->plaintext, $dateStr)) {
|
||||
if(preg_match('~today~', $dateStr[0])) {
|
||||
date_default_timezone_set('UTC');
|
||||
$timestamp = mktime(0, 0, 0, gmdate('n'), gmdate('j'), gmdate('Y'));
|
||||
} else {
|
||||
preg_match('~(?<=ed on ).*\d+~', $dateStr[0], $fullDateStr);
|
||||
} else {
|
||||
preg_match('~(?<=ed on ).*\d+~', $currentElement->plaintext, $fullDateStr);
|
||||
date_default_timezone_set('UTC');
|
||||
$dateObj = strptime($fullDateStr[0], '%A, %b %d, %Y');
|
||||
$timestamp = mktime(0, 0, 0, $dateObj['tm_mon'] + 1, $dateObj['tm_mday'], 1900 + $dateObj['tm_year']);
|
||||
}
|
||||
|
||||
$itemsChunk = explode('<!-- tstart -->', $dateChunk[$block]);
|
||||
|
||||
for($items = 1;$items < count($itemsChunk);$items++) {
|
||||
$item = array();
|
||||
$cols = explode('<td', $itemsChunk[$items]);
|
||||
preg_match('~(?<=href=\"/).*?(?=\")~', $cols[1], $matches);
|
||||
$item['id'] = self::URI . $matches[0];
|
||||
preg_match('~(?<=href=\").*?(?=\")~', $cols[4], $matches);
|
||||
$item['uri'] = $matches[0];
|
||||
$item['timestamp'] = $timestamp;
|
||||
preg_match('~(?<=href=\"/users/).*?(?=\")~', $cols[3], $matches);
|
||||
$item['author'] = $matches[0];
|
||||
preg_match('~(?<=/\">).*?(?=</a>)~', $cols[1], $matches);
|
||||
$item['title'] = $matches[0];
|
||||
preg_match('~(?<=green\">)\d+(?=</font>)~', $cols[8], $matches);
|
||||
$item['seeders'] = $matches[0];
|
||||
preg_match('~(?<=red\">)\d+(?=</font>)~', $cols[9], $matches);
|
||||
$item['leechers'] = $matches[0];
|
||||
preg_match('~(?<=>).*?(?=</td>)~', $cols[5], $matches);
|
||||
$item['size'] = $matches[0];
|
||||
$item['content'] = 'Uploaded by ' . $item['author']
|
||||
. ' , Size ' . $item['size']
|
||||
. '<br>seeders: '
|
||||
. $item['seeders']
|
||||
. ' | leechers: '
|
||||
. $item['leechers']
|
||||
. '<br><a href="'
|
||||
. $item['id']
|
||||
. '">info page</a>';
|
||||
if(isset($item['title']))
|
||||
$this->items[] = $item;
|
||||
}
|
||||
$cursorCount++;
|
||||
}
|
||||
|
||||
$content = $table->find('tr', $cursorCount)->find('a', 1);
|
||||
$cursorCount++;
|
||||
$torrentInfo = $table->find('tr', $cursorCount);
|
||||
$item['timestamp'] = $timestamp;
|
||||
$item['title'] = $content->plaintext;
|
||||
$item['id'] = self::URI . $content->href;
|
||||
$item['uri'] = self::URI . $content->href;
|
||||
$item['author'] = $torrentInfo->find('a[class=user]', 0)->plaintext;
|
||||
$item['seeders'] = $torrentInfo->find('font[class=green]', 0)->plaintext;
|
||||
$item['leechers'] = $torrentInfo->find('font[class=red]', 0)->plaintext;
|
||||
$item['size'] = $torrentInfo->find('td', 3)->plaintext;
|
||||
$item['content'] = 'Uploaded by ' . $item['author']
|
||||
. ' , Size ' . $item['size']
|
||||
. '<br>seeders: '
|
||||
. $item['seeders']
|
||||
. ' | leechers: '
|
||||
. $item['leechers']
|
||||
. '<br><a href="'
|
||||
. $item['id']
|
||||
. '">info page</a>';
|
||||
|
||||
$this->items[] = $item;
|
||||
|
||||
$cursorCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
112
bridges/DiscogsBridge.php
Normal file
112
bridges/DiscogsBridge.php
Normal file
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
class DiscogsBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'teromene';
|
||||
const NAME = 'DiscogsBridge';
|
||||
const URI = 'https://www.discogs.com/';
|
||||
const DESCRIPTION = 'Returns releases from discogs';
|
||||
const PARAMETERS = array(
|
||||
'Artist Releases' => array(
|
||||
'artistid' => array(
|
||||
'name' => 'Artist ID',
|
||||
'type' => 'number',
|
||||
)
|
||||
),
|
||||
'Label Releases' => array(
|
||||
'labelid' => array(
|
||||
'name' => 'Label ID',
|
||||
'type' => 'number',
|
||||
)
|
||||
),
|
||||
'User Wantlist' => array(
|
||||
'username_wantlist' => array(
|
||||
'name' => 'Username',
|
||||
'type' => 'text',
|
||||
)
|
||||
),
|
||||
'User Folder' => array(
|
||||
'username_folder' => array(
|
||||
'name' => 'Username',
|
||||
'type' => 'text',
|
||||
),
|
||||
'folderid' => array(
|
||||
'name' => 'Folder ID',
|
||||
'type' => 'number',
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
public function collectData() {
|
||||
|
||||
if(!empty($this->getInput('artistid')) || !empty($this->getInput('labelid'))) {
|
||||
|
||||
if(!empty($this->getInput('artistid'))) {
|
||||
$data = getContents("https://api.discogs.com/artists/"
|
||||
. $this->getInput('artistid')
|
||||
. "/releases?sort=year&sort_order=desc")
|
||||
or returnServerError("Unable to query discogs !");
|
||||
} elseif(!empty($this->getInput('labelid'))) {
|
||||
$data = getContents("https://api.discogs.com/labels/"
|
||||
. $this->getInput('labelid')
|
||||
. "/releases?sort=year&sort_order=desc")
|
||||
or returnServerError("Unable to query discogs !");
|
||||
}
|
||||
|
||||
$jsonData = json_decode($data, true);
|
||||
foreach($jsonData["releases"] as $release) {
|
||||
|
||||
$item = array();
|
||||
$item["author"] = $release["artist"];
|
||||
$item["title"] = $release["title"];
|
||||
$item["id"] = $release["id"];
|
||||
$resId = array_key_exists("main_release", $release) ? $release["main_release"] : $release["id"];
|
||||
$item["uri"] = self::URI . $this->getInput('artistid') . "/release/" . $resId;
|
||||
$item["timestamp"] = DateTime::createFromFormat("Y", $release["year"])->getTimestamp();
|
||||
$item["content"] = $item["author"] . " - " . $item["title"];
|
||||
$this->items[] = $item;
|
||||
}
|
||||
|
||||
} elseif(!empty($this->getInput("username_wantlist")) || !empty($this->getInput("username_folder"))) {
|
||||
|
||||
if(!empty($this->getInput("username_wantlist"))) {
|
||||
$data = getContents("https://api.discogs.com/users/"
|
||||
. $this->getInput('username_wantlist')
|
||||
. "/wants?sort=added&sort_order=desc")
|
||||
or returnServerError("Unable to query discogs !");
|
||||
$jsonData = json_decode($data, true)["wants"];
|
||||
|
||||
} elseif(!empty($this->getInput("username_folder"))) {
|
||||
$data = getContents("https://api.discogs.com/users/"
|
||||
. $this->getInput('username_folder')
|
||||
. "/collection/folders/"
|
||||
. $this->getInput("folderid")
|
||||
."/releases?sort=added&sort_order=desc")
|
||||
or returnServerError("Unable to query discogs !");
|
||||
$jsonData = json_decode($data, true)["releases"];
|
||||
}
|
||||
foreach($jsonData as $element) {
|
||||
|
||||
$infos = $element["basic_information"];
|
||||
$item = array();
|
||||
$item["title"] = $infos["title"];
|
||||
$item["author"] = $infos["artists"][0]["name"];
|
||||
$item["id"] = $infos["artists"][0]["id"];
|
||||
$item["uri"] = self::URI . $infos["artists"][0]["id"] . "/release/" . $infos["id"];
|
||||
$item["timestamp"] = strtotime($element["date_added"]);
|
||||
$item["content"] = $item["author"] . " - " . $item["title"];
|
||||
$this->items[] = $item;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function getURI() {
|
||||
return self::URI;
|
||||
}
|
||||
|
||||
public function getName() {
|
||||
return static::NAME;
|
||||
}
|
||||
}
|
54
bridges/FDroidBridge.php
Normal file
54
bridges/FDroidBridge.php
Normal file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
class FDroidBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'Mitsukarenai';
|
||||
const NAME = 'F-Droid Bridge';
|
||||
const URI = 'https://f-droid.org/';
|
||||
const CACHE_TIMEOUT = 60 * 60 * 2; // 2 hours
|
||||
const DESCRIPTION = 'Returns latest added/updated apps on the open-source Android apps repository F-Droid';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'u' => array(
|
||||
'name' => 'Widget selection',
|
||||
'type' => 'list',
|
||||
'required' => true,
|
||||
'values' => array(
|
||||
'Latest added apps' => 'added',
|
||||
'Latest updated apps' => 'updated'
|
||||
)
|
||||
)
|
||||
));
|
||||
|
||||
public function collectData(){
|
||||
$url = self::URI;
|
||||
$html = getSimpleHTMLDOM($url)
|
||||
or returnServerError('Could not request F-Droid.');
|
||||
|
||||
// targetting the corresponding widget based on user selection
|
||||
// "updated" is the 4th widget on the page, "added" is the 5th
|
||||
|
||||
switch($this->getInput('u')) {
|
||||
case 'updated':
|
||||
$html_widget = $html->find('div.sidebar-widget', 4);
|
||||
break;
|
||||
default:
|
||||
$html_widget = $html->find('div.sidebar-widget', 5);
|
||||
break;
|
||||
}
|
||||
|
||||
// and now extracting app info from the selected widget (and yeah turns out icons are of heterogeneous sizes)
|
||||
|
||||
foreach($html_widget->find('a') as $element) {
|
||||
$item = array();
|
||||
$item['uri'] = self::URI . $element->href;
|
||||
$item['title'] = $element->find('h4', 0)->plaintext;
|
||||
$item['icon'] = $element->find('img', 0)->src;
|
||||
$item['summary'] = $element->find('span.package-summary', 0)->plaintext;
|
||||
$item['content'] = '
|
||||
<a href="'.$item['uri'].'">
|
||||
<img alt="" style="max-height:128px" src="'.$item['icon'].'">
|
||||
</a><br>'.$item['summary'];
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
}
|
@@ -3,7 +3,7 @@ class GoComicsBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'sky';
|
||||
const NAME = 'GoComics Unofficial RSS';
|
||||
const URI = 'http://www.gocomics.com/';
|
||||
const URI = 'https://www.gocomics.com/';
|
||||
const CACHE_TIMEOUT = 21600; // 6h
|
||||
const DESCRIPTION = 'The Unofficial GoComics RSS';
|
||||
const PARAMETERS = array( array(
|
||||
@@ -18,25 +18,27 @@ class GoComicsBridge extends BridgeAbstract {
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Could not request GoComics: ' . $this->getURI());
|
||||
|
||||
foreach($html->find('div.comic__container') as $element) {
|
||||
//Get info from first page
|
||||
$author = preg_replace('/By /', '', $html->find(".media-subheading", 0)->plaintext);
|
||||
|
||||
$img = $element->find('.item-comic-image img', 0);
|
||||
$link = $element->find('a.js-item-comic-link', 0);
|
||||
$comic = $img->src;
|
||||
$title = $link->title;
|
||||
$url = $html->find('input.js-copy-link', 0)->value;
|
||||
$date = substr($title, -10);
|
||||
if (empty($title))
|
||||
$title = 'GoComics ' . $this->getInput('comicname') . ' on ' . $date;
|
||||
$date = strtotime($date);
|
||||
$link = self::URI . $html->find(".gc-deck--cta-0", 0)->find('a', 0)->href;
|
||||
for($i = 0; $i < 5; $i++) {
|
||||
|
||||
$item = array();
|
||||
$item['id'] = $url;
|
||||
$item['uri'] = $url;
|
||||
$item['title'] = $title;
|
||||
$item['author'] = preg_replace('/by /', '', $element->find('a.link-blended small', 0)->plaintext);
|
||||
$item['timestamp'] = $date;
|
||||
$item['content'] = '<img src="' . $comic . '" alt="' . $title . '" />';
|
||||
|
||||
$page = getSimpleHTMLDOM($link)
|
||||
or returnServerError('Could not request GoComics: ' . $link);
|
||||
$imagelink = $page->find(".img-fluid", 1)->src;
|
||||
$date = explode("/", $link);
|
||||
|
||||
$item['id'] = $imagelink;
|
||||
$item['uri'] = $link;
|
||||
$item['author'] = $author;
|
||||
$item['title'] = 'GoComics ' . $this->getInput('comicname');
|
||||
$item['timestamp'] = DateTime::createFromFormat("Ymd", $date[5] . $date[6] . $date[7])->getTimestamp();
|
||||
$item['content'] = '<img src="' . $imagelink . '" />';
|
||||
|
||||
$link = self::URI . $page->find(".js-previous-comic", 0)->href;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
@@ -95,6 +95,7 @@ class InstagramBridge extends BridgeAbstract {
|
||||
$item['title'] = basename($media->display_url);
|
||||
}
|
||||
$item['timestamp'] = $media->taken_at_timestamp;
|
||||
$item['enclosures'] = array($media->display_url);
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
57
bridges/NotAlwaysBridge.php
Normal file
57
bridges/NotAlwaysBridge.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
class NotAlwaysBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'mozes';
|
||||
const NAME = 'Not Always family Bridge';
|
||||
const URI = 'https://notalwaysright.com/';
|
||||
const DESCRIPTION = 'Returns the latest stories';
|
||||
const CACHE_TIMEOUT = 1800; // 30 minutes
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'filter' => array(
|
||||
'type' => 'list',
|
||||
'name' => 'Filter',
|
||||
'values' => array(
|
||||
'All' => 'all',
|
||||
'Right' => 'right',
|
||||
'Working' => 'working',
|
||||
'Romantic' => 'romantic',
|
||||
'Related' => 'related',
|
||||
'Learning' => 'learning',
|
||||
'Friendly' => 'friendly',
|
||||
'Hopeless' => 'hopeless',
|
||||
'Unfiltered' => 'unfiltered'
|
||||
),
|
||||
'required' => true
|
||||
)
|
||||
));
|
||||
|
||||
public function collectData(){
|
||||
$html = getSimpleHTMLDOM($this->getURI())
|
||||
or returnServerError('Could not request NotAlways.');
|
||||
foreach($html->find('.post') as $post) {
|
||||
#print_r($post);
|
||||
$item = array();
|
||||
$item['uri'] = $post->find('h1', 0)->find('a', 0)->href;
|
||||
$item['content'] = $post;
|
||||
$item['title'] = $post->find('h1', 0)->find('a', 0)->innertext;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function getName(){
|
||||
if(!is_null($this->getInput('filter'))) {
|
||||
return $this->getInput('filter') . ' - NotAlways Bridge';
|
||||
}
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
|
||||
public function getURI(){
|
||||
if(!is_null($this->getInput('filter'))) {
|
||||
return self::URI . $this->getInput('filter') . "/";
|
||||
}
|
||||
|
||||
return parent::getURI();
|
||||
}
|
||||
}
|
73
bridges/PixivBridge.php
Normal file
73
bridges/PixivBridge.php
Normal file
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
class PixivBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'teromene';
|
||||
const NAME = 'Pixiv Bridge';
|
||||
const URI = 'https://www.pixiv.net/';
|
||||
const DESCRIPTION = 'Returns the tag search from pixiv.net';
|
||||
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'tag' => array(
|
||||
'name' => 'Tag to search',
|
||||
'exampleValue' => 'example',
|
||||
'required' => true
|
||||
),
|
||||
));
|
||||
|
||||
|
||||
public function collectData(){
|
||||
|
||||
$html = getContents(static::URI.'search.php?word=' . urlencode($this->getInput('tag')))
|
||||
or returnClientError('Unable to query pixiv.net');
|
||||
$regex = '/<input type="hidden"id="js-mount-point-search-result-list"data-items="([^"]*)/';
|
||||
$timeRegex = '/img\/([0-9]{4})\/([0-9]{2})\/([0-9]{2})\/([0-9]{2})\/([0-9]{2})\/([0-9]{2})\//';
|
||||
|
||||
preg_match_all($regex, $html, $matches, PREG_SET_ORDER, 0);
|
||||
if(!$matches) return;
|
||||
|
||||
$content = json_decode(html_entity_decode($matches[0][1]), true);
|
||||
$count = 0;
|
||||
foreach($content as $result) {
|
||||
if($count == 10) break;
|
||||
$count++;
|
||||
|
||||
$item = array();
|
||||
$item["id"] = $result["illustId"];
|
||||
$item["uri"] = "https://www.pixiv.net/member_illust.php?mode=medium&illust_id=" . $result["illustId"];
|
||||
$item["title"] = $result["illustTitle"];
|
||||
$item["author"] = $result["userName"];
|
||||
|
||||
preg_match_all($timeRegex, $result["url"], $dt, PREG_SET_ORDER, 0);
|
||||
$elementDate = DateTime::createFromFormat("YmdHis",
|
||||
$dt[0][1] . $dt[0][2] . $dt[0][3] . $dt[0][4] . $dt[0][5] . $dt[0][6]);
|
||||
$item["timestamp"] = $elementDate->getTimestamp();
|
||||
|
||||
$item["content"] = "<img src='" . $this->cacheImage($result['url'], $item["id"]) . "' />";
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
|
||||
public function cacheImage($url, $illustId) {
|
||||
|
||||
$url = str_replace("_master1200", "", $url);
|
||||
$url = str_replace("c/240x240/img-master/", "img-original/", $url);
|
||||
$path = CACHE_DIR . '/pixiv_img';
|
||||
|
||||
if(!is_dir($path))
|
||||
mkdir($path, 0755, true);
|
||||
|
||||
if(!is_file($path . '/' . $illustId . '.jpeg')) {
|
||||
$headers = array("Referer: https://www.pixiv.net/member_illust.php?mode=medium&illust_id=" . $illustId);
|
||||
$illust = getContents($url, $headers);
|
||||
if(strpos($illust, "404 Not Found") !== false) {
|
||||
$illust = getContents(str_replace("jpg", "png", $url), $headers);
|
||||
}
|
||||
file_put_contents($path . '/' . $illustId . '.jpeg', $illust);
|
||||
}
|
||||
|
||||
return 'cache/pixiv_img/' . $illustId . ".jpeg";
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -14,7 +14,7 @@ class SoundCloudBridge extends BridgeAbstract {
|
||||
)
|
||||
));
|
||||
|
||||
const CLIENT_ID = '0aca19eae3843844e4053c6d8fdb7875';
|
||||
const CLIENT_ID = '4jkoEFmZEDaqjwJ9Eih4ATNhcH3vMVfp';
|
||||
|
||||
public function collectData(){
|
||||
|
||||
|
57
bridges/SupInfoBridge.php
Normal file
57
bridges/SupInfoBridge.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
class SupInfoBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'teromene';
|
||||
const NAME = 'SupInfoBridge';
|
||||
const URI = 'https://www.supinfo.com';
|
||||
const DESCRIPTION = 'Returns the newest articles.';
|
||||
|
||||
const PARAMETERS = array(array(
|
||||
'tag' => array(
|
||||
'name' => 'Category (not mandatory)',
|
||||
'type' => 'text',
|
||||
)
|
||||
));
|
||||
|
||||
public function collectData() {
|
||||
|
||||
if(empty($this->getInput('tag'))) {
|
||||
$html = getSimpleHTMLDOM(self::URI . '/articles/')
|
||||
or returnServerError('Unable to fetch articles !');
|
||||
} else {
|
||||
$html = getSimpleHTMLDOM(self::URI . '/articles/tag/' . $this->getInput('tag'))
|
||||
or returnServerError('Unable to fetch articles !');
|
||||
}
|
||||
$content = $html->find('#latest', 0)->find('ul[class=courseContent]', 0);
|
||||
|
||||
for($i = 0; $i < 5; $i++) {
|
||||
|
||||
$this->items[] = $this->fetchArticle($content->find('h4', $i)->find('a', 0)->href);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public function fetchArticle($link) {
|
||||
|
||||
$articleHTML = getSimpleHTMLDOM(self::URI . $link)
|
||||
or returnServerError('Unable to fetch article !');
|
||||
|
||||
$article = $articleHTML->find('div[id=courseDocZero]', 0);
|
||||
$item = array();
|
||||
$item['author'] = $article->find('#courseMetas', 0)->find('a', 0)->plaintext;
|
||||
$item['id'] = $link;
|
||||
$item['uri'] = self::URI . $link;
|
||||
$item['title'] = $article->find('h1', 0)->plaintext;
|
||||
$date = explode(' ', $article->find('#courseMetas', 0)->find('span', 1)->plaintext);
|
||||
$item['timestamp'] = DateTime::createFromFormat('d/m/Y H:i:s', $date[2] . ' ' . $date[4])->getTimestamp();
|
||||
|
||||
$article->find('div[id=courseHeader]', 0)->innertext = '';
|
||||
$article->find('div[id=author-infos]', 0)->innertext = '';
|
||||
$article->find('div[id=cartouche-tete]', 0)->innertext = '';
|
||||
$item['content'] = $article;
|
||||
|
||||
return $item;
|
||||
|
||||
}
|
||||
|
||||
}
|
@@ -1,96 +0,0 @@
|
||||
<?php
|
||||
class T411Bridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'ORelio';
|
||||
const NAME = 'T411 Bridge';
|
||||
const URI = 'https://www.t411.al/';
|
||||
const DESCRIPTION = 'Returns the 10 newest torrents with specified search
|
||||
terms <br /> Use url part after "?" mark when using their search engine.';
|
||||
|
||||
const PARAMETERS = array( array(
|
||||
'search' => array(
|
||||
'name' => 'Search criteria',
|
||||
'required' => true
|
||||
)
|
||||
));
|
||||
|
||||
public function collectData(){
|
||||
|
||||
//Utility function for retrieving text based on start and end delimiters
|
||||
function extractFromDelimiters($string, $start, $end){
|
||||
if(strpos($string, $start) !== false) {
|
||||
$section_retrieved = substr($string, strpos($string, $start) + strlen($start));
|
||||
$section_retrieved = substr($section_retrieved, 0, strpos($section_retrieved, $end));
|
||||
return $section_retrieved;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//Retrieve torrent listing from search results, which does not contain torrent description
|
||||
$url = self::URI
|
||||
. 'torrents/search/?search='
|
||||
. urlencode($this->getInput('search'))
|
||||
. '&order=added&type=desc';
|
||||
|
||||
$html = getSimpleHTMLDOM($url)
|
||||
or returnServerError('Could not request t411: ' . $url);
|
||||
|
||||
$results = $html->find('table.results', 0);
|
||||
if (is_null($results))
|
||||
returnServerError('No results from t411: ' . $url);
|
||||
$limit = 0;
|
||||
|
||||
//Process each item individually
|
||||
foreach($results->find('tr') as $element) {
|
||||
|
||||
//Limit total amount of requests and ignore table header
|
||||
if($limit >= 10) {
|
||||
break;
|
||||
}
|
||||
if(is_object($element->find('th', 0))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//Requests are rate-limited
|
||||
usleep(500000); //So we need to wait (500ms)
|
||||
|
||||
//Retrieve data from RSS entry
|
||||
$item_uri = self::URI
|
||||
. 'torrents/details/?id='
|
||||
. extractFromDelimiters($element->find('a.nfo', 0)->outertext, '?id=', '"');
|
||||
|
||||
$item_title = extractFromDelimiters($element->outertext, '" title="', '"');
|
||||
$item_date = strtotime($element->find('dd', 0)->plaintext);
|
||||
|
||||
//Retrieve full description from torrent page
|
||||
$item_html = getSimpleHTMLDOM($item_uri);
|
||||
if(!$item_html) {
|
||||
continue;
|
||||
}
|
||||
|
||||
//Retrieve data from page contents
|
||||
$item_desc = $item_html->find('div.description', 0);
|
||||
$item_author = $item_html->find('a.profile', 0)->innertext;
|
||||
|
||||
//Cleanup advertisments
|
||||
$divs = explode('<div class="align-center">', $item_desc->innertext);
|
||||
$item_desc = '';
|
||||
foreach ($divs as $text)
|
||||
if (strpos($text, 'adprovider.adlure.net') === false)
|
||||
$item_desc = $item_desc . '<div class="align-center">' . $text;
|
||||
|
||||
$item_desc = preg_replace('/<h2 class="align-center">LIENS DE T..?L..?CHARGEMENT<\/h2>/i', '', $item_desc);
|
||||
|
||||
//Build and add final item
|
||||
$item = array();
|
||||
$item['uri'] = $item_uri;
|
||||
$item['title'] = $item_title;
|
||||
$item['author'] = $item_author;
|
||||
$item['timestamp'] = $item_date;
|
||||
$item['content'] = $item_desc;
|
||||
$this->items[] = $item;
|
||||
$limit++;
|
||||
}
|
||||
}
|
||||
}
|
@@ -43,40 +43,225 @@ class VkBridge extends BridgeAbstract
|
||||
or returnServerError('No results for group or user name "' . $this->getInput('u') . '".');
|
||||
|
||||
$text_html = iconv('windows-1251', 'utf-8', $text_html);
|
||||
// makes album link generating work correctly
|
||||
$text_html = str_replace('"class="page_album_link">', '" class="page_album_link">', $text_html);
|
||||
$html = str_get_html($text_html);
|
||||
$pageName = $html->find('.page_name', 0)->plaintext;
|
||||
$this->pageName = $pageName;
|
||||
$pageName = $html->find('.page_name', 0);
|
||||
if (is_object($pageName)) {
|
||||
$pageName = $pageName->plaintext;
|
||||
$this->pageName = htmlspecialchars_decode($pageName);
|
||||
}
|
||||
$pinned_post_item = null;
|
||||
$last_post_id = 0;
|
||||
|
||||
foreach ($html->find('.post') as $post) {
|
||||
|
||||
$is_pinned_post = false;
|
||||
if (strpos($post->getAttribute('class'), 'post_fixed') !== false) {
|
||||
$is_pinned_post = true;
|
||||
}
|
||||
|
||||
if (is_object($post->find('a.wall_post_more', 0))) {
|
||||
//delete link "show full" in content
|
||||
$post->find('a.wall_post_more', 0)->outertext = '';
|
||||
}
|
||||
|
||||
$content_suffix = "";
|
||||
|
||||
// looking for external links
|
||||
$external_link_selectors = array(
|
||||
'a.page_media_link_title',
|
||||
'div.page_media_link_title > a',
|
||||
'div.media_desc > a.lnk',
|
||||
);
|
||||
|
||||
foreach($external_link_selectors as $sel) {
|
||||
if (is_object($post->find($sel, 0))) {
|
||||
$a = $post->find($sel, 0);
|
||||
$innertext = $a->innertext;
|
||||
$parsed_url = parse_url($a->getAttribute('href'));
|
||||
if (strpos($parsed_url['path'], '/away.php') !== 0) continue;
|
||||
parse_str($parsed_url["query"], $parsed_query);
|
||||
$content_suffix .= "<br>External link: <a href='" . $parsed_query["to"] . "'>$innertext</a>";
|
||||
}
|
||||
}
|
||||
|
||||
// remove external link from content
|
||||
$external_link_selectors_to_remove = array(
|
||||
'div.page_media_thumbed_link',
|
||||
'div.page_media_link_desc_wrap',
|
||||
'div.media_desc > a.lnk',
|
||||
);
|
||||
|
||||
foreach($external_link_selectors_to_remove as $sel) {
|
||||
if (is_object($post->find($sel, 0))) {
|
||||
$post->find($sel, 0)->outertext = '';
|
||||
}
|
||||
}
|
||||
|
||||
// looking for article
|
||||
$article = $post->find("a.article_snippet", 0);
|
||||
if (is_object($article)) {
|
||||
$article_title = $article->find("div.article_snippet__title", 0)->innertext;
|
||||
$article_author = $article->find("div.article_snippet__author", 0)->innertext;
|
||||
$article_link = self::URI . ltrim($article->getAttribute('href'), '/');
|
||||
$article_img_element_style = $article->find("div.article_snippet__image", 0)->getAttribute('style');
|
||||
preg_match('/background-image: url\((.*)\)/', $article_img_element_style, $matches);
|
||||
if (count($matches) > 0) {
|
||||
$content_suffix .= "<br><img src='" . $matches[1] . "'>";
|
||||
}
|
||||
$content_suffix .= "<br>Article: <a href='$article_link'>$article_title ($article_author)</a>";
|
||||
$article->outertext = '';
|
||||
}
|
||||
|
||||
// get video on post
|
||||
$video = $post->find('div.post_video_desc', 0);
|
||||
if (is_object($video)) {
|
||||
$video_title = $video->find('div.post_video_title', 0)->plaintext;
|
||||
$video_link = self::URI . ltrim( $video->find('a.lnk', 0)->getAttribute('href'), '/' );
|
||||
$content_suffix .= "<br>Video: <a href='$video_link'>$video_title</a>";
|
||||
$video->outertext = '';
|
||||
}
|
||||
|
||||
// get all photos
|
||||
foreach($post->find('div.wall_text > a.page_post_thumb_wrap') as $a) {
|
||||
$result = $this->getPhoto($a);
|
||||
if ($result == null) continue;
|
||||
$a->outertext = '';
|
||||
$content_suffix .= "<br>$result";
|
||||
}
|
||||
|
||||
// get albums
|
||||
foreach($post->find('.page_album_wrap') as $el) {
|
||||
$a = $el->find('.page_album_link', 0);
|
||||
$album_title = $a->find('.page_album_title_text', 0)->getAttribute('title');
|
||||
$album_link = self::URI . ltrim($a->getAttribute('href'), '/');
|
||||
$el->outertext = '';
|
||||
$content_suffix .= "<br>Album: <a href='$album_link'>$album_title</a>";
|
||||
}
|
||||
|
||||
// get photo documents
|
||||
foreach($post->find('a.page_doc_photo_href') as $a) {
|
||||
$doc_link = self::URI . ltrim($a->getAttribute('href'), '/');
|
||||
$doc_gif_label_element = $a->find(".page_gif_label", 0);
|
||||
$doc_title_element = $a->find(".doc_label", 0);
|
||||
|
||||
if (is_object($doc_gif_label_element)) {
|
||||
$gif_preview_img = backgroundToImg($a->find('.page_doc_photo', 0));
|
||||
$content_suffix .= "<br>Gif: <a href='$doc_link'>$gif_preview_img</a>";
|
||||
|
||||
} else if (is_object($doc_title_element)) {
|
||||
$doc_title = $doc_title_element->innertext;
|
||||
$content_suffix .= "<br>Doc: <a href='$doc_link'>$doc_title</a>";
|
||||
|
||||
} else {
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
$a->outertext = '';
|
||||
}
|
||||
|
||||
// get other documents
|
||||
foreach($post->find('div.page_doc_row') as $div) {
|
||||
$doc_title_element = $div->find("a.page_doc_title", 0);
|
||||
|
||||
if (is_object($doc_title_element)) {
|
||||
$doc_title = $doc_title_element->innertext;
|
||||
$doc_link = self::URI . ltrim($doc_title_element->getAttribute('href'), '/');
|
||||
$content_suffix .= "<br>Doc: <a href='$doc_link'>$doc_title</a>";
|
||||
|
||||
} else {
|
||||
continue;
|
||||
|
||||
}
|
||||
|
||||
$div->outertext = '';
|
||||
}
|
||||
|
||||
// get sign
|
||||
$post_author = $pageName;
|
||||
foreach($post->find('a.wall_signed_by') as $a) {
|
||||
$post_author = $a->innertext;
|
||||
$a->outertext = '';
|
||||
}
|
||||
|
||||
if (is_object($post->find('div.copy_quote', 0))) {
|
||||
$copy_quote = $post->find('div.copy_quote', 0);
|
||||
if ($copy_post_header = $copy_quote->find('div.copy_post_header', 0)) {
|
||||
$copy_post_header->outertext = '';
|
||||
}
|
||||
$copy_quote_content = $copy_quote->innertext;
|
||||
$copy_quote->outertext = "<br>Reposted: <br>$copy_quote_content";
|
||||
}
|
||||
|
||||
$item = array();
|
||||
$item['content'] = strip_tags(backgroundToImg($post->find('div.wall_text', 0)->innertext), '<br><img>');
|
||||
|
||||
if (is_object($post->find('a.page_media_link_title', 0))) {
|
||||
$link = $post->find('a.page_media_link_title', 0)->getAttribute('href');
|
||||
//external link in the post
|
||||
$item['content'] .= "\n\rExternal link: "
|
||||
. str_replace('/away.php?to=', '', urldecode($link));
|
||||
}
|
||||
|
||||
//get video on post
|
||||
if (is_object($post->find('span.post_video_title_content', 0))) {
|
||||
$titleVideo = $post->find('span.post_video_title_content', 0)->plaintext;
|
||||
$linkToVideo = self::URI . $post->find('a.page_post_thumb_video', 0)->getAttribute('href');
|
||||
$item['content'] .= "\n\r {$titleVideo}: {$linkToVideo}";
|
||||
}
|
||||
$item['content'] .= $content_suffix;
|
||||
|
||||
// get post link
|
||||
$item['uri'] = self::URI . $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);
|
||||
$item['post_id'] = intval($preg_match_result[1]);
|
||||
if (substr(self::URI, -1) == '/') {
|
||||
$post_link = self::URI . ltrim($post_link, "/");
|
||||
} else {
|
||||
$post_link = self::URI . $post_link;
|
||||
}
|
||||
$item['uri'] = $post_link;
|
||||
$item['timestamp'] = $this->getTime($post);
|
||||
$item['author'] = $pageName;
|
||||
$this->items[] = $item;
|
||||
$item['title'] = $this->getTitle($item['content']);
|
||||
$item['author'] = $post_author;
|
||||
if ($is_pinned_post) {
|
||||
// do not append it now
|
||||
$pinned_post_item = $item;
|
||||
} else {
|
||||
$last_post_id = $item['post_id'];
|
||||
$this->items[] = $item;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (is_null($pinned_post_item)) {
|
||||
return;
|
||||
} else if (count($this->items) == 0) {
|
||||
$this->items[] = $pinned_post_item;
|
||||
} else if ($last_post_id < $pinned_post_item['post_id']) {
|
||||
$this->items[] = $pinned_post_item;
|
||||
usort($this->items, function ($item1, $item2) {
|
||||
return $item2['post_id'] - $item1['post_id'];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private function getPhoto($a) {
|
||||
$onclick = $a->getAttribute('onclick');
|
||||
preg_match('/return showPhoto\(.+?({.*})/', $onclick, $preg_match_result);
|
||||
if (count($preg_match_result) == 0) return;
|
||||
|
||||
$arg = htmlspecialchars_decode( str_replace('queue:1', '"queue":1', $preg_match_result[1]) );
|
||||
$data = json_decode($arg, true);
|
||||
if ($data == null) return;
|
||||
|
||||
$thumb = $data['temp']['base'] . $data['temp']['x_'][0] . ".jpg";
|
||||
$original = '';
|
||||
foreach(array('y_', 'z_', 'w_') as $key) {
|
||||
if (!isset($data['temp'][$key])) continue;
|
||||
$original = $data['temp']['base'] . $data['temp'][$key][0] . ".jpg";
|
||||
}
|
||||
|
||||
if ($original) {
|
||||
return "<a href='$original'><img src='$thumb'></a>";
|
||||
} else {
|
||||
return "<img src='$thumb'>";
|
||||
}
|
||||
}
|
||||
|
||||
private function getTitle($content)
|
||||
{
|
||||
preg_match('/^["\w\ \p{Cyrillic}\(\)\?#«»-]+/mu', htmlspecialchars_decode($content), $result);
|
||||
if (count($result) == 0) return "untitled";
|
||||
return $result[0];
|
||||
}
|
||||
|
||||
private function getTime($post)
|
||||
|
138
bridges/YGGTorrentBridge.php
Normal file
138
bridges/YGGTorrentBridge.php
Normal file
@@ -0,0 +1,138 @@
|
||||
<?php
|
||||
|
||||
/* This is a mashup of FlickrExploreBridge by sebsauvage and FlickrTagBridge
|
||||
* by erwang.providing the functionality of both in one.
|
||||
*/
|
||||
class YGGTorrentBridge extends BridgeAbstract {
|
||||
|
||||
const MAINTAINER = 'teromene';
|
||||
const NAME = 'Yggtorrent Bridge';
|
||||
const URI = 'https://yggtorrent.is';
|
||||
const DESCRIPTION = 'Returns torrent search from Yggtorrent';
|
||||
|
||||
const PARAMETERS = array(
|
||||
array(
|
||||
"cat" => array(
|
||||
"name" => "category",
|
||||
"type" => "list",
|
||||
"values" => array(
|
||||
"Toute les catégories" => "all.all",
|
||||
"Film/Vidéo - Toutes les sous-catégories" => "2145.all",
|
||||
"Film/Vidéo - Animation" => "2145.2178",
|
||||
"Film/Vidéo - Animation Série" => "2145.2179",
|
||||
"Film/Vidéo - Concert" => "2145.2180",
|
||||
"Film/Vidéo - Documentaire" => "2145.2181",
|
||||
"Film/Vidéo - Émission TV" => "2145.2182",
|
||||
"Film/Vidéo - Film" => "2145.2183",
|
||||
"Film/Vidéo - Série TV" => "2145.2184",
|
||||
"Film/Vidéo - Spectacle" => "2145.2185",
|
||||
"Film/Vidéo - Sport" => "2145.2186",
|
||||
"Film/Vidéo - Vidéo-clips" => "2145.2186",
|
||||
"Audio - Toutes les sous-catégories" => "2139.all",
|
||||
"Audio - Karaoké" => "2139.2147",
|
||||
"Audio - Musique" => "2139.2148",
|
||||
"Audio - Podcast Radio" => "2139.2150",
|
||||
"Audio - Samples" => "2139.2149",
|
||||
"Jeu vidéo - Toutes les sous-catégories" => "2142.all",
|
||||
"Jeu vidéo - Autre" => "2142.2167",
|
||||
"Jeu vidéo - Linux" => "2142.2159",
|
||||
"Jeu vidéo - MacOS" => "2142.2160",
|
||||
"Jeu vidéo - Microsoft" => "2142.2162",
|
||||
"Jeu vidéo - Nintendo" => "2142.2163",
|
||||
"Jeu vidéo - Smartphone" => "2142.2165",
|
||||
"Jeu vidéo - Sony" => "2142.2164",
|
||||
"Jeu vidéo - Tablette" => "2142.2166",
|
||||
"Jeu vidéo - Windows" => "2142.2161",
|
||||
"eBook - Toutes les sous-catégories" => "2140.all",
|
||||
"eBook - Audio" => "2140.2151",
|
||||
"eBook - Bds" => "2140.2152",
|
||||
"eBook - Comics" => "2140.2153",
|
||||
"eBook - Livres" => "2140.2154",
|
||||
"eBook - Mangas" => "2140.2155",
|
||||
"eBook - Presse" => "2140.2156",
|
||||
"Emulation - Toutes les sous-catégories" => "2141.all",
|
||||
"Emulation - Emulateurs" => "2141.2157",
|
||||
"Emulation - Roms" => "2141.2158",
|
||||
"GPS - Toutes les sous-catégories" => "2141.all",
|
||||
"GPS - Applications" => "2141.2168",
|
||||
"GPS - Cartes" => "2141.2169",
|
||||
"GPS - Divers" => "2141.2170"
|
||||
)
|
||||
),
|
||||
"nom" => array(
|
||||
"name" => "Nom",
|
||||
"description" => "Nom du torrent",
|
||||
"type" => "text"
|
||||
),
|
||||
"description" => array(
|
||||
"name" => "Description",
|
||||
"description" => "Description du torrent",
|
||||
"type" => "text"
|
||||
),
|
||||
"fichier" => array(
|
||||
"name" => "Fichier",
|
||||
"description" => "Fichier du torrent",
|
||||
"type" => "text"
|
||||
),
|
||||
"uploader" => array(
|
||||
"name" => "Uploader",
|
||||
"description" => "Uploader du torrent",
|
||||
"type" => "text"
|
||||
),
|
||||
|
||||
)
|
||||
);
|
||||
|
||||
public function collectData() {
|
||||
|
||||
$catInfo = explode(".", $this->getInput("cat"));
|
||||
$category = $catInfo[0];
|
||||
$subcategory = $catInfo[1];
|
||||
|
||||
$html = getSimpleHTMLDOM(self::URI . "/engine/search?name="
|
||||
. $this->getInput("nom")
|
||||
. "&description="
|
||||
. $this->getInput("description")
|
||||
. "&fichier="
|
||||
. $this->getInput("fichier")
|
||||
. "&file="
|
||||
. $this->getInput("uploader")
|
||||
. "&category="
|
||||
. $category
|
||||
. "&sub_category="
|
||||
. $subcategory
|
||||
. "&do=search")
|
||||
or returnServerError("Unable to query Yggtorrent !");
|
||||
|
||||
$count = 0;
|
||||
foreach($html->find(".results", 0)->find("tr") as $row) {
|
||||
$count++;
|
||||
if($count == 1) continue;
|
||||
if($count == 12) break;
|
||||
$item = array();
|
||||
$item["timestamp"] = $row->find(".hidden", 1)->plaintext;
|
||||
$item["title"] = $row->find("a", 1)->plaintext;
|
||||
$torrentData = $this->collectTorrentData($row->find("a", 1)->href);
|
||||
$item["author"] = $torrentData["author"];
|
||||
$item["content"] = $torrentData["content"];
|
||||
$item["seeders"] = $row->find("td", 7)->plaintext;
|
||||
$item["leechers"] = $row->find("td", 8)->plaintext;
|
||||
$item["size"] = $row->find("td", 5)->plaintext;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public function collectTorrentData($url) {
|
||||
|
||||
//For weird reason, the link we get can be invalid, we fix it.
|
||||
$url_full = explode("/", $url);
|
||||
$url_full[6] = urlencode($url_full[6]);
|
||||
$url = implode("/", $url_full);
|
||||
|
||||
$page = getSimpleHTMLDOM($url) or returnServerError("Unable to query Yggtorrent page !");
|
||||
$author = $page->find(".informations", 0)->find("a", 4)->plaintext;
|
||||
$content = $page->find(".default", 1);
|
||||
return array("author" => $author, "content" => $content);
|
||||
}
|
||||
}
|
@@ -207,7 +207,7 @@ class YoutubeBridge extends BridgeAbstract {
|
||||
$html = $this->ytGetSimpleHTMLDOM($url_listing)
|
||||
or returnServerError("Could not request YouTube. Tried:\n - $url_listing");
|
||||
|
||||
$this->ytBridgeParseHtmlListing($html, 'div.yt-lockup', 'h3');
|
||||
$this->ytBridgeParseHtmlListing($html, 'div.yt-lockup', 'h3 > a');
|
||||
$this->feedName = 'Search: ' . str_replace(' - YouTube', '', $html->find('title', 0)->plaintext); // feedName will be used by getName()
|
||||
} else { /* no valid mode */
|
||||
returnClientError("You must either specify either:\n - YouTube
|
||||
|
@@ -303,7 +303,7 @@ EOD;
|
||||
echo $inactiveBridges;
|
||||
?>
|
||||
<section class="footer">
|
||||
<a href="https://github.com/RSS-Bridge/rss-bridge">RSS-Bridge 2018-04-06 ~ Public Domain</a><br />
|
||||
<a href="https://github.com/RSS-Bridge/rss-bridge">RSS-Bridge 2018-04-20 ~ Public Domain</a><br />
|
||||
<?= $activeFoundBridgeCount; ?>/<?= count($bridgeList) ?> active bridges. <br />
|
||||
<?php
|
||||
if($activeFoundBridgeCount !== count($bridgeList)) {
|
||||
|
@@ -5,7 +5,6 @@ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockq
|
||||
border: 0;
|
||||
outline: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
|
||||
}
|
||||
@@ -111,3 +110,8 @@ button.backbutton, button.rss-feed {
|
||||
|
||||
}
|
||||
|
||||
img {
|
||||
|
||||
max-width: 100%;
|
||||
|
||||
}
|
Reference in New Issue
Block a user