]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cinchcast.py
debian/changelog: Annotate bugs to close.
[youtubedl] / youtube_dl / extractor / cinchcast.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import (
6 unified_strdate,
7 xpath_text,
8 )
9
10
11 class CinchcastIE(InfoExtractor):
12 _VALID_URL = r'https?://player\.cinchcast\.com/.*?assetId=(?P<id>[0-9]+)'
13 _TEST = {
14 # Actual test is run in generic, look for undergroundwellness
15 'url': 'http://player.cinchcast.com/?platformId=1&#038;assetType=single&#038;assetId=7141703',
16 'only_matching': True,
17 }
18
19 def _real_extract(self, url):
20 video_id = self._match_id(url)
21 doc = self._download_xml(
22 'http://www.blogtalkradio.com/playerasset/mrss?assetType=single&assetId=%s' % video_id,
23 video_id)
24
25 item = doc.find('.//item')
26 title = xpath_text(item, './title', fatal=True)
27 date_str = xpath_text(
28 item, './{http://developer.longtailvideo.com/trac/}date')
29 upload_date = unified_strdate(date_str, day_first=False)
30 # duration is present but wrong
31 formats = [{
32 'format_id': 'main',
33 'url': item.find('./{http://search.yahoo.com/mrss/}content').attrib['url'],
34 }]
35 backup_url = xpath_text(
36 item, './{http://developer.longtailvideo.com/trac/}backupContent')
37 if backup_url:
38 formats.append({
39 'preference': 2, # seems to be more reliable
40 'format_id': 'backup',
41 'url': backup_url,
42 })
43 self._sort_formats(formats)
44
45 return {
46 'id': video_id,
47 'title': title,
48 'upload_date': upload_date,
49 'formats': formats,
50 }