cinchcast.py 1.7 KB

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