Posted by: Therusef
« on: March 28, 2016, 09:28:38 »nothing at this end. If you all want to come to a consensus on an Excel or XML format I will add the script to upload.
JohnA
JohnA
/*
Author: Similarity Team
Version: 1.0
Description:
Mark files after scan only if tags restrictions satisfied. Priority by rating (you can simply change it).
Warning! Using analysis.rating forces to analyse file, if you didn't analyse files before, it take much time (because this script analyses files only on 1 cpu core).
We suggest to perform analyses before launch of this script (Analyse all context menu).
*/
// album, artist, title - comment/uncomment string to disable/enable such restriction
// threshold - threshold for string comparing algorithm, scores between [0...1], 0 - absolutely different, 1 - absolutely same
// minlength - minimal length of text in the tag for comparing, files don't fit the criterion will be skipped
var myProperties = {
album: { threshold: 0.9, minlength: 2 },
artist: { threshold: 0.9, minlength: 2 },
// title: { threshold: 0.9, minlength: 2 },
}
// unmark all files
results.audio.unmark();
function checkRestrictions(item1, item2) {
// enumerate all selected tag fields
for (var property in myProperties) {
// check each field
var minlength = myProperties[property].minlength;
var threshold = myProperties[property].threshold;
var text1 = item1.audio[property];
var text2 = item2.audio[property];
// skip short tags
if (minlength > 0 && (text1.length < minlength || text2.length < minlength)) return false;
// check text string(tag values) similarity
if (threshold > 0.0 && text.calculate(text1, text2) < threshold) return false;
}
return true;
}
// simple mark by lower bitrate
var dups = results.audio.dups;
for (var idx = 0; idx < dups.length; ++idx) {
// skip counter-pair (1-2 and 2-1), process pair only once
if (dups[idx].item1.path > dups[idx].item2.path) continue;
// check for our special tag restrictions
if (!checkRestrictions(dups[idx].item1, dups[idx].item2)) continue;
// ok now we select by our priority
if (dups[idx].item1.analysis.rating > dups[idx].item2.analysis.rating) dups[idx].item2.marked = true;
else dups[idx].item1.marked = true;
}