about summary refs log tree commit diff
path: root/youtube_dl/postprocessor/metadatafromtitle.py
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2015-03-14 19:55:42 +0100
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2015-03-14 20:06:33 +0100
commit88cf6fb3685c4e012c9f574cbc5f1836c42fc06d (patch)
tree7a2c2e2f1d69c989866cc34563a5a662ac7ef62e /youtube_dl/postprocessor/metadatafromtitle.py
parente7db87f7000143341505cff812d1fa0371ac901e (diff)
downloadyoutube-dl-88cf6fb3685c4e012c9f574cbc5f1836c42fc06d.tar.gz
youtube-dl-88cf6fb3685c4e012c9f574cbc5f1836c42fc06d.tar.xz
youtube-dl-88cf6fb3685c4e012c9f574cbc5f1836c42fc06d.zip
[metadatafromtitle] Some improvements and cleanup
* Remove the 'songtitle' field, 'title' can be used instead.
* Remove newlines in the help text, for consistency with other options.
* Add 'from __future__ import unicode_literals'.
* Call '__init__' from the parent class.
* Add test for the format_to_regex method
Diffstat (limited to 'youtube_dl/postprocessor/metadatafromtitle.py')
-rw-r--r--youtube_dl/postprocessor/metadatafromtitle.py9
1 files changed, 4 insertions, 5 deletions
diff --git a/youtube_dl/postprocessor/metadatafromtitle.py b/youtube_dl/postprocessor/metadatafromtitle.py
index 4c9d3aafe..5019433d3 100644
--- a/youtube_dl/postprocessor/metadatafromtitle.py
+++ b/youtube_dl/postprocessor/metadatafromtitle.py
@@ -1,4 +1,4 @@
-# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
 
 import re
 
@@ -12,20 +12,19 @@ class MetadataFromTitlePPError(PostProcessingError):
 
 class MetadataFromTitlePP(PostProcessor):
     def __init__(self, downloader, titleformat):
+        super(MetadataFromTitlePP, self).__init__(downloader)
         self._titleformat = titleformat
-        self._titleregex = self.fmtToRegex(titleformat)
+        self._titleregex = self.format_to_regex(titleformat)
 
-    def fmtToRegex(self, fmt):
+    def format_to_regex(self, fmt):
         """
         Converts a string like
            '%(title)s - %(artist)s'
         to a regex like
            '(?P<title>.+)\ \-\ (?P<artist>.+)'
-        and a list of the named groups [title, artist]
         """
         lastpos = 0
         regex = ""
-        groups = []
         # replace %(..)s with regex group and escape other string parts
         for match in re.finditer(r'%\((\w+)\)s', fmt):
             regex += re.escape(fmt[lastpos:match.start()])