From 4db79fa1bc482ef5d97c8b73f0bf3683d5cc383c Mon Sep 17 00:00:00 2001 From: Marvin Ewald Date: Tue, 4 Apr 2017 19:18:23 +0200 Subject: [streamango] Add extractor --- youtube_dl/extractor/streamango.py | 54 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 youtube_dl/extractor/streamango.py (limited to 'youtube_dl/extractor/streamango.py') diff --git a/youtube_dl/extractor/streamango.py b/youtube_dl/extractor/streamango.py new file mode 100644 index 000000000..a4ef06b66 --- /dev/null +++ b/youtube_dl/extractor/streamango.py @@ -0,0 +1,54 @@ +# coding: utf-8 +from __future__ import unicode_literals + +from .common import InfoExtractor + + +class StreamangoIE(InfoExtractor): + _VALID_URL = r'https?://(?:www\.)?streamango\.com/(?:f|embed)/(?P.+?)/(?:.+)' + _TESTS = [{ + 'url': 'https://streamango.com/f/clapasobsptpkdfe/20170315_150006_mp4', + 'md5': 'e992787515a182f55e38fc97588d802a', + 'info_dict': { + 'id': 'clapasobsptpkdfe', + 'ext': 'mp4', + 'title': '20170315_150006.mp4', + 'url': r're:https://streamango\.com/v/d/clapasobsptpkdfe~[0-9]{10}~(?:[0-9]+\.){3}[0-9]+~.{8}/720', + } + }, { + 'url': 'https://streamango.com/embed/clapasobsptpkdfe/20170315_150006_mp4', + 'only_matching': True, + }] + + def _real_extract(self, url): + def extract_url(urltype): + return self._search_regex( + r'type\s*:\s*["\']{}["\']\s*,\s*src\s*:\s*["\'](?P.+?)["\'].*'.format(urltype), + webpage, 'video URL', group='url') + + video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) + + title = self._og_search_title(webpage) + url = 'https:' + extract_url('video/mp4') + dashurl = extract_url(r'application/dash\+xml') + + formats = [{ + 'url': url, + 'ext': 'mp4', + 'width': 1280, + 'height': 720, + 'format_id': 'mp4', + }] + + formats.extend(self._extract_mpd_formats( + dashurl, video_id, mpd_id='dash', fatal=False)) + + self._sort_formats(formats) + + return { + 'id': video_id, + 'url': url, + 'title': title, + 'formats': formats, + } -- cgit v1.2.3 From 8068296276657c9d888338c2211c112d69de6fc4 Mon Sep 17 00:00:00 2001 From: Sergey M․ Date: Sat, 15 Apr 2017 21:50:15 +0700 Subject: [streamango] Improve extraction (closes #12643) --- youtube_dl/extractor/streamango.py | 50 +++++++++++++++++++++++--------------- 1 file changed, 30 insertions(+), 20 deletions(-) (limited to 'youtube_dl/extractor/streamango.py') diff --git a/youtube_dl/extractor/streamango.py b/youtube_dl/extractor/streamango.py index a4ef06b66..aa4fad162 100644 --- a/youtube_dl/extractor/streamango.py +++ b/youtube_dl/extractor/streamango.py @@ -1,11 +1,18 @@ # coding: utf-8 from __future__ import unicode_literals +import re + from .common import InfoExtractor +from ..utils import ( + determine_ext, + int_or_none, + js_to_json, +) class StreamangoIE(InfoExtractor): - _VALID_URL = r'https?://(?:www\.)?streamango\.com/(?:f|embed)/(?P.+?)/(?:.+)' + _VALID_URL = r'https?://(?:www\.)?streamango\.com/(?:f|embed)/(?P[^/?#&]+)' _TESTS = [{ 'url': 'https://streamango.com/f/clapasobsptpkdfe/20170315_150006_mp4', 'md5': 'e992787515a182f55e38fc97588d802a', @@ -13,7 +20,6 @@ class StreamangoIE(InfoExtractor): 'id': 'clapasobsptpkdfe', 'ext': 'mp4', 'title': '20170315_150006.mp4', - 'url': r're:https://streamango\.com/v/d/clapasobsptpkdfe~[0-9]{10}~(?:[0-9]+\.){3}[0-9]+~.{8}/720', } }, { 'url': 'https://streamango.com/embed/clapasobsptpkdfe/20170315_150006_mp4', @@ -21,29 +27,33 @@ class StreamangoIE(InfoExtractor): }] def _real_extract(self, url): - def extract_url(urltype): - return self._search_regex( - r'type\s*:\s*["\']{}["\']\s*,\s*src\s*:\s*["\'](?P.+?)["\'].*'.format(urltype), - webpage, 'video URL', group='url') - video_id = self._match_id(url) + webpage = self._download_webpage(url, video_id) title = self._og_search_title(webpage) - url = 'https:' + extract_url('video/mp4') - dashurl = extract_url(r'application/dash\+xml') - - formats = [{ - 'url': url, - 'ext': 'mp4', - 'width': 1280, - 'height': 720, - 'format_id': 'mp4', - }] - - formats.extend(self._extract_mpd_formats( - dashurl, video_id, mpd_id='dash', fatal=False)) + formats = [] + for format_ in re.findall(r'({[^}]*\bsrc\s*:\s*[^}]*})', webpage): + video = self._parse_json( + format_, video_id, transform_source=js_to_json, fatal=False) + if not video: + continue + src = video.get('src') + if not src: + continue + ext = determine_ext(src, default_ext=None) + if video.get('type') == 'application/dash+xml' or ext == 'mpd': + formats.extend(self._extract_mpd_formats( + src, video_id, mpd_id='dash', fatal=False)) + else: + formats.append({ + 'url': src, + 'ext': ext or 'mp4', + 'width': int_or_none(video.get('width')), + 'height': int_or_none(video.get('height')), + 'tbr': int_or_none(video.get('bitrate')), + }) self._sort_formats(formats) return { -- cgit v1.2.3 From eb703e538035b0ebdc076be0ba982aac97d9ef08 Mon Sep 17 00:00:00 2001 From: Luca Steeb Date: Mon, 5 Jun 2017 20:17:43 +0200 Subject: [streamango] Make title optional --- youtube_dl/extractor/streamango.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'youtube_dl/extractor/streamango.py') diff --git a/youtube_dl/extractor/streamango.py b/youtube_dl/extractor/streamango.py index aa4fad162..cf03d5b09 100644 --- a/youtube_dl/extractor/streamango.py +++ b/youtube_dl/extractor/streamango.py @@ -21,6 +21,13 @@ class StreamangoIE(InfoExtractor): 'ext': 'mp4', 'title': '20170315_150006.mp4', } + }, { + 'url': 'https://streamango.com/embed/foqebrpftarclpob/asdf_asd_2_mp4', + 'info_dict': { + 'id': 'foqebrpftarclpob', + 'ext': 'mp4', + 'title': 'foqebrpftarclpob', + } }, { 'url': 'https://streamango.com/embed/clapasobsptpkdfe/20170315_150006_mp4', 'only_matching': True, @@ -31,7 +38,7 @@ class StreamangoIE(InfoExtractor): webpage = self._download_webpage(url, video_id) - title = self._og_search_title(webpage) + title = self._og_search_title(webpage, default=video_id) formats = [] for format_ in re.findall(r'({[^}]*\bsrc\s*:\s*[^}]*})', webpage): -- cgit v1.2.3 From 1508da30c28f2047a6d9d1dcebd529fa6ea56f15 Mon Sep 17 00:00:00 2001 From: Sergey M․ Date: Wed, 7 Jun 2017 21:53:13 +0700 Subject: [streamango] Skip download for test (closes #13292) --- youtube_dl/extractor/streamango.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'youtube_dl/extractor/streamango.py') diff --git a/youtube_dl/extractor/streamango.py b/youtube_dl/extractor/streamango.py index cf03d5b09..a9e34c027 100644 --- a/youtube_dl/extractor/streamango.py +++ b/youtube_dl/extractor/streamango.py @@ -22,12 +22,16 @@ class StreamangoIE(InfoExtractor): 'title': '20170315_150006.mp4', } }, { + # no og:title 'url': 'https://streamango.com/embed/foqebrpftarclpob/asdf_asd_2_mp4', 'info_dict': { 'id': 'foqebrpftarclpob', 'ext': 'mp4', 'title': 'foqebrpftarclpob', - } + }, + 'params': { + 'skip_download': True, + }, }, { 'url': 'https://streamango.com/embed/clapasobsptpkdfe/20170315_150006_mp4', 'only_matching': True, -- cgit v1.2.3