]>
Commit | Line | Data |
---|---|---|
677c1809 | 1 | import json |
677c1809 PH |
2 | |
3 | from .common import InfoExtractor | |
f6acbdec | 4 | from ..utils import int_or_none |
677c1809 | 5 | |
5f6a1245 | 6 | |
677c1809 | 7 | class PodomaticIE(InfoExtractor): |
df773c3d | 8 | _WORKING = False |
677c1809 | 9 | IE_NAME = 'podomatic' |
1d547229 S |
10 | _VALID_URL = r'''(?x) |
11 | (?P<proto>https?):// | |
12 | (?: | |
13 | (?P<channel>[^.]+)\.podomatic\.com/entry| | |
14 | (?:www\.)?podomatic\.com/podcasts/(?P<channel_2>[^/]+)/episodes | |
15 | )/ | |
16 | (?P<id>[^/?#&]+) | |
17 | ''' | |
677c1809 | 18 | |
1d547229 S |
19 | _TESTS = [{ |
20 | 'url': 'http://scienceteachingtips.podomatic.com/entry/2009-01-02T16_03_35-08_00', | |
21 | 'md5': '84bb855fcf3429e6bf72460e1eed782d', | |
22 | 'info_dict': { | |
23 | 'id': '2009-01-02T16_03_35-08_00', | |
24 | 'ext': 'mp3', | |
25 | 'uploader': 'Science Teaching Tips', | |
26 | 'uploader_id': 'scienceteachingtips', | |
27 | 'title': '64. When the Moon Hits Your Eye', | |
28 | 'duration': 446, | |
29 | } | |
30 | }, { | |
31 | 'url': 'http://ostbahnhof.podomatic.com/entry/2013-11-15T16_31_21-08_00', | |
32 | 'md5': 'd2cf443931b6148e27638650e2638297', | |
33 | 'info_dict': { | |
34 | 'id': '2013-11-15T16_31_21-08_00', | |
35 | 'ext': 'mp3', | |
36 | 'uploader': 'Ostbahnhof / Techno Mix', | |
37 | 'uploader_id': 'ostbahnhof', | |
38 | 'title': 'Einunddreizig', | |
39 | 'duration': 3799, | |
40 | } | |
41 | }, { | |
42 | 'url': 'https://www.podomatic.com/podcasts/scienceteachingtips/episodes/2009-01-02T16_03_35-08_00', | |
43 | 'only_matching': True, | |
44 | }] | |
677c1809 PH |
45 | |
46 | def _real_extract(self, url): | |
5ad28e7f | 47 | mobj = self._match_valid_url(url) |
677c1809 | 48 | video_id = mobj.group('id') |
1d547229 | 49 | channel = mobj.group('channel') or mobj.group('channel_2') |
677c1809 | 50 | |
3089bc74 S |
51 | json_url = (('%s://%s.podomatic.com/entry/embed_params/%s' |
52 | + '?permalink=true&rtmp=0') % | |
677c1809 PH |
53 | (mobj.group('proto'), channel, video_id)) |
54 | data_json = self._download_webpage( | |
e6c6d10d | 55 | json_url, video_id, 'Downloading video info') |
677c1809 PH |
56 | data = json.loads(data_json) |
57 | ||
58 | video_url = data['downloadLink'] | |
e6c6d10d S |
59 | if not video_url: |
60 | video_url = '%s/%s' % (data['streamer'].replace('rtmp', 'http'), data['mediaLocation']) | |
677c1809 PH |
61 | uploader = data['podcast'] |
62 | title = data['title'] | |
63 | thumbnail = data['imageLocation'] | |
f6acbdec | 64 | duration = int_or_none(data.get('length'), 1000) |
677c1809 PH |
65 | |
66 | return { | |
67 | 'id': video_id, | |
68 | 'url': video_url, | |
69 | 'title': title, | |
70 | 'uploader': uploader, | |
71 | 'uploader_id': channel, | |
72 | 'thumbnail': thumbnail, | |
73 | 'duration': duration, | |
74 | } |