]> git.bitcoin.ninja Git - youtube-dl/blob - youtube_dl/extractor/podomatic.py
Implement a different adult sites checking algorithm
[youtube-dl] / youtube_dl / extractor / podomatic.py
1 import json
2 import re
3
4 from .common import InfoExtractor
5
6
7 class PodomaticIE(InfoExtractor):
8     IE_NAME = 'podomatic'
9     _VALID_URL = r'^(?P<proto>https?)://(?P<channel>[^.]+)\.podomatic\.com/entry/(?P<id>[^?]+)'
10
11     _TEST = {
12         u"url": u"http://scienceteachingtips.podomatic.com/entry/2009-01-02T16_03_35-08_00",
13         u"file": u"2009-01-02T16_03_35-08_00.mp3",
14         u"md5": u"84bb855fcf3429e6bf72460e1eed782d",
15         u"info_dict": {
16             u"uploader": u"Science Teaching Tips",
17             u"uploader_id": u"scienceteachingtips",
18             u"title": u"64.  When the Moon Hits Your Eye",
19             u"duration": 446,
20         }
21     }
22
23     def _real_extract(self, url):
24         mobj = re.match(self._VALID_URL, url)
25         video_id = mobj.group('id')
26         channel = mobj.group('channel')
27
28         json_url = (('%s://%s.podomatic.com/entry/embed_params/%s' +
29                      '?permalink=true&rtmp=0') %
30                     (mobj.group('proto'), channel, video_id))
31         data_json = self._download_webpage(
32             json_url, video_id, note=u'Downloading video info')
33         data = json.loads(data_json)
34
35         video_url = data['downloadLink']
36         uploader = data['podcast']
37         title = data['title']
38         thumbnail = data['imageLocation']
39         duration = int(data['length'] / 1000.0)
40
41         return {
42             'id': video_id,
43             'url': video_url,
44             'title': title,
45             'uploader': uploader,
46             'uploader_id': channel,
47             'thumbnail': thumbnail,
48             'duration': duration,
49         }