This commit is contained in:
Max Nuding 2023-06-16 15:51:57 +02:00
parent 3103d3e098
commit db80b929ca
Signed by: phlaym
GPG Key ID: A06651BAB6777237

View File

@ -27,6 +27,7 @@ import sharp from 'sharp';
import { WebSocket } from 'ws';
const URL_REGEX = new RegExp(/href="(?<postUrl>[^>]+?)" target="_blank"/gm);
const INVIDIOUS_REGEX = new RegExp(/invidious.*?watch.*?v=(?<videoId>[a-zA-Z_0-9-]+)/gm);
export class TimelineReader {
private static _instance: TimelineReader;
@ -71,8 +72,12 @@ export class TimelineReader {
return null;
}
const videoId = INVIDIOUS_REGEX.exec(url.href)?.groups?.videoId;
const urlString =
videoId !== undefined ? `https://youtube.com/watch?v=${videoId}` : url.toString();
const odesliParams = new URLSearchParams();
odesliParams.append('url', url.toString());
odesliParams.append('url', urlString);
odesliParams.append('userCountry', 'DE');
odesliParams.append('songIfSingle', 'true');
if (ODESLI_API_KEY && ODESLI_API_KEY !== 'CHANGE_ME') {