2018-09-13 20:36:48 +02:00
|
|
|
<?php
|
|
|
|
class ZoneTelechargementBridge extends BridgeAbstract {
|
2018-11-20 16:23:17 +01:00
|
|
|
|
|
|
|
/* This bridge was initally done for the Website Zone Telechargement,
|
|
|
|
* but the website changed it's name and URL.
|
|
|
|
* Therefore, the class name and filename does not correspond to the
|
|
|
|
* name of the bridge. This permits to keep the same RSS Feed URL.
|
|
|
|
*/
|
|
|
|
|
2019-10-03 22:27:10 +02:00
|
|
|
const NAME = 'Zone Telechargement';
|
2021-01-17 12:32:59 +01:00
|
|
|
const URI = 'https://www.zt-za.net/';
|
2019-10-03 22:27:10 +02:00
|
|
|
const DESCRIPTION = 'Suivi de série sur Zone Telechargement';
|
2018-09-13 20:36:48 +02:00
|
|
|
const MAINTAINER = 'sysadminstory';
|
|
|
|
const PARAMETERS = array(
|
|
|
|
'Suivre la publication des épisodes d\'une série en cours de diffusion' => array(
|
|
|
|
'url' => array(
|
|
|
|
'name' => 'URL de la série',
|
|
|
|
'type' => 'text',
|
|
|
|
'required' => true,
|
2020-08-19 14:35:19 +02:00
|
|
|
'title' => 'URL d\'une série sans le https://www.zt-za.com/',
|
2020-12-23 18:13:10 +01:00
|
|
|
'exampleValue' => 'telecharger-series/31079-halt-and-catch-fire-saison-4-french-hd720p.html'),
|
|
|
|
'filter' => array(
|
|
|
|
'name' => 'Type de contenu',
|
|
|
|
'type' => 'list',
|
|
|
|
'title' => 'Type de contenu à suivre : Téléchargement, Streaming ou les deux',
|
|
|
|
'values' => array(
|
|
|
|
'Streaming et Téléchargement' => 'both',
|
|
|
|
'Téléchargement' => 'download',
|
|
|
|
'Streaming' => 'streaming'
|
|
|
|
),
|
|
|
|
'defaultValue' => 'both'
|
2018-09-13 20:36:48 +02:00
|
|
|
)
|
2018-10-22 19:22:02 +02:00
|
|
|
)
|
|
|
|
);
|
2018-09-13 20:36:48 +02:00
|
|
|
|
2020-12-23 18:13:10 +01:00
|
|
|
// This is an URL that is not protected by robot protection for Direct Download
|
2021-01-30 19:02:36 +01:00
|
|
|
const UNPROTECTED_URI = 'https://www.zone-telechargement.net/';
|
2020-08-19 14:35:19 +02:00
|
|
|
|
2020-12-23 18:13:10 +01:00
|
|
|
// This is an URL that is not protected by robot protection for Streaming Links
|
2021-01-17 12:32:59 +01:00
|
|
|
const UNPROTECTED_URI_STREAMING = 'https://zone-telechargement.stream/';
|
2020-12-23 18:13:10 +01:00
|
|
|
|
2018-10-26 18:07:34 +02:00
|
|
|
public function getIcon() {
|
2021-01-17 12:32:59 +01:00
|
|
|
return self::UNPROTECTED_URI . '/templates/Default/images/favicon.ico';
|
2018-10-26 18:07:34 +02:00
|
|
|
}
|
|
|
|
|
2018-09-13 20:36:48 +02:00
|
|
|
public function collectData(){
|
2021-01-17 12:32:59 +01:00
|
|
|
$html = getSimpleHTMLDOM(self::UNPROTECTED_URI . $this->getInput('url'))
|
2018-09-13 20:36:48 +02:00
|
|
|
or returnServerError('Could not request Zone Telechargement.');
|
|
|
|
|
2020-12-23 18:13:10 +01:00
|
|
|
$filter = $this->getInput('filter');
|
|
|
|
|
2018-09-13 20:36:48 +02:00
|
|
|
// Get the TV show title
|
|
|
|
$qualityselector = 'div[style=font-size: 18px;margin: 10px auto;color:red;font-weight:bold;text-align:center;]';
|
2018-10-15 18:23:08 +02:00
|
|
|
$show = trim($html->find('div[class=smallsep]', 0)->next_sibling()->plaintext);
|
|
|
|
$quality = trim(explode("\n", $html->find($qualityselector, 0)->plaintext)[0]);
|
2018-09-13 20:36:48 +02:00
|
|
|
$this->showTitle = $show . ' ' . $quality;
|
|
|
|
|
|
|
|
$episodes = array();
|
|
|
|
|
2020-12-23 18:13:10 +01:00
|
|
|
// Handle the Direct Download links
|
|
|
|
if($filter == 'both' || $filter == 'download') {
|
|
|
|
// Get the post content
|
|
|
|
$linkshtml = $html->find('div[class=postinfo]', 0);
|
|
|
|
|
|
|
|
$list = $linkshtml->find('a');
|
|
|
|
// Construct the table of episodes using the links
|
|
|
|
foreach($list as $element) {
|
|
|
|
// Retrieve episode number from link text
|
|
|
|
$epnumber = explode(' ', $element->plaintext)[1];
|
|
|
|
$hoster = $this->findLinkHoster($element);
|
|
|
|
|
|
|
|
// Format the link and add the link to the corresponding episode table
|
|
|
|
$episodes[$epnumber]['ddl'][] = '<a href="' . $element->href . '">' . $hoster . ' - '
|
|
|
|
. $this->showTitle . ' Episode ' . $epnumber . '</a>';
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
2018-09-13 20:36:48 +02:00
|
|
|
|
2020-12-23 18:13:10 +01:00
|
|
|
// Handle the Streaming links
|
|
|
|
if($filter == 'both' || $filter == 'streaming') {
|
|
|
|
// Get the post content, on the dedicated streaming website
|
2021-01-17 12:32:59 +01:00
|
|
|
$htmlstreaming = getSimpleHTMLDOM(self::UNPROTECTED_URI_STREAMING . $this->getInput('url'))
|
2020-12-23 18:13:10 +01:00
|
|
|
or returnServerError('Could not request Zone Telechargement.');
|
|
|
|
// Get the HTML element containing all the links
|
|
|
|
$streaminglinkshtml = $htmlstreaming->find('p[style=background-color: #FECC00;]', 1)->parent()->next_sibling();
|
|
|
|
// Get all streaming Links
|
|
|
|
$liststreaming = $streaminglinkshtml->find('a');
|
|
|
|
foreach($liststreaming as $elementstreaming) {
|
|
|
|
// Retrieve the episode number from the link text
|
|
|
|
$epnumber = explode(' ', $elementstreaming->plaintext)[1];
|
2018-09-13 20:36:48 +02:00
|
|
|
|
2020-12-23 18:13:10 +01:00
|
|
|
// Format the link and add the link to the corresponding episode table
|
|
|
|
$episodes[$epnumber]['streaming'][] = '<a href="' . $elementstreaming->href . '">'
|
|
|
|
. $this->showTitle . ' Episode ' . $epnumber . '</a>';
|
|
|
|
}
|
2018-09-13 20:36:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Finally construct the items array
|
|
|
|
foreach($episodes as $epnum => $episode) {
|
2020-12-23 18:13:10 +01:00
|
|
|
// Handle the Direct Download links
|
|
|
|
if(array_key_exists('ddl', $episode)) {
|
|
|
|
$item = array();
|
|
|
|
// Add every link available in the episode table separated by a <br/> tag
|
|
|
|
$item['content'] = implode('<br/>', $episode['ddl']);
|
|
|
|
$item['title'] = $this->showTitle . ' Episode ' . $epnum . ' - Téléchargement';
|
|
|
|
// Generate an unique UID by hashing the item title to prevent confusion for RSS readers
|
|
|
|
$item['uid'] = hash('md5', $item['title']);
|
|
|
|
$item['uri'] = self::URI . $this->getInput('url');
|
|
|
|
// Insert the episode at the beginning of the item list, to show the newest episode first
|
|
|
|
array_unshift($this->items, $item);
|
|
|
|
}
|
|
|
|
// Handle the streaming link
|
|
|
|
if(array_key_exists('streaming', $episode)) {
|
|
|
|
$item = array();
|
|
|
|
// Add every link available in the episode table separated by a <br/> tag
|
|
|
|
$item['content'] = implode('<br/>', $episode['streaming']);
|
|
|
|
$item['title'] = $this->showTitle . ' Episode ' . $epnum . ' - Streaming';
|
|
|
|
// Generate an unique UID by hashing the item title to prevent confusion for RSS readers
|
|
|
|
$item['uid'] = hash('md5', $item['title']);
|
|
|
|
$item['uri'] = self::URI . $this->getInput('url');
|
|
|
|
// Insert the episode at the beginning of the item list, to show the newest episode first
|
|
|
|
array_unshift($this->items, $item);
|
|
|
|
}
|
2018-09-13 20:36:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-22 19:22:02 +02:00
|
|
|
public function getName() {
|
2018-09-13 20:36:48 +02:00
|
|
|
switch($this->queriedContext) {
|
|
|
|
case 'Suivre la publication des épisodes d\'une série en cours de diffusion':
|
2018-10-15 18:23:08 +02:00
|
|
|
return $this->showTitle . ' - ' . self::NAME;
|
2018-09-13 20:36:48 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return self::NAME;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-10-22 19:22:02 +02:00
|
|
|
private function findLinkHoster($element) {
|
2018-09-13 20:36:48 +02:00
|
|
|
// The hoster name is one level higher than the link tag : get the parent element
|
|
|
|
$element = $element->parent();
|
|
|
|
// Walk through all elements in the reverse order until finding the one with a div and that is not a <br/>
|
|
|
|
while(!($element->find('div', 0) != null && $element->tag != 'br')) {
|
|
|
|
$element = $element->prev_sibling();
|
|
|
|
}
|
|
|
|
// Return the text of the div : it's the file hoster name !
|
|
|
|
return $element->find('div', 0)->plaintext;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|