Extract playlist author from playlist page title

This commit is contained in:
Maciej Pędzich 2024-03-28 08:37:55 +01:00
parent 7c01bab5a4
commit 5ad05aaf7d

View File

@ -97,10 +97,18 @@ const appFn: ApplicationFunction = (app: Probot, { getRouter }) => {
if (found) { if (found) {
const html = await spotifyResponse.text(); const html = await spotifyResponse.text();
const { description } = await getMetaData({ html }); const { title, description } = await getMetaData({ html });
const author = title?.endsWith('Spotify Playlist')
? 'Spotify'
: title?.match(/(?<=\- playlist by )(.*?)(?= \|)/gm) ?? [
'FAILED TO EXTRACT AUTHOR'
];
const playlistMeta = (description || '') const playlistMeta = (description || '')
.split(' · ') .split(' · ')
.filter((text) => text !== 'Playlist'); .filter((text) => text !== 'Playlist')
.concat(author);
details = playlistMeta.join(' · '); details = playlistMeta.join(' · ');
} }