From c47d92add5bfe156734254599b1861ac727e4582 Mon Sep 17 00:00:00 2001 From: Bocki Date: Thu, 22 Jul 2021 14:38:43 +0200 Subject: [PATCH 1/3] [PokemonTV] New complete bridge --- bridges/PokemonTVBridge.php | 147 ++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 bridges/PokemonTVBridge.php diff --git a/bridges/PokemonTVBridge.php b/bridges/PokemonTVBridge.php new file mode 100644 index 00000000000..c908ec6b48b --- /dev/null +++ b/bridges/PokemonTVBridge.php @@ -0,0 +1,147 @@ + array( + 'name' => 'Language', + 'type' => 'list', + 'required' => true, + 'title' => 'Select your language', + 'values' => array( + 'Danish' => 'dk', + 'Dutch' => 'nl', + 'English (UK)' => 'uk', + 'English (US)' => 'us', + 'Finish' => 'fi', + 'French' => 'fr', + 'German' => 'de', + 'Italian' => 'it', + 'Latin America' => 'el', + 'Norwegian' => 'no', + 'Portoguese' => 'br', + 'Russian' => 'ru', + 'Spanish' => 'es', + 'Swedish' => 'se' + ), + 'defaultValue' => 'English (US)' + ), + 'filtername' => array( + 'name' => 'Series Name Filter', + 'exampleValue' => 'Ultra', + 'required' => false + ), + 'filterseason' => array( + 'name' => 'Series Season Filter', + 'exampleValue' => '5', + 'required' => false + ) + )); + + + public function collectData(){ + $link = 'https://www.pokemon.com/api/pokemontv/v2/channels/' . $this->getInput('language'); + + $html = getSimpleHTMLDOM($link) + or returnServerError('Could not request Channels for : ' . $link); + $parsed_json = json_decode($html); + + $filtername = $this->getInput('filtername'); + $filterseason = $this->getInput('filterseason'); + + foreach($parsed_json as $element) { + if(strlen($filtername) >= 1){ + if (!(stristr($element->{'channel_name'}, $filtername) !== false)) { + continue; + } + } + foreach($element->{'media'} as $mediaelement) { + if(strlen($filterseason) >= 1){ + if ($mediaelement->{'season'} != $filterseason) { + continue; + } + } + switch($element->{'media_type'}){ + case 'movie': + $itemtitle = $element->{'channel_name'}; + break; + case 'episode': + $season = str_pad($mediaelement->{'season'}, 2, '0', STR_PAD_LEFT); + $episode = str_pad($mediaelement->{'episode'}, 2, '0', STR_PAD_LEFT); + $itemtitle = $element->{'channel_name'} . ' - S' . $season . 'E' . $episode; + break; + } + $streamurl = 'https://watch.pokemon.com/' . $this->getCountryCode() . '/#/player?id=' . $mediaelement->{'id'}; + $item = array(); + $item['uri'] = $streamurl; + $item['title'] = $itemtitle; + $item['timestamp'] = $mediaelement->{'last_modified'}; + $item['content'] = '

' . $itemtitle . ' ' . $mediaelement->{'title'} . '



' + . '

' + . $mediaelement->{'description'} + . '

' + . 'Download'; + $this->items[] = $item; + } + } + } + + public function getCountryCode() { + switch($this->getInput('language')){ + case 'us': + return 'en-us'; + break; + case 'de': + return 'de-de'; + break; + case 'fr': + return 'fr-fr'; + break; + case 'es': + return 'es-es'; + break; + case 'el': + return 'es-xl'; + break; + case 'it': + return 'it-it'; + break; + case 'dk': + return 'da-dk'; + break; + case 'fi': + return 'fi-fi'; + break; + case 'br': + return 'pt-br'; + break; + case 'uk': + return 'en-gb'; + break; + case 'ru': + return 'ru-ru'; + break; + case 'nl': + return 'nl-nl'; + break; + case 'no': + return 'nb-no'; + break; + case 'se': + return 'sv-se'; + break; + } + } + + public function getIcon() { + return 'https://assets.pokemon.com/static2/_ui/img/favicon.ico'; + } +} From 74a6911c04baab72d3feec42e606be3da6b1de1f Mon Sep 17 00:00:00 2001 From: Bocki Date: Thu, 22 Jul 2021 14:59:49 +0200 Subject: [PATCH 2/3] fix linting and public function --- bridges/PokemonTVBridge.php | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/bridges/PokemonTVBridge.php b/bridges/PokemonTVBridge.php index c908ec6b48b..ed70651ddbc 100644 --- a/bridges/PokemonTVBridge.php +++ b/bridges/PokemonTVBridge.php @@ -42,7 +42,6 @@ class PokemonTVBridge extends BridgeAbstract { ) )); - public function collectData(){ $link = 'https://www.pokemon.com/api/pokemontv/v2/channels/' . $this->getInput('language'); @@ -54,18 +53,18 @@ public function collectData(){ $filterseason = $this->getInput('filterseason'); foreach($parsed_json as $element) { - if(strlen($filtername) >= 1){ + if(strlen($filtername) >= 1) { if (!(stristr($element->{'channel_name'}, $filtername) !== false)) { continue; } } foreach($element->{'media'} as $mediaelement) { - if(strlen($filterseason) >= 1){ + if(strlen($filterseason) >= 1) { if ($mediaelement->{'season'} != $filterseason) { continue; } } - switch($element->{'media_type'}){ + switch($element->{'media_type'}) { case 'movie': $itemtitle = $element->{'channel_name'}; break; @@ -80,22 +79,21 @@ public function collectData(){ $item['uri'] = $streamurl; $item['title'] = $itemtitle; $item['timestamp'] = $mediaelement->{'last_modified'}; - $item['content'] = '

' . $itemtitle . ' ' . $mediaelement->{'title'} . '



' - . '

' . $mediaelement->{'description'} - . '

' - . 'Download'; + . '

Download'; $this->items[] = $item; } } } - public function getCountryCode() { - switch($this->getInput('language')){ + private function getCountryCode() { + switch($this->getInput('language')) { case 'us': return 'en-us'; break; From a9248b3977eb4f1948718bf706dcbb6281c282ea Mon Sep 17 00:00:00 2001 From: Bocki Date: Thu, 22 Jul 2021 15:02:08 +0200 Subject: [PATCH 3/3] fix more things --- bridges/PokemonTVBridge.php | 1 - 1 file changed, 1 deletion(-) diff --git a/bridges/PokemonTVBridge.php b/bridges/PokemonTVBridge.php index ed70651ddbc..276171feaf8 100644 --- a/bridges/PokemonTVBridge.php +++ b/bridges/PokemonTVBridge.php @@ -10,7 +10,6 @@ class PokemonTVBridge extends BridgeAbstract { 'language' => array( 'name' => 'Language', 'type' => 'list', - 'required' => true, 'title' => 'Select your language', 'values' => array( 'Danish' => 'dk',