Nfb.php
| 1 | <?php |
| 2 | /** |
| 3 | * Nfb.php |
| 4 | * |
| 5 | * @package Embera |
| 6 | * @author Michael Pratt <yo@michael-pratt.com> |
| 7 | * @link http://www.michael-pratt.com/ |
| 8 | * |
| 9 | * For the full copyright and license information, please view the LICENSE |
| 10 | * file that was distributed with this source code. |
| 11 | */ |
| 12 | |
| 13 | namespace Embera\Provider; |
| 14 | |
| 15 | use Embera\Url; |
| 16 | |
| 17 | /** |
| 18 | * Nfb Provider |
| 19 | * Watch quality Canadian documentary, animation and fiction films online |
| 20 | * |
| 21 | * @link https://nfb.ca |
| 22 | * |
| 23 | */ |
| 24 | class Nfb extends ProviderAdapter implements ProviderInterface |
| 25 | { |
| 26 | /** inline {@inheritdoc} */ |
| 27 | protected $endpoint = 'https://www.nfb.ca/remote/services/oembed/?format=json'; |
| 28 | |
| 29 | /** inline {@inheritdoc} */ |
| 30 | protected static $hosts = [ |
| 31 | 'nfb.ca' |
| 32 | ]; |
| 33 | |
| 34 | /** inline {@inheritdoc} */ |
| 35 | protected $httpsSupport = true; |
| 36 | |
| 37 | /** inline {@inheritdoc} */ |
| 38 | protected $responsiveSupport = false; |
| 39 | |
| 40 | /** inline {@inheritdoc} */ |
| 41 | public function validateUrl(Url $url) |
| 42 | { |
| 43 | return (bool) (preg_match('~nfb\.ca/(?:film|playlist)/([^/]+)/?$~i', (string) $url)); |
| 44 | } |
| 45 | |
| 46 | /** inline {@inheritdoc} */ |
| 47 | public function normalizeUrl(Url $url) |
| 48 | { |
| 49 | $url->convertToHttps(); |
| 50 | $url->removeQueryString(); |
| 51 | |
| 52 | return $url; |
| 53 | } |
| 54 | |
| 55 | /** inline {@inheritdoc} */ |
| 56 | public function modifyResponse(array $response = []) |
| 57 | { |
| 58 | // The html response comes "encoded" ... booooo :(, need to decode in order to work.. |
| 59 | if (!empty($response['html'])) { |
| 60 | $response['html'] = html_entity_decode($response['html'], ENT_QUOTES, 'UTF-8'); |
| 61 | } |
| 62 | |
| 63 | return $response; |
| 64 | } |
| 65 | |
| 66 | } |
| 67 |