]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tfo.py
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
15 class TFOIE(InfoExtractor
):
16 _GEO_COUNTRIES
= ['CA']
17 _VALID_URL
= r
'https?://(?:www\.)?tfo\.org/(?:en|fr)/(?:[^/]+/){2}(?P<id>\d+)'
19 'url': 'http://www.tfo.org/en/universe/tfo-247/100463871/video-game-hackathon',
20 'md5': 'cafbe4f47a8dae0ca0159937878100d6',
22 'id': '7da3d50e495c406b8fc0b997659cc075',
24 'title': 'Video Game Hackathon',
25 'description': 'md5:558afeba217c6c8d96c60e5421795c07',
29 def _real_extract(self
, url
):
30 video_id
= self
._match
_id
(url
)
31 self
._request
_webpage
(HEADRequest('http://www.tfo.org/'), video_id
)
32 infos
= self
._download
_json
(
33 'http://www.tfo.org/api/web/video/get_infos', video_id
, data
=json
.dumps({
34 'product_id': video_id
,
35 }).encode(), headers
={
36 'X-tfo-session': self
._get
_cookies
('http://www.tfo.org/')['tfo-session'].value
,
38 if infos
.get('success') == 0:
39 if infos
.get('code') == 'ErrGeoBlocked':
40 self
.raise_geo_restricted(countries
=self
._GEO
_COUNTRIES
)
41 raise ExtractorError('%s said: %s' % (self
.IE_NAME
, clean_html(infos
['msg'])), expected
=True)
42 video_data
= infos
['data']
45 '_type': 'url_transparent',
47 'url': 'limelight:media:' + video_data
['llid'],
48 'title': video_data
['title'],
49 'description': video_data
.get('description'),
50 'series': video_data
.get('collection'),
51 'season_number': int_or_none(video_data
.get('season')),
52 'episode_number': int_or_none(video_data
.get('episode')),
53 'duration': int_or_none(video_data
.get('duration')),
54 'ie_key': 'LimelightMedia',