]>
Commit | Line | Data |
---|---|---|
42bdd9d0 PH |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | ||
4 | from .common import InfoExtractor | |
5 | from ..utils import ( | |
42bdd9d0 PH |
6 | unified_strdate, |
7 | xpath_text, | |
8 | ) | |
9 | ||
10 | ||
11 | class CinchcastIE(InfoExtractor): | |
c983cc3b S |
12 | _VALID_URL = r'https?://player\.cinchcast\.com/.*?(?:assetId|show_id)=(?P<id>[0-9]+)' |
13 | _TESTS = [{ | |
14 | 'url': 'http://player.cinchcast.com/?show_id=5258197&platformId=1&assetType=single', | |
15 | 'info_dict': { | |
16 | 'id': '5258197', | |
17 | 'ext': 'mp3', | |
18 | 'title': 'Train Your Brain to Up Your Game with Coach Mandy', | |
19 | 'upload_date': '20130816', | |
20 | }, | |
21 | }, { | |
42bdd9d0 PH |
22 | # Actual test is run in generic, look for undergroundwellness |
23 | 'url': 'http://player.cinchcast.com/?platformId=1&assetType=single&assetId=7141703', | |
24 | 'only_matching': True, | |
c983cc3b | 25 | }] |
42bdd9d0 PH |
26 | |
27 | def _real_extract(self, url): | |
28 | video_id = self._match_id(url) | |
29 | doc = self._download_xml( | |
30 | 'http://www.blogtalkradio.com/playerasset/mrss?assetType=single&assetId=%s' % video_id, | |
31 | video_id) | |
32 | ||
33 | item = doc.find('.//item') | |
34 | title = xpath_text(item, './title', fatal=True) | |
35 | date_str = xpath_text( | |
36 | item, './{http://developer.longtailvideo.com/trac/}date') | |
37 | upload_date = unified_strdate(date_str, day_first=False) | |
38 | # duration is present but wrong | |
a52c6335 PH |
39 | formats = [{ |
40 | 'format_id': 'main', | |
41 | 'url': item.find('./{http://search.yahoo.com/mrss/}content').attrib['url'], | |
42 | }] | |
42bdd9d0 PH |
43 | backup_url = xpath_text( |
44 | item, './{http://developer.longtailvideo.com/trac/}backupContent') | |
45 | if backup_url: | |
46 | formats.append({ | |
47 | 'preference': 2, # seems to be more reliable | |
48 | 'format_id': 'backup', | |
49 | 'url': backup_url, | |
50 | }) | |
51 | self._sort_formats(formats) | |
52 | ||
53 | return { | |
54 | 'id': video_id, | |
55 | 'title': title, | |
56 | 'upload_date': upload_date, | |
57 | 'formats': formats, | |
58 | } |