libsyn.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. # encoding: utf-8
  2. from .common import InfoExtractor
  3. from ..utils import (
  4. unified_strdate,
  5. )
  6. class LibsynIE(InfoExtractor):
  7. _VALID_URL = r'(?:https?:)?//html5-player\.libsyn\.com/embed/episode/id/(?P<id>[0-9]+)(?:/.*)?'
  8. _TESTS = [{
  9. 'url': "http://html5-player.libsyn.com/embed/episode/id/3377616/",
  10. 'info_dict': {
  11. 'id': "3377616",
  12. 'ext': "mp3",
  13. 'title': "Episode 12: Bassem Youssef: Egypt's Jon Stewart",
  14. 'description': "<p>Bassem Youssef joins executive producer Steve Bodow and senior producer Sara Taksler for a conversation about how&nbsp;<em style=\"font-family: Tahoma, Geneva, sans-serif; font-size: 12.8000001907349px;\">The Daily Show</em>&nbsp;inspired Bassem to create&nbsp;<em style=\"font-family: Tahoma, Geneva, sans-serif; font-size: 12.8000001907349px;\">Al-Bernameg</em>, his massively popular (and now banned) Egyptian news satire program. Sara discusses her soon-to-be-released documentary,&nbsp;<em style=\"font-family: Tahoma, Geneva, sans-serif; font-size: 12.8000001907349px;\">Tickling Giants</em>, which chronicles how Bassem and his staff risked their safety every day to tell jokes.</p>",
  15. },
  16. }]
  17. def _real_extract(self, url):
  18. if url.startswith('//'):
  19. url = 'https:' + url
  20. display_id = self._match_id(url)
  21. webpage = self._download_webpage(url, display_id)
  22. podcast_title = self._search_regex(r'<h2>(.*?)</h2>', webpage, 'show title')
  23. podcast_episode_title = self._search_regex(r'<h3>(.*?)</h3>', webpage, 'episode title')
  24. podcast_date = unified_strdate(self._search_regex(r'<div class="release_date">Released: (.*?)</div>', webpage, 'release date'))
  25. podcast_description = self._search_regex(r'<div id="info_text_body">(.*?)</div>', webpage, 'description')
  26. url0 = self._search_regex(r'var mediaURLLibsyn = "(?P<url0>https?://.*)";', webpage, 'first media URL')
  27. url1 = self._search_regex(r'var mediaURL = "(?P<url1>https?://.*)";', webpage, 'second media URL')
  28. if url0 != url1:
  29. formats = [{
  30. 'url': url0
  31. }, {
  32. 'url': url1
  33. }]
  34. else:
  35. formats = [{
  36. 'url': url0
  37. }]
  38. return {
  39. 'id': display_id,
  40. 'title': podcast_episode_title,
  41. 'description': podcast_description,
  42. 'upload_date': podcast_date,
  43. 'formats': formats,
  44. }