aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2014-03-24 01:41:14 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2014-03-24 01:41:14 +0100
commitf70daac108bc28383cfe5c8843f56e7d8c74eb74 (patch)
tree6a4fb22c1fa0a6e1419404ff9fa49e9586acaaee
parent912b38b428e882c1ab79b6537b94b30e3e3c1def (diff)
[RTS] Add extractor (Fixes #2608)
-rw-r--r--youtube_dl/extractor/rts.py61
1 files changed, 61 insertions, 0 deletions
diff --git a/youtube_dl/extractor/rts.py b/youtube_dl/extractor/rts.py
new file mode 100644
index 000000000..f211637a7
--- /dev/null
+++ b/youtube_dl/extractor/rts.py
@@ -0,0 +1,61 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+import re
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+ parse_duration,
+ parse_iso8601,
+ unescapeHTML,
+)
+
+
+class RTSIE(InfoExtractor):
+ IE_DESC = 'RTS.ch'
+ _VALID_URL = r'^https?://(?:www\.)?rts\.ch/archives/tv/[^/]+/(?P<id>[0-9]+)-.*?\.html'
+
+ _TEST = {
+ 'url': 'http://www.rts.ch/archives/tv/divers/3449373-les-enfants-terribles.html',
+ 'md5': '753b877968ad8afaeddccc374d4256a5',
+ 'info_dict': {
+ 'id': '3449373',
+ 'ext': 'mp4',
+ 'duration': 1488,
+ 'title': 'Les Enfants Terribles',
+ 'description': 'France Pommier et sa soeur Luce Feral, les deux filles de ce groupe de 5.',
+ 'uploader': 'Divers',
+ 'upload_date': '19680921',
+ 'timestamp': -40280400,
+ },
+ }
+
+ def _real_extract(self, url):
+ m = re.match(self._VALID_URL, url)
+ video_id = m.group('id')
+
+ all_info = self._download_json(
+ 'http://www.rts.ch/a/%s.html?f=json/article' % video_id, video_id)
+ info = all_info['video']['JSONinfo']
+
+ upload_timestamp = parse_iso8601(info.get('broadcast_date'))
+ duration = parse_duration(info.get('duration'))
+ thumbnail = unescapeHTML(info.get('preview_image_url'))
+ formats = [{
+ 'format_id': fid,
+ 'url': furl,
+ 'tbr': int_or_none(self._search_regex(
+ r'-([0-9]+)k\.', furl, 'bitrate', default=None)),
+ } for fid, furl in info['streams'].items()]
+ self._sort_formats(formats)
+
+ return {
+ 'id': video_id,
+ 'formats': formats,
+ 'title': info['title'],
+ 'description': info.get('intro'),
+ 'duration': duration,
+ 'uploader': info.get('programName'),
+ 'timestamp': upload_timestamp,
+ }