mirror of
https://github.com/anidl/multi-downloader-nx.git
synced 2026-04-21 00:12:05 +00:00
Minor code cleanup
This commit is contained in:
parent
561ccac6f1
commit
dfa0a31def
7 changed files with 87 additions and 133 deletions
20
@types/crunchyTypes.d.ts
vendored
20
@types/crunchyTypes.d.ts
vendored
|
|
@ -87,26 +87,6 @@ export type CrunchyEpMeta = {
|
|||
image: string,
|
||||
}
|
||||
|
||||
export type DownloadedMedia = {
|
||||
type: 'Video',
|
||||
lang: LanguageItem,
|
||||
path: string,
|
||||
isPrimary?: boolean
|
||||
} | {
|
||||
type: 'Audio',
|
||||
lang: LanguageItem,
|
||||
path: string,
|
||||
isPrimary?: boolean
|
||||
} | {
|
||||
type: 'Chapters',
|
||||
lang: LanguageItem,
|
||||
path: string
|
||||
} | ({
|
||||
type: 'Subtitle',
|
||||
signs: boolean,
|
||||
cc: boolean
|
||||
} & sxItem )
|
||||
|
||||
export type ParseItem = {
|
||||
__class__?: string;
|
||||
isSelected?: boolean,
|
||||
|
|
|
|||
32
@types/downloaderTypes.d.ts
vendored
Normal file
32
@types/downloaderTypes.d.ts
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import type { Font, MergerInput, SubtitleInput } from './modules/module.merger';
|
||||
import type { LanguageItem } from '../modules/module.langsData';
|
||||
|
||||
export type sxItem = {
|
||||
language: LanguageItem,
|
||||
path: string,
|
||||
file: string
|
||||
title: string,
|
||||
fonts: Font[]
|
||||
}
|
||||
|
||||
export type DownloadedMedia = {
|
||||
type: 'Video',
|
||||
lang: LanguageItem,
|
||||
path: string,
|
||||
uncut?: boolean,
|
||||
isPrimary?: boolean
|
||||
} | {
|
||||
type: 'Audio',
|
||||
lang: LanguageItem,
|
||||
path: string,
|
||||
uncut?: boolean,
|
||||
isPrimary?: boolean
|
||||
} | {
|
||||
type: 'Chapters',
|
||||
lang: LanguageItem,
|
||||
path: string
|
||||
} | ({
|
||||
type: 'Subtitle',
|
||||
signs?: boolean,
|
||||
cc: boolean
|
||||
} & sxItem )
|
||||
12
@types/hidiveTypes.d.ts
vendored
12
@types/hidiveTypes.d.ts
vendored
|
|
@ -48,14 +48,4 @@ export interface HidiveSubtitleInfo {
|
|||
language: string;
|
||||
cc: boolean;
|
||||
url: string;
|
||||
}
|
||||
|
||||
export type DownloadedMedia = {
|
||||
type: 'Video',
|
||||
lang: LanguageItem,
|
||||
path: string,
|
||||
uncut: boolean
|
||||
} | ({
|
||||
type: 'Subtitle',
|
||||
cc: boolean
|
||||
} & sxItem )
|
||||
}
|
||||
31
adn.ts
31
adn.ts
|
|
@ -26,15 +26,14 @@ import parseFileName, { Variable } from './modules/module.filename';
|
|||
import { AvailableFilenameVars } from './modules/module.args';
|
||||
|
||||
// Types
|
||||
import { ServiceClass } from './@types/serviceClassInterface';
|
||||
import { AuthData, AuthResponse, SearchData, SearchResponse, SearchResponseItem } from './@types/messageHandler';
|
||||
import { sxItem } from './crunchy';
|
||||
import { DownloadedMedia } from './@types/hidiveTypes';
|
||||
import { ADNSearch, ADNSearchShow } from './@types/adnSearch';
|
||||
import { ADNVideo, ADNVideos } from './@types/adnVideos';
|
||||
import { ADNPlayerConfig } from './@types/adnPlayerConfig';
|
||||
import { ADNStreams } from './@types/adnStreams';
|
||||
import { ADNSubtitles } from './@types/adnSubtitles';
|
||||
import type { ServiceClass } from './@types/serviceClassInterface';
|
||||
import type { AuthData, AuthResponse, SearchData, SearchResponse, SearchResponseItem } from './@types/messageHandler';
|
||||
import type { DownloadedMedia, sxItem } from './@types/downloaderTypes';
|
||||
import type { ADNSearch, ADNSearchShow } from './@types/adnSearch';
|
||||
import type { ADNVideo, ADNVideos } from './@types/adnVideos';
|
||||
import type { ADNPlayerConfig } from './@types/adnPlayerConfig';
|
||||
import type { ADNStreams } from './@types/adnStreams';
|
||||
import type { ADNSubtitles } from './@types/adnSubtitles';
|
||||
|
||||
export default class AnimationDigitalNetwork implements ServiceClass {
|
||||
public cfg: yamlCfg.ConfigObject;
|
||||
|
|
@ -326,8 +325,6 @@ export default class AnimationDigitalNetwork implements ServiceClass {
|
|||
}
|
||||
const merger = new Merger({
|
||||
onlyVid: hasAudioStreams ? data.filter(a => a.type === 'Video').map((a) : MergerInput => {
|
||||
if (a.type === 'Subtitle')
|
||||
throw new Error('Never');
|
||||
return {
|
||||
lang: a.lang,
|
||||
path: a.path,
|
||||
|
|
@ -337,8 +334,6 @@ export default class AnimationDigitalNetwork implements ServiceClass {
|
|||
inverseTrackOrder: false,
|
||||
keepAllVideos: options.keepAllVideos,
|
||||
onlyAudio: hasAudioStreams ? data.filter(a => a.type === 'Audio').map((a) : MergerInput => {
|
||||
if (a.type === 'Subtitle')
|
||||
throw new Error('Never');
|
||||
return {
|
||||
lang: a.lang,
|
||||
path: a.path,
|
||||
|
|
@ -346,10 +341,6 @@ export default class AnimationDigitalNetwork implements ServiceClass {
|
|||
}) : [],
|
||||
output: `${options.output}.${options.mp4 ? 'mp4' : 'mkv'}`,
|
||||
subtitles: data.filter(a => a.type === 'Subtitle').map((a) : SubtitleInput => {
|
||||
if (a.type === 'Video')
|
||||
throw new Error('Never');
|
||||
if (a.type === 'Audio')
|
||||
throw new Error('Never');
|
||||
return {
|
||||
file: a.path,
|
||||
language: a.language,
|
||||
|
|
@ -357,14 +348,10 @@ export default class AnimationDigitalNetwork implements ServiceClass {
|
|||
};
|
||||
}),
|
||||
simul: data.filter(a => a.type === 'Video').map((a) : boolean => {
|
||||
if (a.type === 'Subtitle')
|
||||
throw new Error('Never');
|
||||
return !a.uncut as boolean;
|
||||
})[0],
|
||||
fonts: Merger.makeFontsList(this.cfg.dir.fonts, data.filter(a => a.type === 'Subtitle') as sxItem[]),
|
||||
videoAndAudio: hasAudioStreams ? [] : data.filter(a => a.type === 'Video').map((a) : MergerInput => {
|
||||
if (a.type === 'Subtitle')
|
||||
throw new Error('Never');
|
||||
return {
|
||||
lang: a.lang,
|
||||
path: a.path,
|
||||
|
|
@ -773,7 +760,7 @@ export default class AnimationDigitalNetwork implements ServiceClass {
|
|||
fs.writeFileSync(`${tsFile}.txt`, compiledChapters.join('\r\n'));
|
||||
files.push({
|
||||
path: `${tsFile}.txt`,
|
||||
lang: langsData.languages.find(a=>a.code=='jpn'),
|
||||
lang: langsData.languages.find(a=>a.code=='jpn')!,
|
||||
type: 'Chapters'
|
||||
});
|
||||
} catch {
|
||||
|
|
|
|||
27
ao.ts
27
ao.ts
|
|
@ -27,14 +27,13 @@ import { AvailableFilenameVars } from './modules/module.args';
|
|||
import { parse } from './modules/module.transform-mpd';
|
||||
|
||||
// Types
|
||||
import { ServiceClass } from './@types/serviceClassInterface';
|
||||
import { AuthData, AuthResponse, SearchData, SearchResponse, SearchResponseItem } from './@types/messageHandler';
|
||||
import { AOSearchResult, AnimeOnegaiSearch } from './@types/animeOnegaiSearch';
|
||||
import { AnimeOnegaiSeries } from './@types/animeOnegaiSeries';
|
||||
import { AnimeOnegaiSeasons, Episode } from './@types/animeOnegaiSeasons';
|
||||
import { DownloadedMedia } from './@types/hidiveTypes';
|
||||
import { AnimeOnegaiStream } from './@types/animeOnegaiStream';
|
||||
import { sxItem } from './crunchy';
|
||||
import type { ServiceClass } from './@types/serviceClassInterface';
|
||||
import type { AuthData, AuthResponse, SearchData, SearchResponse, SearchResponseItem } from './@types/messageHandler';
|
||||
import type { AOSearchResult, AnimeOnegaiSearch } from './@types/animeOnegaiSearch';
|
||||
import type { AnimeOnegaiSeries } from './@types/animeOnegaiSeries';
|
||||
import type { AnimeOnegaiSeasons, Episode } from './@types/animeOnegaiSeasons';
|
||||
import type { DownloadedMedia, sxItem } from './@types/downloaderTypes';
|
||||
import type { AnimeOnegaiStream } from './@types/animeOnegaiStream';
|
||||
|
||||
type parsedMultiDubDownload = {
|
||||
data: {
|
||||
|
|
@ -337,8 +336,6 @@ export default class AnimeOnegai implements ServiceClass {
|
|||
}
|
||||
const merger = new Merger({
|
||||
onlyVid: hasAudioStreams ? data.filter(a => a.type === 'Video').map((a) : MergerInput => {
|
||||
if (a.type === 'Subtitle')
|
||||
throw new Error('Never');
|
||||
return {
|
||||
lang: a.lang,
|
||||
path: a.path,
|
||||
|
|
@ -348,8 +345,6 @@ export default class AnimeOnegai implements ServiceClass {
|
|||
inverseTrackOrder: false,
|
||||
keepAllVideos: options.keepAllVideos,
|
||||
onlyAudio: hasAudioStreams ? data.filter(a => a.type === 'Audio').map((a) : MergerInput => {
|
||||
if (a.type === 'Subtitle')
|
||||
throw new Error('Never');
|
||||
return {
|
||||
lang: a.lang,
|
||||
path: a.path,
|
||||
|
|
@ -357,10 +352,6 @@ export default class AnimeOnegai implements ServiceClass {
|
|||
}) : [],
|
||||
output: `${options.output}.${options.mp4 ? 'mp4' : 'mkv'}`,
|
||||
subtitles: data.filter(a => a.type === 'Subtitle').map((a) : SubtitleInput => {
|
||||
if (a.type === 'Video')
|
||||
throw new Error('Never');
|
||||
if (a.type === 'Audio')
|
||||
throw new Error('Never');
|
||||
return {
|
||||
file: a.path,
|
||||
language: a.language,
|
||||
|
|
@ -368,14 +359,10 @@ export default class AnimeOnegai implements ServiceClass {
|
|||
};
|
||||
}),
|
||||
simul: data.filter(a => a.type === 'Video').map((a) : boolean => {
|
||||
if (a.type === 'Subtitle')
|
||||
throw new Error('Never');
|
||||
return !a.uncut as boolean;
|
||||
})[0],
|
||||
fonts: Merger.makeFontsList(this.cfg.dir.fonts, data.filter(a => a.type === 'Subtitle') as sxItem[]),
|
||||
videoAndAudio: hasAudioStreams ? [] : data.filter(a => a.type === 'Video').map((a) : MergerInput => {
|
||||
if (a.type === 'Subtitle')
|
||||
throw new Error('Never');
|
||||
return {
|
||||
lang: a.lang,
|
||||
path: a.path,
|
||||
|
|
|
|||
53
crunchy.ts
53
crunchy.ts
|
|
@ -1,18 +1,17 @@
|
|||
// build-in
|
||||
// Built In
|
||||
import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
import { randomUUID } from 'crypto';
|
||||
|
||||
// package program
|
||||
// Package
|
||||
import packageJson from './package.json';
|
||||
|
||||
// plugins
|
||||
import { console } from './modules/log';
|
||||
// Plugins
|
||||
import shlp from 'sei-helper';
|
||||
import m3u8 from 'm3u8-parsed';
|
||||
import streamdl, { M3U8Json } from './modules/hls-download';
|
||||
import { exec } from './modules/sei-helper-fixes';
|
||||
|
||||
// custom modules
|
||||
import { console } from './modules/log';
|
||||
import * as fontsData from './modules/module.fontsData';
|
||||
import * as langsData from './modules/module.langsData';
|
||||
import * as yamlCfg from './modules/module.cfg-loader';
|
||||
|
|
@ -20,40 +19,32 @@ import * as yargs from './modules/module.app-args';
|
|||
import Merger, { Font, MergerInput, SubtitleInput } from './modules/module.merger';
|
||||
import getKeys, { canDecrypt } from './modules/widevine';
|
||||
//import vttConvert from './modules/module.vttconvert';
|
||||
|
||||
// args
|
||||
|
||||
// load req
|
||||
import { domain, api } from './modules/module.api-urls';
|
||||
import * as reqModule from './modules/module.fetch';
|
||||
import { CrunchySearch } from './@types/crunchySearch';
|
||||
import { CrunchyEpisodeList, CrunchyEpisode } from './@types/crunchyEpisodeList';
|
||||
import { CrunchyDownloadOptions, CrunchyEpMeta, CrunchyMuxOptions, CrunchyMultiDownload, DownloadedMedia, ParseItem, SeriesSearch, SeriesSearchItem } from './@types/crunchyTypes';
|
||||
import { ObjectInfo } from './@types/objectInfo';
|
||||
import parseFileName, { Variable } from './modules/module.filename';
|
||||
import { CrunchyStreams, PlaybackData, Subtitles } from './@types/playbackData';
|
||||
import { downloaded } from './modules/module.downloadArchive';
|
||||
import parseSelect from './modules/module.parseSelect';
|
||||
import { AvailableFilenameVars, getDefault } from './modules/module.args';
|
||||
import { AuthData, AuthResponse, Episode, ResponseBase, SearchData, SearchResponse, SearchResponseItem } from './@types/messageHandler';
|
||||
import { ServiceClass } from './@types/serviceClassInterface';
|
||||
import { CrunchyAndroidStreams } from './@types/crunchyAndroidStreams';
|
||||
import { CrunchyAndroidEpisodes } from './@types/crunchyAndroidEpisodes';
|
||||
import { parse } from './modules/module.transform-mpd';
|
||||
import { CrunchyAndroidObject } from './@types/crunchyAndroidObject';
|
||||
import { CrunchyChapters, CrunchyChapter, CrunchyOldChapter } from './@types/crunchyChapters';
|
||||
import vtt2ass from './modules/module.vtt2ass';
|
||||
import { CrunchyPlayStream } from './@types/crunchyPlayStreams';
|
||||
import { CrunchyPlayStreams } from './@types/enums';
|
||||
import { randomUUID } from 'node:crypto';
|
||||
import streamdl, { M3U8Json } from './modules/hls-download';
|
||||
import { exec } from './modules/sei-helper-fixes';
|
||||
|
||||
export type sxItem = {
|
||||
language: langsData.LanguageItem,
|
||||
path: string,
|
||||
file: string
|
||||
title: string,
|
||||
fonts: Font[]
|
||||
}
|
||||
// Types
|
||||
import type { CrunchyDownloadOptions, CrunchyEpMeta, CrunchyMuxOptions, CrunchyMultiDownload, ParseItem, SeriesSearch, SeriesSearchItem } from './@types/crunchyTypes';
|
||||
import type { DownloadedMedia, sxItem } from './@types/downloaderTypes';
|
||||
import type { CrunchySearch } from './@types/crunchySearch';
|
||||
import type { CrunchyEpisodeList, CrunchyEpisode } from './@types/crunchyEpisodeList';
|
||||
import type { ObjectInfo } from './@types/objectInfo';
|
||||
import type { AuthData, AuthResponse, Episode, ResponseBase, SearchData, SearchResponse, SearchResponseItem } from './@types/messageHandler';
|
||||
import type { ServiceClass } from './@types/serviceClassInterface';
|
||||
import type { CrunchyAndroidStreams } from './@types/crunchyAndroidStreams';
|
||||
import type { CrunchyAndroidEpisodes } from './@types/crunchyAndroidEpisodes';
|
||||
import type { CrunchyPlayStream } from './@types/crunchyPlayStreams';
|
||||
import type { CrunchyAndroidObject } from './@types/crunchyAndroidObject';
|
||||
import type { CrunchyChapters, CrunchyChapter, CrunchyOldChapter } from './@types/crunchyChapters';
|
||||
import type { CrunchyStreams, PlaybackData, Subtitles } from './@types/playbackData';
|
||||
import { CrunchyPlayStreams } from './@types/enums';
|
||||
|
||||
export default class Crunchy implements ServiceClass {
|
||||
public cfg: yamlCfg.ConfigObject;
|
||||
|
|
|
|||
45
hidive.ts
45
hidive.ts
|
|
@ -1,44 +1,43 @@
|
|||
// build-in
|
||||
// Built In
|
||||
import path from 'path';
|
||||
import fs from 'fs-extra';
|
||||
|
||||
// package program
|
||||
// Package
|
||||
import packageJson from './package.json';
|
||||
|
||||
// plugins
|
||||
import { console } from './modules/log';
|
||||
// Plugins
|
||||
import shlp from 'sei-helper';
|
||||
import streamdl, { M3U8Json } from './modules/hls-download';
|
||||
|
||||
// custom modules
|
||||
// Custom Modules
|
||||
import { console } from './modules/log';
|
||||
import streamdl, { M3U8Json } from './modules/hls-download';
|
||||
import * as fontsData from './modules/module.fontsData';
|
||||
import * as langsData from './modules/module.langsData';
|
||||
import * as yamlCfg from './modules/module.cfg-loader';
|
||||
import * as yargs from './modules/module.app-args';
|
||||
import Merger, { Font, MergerInput, SubtitleInput } from './modules/module.merger';
|
||||
import vtt2ass from './modules/module.vtt2ass';
|
||||
|
||||
// load req
|
||||
import { domain, api } from './modules/module.api-urls';
|
||||
import * as reqModule from './modules/module.req';
|
||||
import { DownloadedMedia } from './@types/hidiveTypes';
|
||||
import parseFileName, { Variable } from './modules/module.filename';
|
||||
import { downloaded } from './modules/module.downloadArchive';
|
||||
import parseSelect from './modules/module.parseSelect';
|
||||
import { AvailableFilenameVars } from './modules/module.args';
|
||||
import { AuthData, AuthResponse, SearchData, SearchResponse, SearchResponseItem } from './@types/messageHandler';
|
||||
import { ServiceClass } from './@types/serviceClassInterface';
|
||||
import { sxItem } from './crunchy';
|
||||
import { Hit, NewHidiveSearch } from './@types/newHidiveSearch';
|
||||
import { NewHidiveSeries } from './@types/newHidiveSeries';
|
||||
import { Episode, NewHidiveEpisodeExtra, NewHidiveSeason, NewHidiveSeriesExtra } from './@types/newHidiveSeason';
|
||||
import { NewHidiveEpisode } from './@types/newHidiveEpisode';
|
||||
import { NewHidivePlayback, Subtitle } from './@types/newHidivePlayback';
|
||||
import { MPDParsed, parse } from './modules/module.transform-mpd';
|
||||
import getKeys, { canDecrypt } from './modules/widevine';
|
||||
import { exec } from './modules/sei-helper-fixes';
|
||||
import { KeyContainer } from './modules/license';
|
||||
|
||||
// Types
|
||||
import type { AuthData, AuthResponse, SearchData, SearchResponse, SearchResponseItem } from './@types/messageHandler';
|
||||
import type { ServiceClass } from './@types/serviceClassInterface';
|
||||
import type { Hit, NewHidiveSearch } from './@types/newHidiveSearch';
|
||||
import type { NewHidiveSeries } from './@types/newHidiveSeries';
|
||||
import type { Episode, NewHidiveEpisodeExtra, NewHidiveSeason, NewHidiveSeriesExtra } from './@types/newHidiveSeason';
|
||||
import type { NewHidiveEpisode } from './@types/newHidiveEpisode';
|
||||
import type { NewHidivePlayback, Subtitle } from './@types/newHidivePlayback';
|
||||
import type { DownloadedMedia, sxItem } from './@types/downloaderTypes';
|
||||
|
||||
export default class Hidive implements ServiceClass {
|
||||
public cfg: yamlCfg.ConfigObject;
|
||||
private token: Record<string, any>;
|
||||
|
|
@ -998,8 +997,6 @@ export default class Hidive implements ServiceClass {
|
|||
}
|
||||
const merger = new Merger({
|
||||
onlyVid: hasAudioStreams ? data.filter(a => a.type === 'Video').map((a) : MergerInput => {
|
||||
if (a.type === 'Subtitle')
|
||||
throw new Error('Never');
|
||||
return {
|
||||
lang: a.lang,
|
||||
path: a.path,
|
||||
|
|
@ -1009,8 +1006,6 @@ export default class Hidive implements ServiceClass {
|
|||
inverseTrackOrder: inverseTrackOrder,
|
||||
keepAllVideos: options.keepAllVideos,
|
||||
onlyAudio: hasAudioStreams ? data.filter(a => a.type === 'Audio').map((a) : MergerInput => {
|
||||
if (a.type === 'Subtitle')
|
||||
throw new Error('Never');
|
||||
return {
|
||||
lang: a.lang,
|
||||
path: a.path,
|
||||
|
|
@ -1018,10 +1013,6 @@ export default class Hidive implements ServiceClass {
|
|||
}) : [],
|
||||
output: `${options.output}.${options.mp4 ? 'mp4' : 'mkv'}`,
|
||||
subtitles: data.filter(a => a.type === 'Subtitle').map((a) : SubtitleInput => {
|
||||
if (a.type === 'Video')
|
||||
throw new Error('Never');
|
||||
if (a.type === 'Audio')
|
||||
throw new Error('Never');
|
||||
return {
|
||||
file: a.path,
|
||||
language: a.language,
|
||||
|
|
@ -1029,14 +1020,10 @@ export default class Hidive implements ServiceClass {
|
|||
};
|
||||
}),
|
||||
simul: data.filter(a => a.type === 'Video').map((a) : boolean => {
|
||||
if (a.type === 'Subtitle')
|
||||
throw new Error('Never');
|
||||
return !a.uncut as boolean;
|
||||
})[0],
|
||||
fonts: Merger.makeFontsList(this.cfg.dir.fonts, data.filter(a => a.type === 'Subtitle') as sxItem[]),
|
||||
videoAndAudio: hasAudioStreams ? [] : data.filter(a => a.type === 'Video').map((a) : MergerInput => {
|
||||
if (a.type === 'Subtitle')
|
||||
throw new Error('Never');
|
||||
return {
|
||||
lang: a.lang,
|
||||
path: a.path,
|
||||
|
|
|
|||
Loading…
Reference in a new issue