]>
Raphaƫl G. Git Repositories - youtubedl/blob - youtube_dl/extractor/tubitv.py
c44018aec39c56eb4b8dccc8b4d001f783e2a19d
2 from __future__
import unicode_literals
6 from .common
import InfoExtractor
15 class TubiTvIE(InfoExtractor
):
16 _VALID_URL
= r
'https?://(?:www\.)?tubitv\.com/video/(?P<id>[0-9]+)'
17 _LOGIN_URL
= 'http://tubitv.com/login'
18 _NETRC_MACHINE
= 'tubitv'
19 _GEO_COUNTRIES
= ['US']
21 'url': 'http://tubitv.com/video/283829/the_comedian_at_the_friday',
22 'md5': '43ac06be9326f41912dc64ccf7a80320',
26 'title': 'The Comedian at The Friday',
27 'description': 'A stand up comedian is forced to look at the decisions in his life while on a one week trip to the west coast.',
28 'uploader_id': 'bc168bee0d18dd1cb3b86c68706ab434',
33 (username
, password
) = self
._get
_login
_info
()
41 payload
= urlencode_postdata(form_data
)
42 request
= sanitized_Request(self
._LOGIN
_URL
, payload
)
43 request
.add_header('Content-Type', 'application/x-www-form-urlencoded')
44 login_page
= self
._download
_webpage
(
45 request
, None, False, 'Wrong login info')
46 if not re
.search(r
'id="tubi-logout"', login_page
):
48 'Login failed (invalid username/password)', expected
=True)
50 def _real_initialize(self
):
53 def _real_extract(self
, url
):
54 video_id
= self
._match
_id
(url
)
55 video_data
= self
._download
_json
(
56 'http://tubitv.com/oz/videos/%s/content' % video_id
, video_id
)
57 title
= video_data
['title']
59 formats
= self
._extract
_m
3u8_formats
(
60 self
._proto
_relative
_url
(video_data
['url']),
61 video_id
, 'mp4', 'm3u8_native')
62 self
._sort
_formats
(formats
)
65 for thumbnail_url
in video_data
.get('thumbnails', []):
69 'url': self
._proto
_relative
_url
(thumbnail_url
),
73 for sub
in video_data
.get('subtitles', []):
74 sub_url
= sub
.get('url')
77 subtitles
.setdefault(sub
.get('lang', 'English'), []).append({
78 'url': self
._proto
_relative
_url
(sub_url
),
85 'subtitles': subtitles
,
86 'thumbnails': thumbnails
,
87 'description': video_data
.get('description'),
88 'duration': int_or_none(video_data
.get('duration')),
89 'uploader_id': video_data
.get('publisher_id'),