mirror of
https://github.com/gabehf/Tdarr_Plugins.git
synced 2026-03-15 10:15:54 -07:00
Update Tdarr_Plugin_rename_based_on_codec_schadi.js
This commit is contained in:
parent
a344ca8d4a
commit
1db09504c6
1 changed files with 9 additions and 6 deletions
|
|
@ -90,6 +90,9 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
||||||
var firstVideoStreamCodec;
|
var firstVideoStreamCodec;
|
||||||
var firstAudioStreamCodec;
|
var firstAudioStreamCodec;
|
||||||
|
|
||||||
|
const videoCodecRegex = /(h264|h265|x264|x265|avc|hevc|mpeg2|av1)/gi;
|
||||||
|
const audioCodecRegex = /(aac|ac3|eac3|flac|mp2|mp3|truehd|dts[-. ]hd[-. ]ma|dts[-. ]hd[-. ]es|dts[-. ]hd[-. ]hra|dts[-. ]express|dts)/gi;
|
||||||
|
|
||||||
const videoStream = file.ffProbeData.streams.find((stream) => stream.codec_type === 'video');
|
const videoStream = file.ffProbeData.streams.find((stream) => stream.codec_type === 'video');
|
||||||
|
|
||||||
if (videoStream && inputs.rename_video) {
|
if (videoStream && inputs.rename_video) {
|
||||||
|
|
@ -98,8 +101,8 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
||||||
|
|
||||||
if (videoCodec in codecMap) {
|
if (videoCodec in codecMap) {
|
||||||
const renamedCodec = codecMap[videoCodec];
|
const renamedCodec = codecMap[videoCodec];
|
||||||
file._id = file._id.replace(/(h264|h265|x264|x265|avc|hevc|mpeg2|av1)/gi, renamedCodec);
|
file._id = file._id.replace(videoCodecRegex, renamedCodec);
|
||||||
file.file = file.file.replace(/(h264|h265|x264|x265|avc|hevc|mpeg2|av1)/gi, renamedCodec);
|
file.file = file.file.replace(videoCodecRegex, renamedCodec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -111,8 +114,8 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
||||||
|
|
||||||
if (audioCodec in codecMap) {
|
if (audioCodec in codecMap) {
|
||||||
const renamedCodec = codecMap[audioCodec];
|
const renamedCodec = codecMap[audioCodec];
|
||||||
file._id = file._id.replace(/(aac|ac3|eac3|flac|mp2|mp3|truehd|dts[-. ]hd[-. ]ma|dts[-. ]hd[-. ]es|dts[-. ]hd[-. ]hra|dts[-. ]express|dts)/gi, renamedCodec);
|
file._id = file._id.replace(audioCodecRegex, renamedCodec);
|
||||||
file.file = file.file.replace(/(aac|ac3|eac3|flac|mp2|mp3|truehd|dts[-. ]hd[-. ]ma|dts[-. ]hd[-. ]es|dts[-. ]hd[-. ]hra|dts[-. ]express|dts)/gi, renamedCodec);
|
file.file = file.file.replace(audioCodecRegex, renamedCodec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -142,8 +145,8 @@ const plugin = (file, librarySettings, inputs, otherArguments) => {
|
||||||
const renamedAudioCodec = codecMap[firstAudioStreamCodec];
|
const renamedAudioCodec = codecMap[firstAudioStreamCodec];
|
||||||
|
|
||||||
const renamedFileWithCodecs = additionalFileName
|
const renamedFileWithCodecs = additionalFileName
|
||||||
.replace(/(h264|h265|x264|x265|avc|hevc|mpeg2|av1)/gi, renamedVideoCodec)
|
.replace(videoCodecRegex, renamedVideoCodec)
|
||||||
.replace(/(aac|ac3|eac3|flac|mp2|mp3|truehd|dts[-. ]hd[-. ]ma|dts[-. ]hd[-. ]es|dts[-. ]hd[-. ]hra|dts[-. ]express|dts)/gi, renamedAudioCodec);
|
.replace(audioCodecRegex, renamedAudioCodec);
|
||||||
|
|
||||||
return renamedFileWithCodecs;
|
return renamedFileWithCodecs;
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue