youtube-dl

Another place where youtube-dl lives on
git clone git://git.oshgnacknak.de/youtube-dl.git
Log | Files | Refs | README | LICENSE

tva.py (3158B)


      1 # coding: utf-8
      2 from __future__ import unicode_literals
      3 
      4 from .common import InfoExtractor
      5 from ..utils import (
      6     float_or_none,
      7     int_or_none,
      8     smuggle_url,
      9     strip_or_none,
     10 )
     11 
     12 
     13 class TVAIE(InfoExtractor):
     14     _VALID_URL = r'https?://videos?\.tva\.ca/details/_(?P<id>\d+)'
     15     _TESTS = [{
     16         'url': 'https://videos.tva.ca/details/_5596811470001',
     17         'info_dict': {
     18             'id': '5596811470001',
     19             'ext': 'mp4',
     20             'title': 'Un extrait de l\'Ă©pisode du dimanche 8 octobre 2017 !',
     21             'uploader_id': '5481942443001',
     22             'upload_date': '20171003',
     23             'timestamp': 1507064617,
     24         },
     25         'params': {
     26             # m3u8 download
     27             'skip_download': True,
     28         },
     29         'skip': 'HTTP Error 404: Not Found',
     30     }, {
     31         'url': 'https://video.tva.ca/details/_5596811470001',
     32         'only_matching': True,
     33     }]
     34     BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5481942443001/default_default/index.html?videoId=%s'
     35 
     36     def _real_extract(self, url):
     37         video_id = self._match_id(url)
     38 
     39         return {
     40             '_type': 'url_transparent',
     41             'id': video_id,
     42             'url': smuggle_url(self.BRIGHTCOVE_URL_TEMPLATE % video_id, {'geo_countries': ['CA']}),
     43             'ie_key': 'BrightcoveNew',
     44         }
     45 
     46 
     47 class QubIE(InfoExtractor):
     48     _VALID_URL = r'https?://(?:www\.)?qub\.ca/(?:[^/]+/)*[0-9a-z-]+-(?P<id>\d+)'
     49     _TESTS = [{
     50         'url': 'https://www.qub.ca/tvaplus/tva/alerte-amber/saison-1/episode-01-1000036619',
     51         'md5': '949490fd0e7aee11d0543777611fbd53',
     52         'info_dict': {
     53             'id': '6084352463001',
     54             'ext': 'mp4',
     55             'title': 'Épisode 01',
     56             'uploader_id': '5481942443001',
     57             'upload_date': '20190907',
     58             'timestamp': 1567899756,
     59             'description': 'md5:9c0d7fbb90939420c651fd977df90145',
     60         },
     61     }, {
     62         'url': 'https://www.qub.ca/tele/video/lcn-ca-vous-regarde-rev-30s-ap369664-1009357943',
     63         'only_matching': True,
     64     }]
     65     # reference_id also works with old account_id(5481942443001)
     66     # BRIGHTCOVE_URL_TEMPLATE = 'http://players.brightcove.net/5813221784001/default_default/index.html?videoId=ref:%s'
     67 
     68     def _real_extract(self, url):
     69         entity_id = self._match_id(url)
     70         entity = self._download_json(
     71             'https://www.qub.ca/proxy/pfu/content-delivery-service/v1/entities',
     72             entity_id, query={'id': entity_id})
     73         video_id = entity['videoId']
     74         episode = strip_or_none(entity.get('name'))
     75 
     76         return {
     77             '_type': 'url_transparent',
     78             'id': video_id,
     79             'title': episode,
     80             # 'url': self.BRIGHTCOVE_URL_TEMPLATE % entity['referenceId'],
     81             'url': 'https://videos.tva.ca/details/_' + video_id,
     82             'description': entity.get('longDescription'),
     83             'duration': float_or_none(entity.get('durationMillis'), 1000),
     84             'episode': episode,
     85             'episode_number': int_or_none(entity.get('episodeNumber')),
     86             # 'ie_key': 'BrightcoveNew',
     87             'ie_key': TVAIE.ie_key(),
     88         }