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.

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