Explorar o código

Simplify url_basename

Use urlparse from the standard library.
Jaime Marquínez Ferrándiz %!s(int64=12) %!d(string=hai) anos
pai
achega
9b8aaeed85
Modificáronse 1 ficheiros con 2 adicións e 4 borrados
  1. 2 4
      youtube_dl/utils.py

+ 2 - 4
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]