flake8 compliant, allow non-essential uploader field to be None, fallback to video_id as title (current behavior with generic exractor), make filesize int_or_none
This commit is contained in:
parent
be9e638683
commit
feff838741
@ -2,6 +2,7 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
|
from ..utils import int_or_none
|
||||||
|
|
||||||
|
|
||||||
class Full30IE(InfoExtractor):
|
class Full30IE(InfoExtractor):
|
||||||
@ -12,7 +13,7 @@ class Full30IE(InfoExtractor):
|
|||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'b2a28b99494164ddd55e91a6c4648cbc',
|
'id': 'b2a28b99494164ddd55e91a6c4648cbc',
|
||||||
'title': 'Flamethrower Q&A with Charlie Hobson',
|
'title': 'Flamethrower Q&A with Charlie Hobson',
|
||||||
'uploader' : 'Forgotten Weapons',
|
'uploader': 'Forgotten Weapons',
|
||||||
'thumbnail': r're:^https?://.*52130\.jpg$',
|
'thumbnail': r're:^https?://.*52130\.jpg$',
|
||||||
'ext': 'ogv',
|
'ext': 'ogv',
|
||||||
}
|
}
|
||||||
@ -22,8 +23,8 @@ class Full30IE(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)
|
||||||
|
|
||||||
title = self._html_search_regex(r'<h1 [^>]*class=.video-title[^>]*>([^<]+?)</h1>', webpage, 'title', fatal=False, default=None) or self._og_search_title(webpage)
|
title = self._html_search_regex(r'<h1 [^>]*class=.video-title[^>]*>([^<]+?)</h1>', webpage, 'title', fatal=False, default=None) or self._og_search_title(webpage) or video_id
|
||||||
uploader = self._html_search_regex(r'<h1 class=.channel-title[^>]*>([^<]+)<', webpage, 'uploader', fatal=False, default=None) or None
|
uploader = self._html_search_regex(r'<h1 class=.channel-title[^>]*>([^<]+)<', webpage, 'uploader', fatal=False, default=None) or None
|
||||||
thumbnail = self._html_search_regex(r'<[^>]*property=.og:image. ?content="([^>]*thumbnails[^">]*)"\/>', webpage, 'thumbnail', fatal=False, default=None) or self._og_search_thumbnail(webpage)
|
thumbnail = self._html_search_regex(r'<[^>]*property=.og:image. ?content="([^>]*thumbnails[^">]*)"\/>', webpage, 'thumbnail', fatal=False, default=None) or self._og_search_thumbnail(webpage)
|
||||||
|
|
||||||
# looking for a line like the following
|
# looking for a line like the following
|
||||||
@ -38,17 +39,14 @@ class Full30IE(InfoExtractor):
|
|||||||
# turn sequence of json entries into an actual list
|
# turn sequence of json entries into an actual list
|
||||||
vid_json = vid_json.rstrip()
|
vid_json = vid_json.rstrip()
|
||||||
vid_json = "[" + vid_json + "]"
|
vid_json = "[" + vid_json + "]"
|
||||||
vid_json = vid_json.replace("}", "},").replace(",]","]")
|
vid_json = vid_json.replace("}", "},").replace(",]", "]")
|
||||||
parsed = self._parse_json(vid_json, video_id)
|
parsed = self._parse_json(vid_json, video_id)
|
||||||
|
|
||||||
formats = []
|
formats = [{
|
||||||
for d in parsed:
|
"url": vid_path + entry["name"],
|
||||||
if d["type"] == "object":
|
"resolution": entry["name"][:entry["name"].rfind(".")],
|
||||||
formats.append({
|
"filesize": int_or_none(entry["size"]),
|
||||||
"url" : vid_path + d["name"],
|
} for entry in parsed if entry.get("type") == "object"]
|
||||||
"resolution" : d["name"][:d["name"].rfind(".")],
|
|
||||||
"filesize" : d["size"],
|
|
||||||
})
|
|
||||||
|
|
||||||
self._sort_formats(formats)
|
self._sort_formats(formats)
|
||||||
|
|
||||||
@ -56,6 +54,6 @@ class Full30IE(InfoExtractor):
|
|||||||
'id': video_id,
|
'id': video_id,
|
||||||
'title': title,
|
'title': title,
|
||||||
'uploader': uploader,
|
'uploader': uploader,
|
||||||
'thumbnail' : thumbnail,
|
'thumbnail': thumbnail,
|
||||||
'formats' : formats,
|
'formats': formats,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user