Esempio n. 1
0
 def getFilepath(self, track):
     """Find instances of 4 consecutive digits in the dir and file names.
     
     If there are multiple instances, this function currently favors the 
     leftmost, but this may not be optimal."""
     
     folderFilePath = os.path.join(functions.containingDir(track.filePath), 
                                   track.fileName)
     
     result = None
     match = re.findall("\d{4}", folderFilePath)
     if match:
         result = match[0]
             
     return result
Esempio n. 2
0
    def getFilenameForMB(self, track):
        """Return filename and containing dir with year removed."""

        folderFilePath = os.path.join(functions.containingDir(track.filePath),
                                      track.fileName)
        folderFilePath = os.path.splitext(folderFilePath)[0]

        if "date" in track.metadata:  # If we know the date, try to remove it...
            date = track.metadata["date"]
            folderFilePath = folderFilePath.replace(date, "")
        else:  # ...otherwise just remove the leftmost set of four digits, if any.
            match = re.findall("\d{4}", folderFilePath)
            if match:
                folderFilePath = folderFilePath.replace(match[0], "")

        return mb.FilepathString(toUnicode(folderFilePath))
Esempio n. 3
0
 def getFilenameForMB(self, track):
     """Return filename and containing dir with year removed."""
     
     folderFilePath = os.path.join(functions.containingDir(track.filePath), 
                                   track.fileName)
     folderFilePath = os.path.splitext(folderFilePath)[0]
     
     if "date" in track.metadata: # If we know the date, try to remove it...
         date = track.metadata["date"]
         folderFilePath = folderFilePath.replace(date, "")
     else: # ...otherwise just remove the leftmost set of four digits, if any.
         match = re.findall("\d{4}", folderFilePath)
         if match:
             folderFilePath = folderFilePath.replace(match[0], "")
             
     return mb.FilepathString(toUnicode(folderFilePath))