Browse Source

[extractor/common] Add id and title helpers for generic IEs

Yen Chi Hsuan 9 years ago
parent
commit
98763ee354
1 changed files with 7 additions and 0 deletions
  1. 7 0
      youtube_dl/extractor/common.py

+ 7 - 0
youtube_dl/extractor/common.py

@@ -21,6 +21,7 @@ from ..compat import (
     compat_os_name,
     compat_os_name,
     compat_str,
     compat_str,
     compat_urllib_error,
     compat_urllib_error,
+    compat_urllib_parse_unquote,
     compat_urllib_parse_urlencode,
     compat_urllib_parse_urlencode,
     compat_urllib_request,
     compat_urllib_request,
     compat_urlparse,
     compat_urlparse,
@@ -2020,6 +2021,12 @@ class InfoExtractor(object):
             headers['Ytdl-request-proxy'] = geo_verification_proxy
             headers['Ytdl-request-proxy'] = geo_verification_proxy
         return headers
         return headers
 
 
+    def _generic_id(self, url):
+        return compat_urllib_parse_unquote(os.path.splitext(url.rstrip('/').split('/')[-1])[0])
+
+    def _generic_title(self, url):
+        return compat_urllib_parse_unquote(os.path.splitext(url_basename(url))[0])
+
 
 
 class SearchInfoExtractor(InfoExtractor):
 class SearchInfoExtractor(InfoExtractor):
     """
     """