From 29b809de68aeefb5e991c75929ed3d03fb40c1f1 Mon Sep 17 00:00:00 2001 From: ping Date: Thu, 18 Jun 2015 15:52:04 +0800 Subject: [PATCH 1/3] [qqmusic] Fix album extraction --- youtube_dl/extractor/qqmusic.py | 37 ++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/youtube_dl/extractor/qqmusic.py b/youtube_dl/extractor/qqmusic.py index bafa81c21..d9a783f8a 100644 --- a/youtube_dl/extractor/qqmusic.py +++ b/youtube_dl/extractor/qqmusic.py @@ -163,31 +163,38 @@ class QQMusicAlbumIE(QQPlaylistBaseIE): IE_NAME = 'qqmusic:album' _VALID_URL = r'http://y.qq.com/#type=album&mid=(?P[0-9A-Za-z]+)' - _TEST = { - 'url': 'http://y.qq.com/#type=album&mid=000gXCTb2AhRR1&play=0', + _TESTS = [{ + 'url': 'http://y.qq.com/#type=album&mid=000gXCTb2AhRR1', 'info_dict': { 'id': '000gXCTb2AhRR1', 'title': '我们都是这样长大的', - 'description': 'md5:d216c55a2d4b3537fe4415b8767d74d6', + 'description': 'md5:712f0cdbfc7e776820d08150e6df593d', }, 'playlist_count': 4, - } + }, { + 'url': 'http://y.qq.com/#type=album&mid=002Y5a3b3AlCu3', + 'info_dict': { + 'id': '002Y5a3b3AlCu3', + 'title': '그리고...', + 'description': 'md5:b1d133b8c9bac8fed4e1a97df759f4cf', + }, + 'playlist_count': 8, + }] def _real_extract(self, url): mid = self._match_id(url) - album_page = self._download_webpage( - self.qq_static_url('album', mid), mid, 'Download album page') + album = self._download_json( + 'http://i.y.qq.com/v8/fcg-bin/fcg_v8_album_info_cp.fcg?albummid=%s&format=json' % mid, + mid, 'Download album page')['data'] - entries = self.get_entries_from_page(album_page) - - album_name = self._html_search_regex( - r"albumname\s*:\s*'([^']+)',", album_page, 'album name', - default=None) - - album_detail = self._html_search_regex( - r'
\s*

((?:[^<>]+(?:
)?)+)

', - album_page, 'album details', default=None) + entries = [ + self.url_result( + 'http://y.qq.com/#type=song&mid=' + song['songmid'], 'QQMusic', song['songmid'] + ) for song in album['list'] + ] + album_name = album['name'] + album_detail = album.get('desc') return self.playlist_result(entries, mid, album_name, album_detail) From fc7ae675e26a98bc74918f311d22f515ec7e0477 Mon Sep 17 00:00:00 2001 From: Yen Chi Hsuan Date: Mon, 6 Jul 2015 17:08:32 +0800 Subject: [PATCH 2/3] [qqmusic:album] Strip description --- youtube_dl/extractor/qqmusic.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/youtube_dl/extractor/qqmusic.py b/youtube_dl/extractor/qqmusic.py index e704640e5..6d85d58e3 100644 --- a/youtube_dl/extractor/qqmusic.py +++ b/youtube_dl/extractor/qqmusic.py @@ -169,7 +169,7 @@ class QQMusicAlbumIE(QQPlaylistBaseIE): 'info_dict': { 'id': '000gXCTb2AhRR1', 'title': '我们都是这样长大的', - 'description': 'md5:712f0cdbfc7e776820d08150e6df593d', + 'description': 'md5:179c5dce203a5931970d306aa9607ea6', }, 'playlist_count': 4, }, { @@ -177,7 +177,7 @@ class QQMusicAlbumIE(QQPlaylistBaseIE): 'info_dict': { 'id': '002Y5a3b3AlCu3', 'title': '그리고...', - 'description': 'md5:b1d133b8c9bac8fed4e1a97df759f4cf', + 'description': 'md5:a48823755615508a95080e81b51ba729', }, 'playlist_count': 8, }] @@ -196,6 +196,8 @@ def _real_extract(self, url): ] album_name = album['name'] album_detail = album.get('desc') + if album_detail is not None: + album_detail = album_detail.strip() return self.playlist_result(entries, mid, album_name, album_detail) From dfc4eca21f7d34b5e65f42b284b24077c8bbc109 Mon Sep 17 00:00:00 2001 From: Yen Chi Hsuan Date: Mon, 6 Jul 2015 17:09:17 +0800 Subject: [PATCH 3/3] [qqmusic:album] Playlist names are optional --- youtube_dl/extractor/qqmusic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/extractor/qqmusic.py b/youtube_dl/extractor/qqmusic.py index 6d85d58e3..03e6c688f 100644 --- a/youtube_dl/extractor/qqmusic.py +++ b/youtube_dl/extractor/qqmusic.py @@ -194,7 +194,7 @@ def _real_extract(self, url): 'http://y.qq.com/#type=song&mid=' + song['songmid'], 'QQMusic', song['songmid'] ) for song in album['list'] ] - album_name = album['name'] + album_name = album.get('name') album_detail = album.get('desc') if album_detail is not None: album_detail = album_detail.strip()