aboutsummaryrefslogtreecommitdiffstats
path: root/youtube_dlc/utils.py
diff options
context:
space:
mode:
authorTom-Oliver Heidel <github@tom-oliver.eu>2020-10-09 08:01:31 +0200
committerGitHub <noreply@github.com>2020-10-09 08:01:31 +0200
commitcfd7f14bb3cd4bb21ae67e52526d276ee4bf0e22 (patch)
treef435dea1a56ea74fdc10c5c17cbdb84273a6e1b0 /youtube_dlc/utils.py
parentb492464bf125bd6c352bf4ab6dae1c38e5cb3c90 (diff)
parentcf7cb9428745dc744129e0ba90c626919fb98f48 (diff)
downloadhypervideo-pre-cfd7f14bb3cd4bb21ae67e52526d276ee4bf0e22.tar.lz
hypervideo-pre-cfd7f14bb3cd4bb21ae67e52526d276ee4bf0e22.tar.xz
hypervideo-pre-cfd7f14bb3cd4bb21ae67e52526d276ee4bf0e22.zip
Merge pull request #176 from blackjack4494/mtv_updated_extractor_logic
[Mtv] updated extractor logic & more
Diffstat (limited to 'youtube_dlc/utils.py')
-rw-r--r--youtube_dlc/utils.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/youtube_dlc/utils.py b/youtube_dlc/utils.py
index 32b179c6f..54a4ea2aa 100644
--- a/youtube_dlc/utils.py
+++ b/youtube_dlc/utils.py
@@ -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]