From 73ddab8b2eeb96019b2747d5fa79762ea750a15a Mon Sep 17 00:00:00 2001 From: Tera <1527149+Denoder@users.noreply.github.com> Date: Thu, 21 Mar 2024 06:23:01 +0200 Subject: [PATCH 1/8] Update crunchy.ts --- crunchy.ts | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/crunchy.ts b/crunchy.ts index 2bb9fc4..7f99b0b 100644 --- a/crunchy.ts +++ b/crunchy.ts @@ -2166,7 +2166,7 @@ export default class Crunchy implements ServiceClass { merger.cleanUp(); } - public async listSeriesID(id: string): Promise<{ list: Episode[], data: Record}> { @@ -2229,11 +2229,19 @@ export default class Crunchy implements ServiceClass { for (const key of Object.keys(episodes)) { const item = episodes[key]; const isSpecial = !item.items[0].episode.match(/^\d+$/); - episodes[`${isSpecial ? 'S' : 'E'}${itemIndexes[isSpecial ? 'sp' : 'no']}`] = item; - if (isSpecial) - itemIndexes.sp++; - else - itemIndexes.no++; + const episodeNumber = isSpecial ? item.items[0].episode : item.items[0].episode_number; + const seasonIdentifier = `S${item.items[0].season_id}`; + + if (!data.s) { + episodes[`${isSpecial ? 'S' : 'E'}${itemIndexes[isSpecial ? 'sp' : 'no']}`] = item; + if (isSpecial) + itemIndexes.sp++; + else + itemIndexes.no++; + } else { + episodes[`${isSpecial ? 'S' : 'E'}${episodeNumber}|${seasonIdentifier}`] = item; + } + delete episodes[key]; } @@ -2274,11 +2282,11 @@ export default class Crunchy implements ServiceClass { } public async downloadFromSeriesID(id: string, data: CrunchyMultiDownload) : Promise> { - const { data: episodes } = await this.listSeriesID(id); + const { data: episodes } = await this.listSeriesID(id, data); console.info(''); console.info('-'.repeat(30)); console.info(''); - const selected = this.itemSelectMultiDub(episodes, data.dubLang, data.but, data.all, data.e); + const selected = this.itemSelectMultiDub(episodes, data.dubLang, data.but, data.all, data.e, data.s); for (const key of Object.keys(selected)) { const item = selected[key]; console.info(`[S${item.season}E${item.episodeNumber}] - ${item.episodeTitle} [${ @@ -2293,7 +2301,7 @@ export default class Crunchy implements ServiceClass { public itemSelectMultiDub (eps: Record, dubLang: string[], but?: boolean, all?: boolean, e?: string, ) { + }>, dubLang: string[], but?: boolean, all?: boolean, e?: string, s?: string ) { const doEpsFilter = parseSelect(e as string); const ret: Record = {}; @@ -2301,7 +2309,7 @@ export default class Crunchy implements ServiceClass { for (const key of Object.keys(eps)) { const itemE = eps[key]; itemE.items.forEach((item, index) => { - if (!dubLang.includes(itemE.langs[index]?.code)) + if (!dubLang.includes(itemE.langs[index]?.code) || (s && item.season_id !== s)) return; item.hide_season_title = true; if(item.season_title == '' && item.series_title != ''){ @@ -2313,7 +2321,8 @@ export default class Crunchy implements ServiceClass { item.season_title = 'NO_TITLE'; item.series_title = 'NO_TITLE'; } - const epNum = key.startsWith('E') ? key.slice(1) : key; + + const epNum = key.startsWith('E') ? key.slice(1).split('|')[0] : key.split('|')[0]; // set data const images = (item.images.thumbnail ?? [[ { source: '/notFound.png' } ]])[0]; const epMeta: CrunchyEpMeta = { -- 2.45.2 From 6a4566be17cc1830ccc2235cf92e49766b0035d1 Mon Sep 17 00:00:00 2001 From: Tera <1527149+Denoder@users.noreply.github.com> Date: Thu, 21 Mar 2024 06:24:53 +0200 Subject: [PATCH 2/8] Update crunchyTypes.d.ts --- @types/crunchyTypes.d.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/@types/crunchyTypes.d.ts b/@types/crunchyTypes.d.ts index c9b49e1..9110c90 100644 --- a/@types/crunchyTypes.d.ts +++ b/@types/crunchyTypes.d.ts @@ -44,7 +44,8 @@ export type CrunchyMultiDownload = { dubLang: string[], all?: boolean, but?: boolean, - e?: string + e?: string, + s?: string } export type CrunchyMuxOptions = { -- 2.45.2 From 818d60e196a37c2c3f381b9ebb6f379a34b8bf4d Mon Sep 17 00:00:00 2001 From: AnimeDL Date: Wed, 20 Mar 2024 21:25:33 -0700 Subject: [PATCH 3/8] Verify file is file in CDM folder Make sure when reading cdm folder that a file is a file, not a folder. --- modules/widevine.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/widevine.ts b/modules/widevine.ts index 8e21e07..62d9f8b 100644 --- a/modules/widevine.ts +++ b/modules/widevine.ts @@ -14,7 +14,7 @@ try { files.forEach(function(file) { file = path.join(workingDir, 'widevine', file); const stats = fs.statSync(file); - if (stats.size < 1024*8) { + if (stats.size < 1024*8 && stats.isFile()) { const fileContents = fs.readFileSync(file, {'encoding': 'utf8'}); if (fileContents.includes('-BEGIN RSA PRIVATE KEY-')) { privateKey = fs.readFileSync(file); -- 2.45.2 From 201a772ecff085c5b9aaa0072b4db22f0e9fd3a7 Mon Sep 17 00:00:00 2001 From: Tera <1527149+Denoder@users.noreply.github.com> Date: Thu, 21 Mar 2024 07:46:03 +0200 Subject: [PATCH 4/8] remove bloat --- crunchy.ts | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/crunchy.ts b/crunchy.ts index 7f99b0b..8cab04b 100644 --- a/crunchy.ts +++ b/crunchy.ts @@ -2183,6 +2183,7 @@ export default class Crunchy implements ServiceClass { for(const season of Object.keys(result) as unknown as number[]) { for (const key of Object.keys(result[season])) { const s = result[season][key]; + if (data.s && s.id !== data.s) continue; (await this.getSeasonDataById(s))?.data?.forEach(episode => { //TODO: Make sure the below code is ok //Prepare the episode array @@ -2229,19 +2230,11 @@ export default class Crunchy implements ServiceClass { for (const key of Object.keys(episodes)) { const item = episodes[key]; const isSpecial = !item.items[0].episode.match(/^\d+$/); - const episodeNumber = isSpecial ? item.items[0].episode : item.items[0].episode_number; - const seasonIdentifier = `S${item.items[0].season_id}`; - - if (!data.s) { - episodes[`${isSpecial ? 'S' : 'E'}${itemIndexes[isSpecial ? 'sp' : 'no']}`] = item; - if (isSpecial) - itemIndexes.sp++; - else - itemIndexes.no++; - } else { - episodes[`${isSpecial ? 'S' : 'E'}${episodeNumber}|${seasonIdentifier}`] = item; - } - + episodes[`${isSpecial ? 'S' : 'E'}${itemIndexes[isSpecial ? 'sp' : 'no']}`] = item; + if (isSpecial) + itemIndexes.sp++; + else + itemIndexes.no++; delete episodes[key]; } @@ -2322,7 +2315,7 @@ export default class Crunchy implements ServiceClass { item.series_title = 'NO_TITLE'; } - const epNum = key.startsWith('E') ? key.slice(1).split('|')[0] : key.split('|')[0]; + const epNum = key.startsWith('E') ? key.slice(1) : key; // set data const images = (item.images.thumbnail ?? [[ { source: '/notFound.png' } ]])[0]; const epMeta: CrunchyEpMeta = { -- 2.45.2 From 30771374e5fe6a264df93507f6a0742da4db4edc Mon Sep 17 00:00:00 2001 From: Tera <1527149+Denoder@users.noreply.github.com> Date: Thu, 21 Mar 2024 07:47:54 +0200 Subject: [PATCH 5/8] Update crunchy.ts --- crunchy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crunchy.ts b/crunchy.ts index 8cab04b..d60a500 100644 --- a/crunchy.ts +++ b/crunchy.ts @@ -2302,7 +2302,7 @@ export default class Crunchy implements ServiceClass { for (const key of Object.keys(eps)) { const itemE = eps[key]; itemE.items.forEach((item, index) => { - if (!dubLang.includes(itemE.langs[index]?.code) || (s && item.season_id !== s)) + if (!dubLang.includes(itemE.langs[index]?.code)) return; item.hide_season_title = true; if(item.season_title == '' && item.series_title != ''){ -- 2.45.2 From 4eea557c446ab4c69915cb6d782a626fed402f0c Mon Sep 17 00:00:00 2001 From: Tera <1527149+Denoder@users.noreply.github.com> Date: Thu, 21 Mar 2024 08:06:08 +0200 Subject: [PATCH 6/8] Update crunchy.ts --- crunchy.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crunchy.ts b/crunchy.ts index d60a500..f3d20eb 100644 --- a/crunchy.ts +++ b/crunchy.ts @@ -2279,7 +2279,7 @@ export default class Crunchy implements ServiceClass { console.info(''); console.info('-'.repeat(30)); console.info(''); - const selected = this.itemSelectMultiDub(episodes, data.dubLang, data.but, data.all, data.e, data.s); + const selected = this.itemSelectMultiDub(episodes, data.dubLang, data.but, data.all, data.e); for (const key of Object.keys(selected)) { const item = selected[key]; console.info(`[S${item.season}E${item.episodeNumber}] - ${item.episodeTitle} [${ @@ -2294,7 +2294,7 @@ export default class Crunchy implements ServiceClass { public itemSelectMultiDub (eps: Record, dubLang: string[], but?: boolean, all?: boolean, e?: string, s?: string ) { + }>, dubLang: string[], but?: boolean, all?: boolean, e?: string, ) { const doEpsFilter = parseSelect(e as string); const ret: Record = {}; -- 2.45.2 From cd9a83d3fca43cbc3ec38ad8cf1006c5b5b5087b Mon Sep 17 00:00:00 2001 From: Tera <1527149+Denoder@users.noreply.github.com> Date: Thu, 21 Mar 2024 18:29:08 +0200 Subject: [PATCH 7/8] make data param optional --- crunchy.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crunchy.ts b/crunchy.ts index f3d20eb..0e63fc5 100644 --- a/crunchy.ts +++ b/crunchy.ts @@ -2166,7 +2166,7 @@ export default class Crunchy implements ServiceClass { merger.cleanUp(); } - public async listSeriesID(id: string, data: CrunchyMultiDownload): Promise<{ list: Episode[], data: Record}> { @@ -2183,7 +2183,7 @@ export default class Crunchy implements ServiceClass { for(const season of Object.keys(result) as unknown as number[]) { for (const key of Object.keys(result[season])) { const s = result[season][key]; - if (data.s && s.id !== data.s) continue; + if (data?.s && s.id !== data.s) continue; (await this.getSeasonDataById(s))?.data?.forEach(episode => { //TODO: Make sure the below code is ok //Prepare the episode array -- 2.45.2 From 8cd863c8853b31c12e58a6e51ba26b768a75847f Mon Sep 17 00:00:00 2001 From: Tera <1527149+Denoder@users.noreply.github.com> Date: Thu, 21 Mar 2024 19:37:22 +0200 Subject: [PATCH 8/8] Update crunchy.ts --- crunchy.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crunchy.ts b/crunchy.ts index 0e63fc5..ade1d62 100644 --- a/crunchy.ts +++ b/crunchy.ts @@ -2166,7 +2166,7 @@ export default class Crunchy implements ServiceClass { merger.cleanUp(); } - public async listSeriesID(id: string, data: CrunchyMultiDownload | undefined = undefined): Promise<{ list: Episode[], data: Record}> { -- 2.45.2