]> jfr.im git - yt-dlp.git/blame - youtube_dlc/extractor/voicerepublic.py
Merge branch 'tvnow' of https://github.com/TinyToweringTree/youtube-dl into TinyTower...
[yt-dlp.git] / youtube_dlc / extractor / voicerepublic.py
CommitLineData
c6ddbdb6
D
1from __future__ import unicode_literals
2
3from .common import InfoExtractor
be96f992 4from ..compat import compat_str
a6762c4a
S
5from ..utils import (
6 ExtractorError,
7 determine_ext,
8 int_or_none,
be96f992 9 urljoin,
a6762c4a 10)
c6ddbdb6
D
11
12
13class VoiceRepublicIE(InfoExtractor):
a6762c4a
S
14 _VALID_URL = r'https?://voicerepublic\.com/(?:talks|embed)/(?P<id>[0-9a-z-]+)'
15 _TESTS = [{
16 'url': 'http://voicerepublic.com/talks/watching-the-watchers-building-a-sousveillance-state',
c16f8a46 17 'md5': 'b9174d651323f17783000876347116e3',
c6ddbdb6
D
18 'info_dict': {
19 'id': '2296',
a6762c4a 20 'display_id': 'watching-the-watchers-building-a-sousveillance-state',
c6ddbdb6
D
21 'ext': 'm4a',
22 'title': 'Watching the Watchers: Building a Sousveillance State',
c16f8a46 23 'description': 'Secret surveillance programs have metadata too. The people and companies that operate secret surveillance programs can be surveilled.',
be96f992 24 'duration': 1556,
a6762c4a 25 'view_count': int,
c6ddbdb6 26 }
a6762c4a
S
27 }, {
28 'url': 'http://voicerepublic.com/embed/watching-the-watchers-building-a-sousveillance-state',
29 'only_matching': True,
30 }]
c6ddbdb6
D
31
32 def _real_extract(self, url):
33 display_id = self._match_id(url)
a6762c4a 34
be96f992 35 webpage = self._download_webpage(url, display_id)
c6ddbdb6 36
a6762c4a
S
37 if '>Queued for processing, please stand by...<' in webpage:
38 raise ExtractorError(
39 'Audio is still queued for processing', expected=True)
f03a8a3c 40
be96f992
RA
41 talk = self._parse_json(self._search_regex(
42 r'initialSnapshot\s*=\s*({.+?});',
43 webpage, 'talk'), display_id)['talk']
44 title = talk['title']
45 formats = [{
46 'url': urljoin(url, talk_url),
47 'format_id': format_id,
48 'ext': determine_ext(talk_url) or format_id,
49 'vcodec': 'none',
50 } for format_id, talk_url in talk['media_links'].items()]
f03a8a3c 51 self._sort_formats(formats)
c6ddbdb6
D
52
53 return {
be96f992 54 'id': compat_str(talk.get('id') or display_id),
a6762c4a
S
55 'display_id': display_id,
56 'title': title,
be96f992
RA
57 'description': talk.get('teaser'),
58 'thumbnail': talk.get('image_url'),
59 'duration': int_or_none(talk.get('archived_duration')),
60 'view_count': int_or_none(talk.get('play_count')),
a6762c4a 61 'formats': formats,
c6ddbdb6 62 }