aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYen Chi Hsuan <yan12125@gmail.com>2015-03-18 14:59:33 +0800
committerYen Chi Hsuan <yan12125@gmail.com>2015-04-16 17:34:54 +0800
commit8afff9f849e43c9c4194e302c06b5bec38edd83f (patch)
treea6fa37f4974eacd3b5ee5f75fc0dc4a6dfbeeb8e
parenta2043572aa99c7517c84c31fe8a7e2051d27bf09 (diff)
[QQMusic] Add singer info extractor
-rw-r--r--youtube_dl/extractor/__init__.py5
-rw-r--r--youtube_dl/extractor/qqmusic.py53
2 files changed, 56 insertions, 2 deletions
diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py
index 63bcf666f..65dbcb6cf 100644
--- a/youtube_dl/extractor/__init__.py
+++ b/youtube_dl/extractor/__init__.py
@@ -396,7 +396,10 @@ from .promptfile import PromptFileIE
from .prosiebensat1 import ProSiebenSat1IE
from .puls4 import Puls4IE
from .pyvideo import PyvideoIE
-from .qqmusic import QQMusicIE
+from .qqmusic import (
+ QQMusicIE,
+ QQMusicSingerIE
+)
from .quickvid import QuickVidIE
from .r7 import R7IE
from .radiode import RadioDeIE
diff --git a/youtube_dl/extractor/qqmusic.py b/youtube_dl/extractor/qqmusic.py
index 93440b954..1c22943a5 100644
--- a/youtube_dl/extractor/qqmusic.py
+++ b/youtube_dl/extractor/qqmusic.py
@@ -3,9 +3,11 @@ from __future__ import unicode_literals
import random
import time
+import re
from .common import InfoExtractor
from ..utils import strip_jsonp
+from ..compat import compat_urllib_request
class QQMusicIE(InfoExtractor):
@@ -34,7 +36,7 @@ class QQMusicIE(InfoExtractor):
detail_info_page = self._download_webpage(
'http://s.plcloud.music.qq.com/fcgi-bin/fcg_yqq_song_detail_info.fcg?songmid=%s&play=0' % mid,
- mid, note='Download sont detail info',
+ mid, note='Download song detail info',
errnote='Unable to get song detail info')
song_name = self._html_search_regex(
@@ -62,3 +64,52 @@ class QQMusicIE(InfoExtractor):
'upload_date': publish_time,
'creator': singer,
}
+
+
+class QQMusicSingerIE(InfoExtractor):
+ _VALID_URL = r'http://y.qq.com/#type=singer&mid=(?P<id>[0-9A-Za-z]+)'
+ _TEST = {
+ 'url': 'http://y.qq.com/#type=singer&mid=001BLpXF2DyJe2',
+ 'info_dict': {
+ 'id': '001BLpXF2DyJe2',
+ 'title': '林俊杰',
+ 'description': 'md5:2a222d89ba4455a3af19940c0481bb78',
+ },
+ 'playlist_count': 12,
+ }
+
+ def _real_extract(self, url):
+ mid = self._match_id(url)
+
+ singer_page = self._download_webpage(
+ 'http://y.qq.com/y/static/singer/%s/%s/%s.html' % (mid[-2], mid[-1], mid),
+ 'Download singer page')
+
+ entries = []
+
+ for item in re.findall(r'<span class="data">([^<>]+)</span>', singer_page):
+ song_mid = item.split('|')[-5]
+ entries.append(self.url_result(
+ 'http://y.qq.com/#type=song&mid=' + song_mid, 'QQMusic', song_mid))
+
+ singer_name = self._html_search_regex(
+ r"singername\s*:\s*'([^']+)'", singer_page, 'singer name',
+ default=None)
+
+ singer_id = self._html_search_regex(
+ r"singerid\s*:\s*'([0-9]+)'", singer_page, 'singer id',
+ default=None)
+
+ singer_desc = None
+
+ if singer_id:
+ req = compat_urllib_request.Request(
+ 'http://s.plcloud.music.qq.com/fcgi-bin/fcg_get_singer_desc.fcg?utf8=1&outCharset=utf-8&format=xml&singerid=%s' % singer_id)
+ req.add_header(
+ 'Referer', 'http://s.plcloud.music.qq.com/xhr_proxy_utf8.html')
+ singer_desc_page = self._download_xml(
+ req, 'Donwload singer description XML')
+
+ singer_desc = singer_desc_page.find('./data/info/desc').text
+
+ return self.playlist_result(entries, mid, singer_name, singer_desc)