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

[lnkgo] Make more robust

This commit is contained in:
Naglis Jonaitis 2015-01-14 00:51:48 +02:00
parent a69801e2c6
commit f2cbc96c3e

View File

@ -62,16 +62,18 @@ class LnkGoIE(InfoExtractor):
title = self._og_search_title(webpage) title = self._og_search_title(webpage)
description = self._og_search_description(webpage) description = self._og_search_description(webpage)
thumbnail = self._og_search_thumbnail(webpage)
thumbnail_w = int_or_none( thumbnail_w = int_or_none(
self._og_search_property('image:width', webpage, 'thumbnail width', fatal=False)) self._og_search_property('image:width', webpage, 'thumbnail width', fatal=False))
thumbnail_h = int_or_none( thumbnail_h = int_or_none(
self._og_search_property('image:height', webpage, 'thumbnail height', fatal=False)) self._og_search_property('image:height', webpage, 'thumbnail height', fatal=False))
thumbnails = [{ thumbnail = {
'url': thumbnail, 'url': self._og_search_thumbnail(webpage),
'width': thumbnail_w, }
'height': thumbnail_h, if thumbnail_w and thumbnail_h:
}] thumbnail.update({
'width': thumbnail_w,
'height': thumbnail_h,
})
upload_date = unified_strdate(self._search_regex( upload_date = unified_strdate(self._search_regex(
r'class="meta-item\sair-time">.*?<strong>([^<]+)</strong>', webpage, 'upload date', fatal=False)) r'class="meta-item\sair-time">.*?<strong>([^<]+)</strong>', webpage, 'upload date', fatal=False))
@ -80,7 +82,7 @@ class LnkGoIE(InfoExtractor):
pg_rating = self._search_regex( pg_rating = self._search_regex(
r'pgrating="([^"]+)"', webpage, 'PG rating', fatal=False, default='') r'pgrating="([^"]+)"', webpage, 'PG rating', fatal=False, default='')
age_limit = self._AGE_LIMITS.get(pg_rating, 0) age_limit = self._AGE_LIMITS.get(pg_rating.upper(), 0)
sources_js = self._search_regex( sources_js = self._search_regex(
r'(?s)sources:\s(\[.*?\]),', webpage, 'sources') r'(?s)sources:\s(\[.*?\]),', webpage, 'sources')
@ -114,7 +116,7 @@ class LnkGoIE(InfoExtractor):
'display_id': display_id, 'display_id': display_id,
'title': title, 'title': title,
'formats': formats, 'formats': formats,
'thumbnails': thumbnails, 'thumbnails': [thumbnail],
'duration': duration, 'duration': duration,
'description': description, 'description': description,
'age_limit': age_limit, 'age_limit': age_limit,