From d0518142599d326bac12a66e0173eb0e2da2c66d Mon Sep 17 00:00:00 2001 From: asuyou Date: Thu, 28 Oct 2021 11:19:17 +0100 Subject: Added quality choice based on format --- ui/src/app/formats.ts | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 ui/src/app/formats.ts (limited to 'ui/src/app/formats.ts') diff --git a/ui/src/app/formats.ts b/ui/src/app/formats.ts new file mode 100644 index 0000000..5264cd0 --- /dev/null +++ b/ui/src/app/formats.ts @@ -0,0 +1,39 @@ +export interface Format { + id: string; + text: string; + qualities: Quality[]; +} + +export interface Quality { + id: string; + text: string; +} + +export const Formats: Format[] = [ + { + id: 'any', + text: 'Any', + qualities: [{ id: 'best', text: 'Best' }], + }, + { + id: 'mp4', + text: 'MP4', + qualities: [ + { id: 'best', text: 'Best' }, + { id: '1440', text: '1440p' }, + { id: '1080', text: '1080p' }, + { id: '720', text: '720p' }, + { id: '480', text: '480p' }, + ], + }, + { + id: 'mp3', + text: 'MP3', + qualities: [ + { id: 'best', text: 'Best' }, + { id: '128', text: '128 kbps' }, + { id: '192', text: '192 kbps' }, + { id: '320', text: '320 kbps' }, + ], + }, +]; -- cgit From 26798a4930da04d5ce4d54742e0d8ca8d802e9ba Mon Sep 17 00:00:00 2001 From: asuyou Date: Wed, 3 Nov 2021 21:57:34 +0000 Subject: Any now shows all avaliable formats --- ui/src/app/formats.ts | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'ui/src/app/formats.ts') diff --git a/ui/src/app/formats.ts b/ui/src/app/formats.ts index 5264cd0..4f8dd0c 100644 --- a/ui/src/app/formats.ts +++ b/ui/src/app/formats.ts @@ -7,33 +7,52 @@ export interface Format { export interface Quality { id: string; text: string; + value: string; + fmt?: string; } export const Formats: Format[] = [ { id: 'any', text: 'Any', - qualities: [{ id: 'best', text: 'Best' }], + qualities: [], }, { id: 'mp4', text: 'MP4', qualities: [ - { id: 'best', text: 'Best' }, - { id: '1440', text: '1440p' }, - { id: '1080', text: '1080p' }, - { id: '720', text: '720p' }, - { id: '480', text: '480p' }, + { id: "1", value: 'best', text: 'Best MP4' }, + { id: "2", value: '1440', text: '1440p' }, + { id: "3", value: '1080', text: '1080p' }, + { id: "4", value: '720', text: '720p' }, + { id: "5", value: '480', text: '480p' }, ], }, { id: 'mp3', text: 'MP3', qualities: [ - { id: 'best', text: 'Best' }, - { id: '128', text: '128 kbps' }, - { id: '192', text: '192 kbps' }, - { id: '320', text: '320 kbps' }, + { id: "6", value: 'best', text: 'Best MP3' }, + { id: "7", value: '128', text: '128 kbps' }, + { id: "8", value: '192', text: '192 kbps' }, + { id: "9", value: '320', text: '320 kbps' }, ], }, ]; + +export const fillQualities = (formats: Format[]): Format[] => { + let allQualities: Quality[] = []; + formats.forEach((fmt) => { + fmt.qualities = fmt.qualities.map((ql) => ({ ...ql, fmt: fmt.id })); + allQualities = allQualities.concat(fmt.qualities); + }); + + formats.find((format) => format.id === 'any').qualities = allQualities; + return formats; +}; + +export const getQualityById = (formats: Format[], id: string): Quality => { + return formats + .find(ql => ql.qualities.find(el => el.id === id)).qualities + .find(el => el.id === id) +} -- cgit From b661d4db591c8680905ad22a26a5234066a2c940 Mon Sep 17 00:00:00 2001 From: asuyou Date: Sat, 13 Nov 2021 23:49:30 +0000 Subject: Fixed "any" format to act like original --- ui/src/app/formats.ts | 45 ++++++++++++++++++++------------------------- 1 file changed, 20 insertions(+), 25 deletions(-) (limited to 'ui/src/app/formats.ts') diff --git a/ui/src/app/formats.ts b/ui/src/app/formats.ts index 4f8dd0c..f24b210 100644 --- a/ui/src/app/formats.ts +++ b/ui/src/app/formats.ts @@ -8,51 +8,46 @@ export interface Quality { id: string; text: string; value: string; - fmt?: string; } export const Formats: Format[] = [ { id: 'any', text: 'Any', - qualities: [], + qualities: [ + { id: '0', value: 'best', text: 'Best' }, + { id: '1', value: '1440', text: '1440p' }, + { id: '2', value: '1080', text: '1080p' }, + { id: '3', value: '720', text: '720p' }, + { id: '4', value: '480', text: '480p' }, + { id: '5', value: 'audio', text: 'Audio Only' }, + ], }, { id: 'mp4', text: 'MP4', qualities: [ - { id: "1", value: 'best', text: 'Best MP4' }, - { id: "2", value: '1440', text: '1440p' }, - { id: "3", value: '1080', text: '1080p' }, - { id: "4", value: '720', text: '720p' }, - { id: "5", value: '480', text: '480p' }, + { id: '6', value: 'best', text: 'Best' }, + { id: '7', value: '1440', text: '1440p' }, + { id: '8', value: '1080', text: '1080p' }, + { id: '9', value: '720', text: '720p' }, + { id: '10', value: '480', text: '480p' }, ], }, { id: 'mp3', text: 'MP3', qualities: [ - { id: "6", value: 'best', text: 'Best MP3' }, - { id: "7", value: '128', text: '128 kbps' }, - { id: "8", value: '192', text: '192 kbps' }, - { id: "9", value: '320', text: '320 kbps' }, + { id: '11', value: 'best', text: 'Best' }, + { id: '12', value: '128', text: '128 kbps' }, + { id: '13', value: '192', text: '192 kbps' }, + { id: '14', value: '320', text: '320 kbps' }, ], }, ]; -export const fillQualities = (formats: Format[]): Format[] => { - let allQualities: Quality[] = []; - formats.forEach((fmt) => { - fmt.qualities = fmt.qualities.map((ql) => ({ ...ql, fmt: fmt.id })); - allQualities = allQualities.concat(fmt.qualities); - }); - - formats.find((format) => format.id === 'any').qualities = allQualities; - return formats; -}; - export const getQualityById = (formats: Format[], id: string): Quality => { return formats - .find(ql => ql.qualities.find(el => el.id === id)).qualities - .find(el => el.id === id) -} + .find((ql) => ql.qualities.find((el) => el.id === id)) + .qualities.find((el) => el.id === id); +}; -- cgit From 2e591122f2de091f76ddf2bdb57aaf29e72ed6f4 Mon Sep 17 00:00:00 2001 From: asuyou Date: Fri, 19 Nov 2021 17:57:43 +0000 Subject: Quality stays the same if it exists on next format --- ui/src/app/formats.ts | 37 +++++++++++++++---------------------- 1 file changed, 15 insertions(+), 22 deletions(-) (limited to 'ui/src/app/formats.ts') diff --git a/ui/src/app/formats.ts b/ui/src/app/formats.ts index f24b210..bb2fe07 100644 --- a/ui/src/app/formats.ts +++ b/ui/src/app/formats.ts @@ -7,7 +7,6 @@ export interface Format { export interface Quality { id: string; text: string; - value: string; } export const Formats: Format[] = [ @@ -15,39 +14,33 @@ export const Formats: Format[] = [ id: 'any', text: 'Any', qualities: [ - { id: '0', value: 'best', text: 'Best' }, - { id: '1', value: '1440', text: '1440p' }, - { id: '2', value: '1080', text: '1080p' }, - { id: '3', value: '720', text: '720p' }, - { id: '4', value: '480', text: '480p' }, - { id: '5', value: 'audio', text: 'Audio Only' }, + { id: 'best', text: 'Best' }, + { id: '1440', text: '1440p' }, + { id: '1080', text: '1080p' }, + { id: '720', text: '720p' }, + { id: '480', text: '480p' }, + { id: 'audio', text: 'Audio Only' }, ], }, { id: 'mp4', text: 'MP4', qualities: [ - { id: '6', value: 'best', text: 'Best' }, - { id: '7', value: '1440', text: '1440p' }, - { id: '8', value: '1080', text: '1080p' }, - { id: '9', value: '720', text: '720p' }, - { id: '10', value: '480', text: '480p' }, + { id: 'best', text: 'Best' }, + { id: '1440', text: '1440p' }, + { id: '1080', text: '1080p' }, + { id: '720', text: '720p' }, + { id: '480', text: '480p' }, ], }, { id: 'mp3', text: 'MP3', qualities: [ - { id: '11', value: 'best', text: 'Best' }, - { id: '12', value: '128', text: '128 kbps' }, - { id: '13', value: '192', text: '192 kbps' }, - { id: '14', value: '320', text: '320 kbps' }, + { id: 'best', text: 'Best' }, + { id: '128', text: '128 kbps' }, + { id: '192', text: '192 kbps' }, + { id: '320', text: '320 kbps' }, ], }, ]; - -export const getQualityById = (formats: Format[], id: string): Quality => { - return formats - .find((ql) => ql.qualities.find((el) => el.id === id)) - .qualities.find((el) => el.id === id); -}; -- cgit From 99c366e5c29a80b3d836fca22c37a7be523fc311 Mon Sep 17 00:00:00 2001 From: asuyou Date: Fri, 19 Nov 2021 18:01:02 +0000 Subject: Audio quality sorting now follows mp4 --- ui/src/app/formats.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ui/src/app/formats.ts') diff --git a/ui/src/app/formats.ts b/ui/src/app/formats.ts index bb2fe07..15be903 100644 --- a/ui/src/app/formats.ts +++ b/ui/src/app/formats.ts @@ -38,9 +38,9 @@ export const Formats: Format[] = [ text: 'MP3', qualities: [ { id: 'best', text: 'Best' }, - { id: '128', text: '128 kbps' }, - { id: '192', text: '192 kbps' }, { id: '320', text: '320 kbps' }, + { id: '192', text: '192 kbps' }, + { id: '128', text: '128 kbps' }, ], }, ]; -- cgit