]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/rts.py
e8199b11446e503897500e0e423b3cbd5d52b441
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
16 class RTSIE(InfoExtractor
):
18 _VALID_URL
= r
'^https?://(?:www\.)?rts\.ch/(?:[^/]+/){2,}(?P<id>[0-9]+)-.*?\.html'
22 'url': 'http://www.rts.ch/archives/tv/divers/3449373-les-enfants-terribles.html',
23 'md5': '753b877968ad8afaeddccc374d4256a5',
28 'title': 'Les Enfants Terribles',
29 'description': 'France Pommier et sa soeur Luce Feral, les deux filles de ce groupe de 5.',
31 'upload_date': '19680921',
32 'timestamp': -40280400,
33 'thumbnail': 're:^https?://.*\.image'
37 'url': 'http://www.rts.ch/emissions/passe-moi-les-jumelles/5624067-entre-ciel-et-mer.html',
38 'md5': 'c148457a27bdc9e5b1ffe081a7a8337b',
43 'title': 'Les yeux dans les cieux - Mon homard au Canada',
44 'description': 'md5:d22ee46f5cc5bac0912e5a0c6d44a9f7',
45 'uploader': 'Passe-moi les jumelles',
46 'upload_date': '20140404',
47 'timestamp': 1396635300,
48 'thumbnail': 're:^https?://.*\.image'
52 'url': 'http://www.rts.ch/video/sport/hockey/5745975-1-2-kloten-fribourg-5-2-second-but-pour-gotteron-par-kwiatowski.html',
53 'md5': 'b4326fecd3eb64a458ba73c73e91299d',
58 'title': '1/2, Kloten - Fribourg (5-2): second but pour Gottéron par Kwiatowski',
59 'description': 'Hockey - Playoff',
61 'upload_date': '20140403',
62 'timestamp': 1396556882,
63 'thumbnail': 're:^https?://.*\.image'
65 'skip': 'Blocked outside Switzerland',
68 'url': 'http://www.rts.ch/video/info/journal-continu/5745356-londres-cachee-par-un-epais-smog.html',
69 'md5': '9bb06503773c07ce83d3cbd793cebb91',
74 'title': 'Londres cachée par un épais smog',
75 'description': 'Un important voile de smog recouvre Londres depuis mercredi, provoqué par la pollution et du sable du Sahara.',
76 'uploader': 'Le Journal en continu',
77 'upload_date': '20140403',
78 'timestamp': 1396537322,
79 'thumbnail': 're:^https?://.*\.image'
83 'url': 'http://www.rts.ch/audio/couleur3/programmes/la-belle-video-de-stephane-laurenceau/5706148-urban-hippie-de-damien-krisl-03-04-2014.html',
84 'md5': 'dd8ef6a22dff163d063e2a52bc8adcae',
89 'title': '"Urban Hippie", de Damien Krisl',
90 'description': 'Des Hippies super glam.',
91 'upload_date': '20140403',
92 'timestamp': 1396551600,
97 def _real_extract(self
, url
):
98 m
= re
.match(self
._VALID
_URL
, url
)
99 video_id
= m
.group('id')
101 def download_json(internal_id
):
102 return self
._download
_json
(
103 'http://www.rts.ch/a/%s.html?f=json/article' % internal_id
,
106 all_info
= download_json(video_id
)
108 # video_id extracted out of URL is not always a real id
109 if 'video' not in all_info
and 'audio' not in all_info
:
110 page
= self
._download
_webpage
(url
, video_id
)
111 internal_id
= self
._html
_search
_regex
(
112 r
'<(?:video|audio) data-id="([0-9]+)"', page
,
114 all_info
= download_json(internal_id
)
116 info
= all_info
['video']['JSONinfo'] if 'video' in all_info
else all_info
['audio']
118 upload_timestamp
= parse_iso8601(info
.get('broadcast_date'))
119 duration
= info
.get('duration') or info
.get('cutout') or info
.get('cutduration')
120 if isinstance(duration
, compat_str
):
121 duration
= parse_duration(duration
)
122 view_count
= info
.get('plays')
123 thumbnail
= unescapeHTML(info
.get('preview_image_url'))
125 def extract_bitrate(url
):
126 return int_or_none(self
._search
_regex
(
127 r
'-([0-9]+)k\.', url
, 'bitrate', default
=None))
132 'tbr': extract_bitrate(furl
),
133 } for fid
, furl
in info
['streams'].items()]
137 'format_id': '%s-%sk' % (media
['ext'], media
['rate']),
138 'url': 'http://download-video.rts.ch/%s' % media
['url'],
139 'tbr': media
['rate'] or extract_bitrate(media
['url']),
140 } for media
in info
['media'] if media
.get('rate')])
142 self
._sort
_formats
(formats
)
147 'title': info
['title'],
148 'description': info
.get('intro'),
149 'duration': duration
,
150 'view_count': view_count
,
151 'uploader': info
.get('programName'),
152 'timestamp': upload_timestamp
,
153 'thumbnail': thumbnail
,