1
0
mirror of https://github.com/l1ving/youtube-dl synced 2024-11-22 01:02:57 +08:00

[smotri] Make optional attributes optional

This commit is contained in:
Philipp Hagemeister 2013-12-23 03:38:29 +01:00
parent 1b969041d7
commit 8d0bdeba18

View File

@ -152,14 +152,15 @@ class SmotriIE(InfoExtractor):
video_description = self._search_meta(u'description', video_page) video_description = self._search_meta(u'description', video_page)
END_TEXT = u' на сайте Smotri.com' END_TEXT = u' на сайте Smotri.com'
if video_description.endswith(END_TEXT): if video_description and video_description.endswith(END_TEXT):
video_description = video_description[:-len(END_TEXT)] video_description = video_description[:-len(END_TEXT)]
START_TEXT = u'Смотреть онлайн ролик ' START_TEXT = u'Смотреть онлайн ролик '
if video_description.startswith(START_TEXT): if video_description and video_description.startswith(START_TEXT):
video_description = video_description[len(START_TEXT):] video_description = video_description[len(START_TEXT):]
video_thumbnail = self._search_meta(u'thumbnail', video_page) video_thumbnail = self._search_meta(u'thumbnail', video_page)
upload_date_str = self._search_meta(u'uploadDate', video_page, u'upload date') upload_date_str = self._search_meta(u'uploadDate', video_page, u'upload date')
if upload_date_str:
upload_date_m = re.search(r'(?P<year>\d{4})\.(?P<month>\d{2})\.(?P<day>\d{2})T', upload_date_str) upload_date_m = re.search(r'(?P<year>\d{4})\.(?P<month>\d{2})\.(?P<day>\d{2})T', upload_date_str)
video_upload_date = ( video_upload_date = (
( (
@ -169,8 +170,11 @@ class SmotriIE(InfoExtractor):
) )
if upload_date_m else None if upload_date_m else None
) )
else:
video_upload_date = None
duration_str = self._search_meta(u'duration', video_page) duration_str = self._search_meta(u'duration', video_page)
if duration_str:
duration_m = re.search(r'T(?P<hours>[0-9]{2})H(?P<minutes>[0-9]{2})M(?P<seconds>[0-9]{2})S', duration_str) duration_m = re.search(r'T(?P<hours>[0-9]{2})H(?P<minutes>[0-9]{2})M(?P<seconds>[0-9]{2})S', duration_str)
video_duration = ( video_duration = (
( (
@ -180,6 +184,8 @@ class SmotriIE(InfoExtractor):
) )
if duration_m else None if duration_m else None
) )
else:
video_duration = None
video_uploader = self._html_search_regex( video_uploader = self._html_search_regex(
u'<div class="DescrUser"><div>Автор.*?onmouseover="popup_user_info[^"]+">(.*?)</a>', u'<div class="DescrUser"><div>Автор.*?onmouseover="popup_user_info[^"]+">(.*?)</a>',