cinchcast.py 2.0 KB

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