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