From 530de680966107198ce7ee765967f8d0014af044 Mon Sep 17 00:00:00 2001 From: Ozan Karaali Date: Sat, 12 Oct 2019 15:22:54 +0300 Subject: [PATCH 1/3] [foxcomtr] Add new extractor --- youtube_dl/extractor/extractors.py | 1 + youtube_dl/extractor/foxcomtr.py | 51 ++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 youtube_dl/extractor/foxcomtr.py diff --git a/youtube_dl/extractor/extractors.py b/youtube_dl/extractor/extractors.py index 7a1e0dad6..d5746b9c5 100644 --- a/youtube_dl/extractor/extractors.py +++ b/youtube_dl/extractor/extractors.py @@ -370,6 +370,7 @@ from .fourtube import ( ) from .fox import FOXIE from .fox9 import FOX9IE +from .foxcomtr import FoxComTrIE from .foxgay import FoxgayIE from .foxnews import ( FoxNewsIE, diff --git a/youtube_dl/extractor/foxcomtr.py b/youtube_dl/extractor/foxcomtr.py new file mode 100644 index 000000000..f9263f935 --- /dev/null +++ b/youtube_dl/extractor/foxcomtr.py @@ -0,0 +1,51 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor +from ..utils import unsmuggle_url + + +class FoxComTrIE(InfoExtractor): + _VALID_URL = r'https?://(?:www.)?(?:fox.com.tr/.*|foxplay.com.tr/.*)' + _TESTS = [ + { + 'url': 'https://www.fox.com.tr/Mucize-Doktor/bolum/1', + 'md5': '4c85845537e99429ca28749340a0c00a', + 'info_dict': { + 'id': '1', + 'ext': 'ts', + 'title': 'FOX | Mucize Doktor 1. Bölüm', + } + }, + { + 'url': 'https://www.fox.com.tr/Mucize-Doktor/bolum/2', + 'md5': '04c4f9c72501151ef3ed6a46bd9ecc74', + 'info_dict': { + 'id': '2', + 'ext': 'ts', + 'title': 'FOX | Mucize Doktor 2. Bölüm', + } + }, + ] + + def _real_extract(self, url): + url, smuggled_data = unsmuggle_url(url) + if smuggled_data and 'force_videoid' in smuggled_data: + force_videoid = smuggled_data['force_videoid'] + video_id = force_videoid + else: + video_id = self._generic_id(url) + + webpage = self._download_webpage(url, video_id) + + title = self._og_search_title( + webpage, default=None) or self._html_search_regex( + r'(?s)(.*?)', webpage, 'video title', + default='video') + + m3u8_url = self._html_search_regex(r"videoSrc : '(.*)'", webpage, 'root_url') + return { + 'id': video_id, + 'title': title, + 'formats': reversed(self._extract_m3u8_formats(m3u8_url, video_id, 'ts', 'm3u8_native', fatal=False)), + } From 94e2e0eec052fd20be08419ebdfa6ed379dce3ce Mon Sep 17 00:00:00 2001 From: Ozan Karaali Date: Sun, 13 Oct 2019 01:21:07 +0300 Subject: [PATCH 2/3] [foxcomtr] cleaning code, adding more tests --- youtube_dl/extractor/foxcomtr.py | 37 +++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/youtube_dl/extractor/foxcomtr.py b/youtube_dl/extractor/foxcomtr.py index f9263f935..483d5ecd8 100644 --- a/youtube_dl/extractor/foxcomtr.py +++ b/youtube_dl/extractor/foxcomtr.py @@ -2,7 +2,6 @@ from __future__ import unicode_literals from .common import InfoExtractor -from ..utils import unsmuggle_url class FoxComTrIE(InfoExtractor): @@ -26,26 +25,38 @@ class FoxComTrIE(InfoExtractor): 'title': 'FOX | Mucize Doktor 2. Bölüm', } }, + { + 'url': 'https://www.foxplay.com.tr/4N1K-2/izle', + 'md5': '74fb90d11d519c194e31b77e966bb252', + 'info_dict': { + 'id': 'izle', + 'ext': 'ts', + 'title': '4N1K 2 FOXPlay\'de | Ücretsiz HD Kalitede Film İzle', + } + }, + { + 'url': 'https://www.foxplay.com.tr/Mucize-Doktor/bolumler/4-bolum', + 'md5': '38a8f999e236758f00e7f487560a59ad', + 'info_dict': { + 'id': '4-bolum', + 'ext': 'ts', + 'title': 'Mucize Doktor Dizisi 4. Bölümü İzle', + } + }, ] def _real_extract(self, url): - url, smuggled_data = unsmuggle_url(url) - if smuggled_data and 'force_videoid' in smuggled_data: - force_videoid = smuggled_data['force_videoid'] - video_id = force_videoid - else: - video_id = self._generic_id(url) + video_id = self._generic_id(url) webpage = self._download_webpage(url, video_id) - title = self._og_search_title( - webpage, default=None) or self._html_search_regex( - r'(?s)(.*?)', webpage, 'video title', - default='video') + title = self._og_search_title(webpage, default=None).strip() - m3u8_url = self._html_search_regex(r"videoSrc : '(.*)'", webpage, 'root_url') + m3u8_url = self._html_search_regex(r"videoSrc : '(.*)'", + webpage, 'root_url') return { 'id': video_id, 'title': title, - 'formats': reversed(self._extract_m3u8_formats(m3u8_url, video_id, 'ts', 'm3u8_native', fatal=False)), + 'formats': reversed(self._extract_m3u8_formats( + m3u8_url, video_id, 'ts', 'm3u8_native')), } From 3f1b4347add7cd4bbbe5a3863f18f2dddf203a98 Mon Sep 17 00:00:00 2001 From: Ozan Karaali Date: Sun, 13 Oct 2019 01:29:53 +0300 Subject: [PATCH 3/3] [foxcomtr] one more cleaning --- youtube_dl/extractor/foxcomtr.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/foxcomtr.py b/youtube_dl/extractor/foxcomtr.py index 483d5ecd8..9373b33d2 100644 --- a/youtube_dl/extractor/foxcomtr.py +++ b/youtube_dl/extractor/foxcomtr.py @@ -50,7 +50,7 @@ class FoxComTrIE(InfoExtractor): webpage = self._download_webpage(url, video_id) - title = self._og_search_title(webpage, default=None).strip() + title = self._og_search_title(webpage).strip() m3u8_url = self._html_search_regex(r"videoSrc : '(.*)'", webpage, 'root_url')