From a9b70bb976f66bf4028eea6459348f9dde60688c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20T?= Date: Tue, 19 Nov 2019 17:47:17 +0100 Subject: [PATCH 1/3] [TorrentGalaxyBridge] Add new bridge --- bridges/TorrentGalaxyBridge.php | 121 ++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) create mode 100644 bridges/TorrentGalaxyBridge.php diff --git a/bridges/TorrentGalaxyBridge.php b/bridges/TorrentGalaxyBridge.php new file mode 100644 index 00000000000..d7d40cda34c --- /dev/null +++ b/bridges/TorrentGalaxyBridge.php @@ -0,0 +1,121 @@ + array( + 'name' => 'search', + 'required' => true, + 'title' => 'Type your query' + ), + 'lang' => array( + 'name' => 'language', + 'type' => 'list', + 'exampleValue' => 'All languages', + 'title' => 'Select your language', + 'values' => array( + 'All languages' => '0', + 'English' => '1', + 'French' => '2', + 'German' => '3', + 'Italian' => '4', + 'Japanese' => '5', + 'Spanish' => '6', + 'Russian' => '7', + 'Hindi' => '8', + 'Other / Multiple' => '9', + 'Korean' => '10', + 'Danish' => '11', + 'Norwegian' => '12', + 'Dutch' => '13', + 'Manderin' => '14', + 'Portuguese' => '15', + 'Bengali' => '16', + 'Polish' => '17', + 'Turkish' => '18', + 'Telugu' => '19', + 'Urdu' => '20', + 'Arabic' => '21', + 'Swedish' => '22', + 'Romanian' => '23' + ) + ) + ) + ); + + public function collectData(){ + $url = self::URI . '/torrents.php' . + '?search=' . urlencode($this->getInput('search')) . + '&lang=' . $this->getInput('lang') . + '$sort=id&order=desc'; + $html = getSimpleHTMLDOM($url) + or returnServerError('Error requiring the server.' . curl_error()); + + foreach($html->find('div.tgxtablerow') as $result) { + $identity = $result->find('div.tgxtablecell',3)->find('div a',0); + $authorid = $result->find('div.tgxtablecell',6)->find('a',0); + $creadate = $result->find('div.tgxtablecell',11)->plaintext; + $glxlinks = $result->find('div.tgxtablecell',4); + + $item = array(); + $item['uri'] = self::URI . $identity->href; + $item['title'] = $identity->plaintext; + $item['timestamp'] = DateTime::createFromFormat('d/m/y H:i', $creadate)->format('U'); + $item['author'] = $authorid->plaintext; + $item['content'] = + '' . + '

' . $identity->plaintext . '

' . + '

Links

' . + '

magnet

' . + '

torrent

' . + '

Infos

' . + '

Size: ' . $result->find('div.tgxtablecell',7)->plaintext . '

' . + '

Added by: ' . $authorid->plaintext . '

' . + '

Upload time: ' . $creadate . '

' . + ''; + $item['enclosures'] = array($glxlinks->find('a',0)->href); + $item['categories'] = array($result->find('div.tgxtablecell',0)->plaintext); + if (preg_match('#/torrent/([^/]+)/#', self::URI . $identity->href, $torrentid)) { + $item['uid'] = $torrentid[1]; + } + $this->items[] = $item; + } + } + + public function getName(){ + if(!is_null($this->getInput('search'))) { + return $this->getInput('search') . ' : ' . self::NAME; + } + return parent::getName(); + } + + public function getURI(){ + if(!is_null($this->getInput('search'))) { + return self::URI . '/torrents.php' . + '?search=' . urlencode($this->getInput('search')) . + '&lang=' . $this->getInput('lang'); + } + return parent::getURI(); + } + + public function getDescription(){ + if(!is_null($this->getInput('search'))) { + return 'Latest torrents for "' . $this->getInput('search') . '"'; + } + return parent::getDescription(); + } + + public function getIcon(){ + if(!is_null($this->getInput('search'))) { + return self::URI . '/common/favicon/favicon.ico'; + } + return parent::getIcon(); + } +} \ No newline at end of file From b41fd8460ffcdbb7c41d34155e1ff90c47b354a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20T?= Date: Sun, 1 Dec 2019 15:20:55 +0100 Subject: [PATCH 2/3] [TorrentGalaxyBridge] FIX: space before arguments --- bridges/TorrentGalaxyBridge.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/bridges/TorrentGalaxyBridge.php b/bridges/TorrentGalaxyBridge.php index d7d40cda34c..0981237039f 100644 --- a/bridges/TorrentGalaxyBridge.php +++ b/bridges/TorrentGalaxyBridge.php @@ -59,29 +59,29 @@ public function collectData(){ or returnServerError('Error requiring the server.' . curl_error()); foreach($html->find('div.tgxtablerow') as $result) { - $identity = $result->find('div.tgxtablecell',3)->find('div a',0); - $authorid = $result->find('div.tgxtablecell',6)->find('a',0); - $creadate = $result->find('div.tgxtablecell',11)->plaintext; - $glxlinks = $result->find('div.tgxtablecell',4); + $identity = $result->find('div.tgxtablecell', 3)->find('div a', 0); + $authorid = $result->find('div.tgxtablecell', 6)->find('a', 0); + $creadate = $result->find('div.tgxtablecell', 11)->plaintext; + $glxlinks = $result->find('div.tgxtablecell', 4); $item = array(); $item['uri'] = self::URI . $identity->href; $item['title'] = $identity->plaintext; $item['timestamp'] = DateTime::createFromFormat('d/m/y H:i', $creadate)->format('U'); $item['author'] = $authorid->plaintext; - $item['content'] = + $item['content'] = '' . '

' . $identity->plaintext . '

' . '

Links

' . - '

magnet

' . - '

torrent

' . + '

magnet

' . + '

torrent

' . '

Infos

' . - '

Size: ' . $result->find('div.tgxtablecell',7)->plaintext . '

' . + '

Size: ' . $result->find('div.tgxtablecell', 7)->plaintext . '

' . '

Added by: ' . $authorid->plaintext . '

' . '

Upload time: ' . $creadate . '

' . ''; - $item['enclosures'] = array($glxlinks->find('a',0)->href); - $item['categories'] = array($result->find('div.tgxtablecell',0)->plaintext); + $item['enclosures'] = array($glxlinks->find('a', 0)->href); + $item['categories'] = array($result->find('div.tgxtablecell', 0)->plaintext); if (preg_match('#/torrent/([^/]+)/#', self::URI . $identity->href, $torrentid)) { $item['uid'] = $torrentid[1]; } @@ -118,4 +118,4 @@ public function getIcon(){ } return parent::getIcon(); } -} \ No newline at end of file +} From 561d59b0873e90897809d33c8eab8d6511f8becd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9gory=20T?= Date: Sun, 1 Dec 2019 21:52:52 +0100 Subject: [PATCH 3/3] [TorrentGalaxyBridge] FIX: strings concatenation & URL for search page --- bridges/TorrentGalaxyBridge.php | 37 ++++++++++++++++----------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/bridges/TorrentGalaxyBridge.php b/bridges/TorrentGalaxyBridge.php index 0981237039f..b71d2a5e94d 100644 --- a/bridges/TorrentGalaxyBridge.php +++ b/bridges/TorrentGalaxyBridge.php @@ -51,12 +51,12 @@ class TorrentGalaxyBridge extends BridgeAbstract { ); public function collectData(){ - $url = self::URI . '/torrents.php' . - '?search=' . urlencode($this->getInput('search')) . - '&lang=' . $this->getInput('lang') . - '$sort=id&order=desc'; + $url = self::URI + . '/torrents.php?search=' . urlencode($this->getInput('search')) + . '&lang=' . $this->getInput('lang') + . '&sort=id&order=desc'; $html = getSimpleHTMLDOM($url) - or returnServerError('Error requiring the server.' . curl_error()); + or returnServerError("Error querying the server at $url"); foreach($html->find('div.tgxtablerow') as $result) { $identity = $result->find('div.tgxtablecell', 3)->find('div a', 0); @@ -69,17 +69,16 @@ public function collectData(){ $item['title'] = $identity->plaintext; $item['timestamp'] = DateTime::createFromFormat('d/m/y H:i', $creadate)->format('U'); $item['author'] = $authorid->plaintext; - $item['content'] = - '' . - '

' . $identity->plaintext . '

' . - '

Links

' . - '

magnet

' . - '

torrent

' . - '

Infos

' . - '

Size: ' . $result->find('div.tgxtablecell', 7)->plaintext . '

' . - '

Added by: ' . $authorid->plaintext . '

' . - '

Upload time: ' . $creadate . '

' . - ''; + $item['content'] = <<{$identity->plaintext} +

Links

+

magnet

+

torrent

+

Infos

+

Size: {$result->find('div.tgxtablecell', 7)->plaintext}

+

Added by: {$authorid->plaintext}

+

Upload time: {$creadate}

+HTML; $item['enclosures'] = array($glxlinks->find('a', 0)->href); $item['categories'] = array($result->find('div.tgxtablecell', 0)->plaintext); if (preg_match('#/torrent/([^/]+)/#', self::URI . $identity->href, $torrentid)) { @@ -98,9 +97,9 @@ public function getName(){ public function getURI(){ if(!is_null($this->getInput('search'))) { - return self::URI . '/torrents.php' . - '?search=' . urlencode($this->getInput('search')) . - '&lang=' . $this->getInput('lang'); + return self::URI + . '/torrents.php?search=' . urlencode($this->getInput('search')) + . '&lang=' . $this->getInput('lang'); } return parent::getURI(); }