From f7f8806b14bd88fe61bd4cf18274c2292b335486 Mon Sep 17 00:00:00 2001 From: Tera <1527149+Denoder@users.noreply.github.com> Date: Thu, 21 Mar 2024 20:14:14 +0200 Subject: [PATCH 1/2] sort episodes to have specials at the end --- crunchy.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/crunchy.ts b/crunchy.ts index ade1d62..6f3c939 100644 --- a/crunchy.ts +++ b/crunchy.ts @@ -2238,8 +2238,13 @@ export default class Crunchy implements ServiceClass { delete episodes[key]; } - for (const key of Object.keys(episodes)) { - const item = episodes[key]; + // Sort episodes to have specials at the end + const specials = Object.entries(episodes).filter(a => a[0].startsWith('S')), + normal = Object.entries(episodes).filter(a => a[0].startsWith('E')), + sortedEpisodes = Object.fromEntries([...normal, ...specials]); + + for (const key of Object.keys(sortedEpisodes)) { + const item = sortedEpisodes[key]; console.info(`[${key}] ${ item.items.find(a => !a.season_title.match(/\(\w+ Dub\)/))?.season_title ?? item.items[0].season_title.replace(/\(\w+ Dub\)/g, '').trimEnd() } - Season ${item.items[0].season_number} - ${item.items[0].title} [${ @@ -2249,13 +2254,11 @@ export default class Crunchy implements ServiceClass { }]`); } - //TODO: Sort episodes to have specials at the end - if (!serieshasversions) { console.warn('Couldn\'t find versions on some episodes, fell back to old method.'); } - return { data: episodes, list: Object.entries(episodes).map(([key, value]) => { + return { data: sortedEpisodes, list: Object.entries(sortedEpisodes).map(([key, value]) => { const images = (value.items[0].images.thumbnail ?? [[ { source: '/notFound.png' } ]])[0]; const seconds = Math.floor(value.items[0].duration_ms / 1000); return { -- 2.45.2 From 6009bdaaf92cfa6473fdc42f866a623686ca1ccb Mon Sep 17 00:00:00 2001 From: Tera <1527149+Denoder@users.noreply.github.com> Date: Thu, 21 Mar 2024 23:38:46 +0200 Subject: [PATCH 2/2] Sort episodes to have specials at the end --- crunchy.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crunchy.ts b/crunchy.ts index 6f3c939..fddd838 100644 --- a/crunchy.ts +++ b/crunchy.ts @@ -2240,8 +2240,8 @@ export default class Crunchy implements ServiceClass { // Sort episodes to have specials at the end const specials = Object.entries(episodes).filter(a => a[0].startsWith('S')), - normal = Object.entries(episodes).filter(a => a[0].startsWith('E')), - sortedEpisodes = Object.fromEntries([...normal, ...specials]); + normal = Object.entries(episodes).filter(a => a[0].startsWith('E')), + sortedEpisodes = Object.fromEntries([...normal, ...specials]); for (const key of Object.keys(sortedEpisodes)) { const item = sortedEpisodes[key]; -- 2.45.2