You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

52 lines
1.7 KiB

  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 = []
  27. formats.append({
  28. 'format_id': 'main',
  29. 'url': item.find(
  30. './{http://search.yahoo.com/mrss/}content').attrib['url'],
  31. })
  32. backup_url = xpath_text(
  33. item, './{http://developer.longtailvideo.com/trac/}backupContent')
  34. if backup_url:
  35. formats.append({
  36. 'preference': 2, # seems to be more reliable
  37. 'format_id': 'backup',
  38. 'url': backup_url,
  39. })
  40. self._sort_formats(formats)
  41. return {
  42. 'id': video_id,
  43. 'title': title,
  44. 'upload_date': upload_date,
  45. 'formats': formats,
  46. }