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