parent
be56697645
commit
021e233da1
15 changed files with 2361 additions and 2414 deletions
devices/nos/modules/subtitles/extract-subs
|
@ -1,133 +0,0 @@
|
|||
{
|
||||
"env": {
|
||||
"es2021": true
|
||||
},
|
||||
"extends": ["eslint:recommended", "plugin:@typescript-eslint/recommended"],
|
||||
"parser": "@typescript-eslint/parser",
|
||||
"overrides": [],
|
||||
"parserOptions": {
|
||||
"ecmaVersion": "latest",
|
||||
"sourceType": "module"
|
||||
},
|
||||
"plugins": ["@stylistic", "@typescript-eslint"],
|
||||
"rules": {
|
||||
"array-callback-return": ["error", {
|
||||
"allowImplicit": true,
|
||||
"checkForEach": true
|
||||
}],
|
||||
"no-constructor-return": ["error"],
|
||||
"no-unreachable-loop": ["error", { "ignore": [
|
||||
"ForInStatement", "ForOfStatement"
|
||||
]}],
|
||||
|
||||
|
||||
"block-scoped-var": ["error"],
|
||||
"class-methods-use-this": ["error"],
|
||||
"curly": ["warn"],
|
||||
"default-case-last": ["warn"],
|
||||
"default-param-last": ["error"],
|
||||
"eqeqeq": ["error", "smart"],
|
||||
"func-names": ["warn", "never"],
|
||||
"logical-assignment-operators": ["warn", "always"],
|
||||
"no-array-constructor": ["error"],
|
||||
"no-empty-function": ["warn"],
|
||||
"no-empty-static-block": ["warn"],
|
||||
"no-extend-native": ["error"],
|
||||
"no-extra-bind": ["warn"],
|
||||
"no-implicit-coercion": ["warn"],
|
||||
"no-iterator": ["error"],
|
||||
"no-labels": ["error"],
|
||||
"no-lone-blocks": ["error"],
|
||||
"no-lonely-if": ["error"],
|
||||
"no-loop-func": ["error"],
|
||||
"no-magic-numbers": ["error", {
|
||||
"ignore": [-2, -1, 0.1, 0, 1, 2, 3, 10, 33, 66, 100, 255, 360, 450, 1000],
|
||||
"ignoreDefaultValues": true,
|
||||
"ignoreArrayIndexes": true
|
||||
}],
|
||||
"no-multi-assign": ["error"],
|
||||
"no-new": ["error"],
|
||||
"no-new-func": ["error"],
|
||||
"no-new-wrappers": ["error"],
|
||||
"no-object-constructor": ["error"],
|
||||
"no-proto": ["error"],
|
||||
"no-return-assign": ["error"],
|
||||
"no-sequences": ["error"],
|
||||
"no-shadow": ["error", { "builtinGlobals": true }],
|
||||
"no-undef-init": ["warn"],
|
||||
"no-undefined": ["error"],
|
||||
"no-useless-constructor": ["warn"],
|
||||
"no-useless-escape": ["off"],
|
||||
"no-useless-return": ["error"],
|
||||
"no-var": ["error"],
|
||||
"no-void": ["error"],
|
||||
"no-with": ["error"],
|
||||
"object-shorthand": ["error", "always"],
|
||||
"one-var": ["error", "never"],
|
||||
"operator-assignment": ["warn", "always"],
|
||||
"prefer-arrow-callback": ["error"],
|
||||
"prefer-const": ["error"],
|
||||
"prefer-object-has-own": ["error"],
|
||||
"prefer-regex-literals": ["error"],
|
||||
"prefer-template": ["warn"],
|
||||
|
||||
"no-unused-vars": "off",
|
||||
"@typescript-eslint/no-unused-vars": "warn",
|
||||
"@typescript-eslint/no-unsafe-declaration-merging": "off",
|
||||
|
||||
"@stylistic/array-bracket-newline": ["warn", "consistent"],
|
||||
"@stylistic/array-bracket-spacing": ["warn", "never"],
|
||||
"@stylistic/arrow-parens": ["warn", "always"],
|
||||
"@stylistic/brace-style": ["warn", "stroustrup"],
|
||||
"@stylistic/comma-dangle": ["warn", "always-multiline"],
|
||||
"@stylistic/comma-spacing": ["warn", { "before": false, "after": true }],
|
||||
"@stylistic/comma-style": ["error", "last"],
|
||||
"@stylistic/dot-location": ["error", "property"],
|
||||
"@stylistic/function-call-argument-newline": ["warn", "consistent"],
|
||||
"@stylistic/function-paren-newline": ["warn", "consistent"],
|
||||
"@stylistic/indent": ["warn", 4, {
|
||||
"SwitchCase": 1,
|
||||
"ignoreComments": true
|
||||
}],
|
||||
"@stylistic/key-spacing": ["warn", { "beforeColon": false, "afterColon": true }],
|
||||
"@stylistic/keyword-spacing": ["warn", { "before": true }],
|
||||
"@stylistic/linebreak-style": ["error", "unix"],
|
||||
"@stylistic/lines-between-class-members": ["warn", "always", { "exceptAfterSingleLine": true }],
|
||||
"@stylistic/max-len": ["warn", {
|
||||
"code": 100,
|
||||
"ignoreComments": true,
|
||||
"ignoreTrailingComments": true,
|
||||
"ignoreUrls": true
|
||||
}],
|
||||
"@stylistic/multiline-ternary": ["warn", "always-multiline"],
|
||||
"@stylistic/new-parens": ["error"],
|
||||
"@stylistic/no-mixed-operators": ["warn"],
|
||||
"@stylistic/no-mixed-spaces-and-tabs": ["error"],
|
||||
"@stylistic/no-multi-spaces": ["error"],
|
||||
"@stylistic/no-tabs": ["error"],
|
||||
"@stylistic/no-trailing-spaces": ["error"],
|
||||
"@stylistic/no-whitespace-before-property": ["warn"],
|
||||
"@stylistic/nonblock-statement-body-position": ["error", "below"],
|
||||
"@stylistic/object-curly-newline": ["warn", { "consistent": true }],
|
||||
"@stylistic/object-property-newline": ["warn", {"allowAllPropertiesOnSameLine": false}],
|
||||
"@stylistic/object-curly-spacing": ["warn", "always"],
|
||||
"@stylistic/operator-linebreak": ["warn", "after"],
|
||||
"@stylistic/padded-blocks": ["error", "never"],
|
||||
"@stylistic/padding-line-between-statements": ["warn",
|
||||
{ "blankLine": "always", "prev": "*", "next": "return" },
|
||||
{ "blankLine": "always", "prev": ["const", "let", "var"], "next": "*"},
|
||||
{ "blankLine": "any", "prev": ["const", "let", "var"], "next": ["const", "let", "var"]},
|
||||
{ "blankLine": "always", "prev": ["case", "default"], "next": "*" }
|
||||
],
|
||||
"@stylistic/quote-props": ["error", "consistent-as-needed"],
|
||||
"@stylistic/quotes": ["error", "single", { "avoidEscape": true }],
|
||||
"@stylistic/semi": ["error", "always"],
|
||||
"@stylistic/semi-spacing": ["warn"],
|
||||
"@stylistic/space-before-blocks": ["warn"],
|
||||
"@stylistic/space-before-function-paren": ["warn", "never"],
|
||||
"@stylistic/space-infix-ops": ["warn"],
|
||||
"@stylistic/spaced-comment": ["warn", "always"],
|
||||
"@stylistic/switch-colon-spacing": ["warn"],
|
||||
"@stylistic/wrap-regex": ["warn"]
|
||||
}
|
||||
}
|
|
@ -11,7 +11,7 @@
|
|||
extract-subs = buildNpmPackage {
|
||||
name = "${pname}-npm";
|
||||
src = ./.;
|
||||
npmDepsHash = "sha256-O00VQPCUX6T+rtK3VcAibBipXFwNs4AFA3251qycPBQ=";
|
||||
npmDepsHash = "sha256-mIRn7MsQJCwBYNEL3IK4cV8X+kDouEdc9x59XWgUkYw=";
|
||||
|
||||
nativeBuildInputs = [
|
||||
nodejs_20
|
||||
|
@ -46,6 +46,4 @@ in
|
|||
text = ''
|
||||
exec ${pname} "$@"
|
||||
'';
|
||||
|
||||
meta.mainProgram = pname;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ import { spawnSync as spawn } from 'child_process';
|
|||
|
||||
import { ISO6393To1 } from './lang-codes';
|
||||
|
||||
|
||||
const SPAWN_OPTS = {
|
||||
shell: true,
|
||||
stdio: [process.stdin, process.stdout, process.stderr],
|
||||
|
@ -17,19 +18,8 @@ const SPAWN_OPTS = {
|
|||
const video = process.argv[2];
|
||||
const languages = process.argv[3]?.split(',');
|
||||
|
||||
const escapePath = (p: string): string => p.replaceAll("'", "'\\''");
|
||||
|
||||
// Check if there are 2 params
|
||||
if (video && languages) {
|
||||
main(escapePath(video));
|
||||
}
|
||||
else {
|
||||
console.error('Error: no argument passed');
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
|
||||
function getSubPath(baseName: string, sub: Ffmpeg.FfprobeStream): string {
|
||||
const getSubPath = (baseName: string, sub: Ffmpeg.FfprobeStream): string => {
|
||||
const language = ISO6393To1.get(sub.tags.language);
|
||||
|
||||
const forced = sub.disposition?.forced === 0 ?
|
||||
|
@ -41,9 +31,9 @@ function getSubPath(baseName: string, sub: Ffmpeg.FfprobeStream): string {
|
|||
'.sdh';
|
||||
|
||||
return `${baseName}${forced}.${language}${hearingImpaired}.srt`;
|
||||
}
|
||||
};
|
||||
|
||||
function main(videoPath: string) {
|
||||
const main = (videoPath: string) => {
|
||||
const subIndexes: number[] = [];
|
||||
const baseName = videoPath.split('/').at(-1)!.replace(/\.[^.]*$/, '');
|
||||
|
||||
|
@ -58,9 +48,9 @@ function main(videoPath: string) {
|
|||
languages.forEach((lang) => {
|
||||
let subs = data.streams.filter((s) => {
|
||||
return s['tags'] &&
|
||||
s['tags']['language'] &&
|
||||
s['tags']['language'] === lang &&
|
||||
s.codec_type === 'subtitle';
|
||||
s['tags']['language'] &&
|
||||
s['tags']['language'] === lang &&
|
||||
s.codec_type === 'subtitle';
|
||||
});
|
||||
|
||||
const pgs = subs.filter((s) => s.codec_name === 'hdmv_pgs_subtitle');
|
||||
|
@ -110,4 +100,15 @@ function main(videoPath: string) {
|
|||
`'${videoPath}.bak'`,
|
||||
], SPAWN_OPTS);
|
||||
});
|
||||
};
|
||||
|
||||
const escapePath = (p: string): string => p.replaceAll("'", "'\\''");
|
||||
|
||||
// Check if there are 2 params
|
||||
if (video && languages) {
|
||||
main(escapePath(video));
|
||||
}
|
||||
else {
|
||||
console.error('Error: no argument passed');
|
||||
process.exit(1);
|
||||
}
|
||||
|
|
3728
devices/nos/modules/subtitles/extract-subs/package-lock.json
generated
3728
devices/nos/modules/subtitles/extract-subs/package-lock.json
generated
File diff suppressed because it is too large
Load diff
|
@ -1,14 +1,18 @@
|
|||
{
|
||||
"devDependencies": {
|
||||
"@stylistic/eslint-plugin": "^1.4.0",
|
||||
"@types/node": "^20.10.5",
|
||||
"@typescript-eslint/eslint-plugin": "^6.9.1",
|
||||
"@typescript-eslint/parser": "^6.9.1",
|
||||
"eslint": "^8.52.0",
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/fluent-ffmpeg": "^2.1.24",
|
||||
"fluent-ffmpeg": "^2.1.2"
|
||||
}
|
||||
"devDependencies": {
|
||||
"@eslint/js": "9.12.0",
|
||||
"@stylistic/eslint-plugin": "2.9.0",
|
||||
"@types/eslint__js": "8.42.3",
|
||||
"@types/node": "22.7.5",
|
||||
"eslint": "9.12.0",
|
||||
"eslint-plugin-jsdoc": "50.3.2",
|
||||
"fzf": "0.5.2",
|
||||
"jiti": "2.3.3",
|
||||
"typescript": "5.6.3",
|
||||
"typescript-eslint": "8.8.1"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/fluent-ffmpeg": "2.1.26",
|
||||
"fluent-ffmpeg": "2.1.3"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue