diff options
author | ping <lipng.ong@gmail.com> | 2015-06-18 23:09:04 +0800 |
---|---|---|
committer | ping <lipng.ong@gmail.com> | 2015-06-18 23:09:04 +0800 |
commit | 4d58b24c15ea0efc699a7ad7ee468245029da4e3 (patch) | |
tree | 4257f139627f927a8f522a5d5b7cbe7e262c1966 /youtube_dl/extractor/qqmusic.py | |
parent | 0392ac98d2c5c5a6fd2ab51c51096f82312a287c (diff) |
[qqmusic] Use _check_formats instead
Diffstat (limited to 'youtube_dl/extractor/qqmusic.py')
-rw-r--r-- | youtube_dl/extractor/qqmusic.py | 34 |
1 files changed, 10 insertions, 24 deletions
diff --git a/youtube_dl/extractor/qqmusic.py b/youtube_dl/extractor/qqmusic.py index 5a18191bc..7183c2bb1 100644 --- a/youtube_dl/extractor/qqmusic.py +++ b/youtube_dl/extractor/qqmusic.py @@ -9,13 +9,8 @@ from .common import InfoExtractor from ..utils import ( strip_jsonp, unescapeHTML, - HEADRequest, - ExtractorError, -) -from ..compat import ( - compat_urllib_request, - compat_HTTPError, ) +from ..compat import compat_urllib_request class QQMusicIE(InfoExtractor): @@ -104,24 +99,15 @@ class QQMusicIE(InfoExtractor): formats = [] for format_id, details in self._FORMATS.items(): - video_url = 'http://cc.stream.qqmusic.qq.com/%s%s.%s?vkey=%s&guid=%s&fromtag=0' \ - % (details['prefix'], mid, details['ext'], vkey, guid) - req = HEADRequest(video_url) - try: - res = self._request_webpage( - req, mid, note='Testing %s video URL' % format_id, fatal=False) - except ExtractorError as e: - if isinstance(e.cause, compat_HTTPError) and e.cause.code in [400, 404]: - self.report_warning('Invalid %s video URL' % format_id, mid) - else: - if res: - formats.append({ - 'url': video_url, - 'format': format_id, - 'format_id': format_id, - 'preference': details['preference'], - 'abr': details.get('abr'), - }) + formats.append({ + 'url': 'http://cc.stream.qqmusic.qq.com/%s%s.%s?vkey=%s&guid=%s&fromtag=0' + % (details['prefix'], mid, details['ext'], vkey, guid), + 'format': format_id, + 'format_id': format_id, + 'preference': details['preference'], + 'abr': details.get('abr'), + }) + self._check_formats(formats, mid) self._sort_formats(formats) return { |