Cleanup name to exclude extension and CRC on tag matching

This commit is contained in:
DataHoarder 2023-05-22 17:44:32 +02:00
parent b9129311af
commit 2e142ffbab
Signed by: DataHoarder
SSH key fingerprint: SHA256:OLTRf6Fl87G52SiR7sWLGNzlJt4WOX+tfI2yxo0z7xk

View file

@ -1,7 +1,7 @@
// ==UserScript==
// @name AnimeBytes Mediainfo Improvements
// @author WeebDataHoarder
// @version 1.30.3
// @version 1.30.4
// @downloadURL https://git.gammaspectra.live/WeebDataHoarder/userscripts/raw/branch/master/AnimeBytes/ab-mediainfo.user.js
// @updateURL https://git.gammaspectra.live/WeebDataHoarder/userscripts/raw/branch/master/AnimeBytes/ab-mediainfo.user.js
// @description AnimeBytes Mediainfo Improvements. Adds several listing and matching releases against mediainfo utilities. MIT license
@ -255,8 +255,12 @@ function extractTagsFromFilename(fileName, sourceTags, source = ""){
let tags = {
};
let cleanName = fileName.replace(/\.[^/.]+$/, "")
cleanName = cleanName.replace(/\[[A-F0-9]{8}\]$/i, "")
cleanName = cleanName.replace(/\([A-F0-9]{8}\)$/i, "")
//handle file tags
fileName.split(".").forEach((p) => {
cleanName.split(".").forEach((p) => {
const pCase = p.toUpperCase();
if(pCase === "NF" || pCase === "NETFLIX"){
tags.sourceName = "Netflix";
@ -291,7 +295,7 @@ function extractTagsFromFilename(fileName, sourceTags, source = ""){
}else if(pCase === "REMUX"){
tags.remux = true;
}else if(p.match(/^(bd|(blu-?ray))(-?rip)?$/i) !== null){
tags.source = (fileName.match(/(4K|2160|3840|UHD)/) !== null || sourceTags.source === "UHD Blu-ray") ? "UHD Blu-ray" : "Blu-ray";
tags.source = (cleanName.match(/(4K|2160|3840|UHD)/) !== null || sourceTags.source === "UHD Blu-ray") ? "UHD Blu-ray" : "Blu-ray";
}else if(p.match(/^dvd(-?rip)?$/i) !== null){
tags.source = "DVD";
}else if(p.match(/^web(-?(rip|dl))?$/i) !== null){
@ -306,7 +310,7 @@ function extractTagsFromFilename(fileName, sourceTags, source = ""){
}
});
fileName.split(/[ _\[(\])]/).forEach((p) => {
cleanName.split(/[ _\[(\])]/).forEach((p) => {
const pCase = p.toUpperCase();
if(source === "Web" && (pCase === "NF" || pCase === "NETFLIX")){
tags.sourceName = "Netflix";
@ -383,7 +387,7 @@ function extractTagsFromFilename(fileName, sourceTags, source = ""){
}else if(pCase.indexOf("REMUX") !== -1){
tags.remux = true;
}else if(p.match(/^(bd|(blu-?ray))(-?rip)?$/i) !== null){
tags.source = (fileName.match(/(4K|2160|3840|UHD)/) !== null || sourceTags.source === "UHD Blu-ray") ? "UHD Blu-ray" : "Blu-ray";
tags.source = (cleanName.match(/(4K|2160|3840|UHD)/) !== null || sourceTags.source === "UHD Blu-ray") ? "UHD Blu-ray" : "Blu-ray";
}else if(p.match(/^dvd(-?rip)?$/i) !== null){
tags.source = "DVD";
}else if(p.match(/^web(-?(rip|dl))?$/i) !== null){