cinchcast.py 1.6 KB

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