logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

tva.py (3141B)


  1. import re
  2. from .brightcove import BrightcoveNewIE
  3. from .common import InfoExtractor
  4. from ..utils import float_or_none, int_or_none, smuggle_url, strip_or_none
  5. from ..utils.traversal import traverse_obj
  6. class TVAIE(InfoExtractor):
  7. IE_NAME = 'tvaplus'
  8. IE_DESC = 'TVA+'
  9. _VALID_URL = r'https?://(?:www\.)?tvaplus\.ca/(?:[^/?#]+/)*[\w-]+-(?P<id>\d+)(?:$|[#?])'
  10. _TESTS = [{
  11. 'url': 'https://www.tvaplus.ca/tva/alerte-amber/saison-1/episode-01-1000036619',
  12. 'md5': '949490fd0e7aee11d0543777611fbd53',
  13. 'info_dict': {
  14. 'id': '6084352463001',
  15. 'ext': 'mp4',
  16. 'title': 'Mon dernier jour',
  17. 'uploader_id': '5481942443001',
  18. 'upload_date': '20190907',
  19. 'timestamp': 1567899756,
  20. 'description': 'md5:9c0d7fbb90939420c651fd977df90145',
  21. 'thumbnail': r're:https://.+\.jpg',
  22. 'episode': 'Mon dernier jour',
  23. 'episode_number': 1,
  24. 'tags': ['alerte amber', 'alerte amber saison 1', 'surdemande'],
  25. 'duration': 2625.963,
  26. 'season': 'Season 1',
  27. 'season_number': 1,
  28. 'series': 'Alerte Amber',
  29. 'channel': 'TVA',
  30. },
  31. }, {
  32. 'url': 'https://www.tvaplus.ca/tva/le-baiser-du-barbu/le-baiser-du-barbu-886644190',
  33. 'info_dict': {
  34. 'id': '6354448043112',
  35. 'ext': 'mp4',
  36. 'title': 'Le Baiser du barbu',
  37. 'uploader_id': '5481942443001',
  38. 'upload_date': '20240606',
  39. 'timestamp': 1717694023,
  40. 'description': 'md5:025b1219086c1cbf4bc27e4e034e8b57',
  41. 'thumbnail': r're:https://.+\.jpg',
  42. 'episode': 'Le Baiser du barbu',
  43. 'tags': ['fullepisode', 'films'],
  44. 'duration': 6053.504,
  45. 'series': 'Le Baiser du barbu',
  46. 'channel': 'TVA',
  47. },
  48. }]
  49. _BC_URL_TMPL = 'https://players.brightcove.net/5481942443001/default_default/index.html?videoId={}'
  50. def _real_extract(self, url):
  51. entity_id = self._match_id(url)
  52. webpage = self._download_webpage(url, entity_id)
  53. entity = self._search_nextjs_data(webpage, entity_id)['props']['pageProps']['staticEntity']
  54. video_id = entity['videoId']
  55. episode = strip_or_none(entity.get('name'))
  56. return {
  57. '_type': 'url_transparent',
  58. 'url': smuggle_url(self._BC_URL_TMPL.format(video_id), {'geo_countries': ['CA']}),
  59. 'ie_key': BrightcoveNewIE.ie_key(),
  60. 'id': video_id,
  61. 'title': episode,
  62. 'episode': episode,
  63. **traverse_obj(entity, {
  64. 'description': ('longDescription', {str}),
  65. 'duration': ('durationMillis', {float_or_none(scale=1000)}),
  66. 'channel': ('knownEntities', 'channel', 'name', {str}),
  67. 'series': ('knownEntities', 'videoShow', 'name', {str}),
  68. 'season_number': ('slug', {lambda x: re.search(r'/s(?:ai|ea)son-(\d+)/', x)}, 1, {int_or_none}),
  69. 'episode_number': ('episodeNumber', {int_or_none}),
  70. }),
  71. }