@ -6,7 +6,7 @@ function details() {
Type : "Video" ,
Type : "Video" ,
Operation : "Clean" ,
Operation : "Clean" ,
Description : ` This plugin removes title metadata from video/audio/subtitles, if it exists. Video checking is mandatory, audio and subtitles are optional. \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. 6 ",
Version : "1. 7 ",
Link :
Link :
"https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_MC93_Migz2CleanTitle.js" ,
"https://github.com/HaveAGitGat/Tdarr_Plugins/blob/master/Community/Tdarr_Plugin_MC93_Migz2CleanTitle.js" ,
Tags : "pre-processing,ffmpeg,configurable" ,
Tags : "pre-processing,ffmpeg,configurable" ,
@ -62,10 +62,10 @@ function plugin(file, librarySettings, inputs) {
var convert = false ;
var convert = false ;
// Check if inputs.custom_title_matching has been configured. If it has then set variable
// Check if inputs.custom_title_matching has been configured. If it has then set variable
if ( inputs . custom _title _matching != " ")
if ( typeof inputs . custom _title _matching != " undefined ")
try {
{
var custom _title _matching = inputs . custom _title _matching . toLowerCase ( ) . split ( "," ) ;
var custom _title _matching = inputs . custom _title _matching . toLowerCase ( ) . split ( "," ) ;
} catch ( err ) { }
}
// Check if file is a video. If it isn't then exit plugin.
// Check if file is a video. If it isn't then exit plugin.
if ( file . fileMedium !== "video" ) {
if ( file . fileMedium !== "video" ) {
@ -84,15 +84,16 @@ function plugin(file, librarySettings, inputs) {
// Go through each stream in the file.
// Go through each stream in the file.
for ( var i = 0 ; i < file . ffProbeData . streams . length ; i ++ )
for ( var i = 0 ; i < file . ffProbeData . streams . length ; i ++ )
try {
{
// Check if stream is a video.
// Check if stream is a video.
if ( file . ffProbeData . streams [ i ] . codec _type . toLowerCase ( ) == "video" ) {
if ( file . ffProbeData . streams [ i ] . codec _type . toLowerCase ( ) == "video" ) {
// Check if stream title is not empty, if it's not empty set to "".
// Check if stream title is not empty, if it's not empty set to "".
if ( typeof file . ffProbeData . streams [ i ] . tags . title != "undefined" ) {
if ( typeof file . ffProbeData . streams [ i ] . tags . title != "undefined" )
try {
response . infoLog += ` ☒Video stream title is not empty, most likely junk metadata. Removing title from stream ${ i } \n ` ;
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 ) { }
// Increment videoIdx.
// Increment videoIdx.
videoIdx ++ ;
videoIdx ++ ;
}
}
@ -102,16 +103,23 @@ function plugin(file, librarySettings, inputs) {
file . ffProbeData . streams [ i ] . codec _type . toLowerCase ( ) == "audio" &&
file . ffProbeData . streams [ i ] . codec _type . toLowerCase ( ) == "audio" &&
inputs . clean _audio . toLowerCase ( ) == "true"
inputs . clean _audio . toLowerCase ( ) == "true"
) {
) {
if ( file . ffProbeData . streams [ i ] . tags . title . split ( "." ) . length - 1 > 3 ) {
if ( typeof file . ffProbeData . streams [ i ] . tags . title != "undefined" ) {
if ( file . ffProbeData . streams [ i ] . tags . title . split ( "." ) . length - 1 > 3 )
try {
response . infoLog += ` ☒More then 3 full stops detected in audio title, likely to be junk metadata. Removing title from stream ${ i } \n ` ;
response . infoLog += ` ☒More then 3 full stops detected in audio title, likely to be junk metadata. Removing title from stream ${ i } \n ` ;
ffmpegCommandInsert += ` -metadata:s:a: ${ audioIdx } title="" ` ;
ffmpegCommandInsert += ` -metadata:s:a: ${ audioIdx } title="" ` ;
convert = true ;
convert = true ;
}
} catch ( err ) { }
if ( custom _title _matching . indexOf ( file . ffProbeData . streams [ i ] . tags . title . toLowerCase ( ) ) !== - 1 ) {
if ( typeof inputs . custom _title _matching != "undefined" )
try {
if ( custom _title _matching . indexOf ( file . ffProbeData . streams [ i ] . tags . title . toLowerCase ( ) ) !== - 1 )
{
response . infoLog += ` ☒Audio matched custom input. Removing title from stream ${ i } \n ` ;
response . infoLog += ` ☒Audio matched custom input. Removing title from stream ${ i } \n ` ;
ffmpegCommandInsert += ` -metadata:s:a: ${ audioIdx } title="" ` ;
ffmpegCommandInsert += ` -metadata:s:a: ${ audioIdx } title="" ` ;
convert = true ;
convert = true ;
}
}
} catch ( err ) { }
}
// Increment audioIdx.
// Increment audioIdx.
audioIdx ++ ;
audioIdx ++ ;
}
}
@ -121,20 +129,26 @@ function plugin(file, librarySettings, inputs) {
file . ffProbeData . streams [ i ] . codec _type . toLowerCase ( ) == "subtitle" &&
file . ffProbeData . streams [ i ] . codec _type . toLowerCase ( ) == "subtitle" &&
inputs . clean _subtitles . toLowerCase ( ) == "true"
inputs . clean _subtitles . toLowerCase ( ) == "true"
) {
) {
if ( file . ffProbeData . streams [ i ] . tags . title . split ( "." ) . length - 1 > 3 ) {
if ( typeof file . ffProbeData . streams [ i ] . tags . title != "undefined" ) {
if ( file . ffProbeData . streams [ i ] . tags . title . split ( "." ) . length - 1 > 3 )
try {
response . infoLog += ` ☒More then 3 full stops detected in subtitle title, likely to be junk metadata. Removing title from stream ${ i } \n ` ;
response . infoLog += ` ☒More then 3 full stops detected in subtitle title, likely to be junk metadata. Removing title from stream ${ i } \n ` ;
ffmpegCommandInsert += ` -metadata:s:s: ${ subtitleIdx } title="" ` ;
ffmpegCommandInsert += ` -metadata:s:s: ${ subtitleIdx } title="" ` ;
convert = true ;
convert = true ;
}
} catch ( err ) { }
if ( typeof inputs . custom _title _matching != "undefined" )
try {
if ( custom _title _matching . indexOf ( file . ffProbeData . streams [ i ] . tags . title . toLowerCase ( ) ) !== - 1 ) {
if ( custom _title _matching . indexOf ( file . ffProbeData . streams [ i ] . tags . title . toLowerCase ( ) ) !== - 1 ) {
response . infoLog += ` ☒Subtitle matched custom input. Removing title from stream ${ i } \n ` ;
response . infoLog += ` ☒Subtitle matched custom input. Removing title from stream ${ i } \n ` ;
ffmpegCommandInsert += ` -metadata:s:s: ${ subtitleIdx } title="" ` ;
ffmpegCommandInsert += ` -metadata:s:s: ${ subtitleIdx } title="" ` ;
convert = true ;
convert = true ;
}
}
} catch ( err ) { }
}
// Increment subtitleIdx.
// Increment subtitleIdx.
subtitleIdx ++ ;
subtitleIdx ++ ;
}
}
} catch ( err ) { }
}
// Convert file if convert variable is set to true.
// Convert file if convert variable is set to true.
if ( convert == true ) {
if ( convert == true ) {