stitcher.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import int_or_none
  5. class StitcherIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?stitcher\.com/podcast/[\/a-z\-]+(?P<id>\d+)'
  7. _TEST = {
  8. 'url': 'http://www.stitcher.com/podcast/the-talking-machines/e/40789481?autoplay=true',
  9. 'md5': '391dd4e021e6edeb7b8e68fbf2e9e940',
  10. 'info_dict': {
  11. 'id': '40789481',
  12. 'ext': 'mp3',
  13. 'title': 'Machine Learning Mastery and Cancer Clusters from Talking Machines',
  14. }
  15. }
  16. def _real_extract(self, url):
  17. audio_id = self._match_id(url)
  18. webpage = self._download_webpage(url, audio_id)
  19. title = self._og_search_title(webpage)
  20. url = self._search_regex(r'episodeURL: "(.+?)"', webpage, 'url')
  21. episode_image = self._search_regex(r'episodeImage: "(.+?)"', webpage, 'episode_image', fatal=False)
  22. duration = int_or_none(self._search_regex(r'duration: (\d+?),', webpage, 'duration', fatal=False))
  23. return {
  24. 'id': audio_id,
  25. 'url': url,
  26. 'title': title,
  27. 'duration': duration,
  28. 'thumbnail': episode_image,
  29. 'ext': 'mp3',
  30. 'vcodec': 'none',
  31. }