# HG changeset patch # User mdd # Date 1509831252 -3600 # Node ID 569fa9a431b9321c30c8ea3af619407358d88781 # Parent 319f8c3fd39412586f415702b643949f8a086c7d added filename duplicate checker diff -r 319f8c3fd394 -r 569fa9a431b9 .hgignore --- a/.hgignore Sat Nov 04 22:30:19 2017 +0100 +++ b/.hgignore Sat Nov 04 22:34:12 2017 +0100 @@ -1,4 +1,5 @@ syntax: glob *.pyc -eit.old/* \ No newline at end of file +eit.old/* +testfiles/* diff -r 319f8c3fd394 -r 569fa9a431b9 dupecheck.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/dupecheck.py Sat Nov 04 22:34:12 2017 +0100 @@ -0,0 +1,47 @@ +#!/usr/bin/env python + +import difflib +import os, sys + +BASEDIR="../DREAMBOX" + +FILELIST=[] +DUPLICATES={} + +def similarity(seq1, seq2): + #return difflib.SequenceMatcher(a=seq1.lower(), b=seq2.lower()).ratio() + return difflib.SequenceMatcher(a=seq1, b=seq2).ratio() + +for root, subdirs, files in os.walk(BASEDIR): + for filename in files: + if filename.endswith(".ts"): + file_path = os.path.join(root, filename) + title = filename.split(" - ") + if len(title) == 1: + title = title[0] + else: + title = " - ".join(title[2:]) + title = title[:-3].lower() + FILELIST.append([title, filename, root]) + elif filename.endswith(".mkv"): + title = filename[:-4].lower() + FILELIST.append([title, filename, root]) + + +for idx, item in enumerate(FILELIST): + comparelist = FILELIST[idx+1:] + #print "%d %s (%d to compare)" % (idx, item[0], len(comparelist)) + for idx2, item2 in enumerate(comparelist): + if similarity(item[0], item2[0]) > 0.85: + #print "possible duplicate %d %s" % (idx2, item2[0]) + key = os.path.join(item[2], item[1]) + if not key in DUPLICATES.keys(): + DUPLICATES[key] = [] + DUPLICATES[key].append( + os.path.join(item2[2], item2[1])) + +for base in DUPLICATES.keys(): + print base + for dup in DUPLICATES[base]: + print dup + print "" \ No newline at end of file