mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-09 12:42:28 +01:00
[youtube] Do not warn for videos with allow_rating=0
This fixes #1982 Test video: http://www.youtube.com/watch?v=gi2uH3YxohU
This commit is contained in:
parent
ec98946ef9
commit
46374a56b2
@ -18,6 +18,7 @@
|
|||||||
sanitize_filename,
|
sanitize_filename,
|
||||||
unescapeHTML,
|
unescapeHTML,
|
||||||
)
|
)
|
||||||
|
_NO_DEFAULT = object()
|
||||||
|
|
||||||
|
|
||||||
class InfoExtractor(object):
|
class InfoExtractor(object):
|
||||||
@ -281,7 +282,7 @@ def playlist_result(self, entries, playlist_id=None, playlist_title=None):
|
|||||||
video_info['title'] = playlist_title
|
video_info['title'] = playlist_title
|
||||||
return video_info
|
return video_info
|
||||||
|
|
||||||
def _search_regex(self, pattern, string, name, default=None, fatal=True, flags=0):
|
def _search_regex(self, pattern, string, name, default=_NO_DEFAULT, fatal=True, flags=0):
|
||||||
"""
|
"""
|
||||||
Perform a regex search on the given string, using a single or a list of
|
Perform a regex search on the given string, using a single or a list of
|
||||||
patterns returning the first matching group.
|
patterns returning the first matching group.
|
||||||
@ -303,7 +304,7 @@ def _search_regex(self, pattern, string, name, default=None, fatal=True, flags=0
|
|||||||
if mobj:
|
if mobj:
|
||||||
# return the first matching group
|
# return the first matching group
|
||||||
return next(g for g in mobj.groups() if g is not None)
|
return next(g for g in mobj.groups() if g is not None)
|
||||||
elif default is not None:
|
elif default is not _NO_DEFAULT:
|
||||||
return default
|
return default
|
||||||
elif fatal:
|
elif fatal:
|
||||||
raise RegexNotFoundError(u'Unable to extract %s' % _name)
|
raise RegexNotFoundError(u'Unable to extract %s' % _name)
|
||||||
@ -312,7 +313,7 @@ def _search_regex(self, pattern, string, name, default=None, fatal=True, flags=0
|
|||||||
u'please report this issue on http://yt-dl.org/bug' % _name)
|
u'please report this issue on http://yt-dl.org/bug' % _name)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def _html_search_regex(self, pattern, string, name, default=None, fatal=True, flags=0):
|
def _html_search_regex(self, pattern, string, name, default=_NO_DEFAULT, fatal=True, flags=0):
|
||||||
"""
|
"""
|
||||||
Like _search_regex, but strips HTML tags and unescapes entities.
|
Like _search_regex, but strips HTML tags and unescapes entities.
|
||||||
"""
|
"""
|
||||||
|
@ -32,7 +32,7 @@ def _real_extract(self, url):
|
|||||||
|
|
||||||
video_title = self._html_search_regex(r'<div class="p_5px[^>]*>([^<]+)', webpage, u'title')
|
video_title = self._html_search_regex(r'<div class="p_5px[^>]*>([^<]+)', webpage, u'title')
|
||||||
video_uploader = self._html_search_regex(r'so_s\.addVariable\("owner_u", "([^"]+)', webpage, u'uploader', fatal=False)
|
video_uploader = self._html_search_regex(r'so_s\.addVariable\("owner_u", "([^"]+)', webpage, u'uploader', fatal=False)
|
||||||
video_description = self._html_search_regex(r'<p class="video_description">([^<]+)', webpage, u'description', default=None)
|
video_description = self._html_search_regex(r'<p class="video_description">([^<]+)', webpage, u'description', fatal=False)
|
||||||
video_url= self._html_search_regex(r'var videoMp4 = "([^"]+)', webpage, u'video_url').replace('\\/', '/')
|
video_url= self._html_search_regex(r'var videoMp4 = "([^"]+)', webpage, u'video_url').replace('\\/', '/')
|
||||||
path = compat_urllib_parse_urlparse(video_url).path
|
path = compat_urllib_parse_urlparse(video_url).path
|
||||||
extension = os.path.splitext(path)[1][1:]
|
extension = os.path.splitext(path)[1][1:]
|
||||||
|
@ -1361,7 +1361,9 @@ def _real_extract(self, url):
|
|||||||
video_description = u''
|
video_description = u''
|
||||||
|
|
||||||
def _extract_count(klass):
|
def _extract_count(klass):
|
||||||
count = self._search_regex(r'class="%s">([\d,]+)</span>' % re.escape(klass), video_webpage, klass, fatal=False)
|
count = self._search_regex(
|
||||||
|
r'class="%s">([\d,]+)</span>' % re.escape(klass),
|
||||||
|
video_webpage, klass, default=None)
|
||||||
if count is not None:
|
if count is not None:
|
||||||
return int(count.replace(',', ''))
|
return int(count.replace(',', ''))
|
||||||
return None
|
return None
|
||||||
|
Loading…
Reference in New Issue
Block a user