mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-14 09:45:55 -07:00
Update: Migz2CleanTitle
Updated the way that audio/subtitles decide if the title is junk or not. Fixes issue with conversion loop when used with my CleanAudio plugin.
This commit is contained in:
parent
131406f364
commit
2e37ed84bf
1 changed files with 54 additions and 38 deletions
|
|
@ -5,14 +5,34 @@ function details() {
|
||||||
Name: "Migz-Clean title metadata",
|
Name: "Migz-Clean title metadata",
|
||||||
Type: "Video",
|
Type: "Video",
|
||||||
Operation: "Clean",
|
Operation: "Clean",
|
||||||
Description: `This plugin removes title metadata from video/audio/subtitles, if it exists. \n\n`,
|
Description: `This plugin removes title metadata from video/audio/subtitles, if it exists. Video checking is mandatory, audio and subtitles are optional.\n\n`,
|
||||||
Version: "1.10",
|
Version: "1.20",
|
||||||
Link: "https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_MC93_Migz2CleanTitle.js",
|
Link: "https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_MC93_Migz2CleanTitle.js",
|
||||||
Tags:'pre-processing,ffmpeg',
|
Tags:'pre-processing,ffmpeg,configurable',
|
||||||
|
Inputs: [
|
||||||
|
{
|
||||||
|
name: 'clean_audio',
|
||||||
|
tooltip: `Specify if audio titles should be checked & cleaned. Optional.
|
||||||
|
\\nExample:\\n
|
||||||
|
true
|
||||||
|
|
||||||
|
\\nExample:\\n
|
||||||
|
false`
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'clean_subtitles',
|
||||||
|
tooltip: `Specify if subtitle titles should be checked & cleaned. Optional.
|
||||||
|
\\nExample:\\n
|
||||||
|
true
|
||||||
|
|
||||||
|
\\nExample:\\n
|
||||||
|
false`
|
||||||
|
},
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function plugin(file) {
|
function plugin(file, librarySettings, inputs) {
|
||||||
var response = {
|
var response = {
|
||||||
processFile : false,
|
processFile : false,
|
||||||
preset : '',
|
preset : '',
|
||||||
|
|
@ -37,46 +57,42 @@ function plugin(file) {
|
||||||
return response
|
return response
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
if (typeof file.meta.Title != 'undefined') try {
|
||||||
if (typeof file.meta.Title != 'undefined' ){
|
|
||||||
ffmpegCommandInsert += ` -metadata title="" `
|
ffmpegCommandInsert += ` -metadata title="" `
|
||||||
response.infoLog += "1"
|
|
||||||
convert = true
|
convert = true
|
||||||
}
|
} catch (err) { }
|
||||||
} catch (err) { }
|
|
||||||
|
|
||||||
for (var i = 0; i < file.ffProbeData.streams.length; i++) {
|
for (var i = 0; i < file.ffProbeData.streams.length; i++) try {
|
||||||
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "video") {
|
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "video") {
|
||||||
try {
|
if (typeof file.ffProbeData.streams[i].tags.title != 'undefined') {
|
||||||
if (typeof file.ffProbeData.streams[i].tags.title != 'undefined') {
|
response.infoLog += `☒Video stream title is not empty, most likely junk metadata. Removing title from stream ${i} \n`
|
||||||
ffmpegCommandInsert += ` -metadata:s:v:${videoIdx} title="" `
|
ffmpegCommandInsert += ` -metadata:s:v:${videoIdx} title="" `
|
||||||
convert = true
|
convert = true
|
||||||
}
|
}
|
||||||
} catch (err) { }
|
|
||||||
videoIdx++
|
videoIdx++
|
||||||
}
|
}
|
||||||
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio") {
|
|
||||||
try {
|
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "audio" && inputs.clean_audio.toLowerCase() == "true") {
|
||||||
if (typeof file.ffProbeData.streams[i].tags.title != 'undefined') {
|
if (file.ffProbeData.streams[i].tags.title.split('.').length-1 > 3) {
|
||||||
ffmpegCommandInsert += ` -metadata:s:a:${audioIdx} title="" `
|
response.infoLog += `☒More then 3 full stops detected in subtitle title, likely to be junk metadata. Removing title from stream ${i} \n`
|
||||||
convert = true
|
ffmpegCommandInsert += ` -metadata:s:a:${audioIdx} title="" `
|
||||||
}
|
convert = true
|
||||||
} catch (err) { }
|
}
|
||||||
audioIdx++
|
audioIdx++
|
||||||
}
|
}
|
||||||
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "subtitle") {
|
|
||||||
try {
|
if (file.ffProbeData.streams[i].codec_type.toLowerCase() == "subtitle" && inputs.clean_subtitles.toLowerCase() == "true") {
|
||||||
if (typeof file.ffProbeData.streams[i].tags.title != 'undefined') {
|
if (file.ffProbeData.streams[i].tags.title.split('.').length-1 > 3) {
|
||||||
ffmpegCommandInsert += ` -metadata:s:s:${subtitleIdx} title="" `
|
response.infoLog += `☒More then 3 full stops detected in subtitle title, likely to be junk metadata. Removing title from stream ${i} \n`
|
||||||
convert = true
|
ffmpegCommandInsert += ` -metadata:s:s:${subtitleIdx} title="" `
|
||||||
}
|
convert = true
|
||||||
} catch (err) { }
|
}
|
||||||
subtitleIdx++
|
subtitleIdx++
|
||||||
}
|
}
|
||||||
}
|
} catch (err) { }
|
||||||
|
|
||||||
if (convert == true){
|
if (convert == true) {
|
||||||
response.infoLog += "☒File has title metadata \n"
|
response.infoLog += "☒File has title metadata. Removing \n"
|
||||||
response.preset = `,${ffmpegCommandInsert} -c copy`
|
response.preset = `,${ffmpegCommandInsert} -c copy`
|
||||||
response.reQueueAfter = true;
|
response.reQueueAfter = true;
|
||||||
response.processFile = true;
|
response.processFile = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue