add debug msg

This commit is contained in:
Chris Grimmett 2023-09-28 19:19:37 -08:00
parent 1ee1f3b8e2
commit b3ffb84f73
7 changed files with 92 additions and 2 deletions

1
CHECKS Normal file
View File

@ -0,0 +1 @@
/ futureporn.net

View File

@ -16,3 +16,7 @@ export function getDateFromSafeDate(safeDate: string): Date {
return utcDate;
}
export function formatTimestamp(seconds: number): string {
return new Date(seconds * 1000).toISOString().slice(11, 19);
}

View File

@ -43,7 +43,7 @@ export function unmarshallTimestamps (ts: any) {
}
export function getTimestampsForVod (vodId: number, page: number = 1, pageSize: number = 25): Promise<ITimestamps> {
export function getTimestampsForVod (vodId: number, page: number = 1, pageSize: number = 25): Promise<ITimestamp[]> {
const query = qs.stringify(
{
filters: {

View File

@ -54,6 +54,8 @@ export function getDeprecatedUrl(vod: IVod): string {
}
export function unmarshallVod(d: any): IVod {
console.log(`unmarshalling vod`)
console.log(d)
if (!d.attributes?.vtuber?.data) {
throw new Error("panick! vod data doesn't contain vtuber. please populate.")
@ -80,6 +82,84 @@ export function unmarshallVod(d: any): IVod {
return vod
}
export async function getNextVod(vod: IVod): Promise<IVod | null> {
const query = qs.stringify({
filters: {
date2: {
$gt: vod.date2
},
vtuber: {
slug: {
$eq: vod.vtuber.slug
}
}
},
sort: {
date2: 'asc'
},
fields: ['date2', 'title', 'announceTitle'],
populate: {
vtuber: {
fields: ['slug']
}
}
})
const options = {
next: {
tags: ['vods']
}
}
try {
return fetch(`${strapiUrl}/api/vods?${query}`, options)
.then((res) => res.json())
.then((d) => d.data[0])
.then(unmarshallVod)
} catch (e) {
return null;
}
}
export function getLocalizedDate(vod: IVod): string {
return new Date(vod.date2).toLocaleDateString()
}
export async function getPreviousVod(vod: IVod): Promise<IVod | null> {
const query = qs.stringify({
filters: {
date2: {
$lt: vod.date2
},
vtuber: {
slug: {
$eq: vod.vtuber.slug
}
}
},
sort: {
date2: 'desc'
},
fields: ['date2', 'title', 'announceTitle'],
populate: {
vtuber: {
fields: ['slug']
}
}
})
const options = {
next: {
tags: ['vods']
}
}
try {
return fetch(`${strapiUrl}/api/vods?${query}`, options)
.then((res) => res.json())
.then((d) => d.data[0])
.then(unmarshallVod)
} catch (e) {
return null;
}
}
export async function getVodForDate(date: Date): Promise<IVod> {
const iso8601DateString = date.toISOString().split('T')[0];
const query = qs.stringify(

View File

@ -44,7 +44,8 @@ export function getUrl(slug: string): string {
export function unmarshallVtuber(d: any): IVtuber {
console.log(`unmarshalling vtuber`)
console.log(d)
if (!d) {
console.error('panick! unmarshallVTuber was called with undefined data')

View File

@ -16,6 +16,7 @@
"@fortawesome/react-fontawesome": "^0.2.0",
"@icons-pack/react-simple-icons": "^8.0.1",
"@mux/blurhash": "^0.1.2",
"@mux/mux-player": "^1.14.2",
"@mux/mux-player-react": "^1.14.2",
"@react-hookz/web": "^23.1.0",
"@types/qs": "^6.9.8",

View File

@ -26,6 +26,9 @@ dependencies:
'@mux/blurhash':
specifier: ^0.1.2
version: 0.1.2
'@mux/mux-player':
specifier: ^1.14.2
version: 1.14.2
'@mux/mux-player-react':
specifier: ^1.14.2
version: 1.14.2(@types/react-dom@18.2.7)(@types/react@18.2.22)(react-dom@18.2.0)(react@18.2.0)