]>
Raphaël G. Git Repositories - youtubedl/blob - youtube_dl/extractor/orf.py
2 from __future__
import unicode_literals
8 from . common
import InfoExtractor
9 from .. compat
import compat_str
22 class ORFTVthekIE ( InfoExtractor
):
23 IE_NAME
= 'orf:tvthek'
24 IE_DESC
= 'ORF TVthek'
25 _VALID_URL
= r
'https?://tvthek\.orf\.at/(?:[^/]+/)+(?P<id>\d+)'
28 'url' : 'http://tvthek.orf.at/program/Aufgetischt/2745173/Aufgetischt-Mit-der-Steirischen-Tafelrunde/8891389' ,
30 'md5' : '2942210346ed779588f428a92db88712' ,
34 'title' : 'Aufgetischt: Mit der Steirischen Tafelrunde' ,
35 'description' : 'md5:c1272f0245537812d4e36419c207b67d' ,
37 'upload_date' : '20141208' ,
40 'skip' : 'Blocked outside of Austria / Germany' ,
42 'url' : 'http://tvthek.orf.at/topic/Im-Wandel-der-Zeit/8002126/Best-of-Ingrid-Thurnher/7982256' ,
46 'title' : 'Best of Ingrid Thurnher' ,
47 'upload_date' : '20140527' ,
48 'description' : 'Viele Jahre war Ingrid Thurnher das "Gesicht" der ZIB 2. Vor ihrem Wechsel zur ZIB 2 im Jahr 1995 moderierte sie unter anderem "Land und Leute", "Österreich-Bild" und "Niederösterreich heute".' ,
51 'skip_download' : True , # rtsp downloads
53 '_skip' : 'Blocked outside of Austria / Germany' ,
55 'url' : 'http://tvthek.orf.at/topic/Fluechtlingskrise/10463081/Heimat-Fremde-Heimat/13879132/Senioren-betreuen-Migrantenkinder/13879141' ,
56 'skip_download' : True ,
58 'url' : 'http://tvthek.orf.at/profile/Universum/35429' ,
59 'skip_download' : True ,
62 def _real_extract ( self
, url
):
63 playlist_id
= self
._ match
_ id
( url
)
64 webpage
= self
._ download
_ webpage
( url
, playlist_id
)
66 data_jsb
= self
._ parse
_ json
(
68 r
'<div[^>]+class=(["\' ]).* ?VideoPlaylist
.* ?\
1 [ ^
>]+ data
- jsb
=([ " \' ])(?P<json>.+?)\2',
69 webpage, 'playlist', group='json'),
70 playlist_id, transform_source=unescapeHTML)['playlist']['videos']
72 def quality_to_int(s):
73 m = re.search('([0-9]+)', s)
76 return int(m.group(1))
80 video_id, title = sd.get('id'), sd.get('title')
81 if not video_id or not title:
83 video_id = compat_str(video_id)
85 'preference': -10 if fd['delivery'] == 'hls' else None,
86 'format_id': ' %s-%s-%s ' % (
87 fd['delivery'], fd['quality'], fd['quality_string']),
89 'protocol': fd['protocol'],
90 'quality': quality_to_int(fd['quality']),
91 } for fd in sd['sources']]
93 # Check for geoblocking.
94 # There is a property is_geoprotection, but that's always false
95 geo_str = sd.get('geoprotection_string')
101 if re.match(r'^https?://.*\.mp4$', f['url']))
102 except StopIteration:
105 req = HEADRequest(http_url)
106 self._request_webpage(
108 note='Testing for geoblocking',
110 'This video seems to be blocked outside of %s . '
111 'You may want to try the streaming-* formats.')
115 self._check_formats(formats, video_id)
116 self._sort_formats(formats)
119 for sub in sd.get('subtitles', []):
120 sub_src = sub.get('src')
123 subtitles.setdefault(sub.get('lang', 'de-AT'), []).append({
127 upload_date = unified_strdate(sd.get('created_date'))
133 'subtitles': subtitles,
134 'description': sd.get('description'),
135 'duration': int_or_none(sd.get('duration_in_seconds')),
136 'upload_date': upload_date,
137 'thumbnail': sd.get('image_full_url'),
147 class ORFOE1IE(InfoExtractor):
149 IE_DESC = 'Radio Österreich 1'
150 _VALID_URL = r'https?://oe1\.orf\.at/(?:programm/|konsole \? .*? \b track_id=)(?P<id>[0-9]+)'
152 # Audios on ORF radio are only available for 7 days, so we can't add tests.
154 'url': 'http://oe1.orf.at/konsole?show=on_demand#?track_id=394211',
155 'only_matching': True,
157 'url': 'http://oe1.orf.at/konsole?show=ondemand&track_id=443608&load_day=/programm/konsole/tag/20160726',
158 'only_matching': True,
161 def _real_extract(self, url):
162 show_id = self._match_id(url)
163 data = self._download_json(
164 'http://oe1.orf.at/programm/ %s /konsole' % show_id,
168 timestamp = datetime.datetime.strptime(' %s %s ' % (
169 data['item']['day_label'],
172 unix_timestamp = calendar.timegm(timestamp.utctimetuple())
176 'title': data['item']['title'],
177 'url': data['item']['url_stream'],
179 'description': data['item'].get('info'),
180 'timestamp': unix_timestamp
184 class ORFFM4IE(InfoExtractor):
186 IE_DESC = 'radio FM4'
187 _VALID_URL = r'https?://fm4\.orf\.at/(?:7tage/?#|player/)(?P<date>[0-9]+)/(?P<show>\w+)'
190 'url': 'http://fm4.orf.at/player/20160110/IS/',
191 'md5': '01e736e8f1cef7e13246e880a59ad298',
193 'id': '2016-01-10_2100_tl_54_7DaysSun13_11244',
196 'description': 'md5:384c543f866c4e422a55f66a62d669cd',
198 'timestamp': 1452456073,
199 'upload_date': '20160110',
201 'skip': 'Live streams on FM4 got deleted soon',
204 def _real_extract(self, url):
205 mobj = re.match(self._VALID_URL, url)
206 show_date = mobj.group('date')
207 show_id = mobj.group('show')
209 data = self._download_json(
210 'http://audioapi.orf.at/fm4/json/2.0/broadcasts/ %s /4 %s ' % (show_date, show_id),
214 def extract_entry_dict(info, title, subtitle):
216 'id': info['loopStreamId'].replace('.mp3', ''),
217 'url': 'http://loopstream01.apa.at/?channel=fm4&id= %s ' % info['loopStreamId'],
219 'description': subtitle,
220 'duration': (info['end'] - info['start']) / 1000,
221 'timestamp': info['start'] / 1000,
225 entries = [extract_entry_dict(t, data['title'], data['subtitle']) for t in data['streams']]
230 'title': data['title'],
231 'description': data['subtitle'],
236 class ORFIPTVIE(InfoExtractor):
238 IE_DESC = 'iptv.ORF.at'
239 _VALID_URL = r'https?://iptv\.orf\.at/(?:#/)?stories/(?P<id>\d+)'
242 'url': 'http://iptv.orf.at/stories/2275236/',
243 'md5': 'c8b22af4718a4b4af58342529453e3e5',
247 'title': 'Weitere Evakuierungen um Vulkan Calbuco',
248 'description': 'md5:d689c959bdbcf04efeddedbf2299d633',
250 'thumbnail': r're:^https?://.*\.jpg$',
251 'upload_date': '20150425',
255 def _real_extract(self, url):
256 story_id = self._match_id(url)
258 webpage = self._download_webpage(
259 'http://iptv.orf.at/stories/ %s ' % story_id, story_id)
261 video_id = self._search_regex(
262 r'data-video(?:id)?=" ( \d
+) "', webpage, 'video id')
264 data = self._download_json(
265 'http://bits.orf.at/filehandler/static-api/json/current/data.json?file= %s ' % video_id,
268 duration = float_or_none(data['duration'], 1000)
270 video = data['sources']['default']
271 load_balancer_url = video['loadBalancerUrl']
272 abr = int_or_none(video.get('audioBitrate'))
273 vbr = int_or_none(video.get('bitrate'))
274 fps = int_or_none(video.get('videoFps'))
275 width = int_or_none(video.get('videoWidth'))
276 height = int_or_none(video.get('videoHeight'))
277 thumbnail = video.get('preview')
279 rendition = self._download_json(
280 load_balancer_url, video_id, transform_source=strip_jsonp)
291 for format_id, format_url in rendition['redirect'].items():
292 if format_id == 'rtmp':
296 'format_id': format_id,
299 elif determine_ext(format_url) == 'f4m':
300 formats.extend(self._extract_f4m_formats(
301 format_url, video_id, f4m_id=format_id))
302 elif determine_ext(format_url) == 'm3u8':
303 formats.extend(self._extract_m3u8_formats(
304 format_url, video_id, 'mp4', m3u8_id=format_id))
307 self._sort_formats(formats)
309 title = remove_end(self._og_search_title(webpage), ' - iptv.ORF.at')
310 description = self._og_search_description(webpage)
311 upload_date = unified_strdate(self._html_search_meta(
312 'dc.date', webpage, 'upload date'))
317 'description': description,
318 'duration': duration,
319 'thumbnail': thumbnail,
320 'upload_date': upload_date,