Browse Source

[bilibili] Capture the video-not-exist message

master
Yen Chi Hsuan 9 years ago
parent
commit
24e21613b6
1 changed files with 3 additions and 0 deletions
  1. 3
      youtube_dl/extractor/bilibili.py

3
youtube_dl/extractor/bilibili.py

@ -7,6 +7,7 @@ from .common import InfoExtractor
from ..utils import ( from ..utils import (
int_or_none, int_or_none,
unified_strdate, unified_strdate,
ExtractorError,
) )
@ -30,6 +31,8 @@ class BiliBiliIE(InfoExtractor):
video_id = self._match_id(url) video_id = self._match_id(url)
webpage = self._download_webpage(url, video_id) webpage = self._download_webpage(url, video_id)
if self._search_regex(r'(此视频不存在或被删除)', webpage, 'error message', default=None):
raise ExtractorError('The video does not exist or was deleted', expected=True)
video_code = self._search_regex( video_code = self._search_regex(
r'(?s)<div itemprop="video".*?>(.*?)</div>', webpage, 'video code') r'(?s)<div itemprop="video".*?>(.*?)</div>', webpage, 'video code')

Loading…
Cancel
Save