From: Jaime Marquínez Ferrándiz Date: Tue, 17 Dec 2013 13:56:29 +0000 (+0100) Subject: Simplify url_basename X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=9b8aaeed856f189fef016563a10f7f4e46a1590e;p=youtube-dl Simplify url_basename Use urlparse from the standard library. --- diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py index d5069dcca..4c7ad89c0 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]