Skip to content

Commit

Permalink
[extractor/NiconicoSeries] Fix extraction (yt-dlp#6898)
Browse files Browse the repository at this point in the history
Authored by: sqrtNOT
  • Loading branch information
sqrtNOT authored and aalsuwaidi committed Apr 21, 2024
1 parent 4226272 commit 32061c2
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions yt_dlp/extractor/niconico.py
Expand Up @@ -660,10 +660,10 @@ def _real_extract(self, url):

class NiconicoSeriesIE(InfoExtractor):
IE_NAME = 'niconico:series'
_VALID_URL = r'https?://(?:(?:www\.|sp\.)?nicovideo\.jp|nico\.ms)/series/(?P<id>\d+)'
_VALID_URL = r'https?://(?:(?:www\.|sp\.)?nicovideo\.jp(?:/user/\d+)?|nico\.ms)/series/(?P<id>\d+)'

_TESTS = [{
'url': 'https://www.nicovideo.jp/series/110226',
'url': 'https://www.nicovideo.jp/user/44113208/series/110226',
'info_dict': {
'id': '110226',
'title': 'ご立派ァ!のシリーズ',
Expand All @@ -683,18 +683,17 @@ class NiconicoSeriesIE(InfoExtractor):

def _real_extract(self, url):
list_id = self._match_id(url)
webpage = self._download_webpage(f'https://www.nicovideo.jp/series/{list_id}', list_id)
webpage = self._download_webpage(url, list_id)

title = self._search_regex(
(r'<title>「(.+)(全',
r'<div class="TwitterShareButton"\s+data-text="(.+)\s+https:'),
webpage, 'title', fatal=False)
if title:
title = unescapeHTML(title)
playlist = [
self.url_result(f'https://www.nicovideo.jp/watch/{v_id}', video_id=v_id)
for v_id in re.findall(r'data-href=[\'"](?:https://www\.nicovideo\.jp)?/watch/([a-z0-9]+)', webpage)]
return self.playlist_result(playlist, list_id, 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)


class NiconicoHistoryIE(NiconicoPlaylistBaseIE):
Expand Down

0 comments on commit 32061c2

Please sign in to comment.