KakaoTV.php
| 1 | <?php |
| 2 | /** |
| 3 | * KakaoTV.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 | * KakaoTV Provider |
| 19 | * 톡에서 보는 오리지널 콘� |
| 20 | �츠! 지금 카톡에서 카카오TV 채널을 추가해 �... |
| 21 | * |
| 22 | * @link https://tv.kakao.com |
| 23 | * |
| 24 | */ |
| 25 | class KakaoTV extends ProviderAdapter implements ProviderInterface |
| 26 | { |
| 27 | /** inline {@inheritdoc} */ |
| 28 | protected $endpoint = 'https://tv.kakao.com/oembed?format=json'; |
| 29 | |
| 30 | /** inline {@inheritdoc} */ |
| 31 | protected static $hosts = [ |
| 32 | 'tv.kakao.com' |
| 33 | ]; |
| 34 | |
| 35 | /** inline {@inheritdoc} */ |
| 36 | protected $httpsSupport = true; |
| 37 | |
| 38 | /** inline {@inheritdoc} */ |
| 39 | public function validateUrl(Url $url) |
| 40 | { |
| 41 | return (bool) ( |
| 42 | preg_match('~tv\.kakao\.com/channel/(?:[vl])/(?:[^/]+)$~i', (string) $url) || |
| 43 | preg_match('~tv\.kakao\.com/channel/([^/]+)/(live|clip)link/([^/]+)$~i', (string) $url) || |
| 44 | preg_match('~tv\.kakao\.com/m/channel/(?:[vl])/(?:[^/]+)$~i', (string) $url) |
| 45 | ); |
| 46 | } |
| 47 | |
| 48 | /** inline {@inheritdoc} */ |
| 49 | public function normalizeUrl(Url $url) |
| 50 | { |
| 51 | $url->convertToHttps(); |
| 52 | $url->removeQueryString(); |
| 53 | $url->removeLastSlash(); |
| 54 | |
| 55 | return $url; |
| 56 | } |
| 57 | |
| 58 | } |
| 59 |