Bug fix (did not catch all commentaries and subs)

make-only-subtitle-default
HaveAGitGat 6 years ago committed by GitHub
parent 89ad78d78d
commit c41b441409
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -52,77 +52,63 @@ function plugin(file) {
} else { } else {
var jsonString = JSON.stringify(file)
var ffmpegDataString = JSON.stringify(file.ffProbeData) var ffmpegDataString = JSON.stringify(file.ffProbeData)
var ac3TrackCount = (ffmpegDataString.match(/ac3/g) || []).length; var ac3TrackCount = (ffmpegDataString.match(/ac3/g) || []).length;
var hasAC3Commentary = false var AC3CommentaryCount = 0
var hasSubs = false
for (var i = 0; i < file.ffProbeData.streams.length; i++) { for (var i = 0; i < file.ffProbeData.streams.length; i++) {
try { try {
if (file.ffProbeData.streams[i].codec_name.toLowerCase() == "ac3" && file.ffProbeData.streams[i].tags.title.toLowerCase() == "commentary") { if (file.ffProbeData.streams[i].codec_name.toLowerCase() == "ac3" && file.ffProbeData.streams[i].tags.title.toLowerCase() == "commentary") {
hasAC3Commentary = true AC3CommentaryCount++
}
} catch (err) { }
} }
if(file.ffProbeData.streams[i].codec_type.toLowerCase() == "subtitle"){
var hasOneAC3TrackCommentary hasSubs = true
}
} catch (err) { }
}
if (!!hasAC3Commentary && ac3TrackCount == 1) { var hasOnlyAC3TrackCommentaries
hasOneAC3TrackCommentary = true
if (ac3TrackCount > 0 && AC3CommentaryCount == ac3TrackCount ) {
hasOnlyAC3TrackCommentaries = true
} else { } else {
hasOnlyAC3TrackCommentaries = false
hasOneAC3TrackCommentary = false
} }
var hasNoAC3Track var hasNoAC3Track
if (ac3TrackCount == 0) { if (ac3TrackCount == 0) {
hasNoAC3Track = true hasNoAC3Track = true
} else { } else {
hasNoAC3Track = false hasNoAC3Track = false
} }
if (hasOnlyAC3TrackCommentaries && hasSubs) {
response.infoLog += "File has only AC3 track Commentaries and has subs"
if (hasOneAC3TrackCommentary && jsonString.includes("subrip")) {
response.infoLog += "File has only one AC3 track (commentary) and has subs"
response.preset = '-sn,-map 0:v -map 0:a:0 -map 0:a -map 0:s? -map 0:d? -c copy -c:a:0 ac3' response.preset = '-sn,-map 0:v -map 0:a:0 -map 0:a -map 0:s? -map 0:d? -c copy -c:a:0 ac3'
response.reQueueAfter = true; response.reQueueAfter = true;
response.processFile = true; response.processFile = true;
return response return response
} }
if (hasNoAC3Track && jsonString.includes("subrip")) { if (hasNoAC3Track && hasSubs) {
response.infoLog += "File has no AC3 track and has subs" response.infoLog += "File has no AC3 track and has subs"
response.preset = '-sn,-map 0:v -map 0:a:0 -map 0:a -map 0:s? -map 0:d? -c copy -c:a:0 ac3' response.preset = '-sn,-map 0:v -map 0:a:0 -map 0:a -map 0:s? -map 0:d? -c copy -c:a:0 ac3'
response.reQueueAfter = true; response.reQueueAfter = true;
@ -132,27 +118,24 @@ function plugin(file) {
if (!!hasOneAC3TrackCommentary == true) { if (!!hasOnlyAC3TrackCommentaries == true) {
response.infoLog += " File has only AC3 track Commentaries!"
response.infoLog += " File has only one AC3 track (commentary)!"
response.preset = ',-map 0:v -map 0:a:0 -map 0:a -map 0:s? -map 0:d? -c copy -c:a:0 ac3' response.preset = ',-map 0:v -map 0:a:0 -map 0:a -map 0:s? -map 0:d? -c copy -c:a:0 ac3'
response.reQueueAfter = true; response.reQueueAfter = true;
response.processFile = true; response.processFile = true;
return response return response
} else { } else {
response.infoLog += " File does not have only one AC3 track (commentary)!" response.infoLog += " File does not have only AC3 track Commentaries!"
} }
if (hasNoAC3Track) { if (hasNoAC3Track) {
response.infoLog += " File has no AC3 track!" response.infoLog += " File has no AC3 track!"
response.preset = ',-map 0:v -map 0:a:0 -map 0:a -map 0:s? -map 0:d? -c copy -c:a:0 ac3' response.preset = ',-map 0:v -map 0:a:0 -map 0:a -map 0:s? -map 0:d? -c copy -c:a:0 ac3'
response.reQueueAfter = true; response.reQueueAfter = true;
response.processFile = true; response.processFile = true;
return response return response
} else { } else {
response.infoLog += " File has AC3 track!" response.infoLog += " File has AC3 track!"
} }
@ -160,14 +143,12 @@ function plugin(file) {
if (jsonString.includes("subrip")) { if (hasSubs) {
response.infoLog += " File has subs!" response.infoLog += " File has subs!"
response.preset = '-sn, -c:v copy -c:a copy' response.preset = '-sn, -c:v copy -c:a copy'
response.reQueueAfter = true; response.reQueueAfter = true;
response.processFile = true; response.processFile = true;
return response return response
} else { } else {
response.infoLog += " File has no subs" response.infoLog += " File has no subs"
} }

Loading…
Cancel
Save