feat: add option to download auto-generated subtitles too (#53)

This commit is contained in:
Jelle Glebbeek
2021-05-06 02:06:10 +02:00
parent cd74cebcd2
commit 3715411ca8
6 changed files with 19 additions and 5 deletions

View File

@@ -61,8 +61,13 @@ class DownloadQuery extends Query {
if (this.video.downloadSubs) {
args.push("--all-subs");
args.push("--embed-subs");
args.push("--sub-format")
args.push("srt")
args.push("--convert-subs");
args.push("srt");
if(this.environment.settings.autoGenSubs) {
args.push("--write-auto-sub");
}
}
if (this.environment.settings.outputFormat !== "none") {
args.push("--merge-output-format");

View File

@@ -2,12 +2,13 @@ const os = require("os");
const fs = require("fs").promises;
class Settings {
constructor(paths, env, outputFormat, spoofUserAgent, taskList, nameFormat, nameFormatMode, sizeMode, splitMode, maxConcurrent, updateBinary, updateApplication, cookiePath, statSend, downloadMetadata, downloadThumbnail, keepUnmerged, calculateTotalSize, theme) {
constructor(paths, env, outputFormat, spoofUserAgent, taskList, autoGenSubs, nameFormat, nameFormatMode, sizeMode, splitMode, maxConcurrent, updateBinary, updateApplication, cookiePath, statSend, downloadMetadata, downloadThumbnail, keepUnmerged, calculateTotalSize, theme) {
this.paths = paths;
this.env = env
this.outputFormat = outputFormat == null ? "none" : outputFormat;
this.spoofUserAgent = spoofUserAgent == null ? true : spoofUserAgent;
this.taskList = taskList == null ? true : taskList;
this.autoGenSubs = autoGenSubs == null ? false : autoGenSubs;
this.nameFormat = nameFormat == null ? "%(title).200s-(%(height)sp%(fps).0d).%(ext)s" : nameFormat;
this.nameFormatMode = nameFormatMode == null ? "%(title).200s-(%(height)sp%(fps).0d).%(ext)s" : nameFormatMode;
this.downloadMetadata = downloadMetadata == null ? true : downloadMetadata;
@@ -28,7 +29,7 @@ class Settings {
try {
let result = await fs.readFile(paths.settings, "utf8");
let data = JSON.parse(result);
return new Settings(paths, env, data.outputFormat, data.spoofUserAgent, data.taskList, data.nameFormat, data.nameFormatMode, data.sizeMode, data.splitMode, data.maxConcurrent, data.updateBinary, data.updateApplication, data.cookiePath, data.statSend, data.downloadMetadata, data.downloadThumbnail, data.keepUnmerged, data.calculateTotalSize, data.theme);
return new Settings(paths, env, data.outputFormat, data.spoofUserAgent, data.taskList, data.autoGenSubs, data.nameFormat, data.nameFormatMode, data.sizeMode, data.splitMode, data.maxConcurrent, data.updateBinary, data.updateApplication, data.cookiePath, data.statSend, data.downloadMetadata, data.downloadThumbnail, data.keepUnmerged, data.calculateTotalSize, data.theme);
} catch(err) {
console.log(err);
let settings = new Settings(paths, env);
@@ -42,6 +43,7 @@ class Settings {
this.outputFormat = settings.outputFormat;
this.spoofUserAgent = settings.spoofUserAgent;
this.taskList = settings.taskList;
this.autoGenSubs = settings.autoGenSubs;
this.nameFormat = settings.nameFormat;
this.nameFormatMode = settings.nameFormatMode;
this.downloadMetadata = settings.downloadMetadata;
@@ -68,6 +70,7 @@ class Settings {
outputFormat: this.outputFormat,
spoofUserAgent: this.spoofUserAgent,
taskList: this.taskList,
autoGenSubs: this.autoGenSubs,
nameFormat: this.nameFormat,
nameFormatMode: this.nameFormatMode,
sizeMode: this.sizeMode,

View File

@@ -258,6 +258,10 @@
<input class="check-input" type="checkbox" value="" id="downloadThumbnail">
<label class="check-label" for="downloadThumbnail">Save thumbnail as file</label>
</div>
<div class="mb-1">
<input class="check-input" type="checkbox" value="" id="autoGenSubs">
<label class="check-label" for="autoGenSubs">Download auto-generated subtitles</label>
</div>
<div class="mb-1">
<input class="check-input" type="checkbox" value="" id="keepUnmerged">
<label class="check-label" for="keepUnmerged">Keep unmerged files</label>

View File

@@ -124,6 +124,7 @@ async function init() {
outputFormat: $('#outputFormat').val(),
spoofUserAgent: $('#spoofUserAgent').prop('checked'),
taskList: $('#taskList').prop('checked'),
autoGenSubs: $('#autoGenSubs').prop('checked'),
nameFormatMode: $('#nameFormat').val(),
nameFormat: $('#nameFormatCustom').val(),
downloadMetadata: $('#downloadMetadata').prop('checked'),
@@ -159,6 +160,7 @@ async function init() {
$('#updateApplication').prop('checked', settings.updateApplication);
$('#spoofUserAgent').prop('checked', settings.spoofUserAgent);
$('#taskList').prop('checked', settings.taskList);
$('#autoGenSubs').prop('checked', settings.autoGenSubs);
$('#nameFormatCustom').val(settings.nameFormat);
$('#nameFormat').val(settings.nameFormatMode);
$('#outputFormat').val(settings.outputFormat);

View File

@@ -2,8 +2,8 @@ const fs = require('fs').promises;
const os = require("os");
const Settings = require('../modules/persistence/Settings');
const env = {version: "2.0.0-test1"};
const defaultSettingsInstance = new Settings({settings: "tests/test-settings.json"}, env, "none", true, true, "%(title).200s-(%(height)sp%(fps).0d).%(ext)s", "%(title).200s-(%(height)sp%(fps).0d).%(ext)s", "click", "49", 8, true, true, "C:\\Users\\user\\cookies.txt", false, true, false, false, true, "dark");
const defaultSettings = "{\"outputFormat\":\"none\",\"spoofUserAgent\":true,\"taskList\":true,\"nameFormat\":\"%(title).200s-(%(height)sp%(fps).0d).%(ext)s\",\"nameFormatMode\":\"%(title).200s-(%(height)sp%(fps).0d).%(ext)s\",\"sizeMode\":\"click\",\"splitMode\":\"49\",\"maxConcurrent\":8,\"defaultConcurrent\":8,\"updateBinary\":true,\"updateApplication\":true,\"statSend\":false,\"downloadMetadata\":true,\"downloadThumbnail\":false,\"keepUnmerged\":false,\"calculateTotalSize\":true,\"theme\":\"dark\",\"version\":\"2.0.0-test1\"}"
const defaultSettingsInstance = new Settings({settings: "tests/test-settings.json"}, env, "none", true, true, false, "%(title).200s-(%(height)sp%(fps).0d).%(ext)s", "%(title).200s-(%(height)sp%(fps).0d).%(ext)s", "click", "49", 8, true, true, "C:\\Users\\user\\cookies.txt", false, true, false, false, true, "dark");
const defaultSettings = "{\"outputFormat\":\"none\",\"spoofUserAgent\":true,\"taskList\":true,\"autoGenSubs\":false,\"nameFormat\":\"%(title).200s-(%(height)sp%(fps).0d).%(ext)s\",\"nameFormatMode\":\"%(title).200s-(%(height)sp%(fps).0d).%(ext)s\",\"sizeMode\":\"click\",\"splitMode\":\"49\",\"maxConcurrent\":8,\"defaultConcurrent\":8,\"updateBinary\":true,\"updateApplication\":true,\"statSend\":false,\"downloadMetadata\":true,\"downloadThumbnail\":false,\"keepUnmerged\":false,\"calculateTotalSize\":true,\"theme\":\"dark\",\"version\":\"2.0.0-test1\"}"
describe('Load settings from file', () => {
beforeEach(() => {

View File

@@ -1 +1 @@
{"outputFormat":"none","spoofUserAgent":true,"taskList":true,"nameFormat":"%(title).200s-(%(height)sp%(fps).0d).%(ext)s","nameFormatMode":"%(title).200s-(%(height)sp%(fps).0d).%(ext)s","sizeMode":"click","splitMode":"49","maxConcurrent":8,"defaultConcurrent":8,"updateBinary":true,"updateApplication":true,"cookiePath":"C:\\Users\\user\\cookies.txt","statSend":false,"downloadMetadata":true,"downloadThumbnail":false,"keepUnmerged":false,"calculateTotalSize":true,"theme": "dark","version":"2.0.0-test1"}
{"outputFormat":"none","spoofUserAgent":true,"taskList":true,"autoGenSubs":false,"nameFormat":"%(title).200s-(%(height)sp%(fps).0d).%(ext)s","nameFormatMode":"%(title).200s-(%(height)sp%(fps).0d).%(ext)s","sizeMode":"click","splitMode":"49","maxConcurrent":8,"defaultConcurrent":8,"updateBinary":true,"updateApplication":true,"cookiePath":"C:\\Users\\user\\cookies.txt","statSend":false,"downloadMetadata":true,"downloadThumbnail":false,"keepUnmerged":false,"calculateTotalSize":true,"theme": "dark","version":"2.0.0-test1"}