1
0
mirror of https://github.com/yt-dlp/yt-dlp synced 2025-07-04 04:52:52 -05:00

[mtv] fix mtv.com and more(?)

This commit is contained in:
Unknown
2020-10-09 07:06:49 +02:00
parent 39b7f3ec15
commit b6e0c7d2e3
2 changed files with 46 additions and 2 deletions

View File

@ -1984,6 +1984,7 @@ def get_elements_by_attribute(attribute, value, html, escape_value=True):
class HTMLAttributeParser(compat_HTMLParser):
"""Trivial HTML parser to gather the attributes for a single element"""
def __init__(self):
self.attrs = {}
compat_HTMLParser.__init__(self)
@ -2378,6 +2379,7 @@ class GeoRestrictedError(ExtractorError):
This exception may be thrown when a video is not available from your
geographic location due to geographic restrictions imposed by a website.
"""
def __init__(self, msg, countries=None):
super(GeoRestrictedError, self).__init__(msg, expected=True)
self.msg = msg
@ -3558,6 +3560,11 @@ def remove_quotes(s):
return s
def get_domain(url):
domain = re.match(r'(?:https?:\/\/)?(?:www\.)?(?P<domain>[^\n\/]+\.[^\n\/]+)(?:\/(.*))?', url)
return domain.group('domain') if domain else None
def url_basename(url):
path = compat_urlparse.urlparse(url).path
return path.strip('/').split('/')[-1]