[voicerepublic] Remove creator field
[youtube-dl] / youtube_dl / extractor / voicerepublic.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6 from ..compat import (
7     compat_urllib_request,
8 )
9
10
11 class VoiceRepublicIE(InfoExtractor):
12     _VALID_URL = r'https?://voicerepublic\.com/talks/(?P<id>[0-9a-z-]+)'
13     _TEST = {
14         'url': 'https://voicerepublic.com/talks/watching-the-watchers-building-a-sousveillance-state',
15         'md5': '0554a24d1657915aa8e8f84e15dc9353',
16         'info_dict': {
17             'id': '2296',
18             'ext': 'm4a',
19             'title': 'Watching the Watchers: Building a Sousveillance State',
20             'thumbnail': 'https://voicerepublic.com/system/flyer/2296.png',
21             'description': 'md5:715ba964958afa2398df615809cfecb1',
22         }
23     }
24
25     def _real_extract(self, url):
26         display_id = self._match_id(url)
27         req = compat_urllib_request.Request(url)
28         # Older versions of Firefox get redirected to an "upgrade browser" page
29         req.add_header('User-Agent', 'youtube-dl')
30         webpage = self._download_webpage(req, display_id)
31         thumbnail = self._og_search_thumbnail(webpage)
32         video_id = self._search_regex(r'/(\d+)\.png', thumbnail, 'id')
33
34         if '<div class=\'vr-player jp-jplayer\'' in webpage:
35             formats = [{
36                 'url': 'https://voicerepublic.com/vrmedia/{}-clean.{}'.format(video_id, ext),
37                 'ext': ext,
38                 'format_id': ext,
39                 'vcodec': 'none',
40             } for ext in ['m4a', 'mp3', 'ogg']]
41             self._sort_formats(formats)
42         else:
43             # Audio is still queued for processing
44             formats = []
45
46         return {
47             'id': video_id,
48             'title': self._og_search_title(webpage),
49             'formats': formats,
50             'url': self._og_search_url(webpage),
51             'thumbnail': thumbnail,
52             'description': self._og_search_description(webpage),
53         }