angel.py 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. import re
  2. from .common import InfoExtractor
  3. from ..utils import merge_dicts, url_or_none
  4. class AngelIE(InfoExtractor):
  5. _VALID_URL = r'https?://(?:www\.)?angel\.com/watch/(?P<series>[^/?#]+)/episode/(?P<id>[\w-]+)/season-(?P<season_number>\d+)/episode-(?P<episode_number>\d+)/(?P<title>[^/?#]+)'
  6. _TESTS = [{
  7. 'url': 'https://www.angel.com/watch/tuttle-twins/episode/2f3d0382-ea82-4cdc-958e-84fbadadc710/season-1/episode-1/when-laws-give-you-lemons',
  8. 'md5': '4734e5cfdd64a568e837246aa3eaa524',
  9. 'info_dict': {
  10. 'id': '2f3d0382-ea82-4cdc-958e-84fbadadc710',
  11. 'ext': 'mp4',
  12. 'title': 'Tuttle Twins Season 1, Episode 1: When Laws Give You Lemons',
  13. 'description': 'md5:73b704897c20ab59c433a9c0a8202d5e',
  14. 'thumbnail': r're:^https?://images.angelstudios.com/image/upload/angel-app/.*$',
  15. 'duration': 1359.0,
  16. },
  17. }, {
  18. 'url': 'https://www.angel.com/watch/the-chosen/episode/8dfb714d-bca5-4812-8125-24fb9514cd10/season-1/episode-1/i-have-called-you-by-name',
  19. 'md5': 'e4774bad0a5f0ad2e90d175cafdb797d',
  20. 'info_dict': {
  21. 'id': '8dfb714d-bca5-4812-8125-24fb9514cd10',
  22. 'ext': 'mp4',
  23. 'title': 'The Chosen Season 1, Episode 1: I Have Called You By Name',
  24. 'description': 'md5:aadfb4827a94415de5ff6426e6dee3be',
  25. 'thumbnail': r're:^https?://images.angelstudios.com/image/upload/angel-app/.*$',
  26. 'duration': 3276.0,
  27. },
  28. }]
  29. def _real_extract(self, url):
  30. video_id = self._match_id(url)
  31. webpage = self._download_webpage(url, video_id)
  32. json_ld = self._search_json_ld(webpage, video_id)
  33. formats, subtitles = self._extract_m3u8_formats_and_subtitles(
  34. json_ld.pop('url'), video_id, note='Downloading HD m3u8 information')
  35. info_dict = {
  36. 'id': video_id,
  37. 'title': self._og_search_title(webpage),
  38. 'description': self._og_search_description(webpage),
  39. 'formats': formats,
  40. 'subtitles': subtitles,
  41. }
  42. # Angel uses cloudinary in the background and supports image transformations.
  43. # We remove these transformations and return the source file
  44. base_thumbnail_url = url_or_none(self._og_search_thumbnail(webpage)) or json_ld.pop('thumbnails')
  45. if base_thumbnail_url:
  46. info_dict['thumbnail'] = re.sub(r'(/upload)/.+(/angel-app/.+)$', r'\1\2', base_thumbnail_url)
  47. return merge_dicts(info_dict, json_ld)