first working version

This commit is contained in:
Thomas Ruoff
2020-11-28 00:28:38 +01:00
parent 8762aef219
commit a17153759e
22 changed files with 1592 additions and 214 deletions

View File

@@ -1,6 +0,0 @@
// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
export default (req, res) => {
res.statusCode = 200
res.json({ name: 'John Doe' })
}

125
pages/api/songs.js Normal file
View File

@@ -0,0 +1,125 @@
const { DateTime } = require("luxon");
const SONGS = [
{
id: "Bys-OE_C7lQ",
title: "A Christmas Twist - Si Cranstoun",
startSeconds: 4,
},
{
id: "lheIRyhsUSE",
title: "EAV - Fata Morgana 1986",
},
{
id: "Dqn01vCQnUs",
title: "Sheena Easton - My Baby Takes The Morning Train (with Lyric)HQ",
},
{
id: "b_BzMuOAKUs",
title: "Rod Stewart - Have I Told You Lately",
},
{
id: "3D-j9PcOPAk",
title: "Deifedanz",
},
{
id: "9HvpIgHBSdo",
title: 'Gregory Porter - "Be Good (Lion\'s Song)" Official Video',
},
{
id: "3FKA-3uRdQY",
title:
"Doris Day - Whatever Will Be Will Be Que Sera Sera (Best All Time Hits Forever 2014 / HQ) Mu©o",
},
{
id: "WIoHSu5v1Mo",
title: "The Specials - Message to you Rudy",
},
{
id: "6ZwjdGSqO0k",
title: "George Harrison - Got My Mind Set On You (Version I)",
},
{
id: "lAj-Q_W9AT4",
title: "George Strait - Write This Down (Closed Captioned)",
},
{
id: "YiadNVhaGwk",
title: "Chuck Berry - Run Rudolph Run (Official Video)",
},
{
id: "_6FBfAQ-NDE",
title: "Depeche Mode - Just Can't Get Enough (Official Video)",
},
{
id: "X22vAmpZSdY",
title: "MIEKE TELKAMP ★★★ TULPEN AUS AMSTERDAM ★★★ 1961",
},
{
id: "uvGvmsLQaHA",
title: "Elvis Presley - Green Green Grass Of Home (best video)",
},
{
id: "5vheNbQlsyU",
title:
"Lady Gaga - Always Remember Us This Way (from A Star Is Born) (Official Music Video)",
},
{
id: "4WM_R-6AKHE",
title: "Mockingbird - Carly Simon & James Taylor",
},
{
id: "MgIwLeASnkw",
title: "Elmo & Patsy - Grandma Got Run over by a Reindeer",
},
{
id: "SLErVV1TxUI",
title: "Gänsehaut - Karl der Käfer 1983",
},
{
id: "js-2cqqY1K8",
title: "The Beautiful South - Perfect 10 (Official Video)",
},
{
id: "S6nSpBiekzQ",
title: "Les Négresses Vertes - Zobi La Mouche (Official Music Video)",
},
{
id: "z0qW9P-uYfM",
title: "Elton John - Don't Go Breaking My Heart (with Kiki Dee)",
},
{
id: "Pgqa3cVOxUc",
title: "The Undertones - My Perfect Cousin (Official Video)",
},
{
id: "lLLL1KxpYMA",
title: "Madness - Night Boat to Cairo (Official HD Video)",
},
{
id: "qTx-sdR6Yzk",
title: 'Dropkick Murphys - "The Season\'s Upon Us" (Video)',
},
];
export default async (req, res) => {
const unlocked = !!req.query.unlock;
const NOW = DateTime.utc().setZone("Europe/Berlin");
const getLockedData = (index) => {
const dayString = ("00" + (index + 1)).substr(-2, 2);
const lockedUntilDateTime = DateTime.fromISO(
`${NOW.year}-12-${dayString}T00:00:00.000+01:00`
);
return {
locked: unlocked ? false : NOW < lockedUntilDateTime,
lockedUntil: lockedUntilDateTime.toISO(),
};
};
const songs = SONGS.map((item, index) => ({
...item,
...getLockedData(index),
}));
res.json({ songs });
};