aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/voicerepublic.py
diff options
context:
space:
mode:
authorDuncan <duncan@vtllf.org>2015-05-10 12:30:07 +1200
committerDuncan <duncan@vtllf.org>2015-05-10 12:39:24 +1200
commitc6ddbdb66c5d6ead5e198013c54ef53d641063f1 (patch)
tree7afa7e2364e5bad669ee28d8d44f3e561b234fc9 /youtube_dl/extractor/voicerepublic.py
parent3800b908b1976f242b41d5a2d114418559ce3b48 (diff)
[voicerepublic] Add new extractor
Diffstat (limited to 'youtube_dl/extractor/voicerepublic.py')
-rw-r--r--youtube_dl/extractor/voicerepublic.py55
1 files changed, 55 insertions, 0 deletions
diff --git a/youtube_dl/extractor/voicerepublic.py b/youtube_dl/extractor/voicerepublic.py
new file mode 100644
index 000000000..1a90693cb
--- /dev/null
+++ b/youtube_dl/extractor/voicerepublic.py
@@ -0,0 +1,55 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+
+from ..compat import (
+ compat_urllib_request,
+)
+
+
+class VoiceRepublicIE(InfoExtractor):
+ _VALID_URL = r'https?://voicerepublic\.com/talks/(?P<id>[0-9a-z-]+)'
+ _TEST = {
+ 'url': 'https://voicerepublic.com/talks/watching-the-watchers-building-a-sousveillance-state',
+ 'md5': '0554a24d1657915aa8e8f84e15dc9353',
+ 'info_dict': {
+ 'id': '2296',
+ 'ext': 'm4a',
+ 'title': 'Watching the Watchers: Building a Sousveillance State',
+ 'thumbnail': 'https://voicerepublic.com/system/flyer/2296.png',
+ 'description': 'md5:715ba964958afa2398df615809cfecb1',
+ 'creator': 'M. C. McGrath',
+ }
+ }
+
+ def _real_extract(self, url):
+ display_id = self._match_id(url)
+ req = compat_urllib_request.Request(url)
+ # Older versions of Firefox get redirected to an "upgrade browser" page
+ req.add_header('User-Agent', 'youtube-dl')
+ webpage = self._download_webpage(req, display_id)
+ thumbnail = self._og_search_thumbnail(webpage)
+ video_id = self._search_regex(r'/(\d+)\.png', thumbnail, 'id')
+
+ if '<div class=\'vr-player jp-jplayer\'' in webpage:
+ formats = [{
+ 'url': 'https://voicerepublic.com/vrmedia/{}-clean.{}'.format(video_id, ext),
+ 'ext': ext,
+ 'format_id': ext,
+ 'vcodec': 'none',
+ } for ext in ['m4a', 'mp3', 'ogg']]
+ self._sort_formats(formats)
+ else:
+ # Audio is still queued for processing
+ formats = []
+
+ return {
+ 'id': video_id,
+ 'title': self._og_search_title(webpage),
+ 'formats': formats,
+ 'url': self._og_search_url(webpage),
+ 'thumbnail': thumbnail,
+ 'description': self._og_search_description(webpage),
+ 'creator': self._search_regex(r'<meta content=\'([^\']*?)\' name=\'author\'>', webpage, 'author', fatal=False),
+ }