]> Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tva.py
3ced098f929e4fe155cd28cd28c5610658ad2260
[youtubedl] / youtube_dl / extractor / tva.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5 from ..utils import (
6 int_or_none,
7 parse_iso8601,
8 smuggle_url,
9 )
10
11
12 class TVAIE(InfoExtractor):
13 _VALID_URL = r'https?://videos\.tva\.ca/episode/(?P<id>\d+)'
14 _TEST = {
15 'url': 'http://videos.tva.ca/episode/85538',
16 'info_dict': {
17 'id': '85538',
18 'ext': 'mp4',
19 'title': 'Épisode du 25 janvier 2017',
20 'description': 'md5:e9e7fb5532ab37984d2dc87229cadf98',
21 'upload_date': '20170126',
22 'timestamp': 1485442329,
23 },
24 'params': {
25 # m3u8 download
26 'skip_download': True,
27 }
28 }
29
30 def _real_extract(self, url):
31 video_id = self._match_id(url)
32 video_data = self._download_json(
33 "https://d18jmrhziuoi7p.cloudfront.net/isl/api/v1/dataservice/Items('%s')" % video_id,
34 video_id, query={
35 '$expand': 'Metadata,CustomId',
36 '$select': 'Metadata,Id,Title,ShortDescription,LongDescription,CreatedDate,CustomId,AverageUserRating,Categories,ShowName',
37 '$format': 'json',
38 })
39 metadata = video_data.get('Metadata', {})
40
41 return {
42 '_type': 'url_transparent',
43 'id': video_id,
44 'title': video_data['Title'],
45 'url': smuggle_url('ooyala:' + video_data['CustomId'], {'supportedformats': 'm3u8,hds'}),
46 'description': video_data.get('LongDescription') or video_data.get('ShortDescription'),
47 'series': video_data.get('ShowName'),
48 'episode': metadata.get('EpisodeTitle'),
49 'episode_number': int_or_none(metadata.get('EpisodeNumber')),
50 'categories': video_data.get('Categories'),
51 'average_rating': video_data.get('AverageUserRating'),
52 'timestamp': parse_iso8601(video_data.get('CreatedDate')),
53 'ie_key': 'Ooyala',
54 }