mirror of
https://github.com/yt-dlp/yt-dlp
synced 2025-01-31 04:22:25 +01:00
[ie/niconico:series] Fix extractor (#11822)
Closes #7320, Closes #12001 Authored by: test20140
This commit is contained in:
parent
76ac023ff0
commit
bc88b904cd
1 changed files with 21 additions and 13 deletions
|
@ -592,8 +592,8 @@ class NiconicoPlaylistBaseIE(InfoExtractor):
|
|||
@staticmethod
|
||||
def _parse_owner(item):
|
||||
return {
|
||||
'uploader': traverse_obj(item, ('owner', 'name')),
|
||||
'uploader_id': traverse_obj(item, ('owner', 'id')),
|
||||
'uploader': traverse_obj(item, ('owner', ('name', ('user', 'nickname')), {str}, any)),
|
||||
'uploader_id': traverse_obj(item, ('owner', 'id', {str})),
|
||||
}
|
||||
|
||||
def _fetch_page(self, list_id, page):
|
||||
|
@ -666,7 +666,7 @@ class NiconicoPlaylistIE(NiconicoPlaylistBaseIE):
|
|||
mylist.get('name'), mylist.get('description'), **self._parse_owner(mylist))
|
||||
|
||||
|
||||
class NiconicoSeriesIE(InfoExtractor):
|
||||
class NiconicoSeriesIE(NiconicoPlaylistBaseIE):
|
||||
IE_NAME = 'niconico:series'
|
||||
_VALID_URL = r'https?://(?:(?:www\.|sp\.)?nicovideo\.jp(?:/user/\d+)?|nico\.ms)/series/(?P<id>\d+)'
|
||||
|
||||
|
@ -675,6 +675,9 @@ class NiconicoSeriesIE(InfoExtractor):
|
|||
'info_dict': {
|
||||
'id': '110226',
|
||||
'title': 'ご立派ァ!のシリーズ',
|
||||
'description': '楽しそうな外人の吹き替えをさせたら終身名誉ホモガキの右に出る人はいませんね…',
|
||||
'uploader': 'アルファるふぁ',
|
||||
'uploader_id': '44113208',
|
||||
},
|
||||
'playlist_mincount': 10,
|
||||
}, {
|
||||
|
@ -682,6 +685,9 @@ class NiconicoSeriesIE(InfoExtractor):
|
|||
'info_dict': {
|
||||
'id': '12312',
|
||||
'title': 'バトルスピリッツ お勧めカード紹介(調整中)',
|
||||
'description': '',
|
||||
'uploader': '野鳥',
|
||||
'uploader_id': '2275360',
|
||||
},
|
||||
'playlist_mincount': 103,
|
||||
}, {
|
||||
|
@ -689,19 +695,21 @@ class NiconicoSeriesIE(InfoExtractor):
|
|||
'only_matching': True,
|
||||
}]
|
||||
|
||||
def _call_api(self, list_id, resource, query):
|
||||
return self._download_json(
|
||||
f'https://nvapi.nicovideo.jp/v2/series/{list_id}', list_id,
|
||||
f'Downloading {resource}', query=query,
|
||||
headers=self._API_HEADERS)['data']
|
||||
|
||||
def _real_extract(self, url):
|
||||
list_id = self._match_id(url)
|
||||
webpage = self._download_webpage(url, list_id)
|
||||
series = self._call_api(list_id, 'list', {
|
||||
'pageSize': 1,
|
||||
})['detail']
|
||||
|
||||
title = self._search_regex(
|
||||
(r'<title>「(.+)(全',
|
||||
r'<div class="TwitterShareButton"\s+data-text="(.+)\s+https:'),
|
||||
webpage, 'title', fatal=False)
|
||||
if title:
|
||||
title = unescapeHTML(title)
|
||||
json_data = next(self._yield_json_ld(webpage, None, fatal=False))
|
||||
return self.playlist_from_matches(
|
||||
traverse_obj(json_data, ('itemListElement', ..., 'url')), list_id, title, ie=NiconicoIE)
|
||||
return self.playlist_result(
|
||||
self._entries(list_id), list_id,
|
||||
series.get('title'), series.get('description'), **self._parse_owner(series))
|
||||
|
||||
|
||||
class NiconicoHistoryIE(NiconicoPlaylistBaseIE):
|
||||
|
|
Loading…
Add table
Reference in a new issue