From 5ad05aaf7d83d8e41ce95c2839e5793c4c19c1b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20P=C4=99dzich?= Date: Thu, 28 Mar 2024 08:37:55 +0100 Subject: [PATCH] Extract playlist author from playlist page title --- appFn.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/appFn.ts b/appFn.ts index 1a3a9b6..e2e8a8e 100644 --- a/appFn.ts +++ b/appFn.ts @@ -97,10 +97,18 @@ const appFn: ApplicationFunction = (app: Probot, { getRouter }) => { if (found) { 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 || '') .split(' · ') - .filter((text) => text !== 'Playlist'); + .filter((text) => text !== 'Playlist') + .concat(author); details = playlistMeta.join(' · '); }