aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2013-12-17 04:13:36 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2013-12-17 04:13:36 +0100
commit29eb5174031cfc0b5de556da3da7761ac377de4e (patch)
treebdc0158bbf6a069777719d70c89b96939c1c651a /youtube_dl
parent44c471c3b873473157adb8ba8a55667ab54b2602 (diff)
Add webpage_url_basename info_dict field (Fixes #1938)
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/YoutubeDL.py4
-rw-r--r--youtube_dl/utils.py7
2 files changed, 11 insertions, 0 deletions
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py
index b1f87415b..2a078adfb 100644
--- a/youtube_dl/YoutubeDL.py
+++ b/youtube_dl/YoutubeDL.py
@@ -47,6 +47,7 @@ from .utils import (
subtitles_filename,
takewhile_inclusive,
UnavailableVideoError,
+ url_basename,
write_json_file,
write_string,
YoutubeDLHandler,
@@ -484,6 +485,7 @@ class YoutubeDL(object):
{
'extractor': ie.IE_NAME,
'webpage_url': url,
+ 'webpage_url_basename': url_basename(url),
'extractor_key': ie.ie_key(),
})
if process:
@@ -576,6 +578,7 @@ class YoutubeDL(object):
'playlist_index': i + playliststart,
'extractor': ie_result['extractor'],
'webpage_url': ie_result['webpage_url'],
+ 'webpage_url_basename': url_basename(ie_result['webpage_url']),
'extractor_key': ie_result['extractor_key'],
}
@@ -596,6 +599,7 @@ class YoutubeDL(object):
{
'extractor': ie_result['extractor'],
'webpage_url': ie_result['webpage_url'],
+ 'webpage_url_basename': url_basename(ie_result['webpage_url']),
'extractor_key': ie_result['extractor_key'],
})
return r
diff --git a/youtube_dl/utils.py b/youtube_dl/utils.py
index dbfac0f43..a249c7ec1 100644
--- a/youtube_dl/utils.py
+++ b/youtube_dl/utils.py
@@ -1084,3 +1084,10 @@ def remove_start(s, start):
if s.startswith(start):
return s[len(start):]
return s
+
+
+def url_basename(url):
+ m = re.match(r'(?:https?:|)//[^/]+/(?:[^/?#]+/)?([^/?#]+)/?(?:[?#]|$)', url)
+ if not m:
+ return u''
+ return m.group(1)