[TVer] Improve extraction (#3634)

Authored by: Lesmiscore
This commit is contained in:
Lesmiscore 2022-05-04 23:16:56 +09:00 committed by GitHub
parent f963b7ab18
commit b58f8d8f2c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,8 +1,10 @@
from .common import InfoExtractor from .common import InfoExtractor
from ..utils import ( from ..utils import (
ExtractorError, ExtractorError,
join_nonempty,
smuggle_url, smuggle_url,
str_or_none, str_or_none,
strip_or_none,
traverse_obj, traverse_obj,
) )
@ -11,19 +13,16 @@ class TVerIE(InfoExtractor):
_VALID_URL = r'https?://(?:www\.)?tver\.jp/(?:(?P<type>lp|corner|series|episodes?|feature|tokyo2020/video)/)+(?P<id>[a-zA-Z0-9]+)' _VALID_URL = r'https?://(?:www\.)?tver\.jp/(?:(?P<type>lp|corner|series|episodes?|feature|tokyo2020/video)/)+(?P<id>[a-zA-Z0-9]+)'
_TESTS = [{ _TESTS = [{
'skip': 'videos are only available for 7 days', 'skip': 'videos are only available for 7 days',
'url': 'https://tver.jp/episodes/ephss8yveb', 'url': 'https://tver.jp/episodes/ep83nf3w4p',
'info_dict': { 'info_dict': {
'title': '#44 料理と値段と店主にびっくり オモてなしすぎウマい店 2時間SP', 'title': '家事ヤロウ!!! 売り場席巻のチーズSP財前直見×森泉親子の脱東京暮らし密着',
'description': 'md5:66985373a66fed8ad3cd595a3cfebb13', 'description': 'md5:dc2c06b6acc23f1e7c730c513737719b',
}, 'series': '家事ヤロウ!!!',
'add_ie': ['BrightcoveNew'], 'episode': '売り場席巻のチーズSP財前直見×森泉親子の脱東京暮らし密着',
}, { 'alt_title': '売り場席巻のチーズSP財前直見×森泉親子の脱東京暮らし密着',
'skip': 'videos are only available for 7 days', 'channel': 'テレビ朝日',
'url': 'https://tver.jp/lp/episodes/ep6f16g26p', 'onair_label': '5月3日(火)放送分',
'info_dict': { 'ext_title': '家事ヤロウ!!! 売り場席巻のチーズSP財前直見×森泉親子の脱東京暮らし密着 テレビ朝日 5月3日(火)放送分',
# sorry but this is "correct"
'title': '4月11日(月)23時06分 ~ 放送予定',
'description': 'md5:4029cc5f4b1e8090dfc5b7bd2bc5cd0b',
}, },
'add_ie': ['BrightcoveNew'], 'add_ie': ['BrightcoveNew'],
}, { }, {
@ -78,14 +77,26 @@ class TVerIE(InfoExtractor):
'x-tver-platform-type': 'web' 'x-tver-platform-type': 'web'
}) })
additional_content_info = traverse_obj(
additional_info, ('result', 'episode', 'content'), get_all=False) or {}
episode = strip_or_none(additional_content_info.get('title'))
series = str_or_none(additional_content_info.get('seriesTitle'))
title = (
join_nonempty(series, episode, delim=' ')
or str_or_none(video_info.get('title')))
provider = str_or_none(additional_content_info.get('productionProviderName'))
onair_label = str_or_none(additional_content_info.get('broadcastDateLabel'))
return { return {
'_type': 'url_transparent', '_type': 'url_transparent',
'title': str_or_none(video_info.get('title')), 'title': title,
'series': series,
'episode': episode,
# an another title which is considered "full title" for some viewers
'alt_title': join_nonempty(title, provider, onair_label, delim=' '),
'channel': provider,
'description': str_or_none(video_info.get('description')), 'description': str_or_none(video_info.get('description')),
'url': smuggle_url( 'url': smuggle_url(
self.BRIGHTCOVE_URL_TEMPLATE % (p_id, r_id), {'geo_countries': ['JP']}), self.BRIGHTCOVE_URL_TEMPLATE % (p_id, r_id), {'geo_countries': ['JP']}),
'series': traverse_obj(
additional_info, ('result', ('episode', 'series'), 'content', ('seriesTitle', 'title')),
get_all=False),
'ie_key': 'BrightcoveNew', 'ie_key': 'BrightcoveNew',
} }