]> Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/cinchcast.py
Annotate changelog with bug being closed.
[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|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 }, {
22 # Actual test is run in generic, look for undergroundwellness
23 'url': 'http://player.cinchcast.com/?platformId=1&#038;assetType=single&#038;assetId=7141703',
24 'only_matching': True,
25 }]
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
39 formats = [{
40 'format_id': 'main',
41 'url': item.find('./{http://search.yahoo.com/mrss/}content').attrib['url'],
42 }]
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 }