2015-01-20 19:40:30 +03:00
|
|
|
<?php
|
|
|
|
|
2022-09-04 05:35:21 +03:00
|
|
|
declare(strict_types=1);
|
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
class EZTVBridge extends BridgeAbstract
|
2022-07-01 16:10:30 +03:00
|
|
|
{
|
2018-06-30 00:55:33 +03:00
|
|
|
const MAINTAINER = 'alexAubin';
|
2017-02-11 18:16:56 +03:00
|
|
|
const NAME = 'EZTV';
|
2022-09-15 18:47:57 +03:00
|
|
|
const URI = 'https://eztvstatus.com';
|
2022-09-04 05:35:21 +03:00
|
|
|
const DESCRIPTION = 'Search for torrents by IMDB id. You can find IMDB id in the url of a tv show.';
|
2015-11-05 18:50:18 +03:00
|
|
|
|
2022-03-26 00:21:47 +03:00
|
|
|
const PARAMETERS = [
|
2022-07-01 16:10:30 +03:00
|
|
|
[
|
2022-03-26 00:21:47 +03:00
|
|
|
'ids' => [
|
2022-09-04 05:35:21 +03:00
|
|
|
'name' => 'IMDB ids',
|
2022-03-26 00:21:47 +03:00
|
|
|
'exampleValue' => '8740790,1733785',
|
|
|
|
'required' => true,
|
2022-09-04 05:35:21 +03:00
|
|
|
'title' => 'One or more IMDB ids'
|
2022-03-26 00:21:47 +03:00
|
|
|
],
|
|
|
|
'no480' => [
|
|
|
|
'name' => 'No 480p',
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'title' => 'Activate to exclude 480p torrents'
|
|
|
|
],
|
|
|
|
'no720' => [
|
|
|
|
'name' => 'No 720p',
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'title' => 'Activate to exclude 720p torrents'
|
|
|
|
],
|
|
|
|
'no1080' => [
|
|
|
|
'name' => 'No 1080p',
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'title' => 'Activate to exclude 1080p torrents'
|
|
|
|
],
|
|
|
|
'no2160' => [
|
|
|
|
'name' => 'No 2160p',
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'title' => 'Activate to exclude 2160p torrents'
|
|
|
|
],
|
|
|
|
'noUnknownRes' => [
|
|
|
|
'name' => 'No Unknown resolution',
|
|
|
|
'type' => 'checkbox',
|
|
|
|
'title' => 'Activate to exclude unknown resolution torrents'
|
|
|
|
],
|
2022-07-01 16:10:30 +03:00
|
|
|
]
|
2022-03-26 00:21:47 +03:00
|
|
|
];
|
2015-11-05 18:50:18 +03:00
|
|
|
|
2022-03-26 00:21:47 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
2022-09-15 18:47:57 +03:00
|
|
|
$eztv_uri = $this->getEztvUri();
|
|
|
|
Debug::log($eztv_uri);
|
2022-09-04 05:35:21 +03:00
|
|
|
$ids = explode(',', trim($this->getInput('ids')));
|
|
|
|
foreach ($ids as $id) {
|
2022-09-15 18:47:57 +03:00
|
|
|
$data = json_decode(getContents(sprintf('%s/api/get-torrents?imdb_id=%s', $eztv_uri, $id)));
|
2022-09-04 05:35:21 +03:00
|
|
|
if (!isset($data->torrents)) {
|
|
|
|
// No results
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
foreach ($data->torrents as $torrent) {
|
2022-03-26 00:21:47 +03:00
|
|
|
$title = $torrent->title;
|
|
|
|
$regex480 = '/480p/';
|
|
|
|
$regex720 = '/720p/';
|
|
|
|
$regex1080 = '/1080p/';
|
|
|
|
$regex2160 = '/2160p/';
|
|
|
|
$regexUnknown = '/(480p|720p|1080p|2160p)/';
|
|
|
|
// Skip unwanted resolution torrents
|
|
|
|
if (
|
|
|
|
(preg_match($regex480, $title) === 1 && $this->getInput('no480'))
|
|
|
|
|| (preg_match($regex720, $title) === 1 && $this->getInput('no720'))
|
|
|
|
|| (preg_match($regex1080, $title) === 1 && $this->getInput('no1080'))
|
|
|
|
|| (preg_match($regex2160, $title) === 1 && $this->getInput('no2160'))
|
|
|
|
|| (preg_match($regexUnknown, $title) !== 1 && $this->getInput('noUnknownRes'))
|
|
|
|
) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
$this->items[] = $this->getItemFromTorrent($torrent);
|
2017-02-11 18:16:56 +03:00
|
|
|
}
|
|
|
|
}
|
2022-09-04 05:35:21 +03:00
|
|
|
usort($this->items, function ($torrent1, $torrent2) {
|
|
|
|
return $torrent2['timestamp'] <=> $torrent1['timestamp'];
|
|
|
|
});
|
|
|
|
}
|
2022-03-26 00:21:47 +03:00
|
|
|
|
2022-09-15 18:47:57 +03:00
|
|
|
protected function getEztvUri()
|
|
|
|
{
|
|
|
|
$html = getSimpleHTMLDom(self::URI);
|
|
|
|
$urls = $html->find('a.domainLink');
|
|
|
|
foreach ($urls as $url) {
|
|
|
|
$headers = get_headers($url->href);
|
|
|
|
if (substr($headers[0], 9, 3) === '200') {
|
|
|
|
return $url->href;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
throw new Exception('No valid EZTV URI available');
|
|
|
|
}
|
|
|
|
|
2022-09-04 05:35:21 +03:00
|
|
|
protected function getItemFromTorrent($torrent)
|
|
|
|
{
|
|
|
|
$item = [];
|
|
|
|
$item['uri'] = $torrent->episode_url;
|
|
|
|
$item['author'] = $torrent->imdb_id;
|
|
|
|
$item['timestamp'] = $torrent->date_released_unix;
|
|
|
|
$item['title'] = $torrent->title;
|
|
|
|
$item['enclosures'][] = $torrent->torrent_url;
|
|
|
|
|
|
|
|
$thumbnailUri = 'https:' . $torrent->small_screenshot;
|
|
|
|
$torrentSize = format_bytes((int) $torrent->size_bytes);
|
|
|
|
|
|
|
|
$item['content'] = $torrent->filename . '<br>File size: '
|
|
|
|
. $torrentSize . '<br><a href="' . $torrent->magnet_url
|
|
|
|
. '">magnet link</a><br><a href="' . $torrent->torrent_url
|
|
|
|
. '">torrent link</a><br><img src="' . $thumbnailUri . '" />';
|
|
|
|
|
|
|
|
return $item;
|
2015-01-20 19:40:30 +03:00
|
|
|
}
|
|
|
|
}
|