]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[streamango] Add extractor
authorMarvin Ewald <marvin.e@protonmail.ch>
Tue, 4 Apr 2017 17:18:23 +0000 (19:18 +0200)
committerSergey M․ <dstftw@gmail.com>
Sat, 15 Apr 2017 14:50:46 +0000 (21:50 +0700)
youtube_dl/extractor/extractors.py
youtube_dl/extractor/streamango.py [new file with mode: 0644]

index 72d28a7e65f7a5ea9d6be5631586b7542e483d12..a92cbefed2f342086dbf5b37409e4bb2e6e7fd62 100644 (file)
@@ -939,6 +939,7 @@ from .srmediathek import SRMediathekIE
 from .stanfordoc import StanfordOpenClassroomIE
 from .steam import SteamIE
 from .streamable import StreamableIE
+from .streamango import StreamangoIE
 from .streamcloud import StreamcloudIE
 from .streamcz import StreamCZIE
 from .streetvoice import StreetVoiceIE
diff --git a/youtube_dl/extractor/streamango.py b/youtube_dl/extractor/streamango.py
new file mode 100644 (file)
index 0000000..a4ef06b
--- /dev/null
@@ -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<id>.+?)/(?:.+)'
+    _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<url>.+?)["\'].*'.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,
+        }