[extractor/twitcasting] Fix videos with password (#5894)

Closes #5888
Authored by: bashonly, Spicadox
This commit is contained in:
Sam 2022-12-29 06:15:38 -05:00 committed by GitHub
parent 153e88a751
commit 9a9006ba20
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 22 additions and 12 deletions

View File

@ -38,7 +38,7 @@ class TwitCastingIE(InfoExtractor):
'description': 'Twitter Oficial da cantora brasileira Ivete Sangalo.', 'description': 'Twitter Oficial da cantora brasileira Ivete Sangalo.',
'thumbnail': r're:^https?://.*\.jpg$', 'thumbnail': r're:^https?://.*\.jpg$',
'upload_date': '20110822', 'upload_date': '20110822',
'timestamp': 1314010824, 'timestamp': 1313978424,
'duration': 32, 'duration': 32,
'view_count': int, 'view_count': int,
}, },
@ -52,10 +52,10 @@ class TwitCastingIE(InfoExtractor):
'ext': 'mp4', 'ext': 'mp4',
'title': 'Live playing something #3689740', 'title': 'Live playing something #3689740',
'uploader_id': 'mttbernardini', 'uploader_id': 'mttbernardini',
'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ù.', 'description': 'md5:1dc7efa2f1ab932fcd119265cebeec69',
'thumbnail': r're:^https?://.*\.jpg$', 'thumbnail': r're:^https?://.*\.jpg$',
'upload_date': '20120212', 'upload_date': '20120211',
'timestamp': 1329028024, 'timestamp': 1328995624,
'duration': 681, 'duration': 681,
'view_count': int, 'view_count': int,
}, },
@ -64,15 +64,22 @@ class TwitCastingIE(InfoExtractor):
'videopassword': 'abc', 'videopassword': 'abc',
}, },
}, { }, {
'note': 'archive is split in 2 parts',
'url': 'https://twitcasting.tv/loft_heaven/movie/685979292', 'url': 'https://twitcasting.tv/loft_heaven/movie/685979292',
'info_dict': { 'info_dict': {
'id': '685979292', 'id': '685979292',
'ext': 'mp4', 'ext': 'mp4',
'title': '南波一海のhear_here “ナタリー望月哲さんに聞く編集と「渋谷系狂騒曲」”', 'title': '【無料配信】南波一海のhear/here “ナタリー望月哲さんに聞く編集と「渋谷系狂騒曲」”',
'duration': 6964.599334, 'uploader_id': 'loft_heaven',
'description': 'md5:3a0c7b53019df987ce545c935538bacf',
'upload_date': '20210604',
'timestamp': 1622802114,
'thumbnail': r're:^https?://.*\.jpg$',
'duration': 6964,
'view_count': int,
},
'params': {
'skip_download': True,
}, },
'playlist_mincount': 2,
}] }]
def _parse_data_movie_playlist(self, dmp, video_id): def _parse_data_movie_playlist(self, dmp, video_id):
@ -88,15 +95,18 @@ class TwitCastingIE(InfoExtractor):
def _real_extract(self, url): def _real_extract(self, url):
uploader_id, video_id = self._match_valid_url(url).groups() uploader_id, video_id = self._match_valid_url(url).groups()
webpage, urlh = self._download_webpage_handle(url, video_id)
video_password = self.get_param('videopassword') video_password = self.get_param('videopassword')
request_data = None request_data = None
if video_password: if video_password:
request_data = urlencode_postdata({ request_data = urlencode_postdata({
'password': video_password, 'password': video_password,
**self._hidden_inputs(webpage),
}, encoding='utf-8') }, encoding='utf-8')
webpage, urlh = self._download_webpage_handle( webpage, urlh = self._download_webpage_handle(
url, video_id, data=request_data, url, video_id, data=request_data,
headers={'Origin': 'https://twitcasting.tv'}) headers={'Origin': 'https://twitcasting.tv'},
note='Trying video password')
if urlh.geturl() != url and request_data: if urlh.geturl() != url and request_data:
webpage = self._download_webpage( webpage = self._download_webpage(
urlh.geturl(), video_id, data=request_data, urlh.geturl(), video_id, data=request_data,
@ -122,7 +132,7 @@ class TwitCastingIE(InfoExtractor):
duration = (try_get(video_js_data, lambda x: sum(float_or_none(y.get('duration')) for y in x) / 1000) duration = (try_get(video_js_data, lambda x: sum(float_or_none(y.get('duration')) for y in x) / 1000)
or parse_duration(clean_html(get_element_by_class('tw-player-duration-time', webpage)))) or parse_duration(clean_html(get_element_by_class('tw-player-duration-time', webpage))))
view_count = str_to_int(self._search_regex( view_count = str_to_int(self._search_regex(
(r'Total\s*:\s*([\d,]+)\s*Views', r'総視聴者\s*:\s*([\d,]+)\s*</'), webpage, 'views', None)) (r'Total\s*:\s*Views\s*([\d,]+)', r'総視聴者\s*:\s*([\d,]+)\s*</'), webpage, 'views', None))
timestamp = unified_timestamp(self._search_regex( timestamp = unified_timestamp(self._search_regex(
r'data-toggle="true"[^>]+datetime="([^"]+)"', r'data-toggle="true"[^>]+datetime="([^"]+)"',
webpage, 'datetime', None)) webpage, 'datetime', None))