]> gitweb @ CieloNegro.org - youtube-dl.git/commitdiff
[vyborymos] Add extractor (Closes #10692)
authorSergey M․ <dstftw@gmail.com>
Sun, 18 Sep 2016 09:56:40 +0000 (16:56 +0700)
committerSergey M․ <dstftw@gmail.com>
Sun, 18 Sep 2016 09:56:40 +0000 (16:56 +0700)
youtube_dl/extractor/extractors.py
youtube_dl/extractor/vyborymos.py [new file with mode: 0644]

index 4baf4cd481add547585de6b672553547ee851c1f..8166fd4f9fcbb69e22b4a2fd8ae881ff27f991ee 100644 (file)
@@ -1069,6 +1069,7 @@ from .vporn import VpornIE
 from .vrt import VRTIE
 from .vube import VubeIE
 from .vuclip import VuClipIE
+from .vyborymos import VyboryMosIE
 from .walla import WallaIE
 from .washingtonpost import (
     WashingtonPostIE,
diff --git a/youtube_dl/extractor/vyborymos.py b/youtube_dl/extractor/vyborymos.py
new file mode 100644 (file)
index 0000000..884aecb
--- /dev/null
@@ -0,0 +1,55 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+
+
+class VyboryMosIE(InfoExtractor):
+    _VALID_URL = r'https?://vybory\.mos\.ru/(?:#precinct/|account/channels\?.*?\bstation_id=)(?P<id>\d+)'
+    _TESTS = [{
+        'url': 'http://vybory.mos.ru/#precinct/13636',
+        'info_dict': {
+            'id': '13636',
+            'ext': 'mp4',
+            'title': 're:^Участковая избирательная комиссия №2231 [0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}:[0-9]{2}$',
+            'description': 'Россия, Москва, улица Введенского, 32А',
+            'is_live': True,
+        },
+        'params': {
+            'skip_download': True,
+        }
+    }, {
+        'url': 'http://vybory.mos.ru/account/channels?station_id=13636',
+        'only_matching': True,
+    }]
+
+    def _real_extract(self, url):
+        station_id = self._match_id(url)
+
+        channels = self._download_json(
+            'http://vybory.mos.ru/account/channels?station_id=%s' % station_id,
+            station_id)
+
+        formats = []
+        for cam_num, (sid, hosts, name, _) in enumerate(channels, 1):
+            for num, host in enumerate(hosts, 1):
+                formats.append({
+                    'url': 'http://%s/master.m3u8?sid=%s' % (host, sid),
+                    'ext': 'mp4',
+                    'format_id': 'camera%d-host%d' % (cam_num, num),
+                    'format_note': '%s, %s' % (name, host),
+                })
+
+        info = self._download_json(
+            'http://vybory.mos.ru/json/voting_stations/136/%s.json' % station_id,
+            station_id, 'Downloading station info')
+
+        title = info['name']
+
+        return {
+            'id': station_id,
+            'title': self._live_title(title),
+            'description': info.get('address'),
+            'is_live': True,
+            'formats': formats,
+        }