aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/niconico.py
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2014-10-29 11:04:48 +0100
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2014-10-29 11:04:48 +0100
commita9bad429b309e614b4b8905c085ef425350ceeb2 (patch)
treef9a582df986a15a47504e4a40703508679ba08ef /youtube_dl/extractor/niconico.py
parent50c8266ef0b2b6d011257a909f47fd623dda8eb2 (diff)
[niconico] Add extractor for playlists (closes #4043)
Diffstat (limited to 'youtube_dl/extractor/niconico.py')
-rw-r--r--youtube_dl/extractor/niconico.py34
1 files changed, 34 insertions, 0 deletions
diff --git a/youtube_dl/extractor/niconico.py b/youtube_dl/extractor/niconico.py
index 7b85589b7..62d5707fe 100644
--- a/youtube_dl/extractor/niconico.py
+++ b/youtube_dl/extractor/niconico.py
@@ -2,6 +2,7 @@
from __future__ import unicode_literals
import re
+import json
from .common import InfoExtractor
from ..utils import (
@@ -146,3 +147,36 @@ class NiconicoIE(InfoExtractor):
'duration': duration,
'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,
+ }