From 9b8aaeed856f189fef016563a10f7f4e46a1590e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaime=20Marqui=CC=81nez=20Ferra=CC=81ndiz?= Date: Tue, 17 Dec 2013 14:56:29 +0100 Subject: [PATCH] Simplify url_basename Use urlparse from the standard library. --- youtube_dl/utils.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) 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]