X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fpostprocessor%2Fmetadatafromtitle.py;h=f5c14d974f4b44c9a5c014a536a0b2f72c65b2db;hb=d51e23d9fc709a80ca037199a46e59c729a1192e;hp=4c9d3aafec43ec12be9dcb4eba991274d8dbe849;hpb=e7db87f7000143341505cff812d1fa0371ac901e;p=youtube-dl diff --git a/youtube_dl/postprocessor/metadatafromtitle.py b/youtube_dl/postprocessor/metadatafromtitle.py index 4c9d3aafe..f5c14d974 100644 --- a/youtube_dl/postprocessor/metadatafromtitle.py +++ b/youtube_dl/postprocessor/metadatafromtitle.py @@ -1,48 +1,48 @@ -# -*- coding: utf-8 -*- +from __future__ import unicode_literals import re from .common import PostProcessor -from ..utils import PostProcessingError - - -class MetadataFromTitlePPError(PostProcessingError): - pass 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) + if re.search(r'%\(\w+\)s', titleformat) + else titleformat) - def fmtToRegex(self, fmt): - """ + def format_to_regex(self, fmt): + r""" Converts a string like '%(title)s - %(artist)s' to a regex like '(?P