]>
jfr.im git - yt-dlp.git/blob - youtube_dlc/extractor/twitcasting.py
2 from __future__
import unicode_literals
6 from . common
import InfoExtractor
19 class TwitCastingIE ( InfoExtractor
):
20 _VALID_URL
= r
'https?://(?:[^/]+\.)?twitcasting\.tv/(?P<uploader_id>[^/]+)/movie/(?P<id>\d+)'
22 'url' : 'https://twitcasting.tv/ivetesangalo/movie/2357609' ,
23 'md5' : '745243cad58c4681dc752490f7540d7f' ,
27 'title' : 'Live #2357609' ,
28 'uploader_id' : 'ivetesangalo' ,
29 'description' : 'Twitter Oficial da cantora brasileira Ivete Sangalo.' ,
30 'thumbnail' : r
're:^https?://.*\.jpg$' ,
31 'upload_date' : '20110822' ,
32 'timestamp' : 1314010824 ,
37 'skip_download' : True ,
40 'url' : 'https://twitcasting.tv/mttbernardini/movie/3689740' ,
44 'title' : 'Live playing something #3689740' ,
45 'uploader_id' : 'mttbernardini' ,
46 'description' : 'Salve, io sono Matto (ma con la e). Questa è la mia presentazione, in quanto sono letteralmente matto (nel senso di strano), con qualcosa in più.' ,
47 'thumbnail' : r
're:^https?://.*\.jpg$' ,
48 'upload_date' : '20120212' ,
49 'timestamp' : 1329028024 ,
54 'skip_download' : True ,
55 'videopassword' : 'abc' ,
59 def _real_extract ( self
, url
):
60 uploader_id
, video_id
= re
. match ( self
._ VALID
_U RL
, url
). groups ()
62 video_password
= self
._ downloader
. params
. get ( 'videopassword' )
65 request_data
= urlencode_postdata ({
66 'password' : video_password
,
68 webpage
= self
._ download
_ webpage
( url
, video_id
, data
= request_data
)
70 title
= clean_html ( get_element_by_id (
71 'movietitle' , webpage
)) or self
._ html
_ search
_ meta
(
72 [ 'og:title' , 'twitter:title' ], webpage
, fatal
= True )
75 m3u8_url
= self
._ search
_ regex
(
76 r
'data-movie-url=(["\' ])( ?P
< url
>( ?
:( ?
! \
1 ).)+) \
1 ',
77 webpage, ' m3u8 url
', group=' url
', default=None)
79 video_js_data = self._parse_json(self._search_regex(
80 r"data-movie-playlist=' ( \
[[ ^
']+\])' ",
81 webpage, 'movie playlist'), video_id)[0]
82 m3u8_url = video_js_data['source']['url']
84 # use `m3u8` entry_protocol until EXT-X-MAP is properly supported by `m3u8_native` entry_protocol
85 formats = self._extract_m3u8_formats(
86 m3u8_url, video_id, 'mp4', m3u8_id='hls')
88 thumbnail = video_js_data.get('thumbnailUrl') or self._og_search_thumbnail(webpage)
89 description = clean_html(get_element_by_id(
90 'authorcomment', webpage)) or self._html_search_meta(
91 ['description', 'og:description', 'twitter:description'], webpage)
92 duration = float_or_none(video_js_data.get(
93 'duration'), 1000) or parse_duration(clean_html(
94 get_element_by_class('tw-player-duration-time', webpage)))
95 view_count = str_to_int(self._search_regex(
96 r'Total\s*:\s*([\d,]+)\s*Views', webpage, 'views', None))
97 timestamp = unified_timestamp(self._search_regex(
98 r'data-toggle=" true
"[^>]+datetime=" ([ ^
"]+)" ',
99 webpage, ' datetime
', None))
104 ' description
': description,
105 ' thumbnail
': thumbnail,
106 ' timestamp
': timestamp,
107 ' uploader_id
': uploader_id,
108 ' duration
': duration,
109 ' view_count
': view_count,