logo

youtube-dl

[mirror] Download/Watch videos from video hostersgit clone https://hacktivis.me/git/mirror/youtube-dl.git

callin.py (3068B)


  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import compat_str
  5. from ..utils import (
  6. ExtractorError,
  7. traverse_obj,
  8. try_get,
  9. )
  10. class CallinIE(InfoExtractor):
  11. _VALID_URL = r'https?://(?:www\.)?callin\.com/episode/(?:[^/#?-]+-)*(?P<id>[^/#?-]+)'
  12. _TESTS = [{
  13. 'url': 'https://www.callin.com/episode/fcc-commissioner-brendan-carr-on-elons-PrumRdSQJW',
  14. 'md5': '14ede27ee2c957b7e4db93140fc0745c',
  15. 'info_dict': {
  16. 'id': 'PrumRdSQJW',
  17. 'ext': 'mp4',
  18. 'title': 'FCC Commissioner Brendan Carr on Elon’s Starlink',
  19. 'description': 'Or, why the government doesn’t like SpaceX',
  20. 'channel': 'The Pull Request',
  21. 'channel_url': 'https://callin.com/show/the-pull-request-ucnDJmEKAa',
  22. }
  23. }, {
  24. 'url': 'https://www.callin.com/episode/episode-81-elites-melt-down-over-student-debt-lzxMidUnjA',
  25. 'md5': '16f704ddbf82a27e3930533b12062f07',
  26. 'info_dict': {
  27. 'id': 'lzxMidUnjA',
  28. 'ext': 'mp4',
  29. 'title': 'Episode 81- Elites MELT DOWN over Student Debt Victory? Rumble in NYC?',
  30. 'description': 'Let’s talk todays episode about the primary election shake up in NYC and the elites melting down over student debt cancelation.',
  31. 'channel': 'The DEBRIEF With Briahna Joy Gray',
  32. 'channel_url': 'https://callin.com/show/the-debrief-with-briahna-joy-gray-siiFDzGegm',
  33. }
  34. }]
  35. def _search_nextjs_data(self, webpage, video_id, transform_source=None, fatal=True, **kw):
  36. return self._parse_json(
  37. self._search_regex(
  38. r'(?s)<script[^>]+id=[\'"]__NEXT_DATA__[\'"][^>]*>([^<]+)</script>',
  39. webpage, 'next.js data', fatal=fatal, **kw),
  40. video_id, transform_source=transform_source, fatal=fatal)
  41. def _real_extract(self, url):
  42. video_id = self._match_id(url)
  43. webpage = self._download_webpage(url, video_id)
  44. next_data = self._search_nextjs_data(webpage, video_id)
  45. episode = traverse_obj(next_data, ('props', 'pageProps', 'episode'), expected_type=dict)
  46. if not episode:
  47. raise ExtractorError('Failed to find episode data')
  48. title = episode.get('title') or self._og_search_title(webpage)
  49. description = episode.get('description') or self._og_search_description(webpage)
  50. formats = []
  51. formats.extend(self._extract_m3u8_formats(
  52. episode.get('m3u8'), video_id, 'mp4',
  53. entry_protocol='m3u8_native', fatal=False))
  54. self._sort_formats(formats)
  55. channel = try_get(episode, lambda x: x['show']['title'], compat_str)
  56. channel_url = try_get(episode, lambda x: x['show']['linkObj']['resourceUrl'], compat_str)
  57. return {
  58. 'id': video_id,
  59. 'title': title,
  60. 'description': description,
  61. 'formats': formats,
  62. 'channel': channel,
  63. 'channel_url': channel_url,
  64. }