Fix #32
This commit is contained in:
@ -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,7 @@ 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);
|
||||
return categoryTitle === 'Music';
|
||||
}
|
||||
|
||||
@ -131,7 +135,6 @@ export class TimelineReader {
|
||||
const odesliApiUrl = `https://api.song.link/v1-alpha.1/links?${odesliParams}`;
|
||||
try {
|
||||
const response = await fetch(odesliApiUrl);
|
||||
log.debug('received odesli response', response.status);
|
||||
if (response.status === 429) {
|
||||
throw new Error('Rate limit reached', { cause: 429 });
|
||||
}
|
||||
@ -141,9 +144,8 @@ export class TimelineReader {
|
||||
}
|
||||
const info = odesliInfo.entitiesByUniqueId[odesliInfo.entityUniqueId];
|
||||
const platform: Platform = 'youtube';
|
||||
log.debug(url, 'odesli response', info, 'YT URL', odesliInfo.linksByPlatform[platform]?.url);
|
||||
if (info.platforms.includes(platform)) {
|
||||
let youtubeId =
|
||||
const youtubeId =
|
||||
videoId ??
|
||||
YOUTUBE_REGEX.exec(url.href)?.groups?.videoId ??
|
||||
new URL(odesliInfo.pageUrl).pathname.split('/y/').pop();
|
||||
@ -153,7 +155,7 @@ export class TimelineReader {
|
||||
}
|
||||
const isMusic = await TimelineReader.isMusicVideo(youtubeId);
|
||||
if (!isMusic) {
|
||||
log.debug('Probably not a music video', url, odesliInfo);
|
||||
log.debug('Probably not a music video', url);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user