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.

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