dbr / tvnamer

Automatic TV episode file renamer, uses data from thetvdb.com via tvdb_api
https://pypi.python.org/pypi/tvnamer/
The Unlicense
909 stars 115 forks source link

Blacklist doesn't process full_path correctly #120

Open felciano opened 8 years ago

felciano commented 8 years ago

The blacklist feature doesn't correctly allow you to filter out files based on path components. For example, I believe the following should tell tvnamer to ignore any files under the .AppleDouble directory:

{
    "is_regex": false,
    "full_path": true,
    "match": ".AppleDouble"
}

This doesn't work -- any media files (or rather their corresponding resource forks, which I believe is what ends up being created by OSX in AppleDouble directories) are processed by tvnamer as if they were real media files.

I believe the culprit is _findFilesInPath which incorrectly checks the blacklist with a file basename instead of full pathname:

        for subf in os.listdir(string_type(startpath)):
            newpath = os.path.join(startpath, subf)
            newpath = os.path.abspath(newpath)
            if os.path.isfile(newpath):
                if not self._checkExtension(subf):
                    continue
                elif self._blacklistedFilename(subf):
                    continue
                else:
                    allfiles.append(newpath)
            else:
                if self.recursive:
                    allfiles.extend(self._findFilesInPath(newpath))
                #end if recursive
            #end if isfile
        #end for sf

The line in the middle should read:

                elif self._blacklistedFilename(newpath):

instead of

                elif self._blacklistedFilename(subf):
queeup commented 7 years ago

Yes you are right. @dbr could you check this pls.