Updated Build
This commit is contained in:
parent
ff4e8792b0
commit
38c571a49c
9 changed files with 27 additions and 239 deletions
0
modules/iso639.d.ts → @types/iso639.d.ts
vendored
0
modules/iso639.d.ts → @types/iso639.d.ts
vendored
|
|
@ -1,31 +0,0 @@
|
|||
# Downloading
|
||||
videoQuality: 720p
|
||||
nServer: 1
|
||||
kStream: 1
|
||||
tsparts: 10
|
||||
hsLang: none
|
||||
dlSubs: all
|
||||
|
||||
# Muxing
|
||||
dubLanguage: jpn
|
||||
defSubLang: none
|
||||
useBCPtags: false
|
||||
mp4mux: false
|
||||
muxSubs: false
|
||||
|
||||
# Filenaming
|
||||
filenameTemplate: "[{rel_group}] {title} - {ep_num} [{suffix}]"
|
||||
releaseGroup: CR
|
||||
epNumLength: 2
|
||||
fileSuffix: SIZEp
|
||||
|
||||
# Proxy
|
||||
proxy: ''
|
||||
proxy_auth: ''
|
||||
proxy_ups: false
|
||||
use_curl: false
|
||||
|
||||
# Utilities
|
||||
useFolder: false
|
||||
noCleanUp: false
|
||||
noTrashFolder: false
|
||||
|
|
@ -1,77 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
// build requirements
|
||||
const pkg = require('../package.json');
|
||||
const fs = require('fs-extra');
|
||||
const { exec } = require('pkg');
|
||||
const { lookpath } = require('lookpath');
|
||||
|
||||
const buildsDir = './_builds';
|
||||
const curNodeVer = 'node16-';
|
||||
|
||||
// main
|
||||
(async function (){
|
||||
doBuild();
|
||||
})();
|
||||
|
||||
// do build
|
||||
async function doBuild(nodeVer){
|
||||
const buildStr = `${pkg.name}-${pkg.version}`;
|
||||
nodeVer = nodeVer ? nodeVer : '';
|
||||
const acceptableBuilds = ['win64','linux64','macos64'];
|
||||
const buildType = process.argv[2];
|
||||
if(!acceptableBuilds.includes(buildType)){
|
||||
console.error('[ERROR] unknown build type!');
|
||||
process.exit(1);
|
||||
}
|
||||
if(!fs.existsSync(buildsDir)){
|
||||
fs.mkdirSync(buildsDir);
|
||||
}
|
||||
const buildFull = `${buildStr}-${buildType}`;
|
||||
const buildDir = `${buildsDir}`;
|
||||
|
||||
const buildConfig = [
|
||||
pkg.main,
|
||||
'--target', nodeVer + getTarget(buildType),
|
||||
'--output', `${buildDir}/${pkg.short_name}`,
|
||||
];
|
||||
const buildConfigBeta = [
|
||||
`${pkg.short_name}-beta.js`,
|
||||
'--target', nodeVer + getTarget(buildType),
|
||||
'--output', `${buildDir}/${pkg.short_name}-beta`,
|
||||
];
|
||||
console.log(`[Build] Build configuration: ${buildFull}`);
|
||||
try {
|
||||
const targetCrClassic = await lookpath(`${buildDir}/${pkg.short_name}`);
|
||||
const targetCrBeta = await lookpath(`${buildDir}/${pkg.short_name}-beta`);
|
||||
if(!fs.existsSync(targetCrClassic)){
|
||||
fs.removeSync(targetCrClassic);
|
||||
}
|
||||
if(!fs.existsSync(targetCrBeta)){
|
||||
fs.removeSync(targetCrBeta);
|
||||
}
|
||||
await exec(buildConfig);
|
||||
await exec(buildConfigBeta);
|
||||
}
|
||||
catch(e){
|
||||
console.log(e);
|
||||
if(nodeVer == ''){
|
||||
await doBuild(curNodeVer);
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
console.log('[LOG] Build ready:', buildFull);
|
||||
}
|
||||
|
||||
function getTarget(bt){
|
||||
switch(bt){
|
||||
case 'win64':
|
||||
return 'windows-x64';
|
||||
case 'linux64':
|
||||
return 'linux-x64';
|
||||
case 'macos64':
|
||||
return 'macos-x64';
|
||||
default:
|
||||
return 'windows-x64';
|
||||
}
|
||||
}
|
||||
|
|
@ -1,80 +0,0 @@
|
|||
#!/usr/bin/env node
|
||||
|
||||
// build requirements
|
||||
const pkg = require('../package.json');
|
||||
const fs = require('fs-extra');
|
||||
const { exec } = require('pkg');
|
||||
|
||||
const buildsDir = './_builds';
|
||||
const curNodeVer = 'node16-';
|
||||
|
||||
// main
|
||||
(async function (){
|
||||
doBuild();
|
||||
})();
|
||||
|
||||
// do build
|
||||
async function doBuild(nodeVer){
|
||||
const buildStr = `${pkg.name}-${pkg.version}`;
|
||||
nodeVer = nodeVer ? nodeVer : '';
|
||||
const acceptableBuilds = ['win64','linux64','macos64'];
|
||||
const buildType = process.argv[2];
|
||||
if(!acceptableBuilds.includes(buildType)){
|
||||
console.error('[ERROR] unknown build type!');
|
||||
process.exit(1);
|
||||
}
|
||||
if(!fs.existsSync(buildsDir)){
|
||||
fs.mkdirSync(buildsDir);
|
||||
}
|
||||
const buildFull = `${buildStr}-${buildType}`;
|
||||
const buildDir = `${buildsDir}/${buildFull}`;
|
||||
if(fs.existsSync(buildDir)){
|
||||
fs.removeSync(buildDir);
|
||||
}
|
||||
fs.mkdirSync(buildDir);
|
||||
const buildConfig = [
|
||||
pkg.main,
|
||||
'--target', nodeVer + getTarget(buildType),
|
||||
'--output', `${buildDir}/${pkg.short_name}`,
|
||||
];
|
||||
const buildConfigBeta = [
|
||||
`${pkg.short_name}-beta.js`,
|
||||
'--target', nodeVer + getTarget(buildType),
|
||||
'--output', `${buildDir}/${pkg.short_name}-beta`,
|
||||
];
|
||||
console.log(`[Build] Build configuration: ${buildFull}`);
|
||||
try {
|
||||
await exec(buildConfig);
|
||||
await exec(buildConfigBeta);
|
||||
}
|
||||
catch(e){
|
||||
console.log(e);
|
||||
if(nodeVer == ''){
|
||||
await doBuild(curNodeVer);
|
||||
}
|
||||
process.exit(1);
|
||||
}
|
||||
if(buildType == 'win64'){
|
||||
fs.copySync('./modules/cmd-here.bat', `${buildDir}/cmd-here.bat`);
|
||||
}
|
||||
fs.copySync('./docs/', `${buildDir}/docs/`);
|
||||
fs.copySync('./LICENSE.md', `${buildDir}/docs/LICENSE.md`);
|
||||
if(fs.existsSync(`${buildsDir}/${buildFull}.7z`)){
|
||||
fs.removeSync(`${buildsDir}/${buildFull}.7z`);
|
||||
}
|
||||
require('child_process').execSync(`7z a -t7z "${buildsDir}/${buildFull}.7z" "${buildDir}"`, {stdio:[0,1,2]});
|
||||
console.log('[LOG] Build ready:', `${buildsDir}/${buildFull}.7z`);
|
||||
}
|
||||
|
||||
function getTarget(bt){
|
||||
switch(bt){
|
||||
case 'win64':
|
||||
return 'windows-x64';
|
||||
case 'linux64':
|
||||
return 'linux-x64';
|
||||
case 'macos64':
|
||||
return 'macos-x64';
|
||||
default:
|
||||
return 'windows-x64';
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
@echo off
|
||||
title CmdHere
|
||||
cmd /k PROMPT @$S$P$_$_$G$S
|
||||
60
funi.ts
60
funi.ts
|
|
@ -38,6 +38,7 @@ import { EpisodeData, MediaChild } from './@types/episode';
|
|||
import { Subtitle } from './@types/subtitleObject';
|
||||
import { StreamData } from './@types/streamData';
|
||||
import { DownloadedFile } from './@types/downloadedFile';
|
||||
import parseFileName, { Variable } from './modules/module.filename';
|
||||
|
||||
// check page
|
||||
argv.p = 1;
|
||||
|
|
@ -591,7 +592,21 @@ async function downloadStreams(){
|
|||
console.log(`[INFO] Selected layer: ${argv.q} (${plLayersRes[argv.q].width}x${plLayersRes[argv.q].height}) @ ${plSelectedServer}`);
|
||||
console.log('[INFO] Stream URL:',videoUrl);
|
||||
|
||||
fnOutput = parseFileName(argv.fileName, title, fnEpNum, showTitle, season, plLayersRes[argv.q].width, plLayersRes[argv.q].height);
|
||||
fnOutput = parseFileName(argv.fileName, ([
|
||||
['episode', fnEpNum],
|
||||
['title', title],
|
||||
['showTitle', showTitle],
|
||||
['season', season],
|
||||
['width', plLayersRes[argv.q].width],
|
||||
['height', plLayersRes[argv.q].height],
|
||||
['service', 'Funimation']
|
||||
] as [appYargs.AvailableFilenameVars, string|number][]).map((a): Variable => {
|
||||
return {
|
||||
name: a[0],
|
||||
replaceWith: a[1],
|
||||
type: typeof a[1],
|
||||
} as Variable;
|
||||
}), argv.numbers)
|
||||
if (fnOutput.length < 1)
|
||||
throw new Error(`Invalid path generated for input ${argv.fileName}`);
|
||||
console.log(`[INFO] Output filename: ${fnOutput.join(path.sep)}.ts`);
|
||||
|
|
@ -761,45 +776,4 @@ async function downloadFile(filename: string, chunkList: {
|
|||
}).download();
|
||||
|
||||
return downloadStatus.ok;
|
||||
}
|
||||
|
||||
function parseFileName(input: string, title: string, episode:number|string, showTitle: string, season: number, width: number, height: number): string[] {
|
||||
const varRegex = /\${[A-Za-z1-9]+}/g;
|
||||
const vars = input.match(varRegex);
|
||||
if (!vars)
|
||||
return [input];
|
||||
for (let i = 0; i < vars.length; i++) {
|
||||
const type = vars[i];
|
||||
switch (type.slice(2, -1).toLowerCase()) {
|
||||
case 'title':
|
||||
input = input.replace(vars[i], title);
|
||||
break;
|
||||
case 'episode': {
|
||||
if (typeof episode === 'number') {
|
||||
const len = episode.toFixed(0).toString().length;
|
||||
input = input.replace(vars[i], len < argv.numbers ? '0'.repeat(argv.numbers - len) + episode : episode.toString());
|
||||
} else {
|
||||
input = input.replace(vars[i], episode);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'showtitle':
|
||||
input = input.replace(vars[i], showTitle);
|
||||
break;
|
||||
case 'season': {
|
||||
const len = season.toFixed(0).toString().length;
|
||||
input = input.replace(vars[i], len < argv.numbers ? '0'.repeat(argv.numbers - len) + season : season.toString());
|
||||
break;
|
||||
}
|
||||
case 'width':
|
||||
input = input.replace(vars[i], width.toString());
|
||||
break;
|
||||
case 'height':
|
||||
input = input.replace(vars[i], height.toString());
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
return input.split(path.sep).map(a => shlp.cleanupFilename(a));
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ import { exec } from 'pkg';
|
|||
import { execSync } from 'child_process';
|
||||
|
||||
const buildsDir = './_builds';
|
||||
const nodeVer = 'node14-';
|
||||
const nodeVer = 'node16-';
|
||||
|
||||
// main
|
||||
(async function(){
|
||||
|
|
|
|||
|
|
@ -1,13 +1,15 @@
|
|||
{
|
||||
"name": "funimation-downloader-nx",
|
||||
"short_name": "funi",
|
||||
"name": "multi-downloader-nx",
|
||||
"short_name": "aniDL",
|
||||
"version": "5.0.0",
|
||||
"description": "Download videos from Funimation via cli.",
|
||||
"description": "Download videos from Funimation or Crunchyroll via cli.",
|
||||
"keywords": [
|
||||
"download",
|
||||
"downloader",
|
||||
"funimation",
|
||||
"funimationnow",
|
||||
"crunchy",
|
||||
"crunchyroll",
|
||||
"util",
|
||||
"utility",
|
||||
"cli"
|
||||
|
|
|
|||
5
tsc.ts
5
tsc.ts
|
|
@ -8,7 +8,10 @@ const ignore = [
|
|||
'lib',
|
||||
'node_modules',
|
||||
'@types',
|
||||
path.join('bin', 'mkvtoolnix')
|
||||
path.join('bin', 'mkvtoolnix'),
|
||||
path.join('config', 'token.yml'),
|
||||
'.eslint',
|
||||
'tsconfig.json'
|
||||
].map(a => path.join(__dirname, a));
|
||||
|
||||
(async () => {
|
||||
|
|
|
|||
Loading…
Reference in a new issue