Skip to content

A feature-rich command-line audio/video downloader

Simplify url_basename

Jaime Marquínez Ferrándiz9b8aaeed856f
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index d5069dcca9..4c7ad89c0b 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -1092,7 +1092,5 @@ def remove_start(s, start):
def url_basename(url):
- m = re.match(r'(?:https?:|)//[^/]+/(?:[^?#]+/)?([^/?#]+)/?(?:[?#]|$)', url)
- if not m:
- return u''
- return m.group(1)
+ path = compat_urlparse.urlparse(url).path
+ return path.strip(u'/').split(u'/')[-1]