]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/rts.py
5e84c109802e34ce8f57496ee3b7e2cd409c0788
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
18 class RTSIE(InfoExtractor
):
20 _VALID_URL
= r
'https?://(?:www\.)?rts\.ch/(?:(?:[^/]+/){2,}(?P<id>[0-9]+)-(?P<display_id>.+?)\.html|play/tv/[^/]+/video/(?P<display_id_new>.+?)\?id=(?P<id_new>[0-9]+))'
24 'url': 'http://www.rts.ch/archives/tv/divers/3449373-les-enfants-terribles.html',
25 'md5': '753b877968ad8afaeddccc374d4256a5',
28 'display_id': 'les-enfants-terribles',
31 'title': 'Les Enfants Terribles',
32 'description': 'France Pommier et sa soeur Luce Feral, les deux filles de ce groupe de 5.',
34 'upload_date': '19680921',
35 'timestamp': -40280400,
36 'thumbnail': 're:^https?://.*\.image',
41 'url': 'http://www.rts.ch/emissions/passe-moi-les-jumelles/5624067-entre-ciel-et-mer.html',
42 'md5': 'c148457a27bdc9e5b1ffe081a7a8337b',
45 'display_id': 'entre-ciel-et-mer',
48 'title': 'Les yeux dans les cieux - Mon homard au Canada',
49 'description': 'md5:d22ee46f5cc5bac0912e5a0c6d44a9f7',
50 'uploader': 'Passe-moi les jumelles',
51 'upload_date': '20140404',
52 'timestamp': 1396635300,
53 'thumbnail': 're:^https?://.*\.image',
58 'url': 'http://www.rts.ch/video/sport/hockey/5745975-1-2-kloten-fribourg-5-2-second-but-pour-gotteron-par-kwiatowski.html',
59 'md5': 'b4326fecd3eb64a458ba73c73e91299d',
62 'display_id': '1-2-kloten-fribourg-5-2-second-but-pour-gotteron-par-kwiatowski',
65 'title': '1/2, Kloten - Fribourg (5-2): second but pour Gottéron par Kwiatowski',
66 'description': 'Hockey - Playoff',
68 'upload_date': '20140403',
69 'timestamp': 1396556882,
70 'thumbnail': 're:^https?://.*\.image',
73 'skip': 'Blocked outside Switzerland',
76 'url': 'http://www.rts.ch/video/info/journal-continu/5745356-londres-cachee-par-un-epais-smog.html',
77 'md5': '9bb06503773c07ce83d3cbd793cebb91',
80 'display_id': 'londres-cachee-par-un-epais-smog',
83 'title': 'Londres cachée par un épais smog',
84 'description': 'Un important voile de smog recouvre Londres depuis mercredi, provoqué par la pollution et du sable du Sahara.',
85 'uploader': 'Le Journal en continu',
86 'upload_date': '20140403',
87 'timestamp': 1396537322,
88 'thumbnail': 're:^https?://.*\.image',
93 'url': 'http://www.rts.ch/audio/couleur3/programmes/la-belle-video-de-stephane-laurenceau/5706148-urban-hippie-de-damien-krisl-03-04-2014.html',
94 'md5': 'dd8ef6a22dff163d063e2a52bc8adcae',
97 'display_id': 'urban-hippie-de-damien-krisl-03-04-2014',
100 'title': '"Urban Hippie", de Damien Krisl',
101 'description': 'Des Hippies super glam.',
102 'upload_date': '20140403',
103 'timestamp': 1396551600,
107 'url': 'http://www.rts.ch/play/tv/-/video/le-19h30?id=6348260',
108 'md5': '968777c8779e5aa2434be96c54e19743',
111 'display_id': 'le-19h30',
116 'uploader': 'Le 19h30',
117 'upload_date': '20141201',
118 'timestamp': 1417458600,
119 'thumbnail': 're:^https?://.*\.image',
124 'url': 'http://www.rts.ch/play/tv/le-19h30/video/le-chantier-du-nouveau-parlement-vaudois-a-permis-une-trouvaille-historique?id=6348280',
125 'only_matching': True,
129 def _real_extract(self
, url
):
130 m
= re
.match(self
._VALID
_URL
, url
)
131 video_id
= m
.group('id') or m
.group('id_new')
132 display_id
= m
.group('display_id') or m
.group('display_id_new')
134 def download_json(internal_id
):
135 return self
._download
_json
(
136 'http://www.rts.ch/a/%s.html?f=json/article' % internal_id
,
139 all_info
= download_json(video_id
)
141 # video_id extracted out of URL is not always a real id
142 if 'video' not in all_info
and 'audio' not in all_info
:
143 page
= self
._download
_webpage
(url
, display_id
)
144 internal_id
= self
._html
_search
_regex
(
145 r
'<(?:video|audio) data-id="([0-9]+)"', page
,
147 all_info
= download_json(internal_id
)
149 info
= all_info
['video']['JSONinfo'] if 'video' in all_info
else all_info
['audio']
151 upload_timestamp
= parse_iso8601(info
.get('broadcast_date'))
152 duration
= info
.get('duration') or info
.get('cutout') or info
.get('cutduration')
153 if isinstance(duration
, compat_str
):
154 duration
= parse_duration(duration
)
155 view_count
= info
.get('plays')
156 thumbnail
= unescapeHTML(info
.get('preview_image_url'))
158 def extract_bitrate(url
):
159 return int_or_none(self
._search
_regex
(
160 r
'-([0-9]+)k\.', url
, 'bitrate', default
=None))
165 'tbr': extract_bitrate(furl
),
166 } for fid
, furl
in info
['streams'].items()]
170 'format_id': '%s-%sk' % (media
['ext'], media
['rate']),
171 'url': 'http://download-video.rts.ch/%s' % media
['url'],
172 'tbr': media
['rate'] or extract_bitrate(media
['url']),
173 } for media
in info
['media'] if media
.get('rate')])
175 self
._sort
_formats
(formats
)
179 'display_id': display_id
,
181 'title': info
['title'],
182 'description': info
.get('intro'),
183 'duration': duration
,
184 'view_count': view_count
,
185 'uploader': info
.get('programName'),
186 'timestamp': upload_timestamp
,
187 'thumbnail': thumbnail
,