diff options
author | Yen Chi Hsuan <yan12125@gmail.com> | 2015-05-27 04:23:21 +0800 |
---|---|---|
committer | Yen Chi Hsuan <yan12125@gmail.com> | 2015-05-27 04:23:21 +0800 |
commit | 6d00a2dcd110f12a0aa110f5479df76613792fbd (patch) | |
tree | 02dff8ff9cbaecbfd48285dc7b09d9df05a314ce /youtube_dl/extractor/bilibili.py | |
parent | b535170b218131afd1165776e611691479627ce8 (diff) |
[bilibili] Catch API call failures
JSON are returned in a failed API call
Diffstat (limited to 'youtube_dl/extractor/bilibili.py')
-rw-r--r-- | youtube_dl/extractor/bilibili.py | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/youtube_dl/extractor/bilibili.py b/youtube_dl/extractor/bilibili.py index a8bea2c10..2103ed73a 100644 --- a/youtube_dl/extractor/bilibili.py +++ b/youtube_dl/extractor/bilibili.py @@ -3,6 +3,8 @@ from __future__ import unicode_literals import re import itertools +import json +import xml.etree.ElementTree as ET from .common import InfoExtractor from ..utils import ( @@ -67,11 +69,19 @@ class BiliBiliIE(InfoExtractor): entries = [] - lq_doc = self._download_xml( + lq_page = self._download_webpage( 'http://interface.bilibili.com/v_cdn_play?appkey=1&cid=%s' % cid, video_id, note='Downloading LQ video info' ) + try: + err_info = json.loads(lq_page) + raise ExtractorError( + 'BiliBili said: ' + err_info['error_text'], expected=True) + except ValueError: + pass + + lq_doc = ET.fromstring(lq_page) lq_durls = lq_doc.findall('./durl') hq_doc = self._download_xml( |