playlists support v1
All checks were successful
Deploy App / build (push) Successful in 4m19s
Deploy App / deploy (push) Successful in 16s

This commit is contained in:
valere
2025-10-09 22:47:30 +02:00
parent c86e345117
commit e2c5693948
30 changed files with 620 additions and 554 deletions

View File

@@ -2,41 +2,158 @@ import { eventHandler } from 'h3'
export default eventHandler(() => {
return [
{
id: 'ES2012',
name: '2012',
duration: 0,
description: '🐉💧',
color1: '#ffffff',
color2: '#32021F',
color3: '#00ff00'
},
{
id: 'ES2013',
name: '2013',
duration: 0,
description: '🐍💧',
color1: '#ffffff',
color2: '#32021F',
color3: '#00ff00'
},
{
id: 'ES2015',
name: '2015',
duration: 0,
description: '🐐🌳',
color1: '#ffffff',
color2: '#32021F',
color3: '#00ff00'
},
{
id: 'ES2016',
name: '2016',
duration: 0,
description: '🐒🔥',
color1: '#ffffff',
color2: '#32021F',
color3: '#00ff00'
},
{
id: 'ES2017',
name: '2017',
duration: 0,
description: '🐓🔥',
color1: '#ffffff',
color2: '#32021F',
color3: '#00ff00'
},
{
id: 'ES2018',
name: '2018',
duration: 0,
description: '🐕🌱',
color1: '#ffffff',
color2: '#32021F',
color3: '#00ff00'
},
{
id: 'ES2019',
name: '2019',
duration: 0,
description: '🐖🌱',
color1: '#ffffff',
color2: '#32021F',
color3: '#00ff00'
},
{
id: 'ES2020',
name: '2020',
duration: 0,
description: '🐀🪙',
color1: '#ffffff',
color2: '#32021F',
color3: '#00ff00'
},
{
id: 'ES2021',
name: '2021',
duration: 0,
description: '🐃🪙',
color1: '#ffffff',
color2: '#32021F',
color3: '#00ff00'
},
{
id: 'ES2022',
name: '2022',
duration: 0,
description: '🐅💧',
color1: '#ffffff',
color2: '#32021F',
color3: '#00ff00'
},
{
id: 'ES2023',
name: '2023',
duration: 0,
description: '🐇💧',
color1: '#ffffff',
color2: '#32021F',
color3: '#00ff00'
},
{
id: 'ES2024',
name: '2024',
duration: 0,
description: '🐉🌳',
color1: '#ffffff',
color2: '#32021F',
color3: '#00ff00'
},
{
id: 'ES2025',
name: '2025',
duration: 0,
description: '🐍🌳',
color1: '#ffffff',
color2: '#32021F',
color3: '#00ff00'
},
{
id: 'ES00A',
name: 'zero',
name: 'manifeste',
duration: 2794,
description: 'Zero is for manifesto',
color1: '#ffffff',
color2: '#48959d',
color3: '#00ff00',
color3: '#00ff00'
},
{
id: 'ES00B',
name: 'zero b-side',
name: 'manifeste B',
duration: 2470,
description: 'Even Zero has a b-side',
color1: '#0d01b9',
color2: '#3b7589',
color3: '#00ff00',
color3: '#00ff00'
},
{
id: 'ES01A',
name: 'first',
name: '...',
duration: 3487,
description: '...',
color1: '#c7b3aa',
color2: '#000100',
color3: '#00ff00',
color3: '#00ff00'
},
{
id: 'ES01B',
name: 'first b-side',
name: '... B',
duration: 3773,
description: '...',
color1: '#f7dd01',
color2: '#010103',
color3: '#00ff00',
color3: '#00ff00'
}
]
})

69
server/api/playlists.ts Normal file
View File

@@ -0,0 +1,69 @@
import fs from 'fs'
import path from 'path'
import { eventHandler } from 'h3'
import { getCardFromDate } from '../../utils/cards'
export default eventHandler(async (event) => {
const basePath = path.join(process.cwd(), '/mnt/media/files/music')
try {
let allTracks: any[] = []
const dirPath = basePath
const urlPrefix = `https://files.erudi.fr/music`
let files = await fs.promises.readdir(dirPath)
files = files.filter((f) => !f.startsWith('.'))
const tracks = files.map((file, index) => {
const EXT_RE = /\.(mp3|flac|wav|opus)$/i
const nameWithoutExt = file.replace(EXT_RE, '')
// On split sur __
const parts = nameWithoutExt.split('__')
let stamp = parts[0] || ''
let artist = parts[1] || ''
let title = parts[2] || ''
title = title.replaceAll('_', ' ')
artist = artist.replaceAll('_', ' ')
// Parser la date depuis le stamp
let year = 2020,
month = 1,
day = 1,
hour = 0
if (stamp.length === 10) {
year = Number(stamp.slice(0, 4))
month = Number(stamp.slice(4, 6))
day = Number(stamp.slice(6, 8))
hour = Number(stamp.slice(8, 10))
}
const date = new Date(year, month - 1, day, hour)
const card = getCardFromDate(date)
const url = `${urlPrefix}/${encodeURIComponent(file)}`
return {
id: Number(`${year}${index + 1}`),
compilationId: `ES${year}`,
date,
title: title.trim(),
artist: artist.trim(),
url,
coverId: '',
card
}
})
tracks.sort((a, b) => b.date.getTime() - a.date.getTime())
allTracks.push(...tracks)
return allTracks
} catch (error) {
return {
success: false,
error: (error as Error).message
}
}
})

View File

@@ -1,24 +0,0 @@
import fs from 'fs'
import path from 'path'
import { eventHandler } from 'h3'
export default eventHandler(async (event) => {
const id = event.context.params?.id || ''
const directoryPath = path.join(process.cwd(), '/mnt/media/files/music/' + id) // replace 'your-folder' with the folder you want to list
try {
// Read the directory contents
const files = await fs.promises.readdir(directoryPath)
return {
success: true,
files: files.filter(file => !file.startsWith('.')) // optional: exclude unwanted files
}
} catch (error) {
return {
success: false,
error: error.message
}
}
})

View File

@@ -1,22 +0,0 @@
import fs from 'fs'
import path from 'path'
import { eventHandler } from 'h3'
export default eventHandler(async (event) => {
const directoryPath = path.join(process.cwd(), '/mnt/media/files/music')
try {
// Read the directory contents
const files = await fs.promises.readdir(directoryPath)
return {
success: true,
files: files.filter(file => !file.startsWith('.')).reverse() // exclude unwanted files
}
} catch (error) {
return {
success: false,
error: error.message
}
}
})

View File

@@ -1,446 +1,409 @@
import { eventHandler } from 'h3'
export default eventHandler(() => {
return [
const tracks = [
{
id: 0,
order: 1,
compilationId: 'ES00A',
title: 'The grinding wheel',
artist: 0,
start: 0,
url: 'https://arakirecords.bandcamp.com/track/the-grinding-wheel',
coverId: 'a3236746052',
link: 'https://arakirecords.bandcamp.com/track/the-grinding-wheel',
coverId: 'a3236746052'
},
{
id: 1,
order: 2,
compilationId: 'ES00A',
title: 'Bleach',
artist: 1,
start: 392,
url: 'https://the-kundalini-genie.bandcamp.com/track/bleach-2',
coverId: 'a1714786533',
link: 'https://the-kundalini-genie.bandcamp.com/track/bleach-2',
coverId: 'a1714786533'
},
{
id: 2,
order: 3,
compilationId: 'ES00A',
title: 'Televised mind',
artist: 2,
start: 896,
url: 'https://fontainesdc.bandcamp.com/track/televised-mind',
link: 'https://fontainesdc.bandcamp.com/track/televised-mind',
coverId: 'a3772806156'
},
{
id: 3,
order: 4,
compilationId: 'ES00A',
title: 'In it',
artist: 3,
start: 1139,
url: 'https://howlinbananarecords.bandcamp.com/track/in-it',
coverId: 'a1720372066',
link: 'https://howlinbananarecords.bandcamp.com/track/in-it',
coverId: 'a1720372066'
},
{
id: 4,
order: 5,
compilationId: 'ES00A',
title: 'Bad michel',
artist: 4,
start: 1245,
url: 'https://johnnymafia.bandcamp.com/track/bad-michel-3',
coverId: 'a0984622869',
link: 'https://johnnymafia.bandcamp.com/track/bad-michel-3',
coverId: 'a0984622869'
},
{
id: 5,
order: 6,
compilationId: 'ES00A',
title: 'Overall',
artist: 5,
start: 1394,
url: 'https://newcandys.bandcamp.com/track/overall',
coverId: 'a0559661270',
link: 'https://newcandys.bandcamp.com/track/overall',
coverId: 'a0559661270'
},
{
id: 6,
order: 7,
compilationId: 'ES00A',
title: 'Blowup',
artist: 6,
start: 1674,
url: 'https://magicshoppe.bandcamp.com/track/blowup',
coverId: 'a1444895293',
link: 'https://magicshoppe.bandcamp.com/track/blowup',
coverId: 'a1444895293'
},
{
id: 7,
order: 8,
compilationId: 'ES00A',
title: 'Guitar jet',
artist: 7,
start: 1880,
url: 'https://radiomartiko.bandcamp.com/track/guitare-jet',
coverId: 'a1494681687',
link: 'https://radiomartiko.bandcamp.com/track/guitare-jet',
coverId: 'a1494681687'
},
{
id: 8,
order: 9,
compilationId: 'ES00A',
title: 'Intercontinental radio waves',
artist: 8,
start: 2024,
url: 'https://traams.bandcamp.com/track/intercontinental-radio-waves',
coverId: 'a0046738552',
link: 'https://traams.bandcamp.com/track/intercontinental-radio-waves',
coverId: 'a0046738552'
},
{
id: 9,
order: 10,
compilationId: 'ES00A',
title: 'Here comes the sun',
artist: 9,
start: 2211,
url: 'https://blue-orchid.bandcamp.com/track/here-come-the-sun',
coverId: 'a4102567047',
link: 'https://blue-orchid.bandcamp.com/track/here-come-the-sun',
coverId: 'a4102567047'
},
{
id: 10,
order: 11,
compilationId: 'ES00A',
title: 'Like in the movies',
artist: 10,
start: 2560,
url: 'https://bruitblanc.bandcamp.com/track/like-in-the-movies-2',
coverId: 'a2203158939',
link: 'https://bruitblanc.bandcamp.com/track/like-in-the-movies-2',
coverId: 'a2203158939'
},
{
id: 11,
order: 1,
compilationId: 'ES00B',
title: 'Ce que révèle l\'éclipse',
title: "Ce que révèle l'éclipse",
artist: 0,
start: 0,
url: 'https://arakirecords.bandcamp.com/track/ce-que-r-v-le-l-clipse',
coverId: 'a3236746052',
link: 'https://arakirecords.bandcamp.com/track/ce-que-r-v-le-l-clipse',
coverId: 'a3236746052'
},
{
id: 12,
order: 2,
compilationId: 'ES00B',
title: 'Bleedin\' Gums Mushrool',
title: "Bleedin' Gums Mushrool",
artist: 1,
start: 263,
url: 'https://the-kundalini-genie.bandcamp.com/track/bleedin-gums-mushroom',
coverId: 'a1714786533',
link: 'https://the-kundalini-genie.bandcamp.com/track/bleedin-gums-mushroom',
coverId: 'a1714786533'
},
{
id: 13,
order: 3,
compilationId: 'ES00B',
title: 'A lucid dream',
artist: 2,
start: 554,
url: 'https://fontainesdc.bandcamp.com/track/a-lucid-dream',
coverId: 'a3772806156',
link: 'https://fontainesdc.bandcamp.com/track/a-lucid-dream',
coverId: 'a3772806156'
},
{
id: 14,
order: 4,
compilationId: 'ES00B',
title: 'Lights off',
artist: 3,
start: 781,
url: 'https://howlinbananarecords.bandcamp.com/track/lights-off',
coverId: 'a1720372066',
link: 'https://howlinbananarecords.bandcamp.com/track/lights-off',
coverId: 'a1720372066'
},
{
id: 15,
order: 5,
compilationId: 'ES00B',
title: 'I\'m sentimental',
title: "I'm sentimental",
artist: 4,
start: 969,
url: 'https://johnnymafia.bandcamp.com/track/im-sentimental-2',
coverId: 'a2333676849',
link: 'https://johnnymafia.bandcamp.com/track/im-sentimental-2',
coverId: 'a2333676849'
},
{
id: 16,
order: 6,
compilationId: 'ES00B',
title: 'Thrill or trip',
artist: 5,
start: 1128,
url: 'https://newcandys.bandcamp.com/track/thrill-or-trip',
coverId: 'a0559661270',
link: 'https://newcandys.bandcamp.com/track/thrill-or-trip',
coverId: 'a0559661270'
},
{
id: 17,
order: 7,
compilationId: 'ES00B',
title: 'Redhead',
artist: 6,
start: 1303,
url: 'https://magicshoppe.bandcamp.com/track/redhead',
coverId: 'a0594426943',
link: 'https://magicshoppe.bandcamp.com/track/redhead',
coverId: 'a0594426943'
},
{
id: 18,
order: 8,
compilationId: 'ES00B',
title: 'Supersonic twist',
artist: 7,
start: 1584,
url: 'https://open.spotify.com/track/66voQIZAJ3zD3Eju2qtNjF',
coverId: 'a1494681687',
link: 'https://open.spotify.com/track/66voQIZAJ3zD3Eju2qtNjF',
coverId: 'a1494681687'
},
{
id: 19,
order: 9,
compilationId: 'ES00B',
title: 'Flowers',
artist: 8,
start: 1749,
url: 'https://traams.bandcamp.com/track/flowers',
coverId: 'a3644668199',
link: 'https://traams.bandcamp.com/track/flowers',
coverId: 'a3644668199'
},
{
id: 20,
order: 10,
compilationId: 'ES00B',
title: 'The shade',
artist: 9,
start: 1924,
url: 'https://blue-orchid.bandcamp.com/track/the-shade',
coverId: 'a0804204790',
link: 'https://blue-orchid.bandcamp.com/track/the-shade',
coverId: 'a0804204790'
},
{
id: 21,
order: 11,
compilationId: 'ES00B',
title: 'Like in the movies',
artist: 10,
start: 2186,
url: 'https://bruitblanc.bandcamp.com/track/like-in-the-movies',
coverId: 'a3647322740',
link: 'https://bruitblanc.bandcamp.com/track/like-in-the-movies',
coverId: 'a3647322740'
},
{
id: 22,
order: 1,
compilationId: 'ES01A',
title: 'He Walked In',
artist: 11,
start: 0,
url: 'https://kidcongothepinkmonkeybirds.bandcamp.com/track/he-walked-in',
coverId: 'a0336300523',
link: 'https://kidcongothepinkmonkeybirds.bandcamp.com/track/he-walked-in',
coverId: 'a0336300523'
},
{
id: 23,
order: 2,
compilationId: 'ES01A',
title: 'The Third Wave',
artist: 12,
start: 841,
url: 'https://firefriend.bandcamp.com/track/the-third-wave',
coverId: 'a2803689859',
link: 'https://firefriend.bandcamp.com/track/the-third-wave',
coverId: 'a2803689859'
},
{
id: 24,
order: 3,
compilationId: 'ES01A',
title: 'Broadcaster',
artist: 13,
start: 1104.5,
url: 'https://squiduk.bandcamp.com/track/broadcaster',
coverId: 'a3391719769',
link: 'https://squiduk.bandcamp.com/track/broadcaster',
coverId: 'a3391719769'
},
{
id: 25,
order: 4,
compilationId: 'ES01A',
title: 'Mourn',
artist: 14,
start: 1441,
url: 'https://lysistrata.bandcamp.com/track/mourn-2',
coverId: 'a0872900041',
link: 'https://lysistrata.bandcamp.com/track/mourn-2',
coverId: 'a0872900041'
},
{
id: 26,
order: 5,
compilationId: 'ES01A',
title: 'Let it Blow',
artist: 15,
start: 1844.8,
url: 'https://pabloxbroadcastingservices.bandcamp.com/track/let-it-blow',
coverId: 'a4000148031',
link: 'https://pabloxbroadcastingservices.bandcamp.com/track/let-it-blow',
coverId: 'a4000148031'
},
{
id: 27,
order: 6,
compilationId: 'ES01A',
title: 'Sunday Mourning',
artist: 16,
start: 2091.7,
url: 'https://nightbeats.bandcamp.com/track/sunday-mourning',
coverId: 'a0031987121',
link: 'https://nightbeats.bandcamp.com/track/sunday-mourning',
coverId: 'a0031987121'
},
{
id: 28,
order: 7,
compilationId: 'ES01A',
title: '3030 Instrumental',
artist: 17,
start: 2339.3,
url: 'https://delthefunkyhomosapien.bandcamp.com/track/3030',
coverId: 'a1948146136',
link: 'https://delthefunkyhomosapien.bandcamp.com/track/3030',
coverId: 'a1948146136'
},
{
id: 29,
order: 8,
compilationId: 'ES01A',
title: 'Immortality Break',
artist: 18,
start: 2530.5,
url: 'https://theaa.bandcamp.com/track/immortality-break',
coverId: 'a2749250329',
link: 'https://theaa.bandcamp.com/track/immortality-break',
coverId: 'a2749250329'
},
{
id: 30,
order: 9,
compilationId: 'ES01A',
title: 'Lazy Bones',
artist: 19,
start: 2718,
url: 'https://woodenshjips.bandcamp.com/track/lazy-bones',
coverId: 'a1884221104',
link: 'https://woodenshjips.bandcamp.com/track/lazy-bones',
coverId: 'a1884221104'
},
{
id: 31,
order: 10,
compilationId: 'ES01A',
title: 'On the Train of Aches',
artist: 20,
start: 2948,
url: 'https://silasjdirge.bandcamp.com/track/on-the-train-of-aches',
coverId: 'a1124177379',
link: 'https://silasjdirge.bandcamp.com/track/on-the-train-of-aches',
coverId: 'a1124177379'
},
{
id: 32,
order: 11,
compilationId: 'ES01A',
title: 'Me',
artist: 21,
start: 3265,
url: 'https://secretcolours.bandcamp.com/track/me',
coverId: 'a1497022499',
link: 'https://secretcolours.bandcamp.com/track/me',
coverId: 'a1497022499'
},
{
id: 33,
order: 1,
compilationId: 'ES01B',
title: 'Lady Hawke Blues',
artist: 11,
start: 0,
url: 'https://kidcongothepinkmonkeybirds.bandcamp.com/track/lady-hawke-blues',
coverId: 'a2532623230',
link: 'https://kidcongothepinkmonkeybirds.bandcamp.com/track/lady-hawke-blues',
coverId: 'a2532623230'
},
{
id: 34,
order: 2,
compilationId: 'ES01B',
title: 'Dreamscapes',
artist: 12,
start: 235,
url: 'https://littlecloudrecords.bandcamp.com/track/dreamscapes',
coverId: 'a3498981203',
link: 'https://littlecloudrecords.bandcamp.com/track/dreamscapes',
coverId: 'a3498981203'
},
{
id: 35,
order: 3,
compilationId: 'ES01B',
title: 'Crispy Skin',
artist: 13,
start: 644.2,
url: 'https://squiduk.bandcamp.com/track/crispy-skin-2',
coverId: 'a2516727021',
link: 'https://squiduk.bandcamp.com/track/crispy-skin-2',
coverId: 'a2516727021'
},
{
id: 36,
order: 4,
compilationId: 'ES01B',
title: 'The Boy Who Stood Above The Earth',
artist: 14,
start: 1018,
url: 'https://lysistrata.bandcamp.com/track/the-boy-who-stood-above-the-earth-2',
coverId: 'a0350933426',
link: 'https://lysistrata.bandcamp.com/track/the-boy-who-stood-above-the-earth-2',
coverId: 'a0350933426'
},
{
id: 37,
order: 5,
compilationId: 'ES01B',
title: 'Better Off Alone',
artist: 15,
start: 1698,
url: 'https://pabloxbroadcastingservices.bandcamp.com/track/better-off-alone',
coverId: 'a4000148031',
link: 'https://pabloxbroadcastingservices.bandcamp.com/track/better-off-alone',
coverId: 'a4000148031'
},
{
id: 38,
order: 6,
compilationId: 'ES01B',
title: 'Celebration #1',
artist: 16,
start: 2235,
url: 'https://nightbeats.bandcamp.com/track/celebration-1',
coverId: 'a0031987121',
link: 'https://nightbeats.bandcamp.com/track/celebration-1',
coverId: 'a0031987121'
},
{
id: 39,
order: 7,
compilationId: 'ES01B',
title: '3030 Instrumental',
artist: 17,
start: 2458.3,
url: 'https://delthefunkyhomosapien.bandcamp.com/track/3030',
coverId: 'a1948146136',
link: 'https://delthefunkyhomosapien.bandcamp.com/track/3030',
coverId: 'a1948146136'
},
{
id: 40,
order: 8,
compilationId: 'ES01B',
title: 'The Emptiness Of Nothingness',
artist: 18,
start: 2864.5,
url: 'https://theaa.bandcamp.com/track/the-emptiness-of-nothingness',
coverId: 'a1053923875',
link: 'https://theaa.bandcamp.com/track/the-emptiness-of-nothingness',
coverId: 'a1053923875'
},
{
id: 41,
order: 9,
compilationId: 'ES01B',
title: 'Rising',
artist: 19,
start: 3145,
url: 'https://woodenshjips.bandcamp.com/track/rising',
coverId: 'a1884221104',
link: 'https://woodenshjips.bandcamp.com/track/rising',
coverId: 'a1884221104'
},
{
id: 42,
order: 10,
compilationId: 'ES01B',
title: 'The Last Time',
artist: 22,
start: 3447,
url: 'https://www.discogs.com/release/12110815-Larry-McNeil-And-The-Blue-Knights-Jealous-Woman',
coverId: 'https://i.discogs.com/Yr05_neEXwzPwKlDeV7dimmTG34atkAMgpxbMBhHBkI/rs:fit/g:sm/q:90/h:600/w:600/czM6Ly9kaXNjb2dz/LWRhdGFiYXNlLWlt/YWdlcy9SLTEyMTEw/ODE1LTE1Mjg1NjU1/NzQtMjcyOC5qcGVn.jpeg',
link: 'https://www.discogs.com/release/12110815-Larry-McNeil-And-The-Blue-Knights-Jealous-Woman',
coverId:
'https://i.discogs.com/Yr05_neEXwzPwKlDeV7dimmTG34atkAMgpxbMBhHBkI/rs:fit/g:sm/q:90/h:600/w:600/czM6Ly9kaXNjb2dz/LWRhdGFiYXNlLWlt/YWdlcy9SLTEyMTEw/ODE1LTE1Mjg1NjU1/NzQtMjcyOC5qcGVn.jpeg'
},
{
id: 43,
order: 11,
compilationId: 'ES01B',
title: 'Guajira Con Arpa',
artist: 23,
start: 3586,
url: 'https://elpalmasmusic.bandcamp.com/track/guajira-con-arpa',
coverId: 'a3463036407',
},
link: 'https://elpalmasmusic.bandcamp.com/track/guajira-con-arpa',
coverId: 'a3463036407'
}
]
return tracks.map((track, index) => ({
id: index + 1,
...track,
url: `https://files.erudi.fr/evilspins/${track.compilationId}.mp3`
}))
})