Compare commits
1 Commits
main
...
fix-ismusi
Author | SHA1 | Date | |
---|---|---|---|
45678d7e6a |
@ -4,7 +4,7 @@ import {
|
||||
ODESLI_API_KEY,
|
||||
YOUTUBE_API_KEY
|
||||
} from '$env/static/private';
|
||||
import { log } from '$lib/log';
|
||||
import { enableVerboseLog, log } from '$lib/log';
|
||||
import type {
|
||||
Account,
|
||||
AccountAvatar,
|
||||
@ -59,13 +59,17 @@ export class TimelineReader {
|
||||
}
|
||||
|
||||
const item = respObj.items[0];
|
||||
if (item.tags?.includes('music')) {
|
||||
if (!item.snippet) {
|
||||
console.warn('Could not load snippet for video', videoId, item);
|
||||
return false;
|
||||
}
|
||||
if (item.snippet.tags?.includes('music')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const categorySearchParams = new URLSearchParams([
|
||||
['part', 'snippet'],
|
||||
['id', item.categoryId],
|
||||
['id', item.snippet.categoryId],
|
||||
['key', YOUTUBE_API_KEY]
|
||||
]);
|
||||
const youtubeCategoryUrl = new URL(
|
||||
@ -73,7 +77,25 @@ export class TimelineReader {
|
||||
);
|
||||
const categoryTitle: string = await fetch(youtubeCategoryUrl)
|
||||
.then((r) => r.json())
|
||||
.then((r) => r.items[0]?.title);
|
||||
.then((r) => r.items[0]?.snippet?.title);
|
||||
if (enableVerboseLog) {
|
||||
log.verbose(
|
||||
'Video',
|
||||
videoId,
|
||||
'category',
|
||||
categoryTitle,
|
||||
'tags',
|
||||
item.snippet.tags,
|
||||
'category id',
|
||||
item.snippet.categoryId,
|
||||
'response',
|
||||
respObj,
|
||||
'snippet',
|
||||
item.snippet
|
||||
);
|
||||
} else {
|
||||
log.debug('Video', videoId, 'category', categoryTitle);
|
||||
}
|
||||
return categoryTitle === 'Music';
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user