mirror of
				https://github.com/ytdl-org/youtube-dl.git
				synced 2025-10-29 09:26:20 -07:00 
			
		
		
		
	[niconico] Add extractor for playlists (closes #4043)
This commit is contained in:
		| @@ -252,7 +252,7 @@ from .newstube import NewstubeIE | |||||||
| from .nfb import NFBIE | from .nfb import NFBIE | ||||||
| from .nfl import NFLIE | from .nfl import NFLIE | ||||||
| from .nhl import NHLIE, NHLVideocenterIE | from .nhl import NHLIE, NHLVideocenterIE | ||||||
| from .niconico import NiconicoIE | from .niconico import NiconicoIE, NiconicoPlaylistIE | ||||||
| from .ninegag import NineGagIE | from .ninegag import NineGagIE | ||||||
| from .noco import NocoIE | from .noco import NocoIE | ||||||
| from .normalboots import NormalbootsIE | from .normalboots import NormalbootsIE | ||||||
|   | |||||||
| @@ -2,6 +2,7 @@ | |||||||
| from __future__ import unicode_literals | from __future__ import unicode_literals | ||||||
|  |  | ||||||
| import re | import re | ||||||
|  | import json | ||||||
|  |  | ||||||
| from .common import InfoExtractor | from .common import InfoExtractor | ||||||
| from ..utils import ( | from ..utils import ( | ||||||
| @@ -146,3 +147,36 @@ class NiconicoIE(InfoExtractor): | |||||||
|             'duration': duration, |             'duration': duration, | ||||||
|             'webpage_url': webpage_url, |             'webpage_url': webpage_url, | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | class NiconicoPlaylistIE(InfoExtractor): | ||||||
|  |     _VALID_URL = r'https?://www\.nicovideo\.jp/mylist/(?P<id>\d+)' | ||||||
|  |  | ||||||
|  |     _TEST = { | ||||||
|  |         'url': 'http://www.nicovideo.jp/mylist/27411728', | ||||||
|  |         'info_dict': { | ||||||
|  |             'id': '27411728', | ||||||
|  |             'title': 'AKB48のオールナイトニッポン', | ||||||
|  |         }, | ||||||
|  |         'playlist_mincount': 225, | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     def _real_extract(self, url): | ||||||
|  |         list_id = self._match_id(url) | ||||||
|  |         webpage = self._download_webpage(url, list_id) | ||||||
|  |  | ||||||
|  |         entries_json = self._search_regex(r'Mylist\.preload\(\d+, (\[.*\])\);', | ||||||
|  |             webpage, 'entries') | ||||||
|  |         entries = json.loads(entries_json) | ||||||
|  |         entries = [{ | ||||||
|  |             '_type': 'url', | ||||||
|  |             'ie_key': NiconicoIE.ie_key(), | ||||||
|  |             'url': 'http://www.nicovideo.jp/watch/%s' % entry['item_id'], | ||||||
|  |         } for entry in entries] | ||||||
|  |  | ||||||
|  |         return { | ||||||
|  |             '_type': 'playlist', | ||||||
|  |             'title': self._search_regex(r'\s+name: "(.*?)"', webpage, 'title'), | ||||||
|  |             'id': list_id, | ||||||
|  |             'entries': entries, | ||||||
|  |         } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user