mirror of
https://github.com/maciejpedzich/playlist-entry-validator.git
synced 2024-11-27 16:05:48 +01:00
Compare commits
3 Commits
4ecd9df628
...
f2c99ea418
Author | SHA1 | Date | |
---|---|---|---|
f2c99ea418 | |||
87b7723e32 | |||
66531d5b54 |
53
appFn.ts
53
appFn.ts
@ -132,7 +132,11 @@ const appFn: ApplicationFunction = (app: Probot, { getRouter }) => {
|
||||
|
||||
if (found) {
|
||||
const html = await spotifyResponse.text();
|
||||
const { author: authorUrl, description } = await getMetaData({
|
||||
const {
|
||||
// author: authorUrl,
|
||||
description,
|
||||
title
|
||||
} = await getMetaData({
|
||||
html,
|
||||
customRules: {
|
||||
author: {
|
||||
@ -146,32 +150,39 @@ const appFn: ApplicationFunction = (app: Probot, { getRouter }) => {
|
||||
}
|
||||
});
|
||||
|
||||
let authorName = (authorUrl as string).endsWith('/user/spotify')
|
||||
? 'Spotify'
|
||||
: '';
|
||||
// let authorName = (authorUrl as string).endsWith('/user/spotify')
|
||||
// ? 'Spotify'
|
||||
// : '';
|
||||
|
||||
if (authorName === '') {
|
||||
const playlistAuthorResponse = await fetch(authorUrl as string);
|
||||
// if (authorName === '') {
|
||||
// const playlistAuthorResponse = await fetch(authorUrl as string);
|
||||
|
||||
if (!playlistAuthorResponse.ok)
|
||||
throw new Error(
|
||||
`Received ${playlistAuthorResponse.status} status code from ${authorUrl}`
|
||||
);
|
||||
// if (!playlistAuthorResponse.ok)
|
||||
// throw new Error(
|
||||
// `Received ${playlistAuthorResponse.status} status code from ${authorUrl}`
|
||||
// );
|
||||
|
||||
const authorPageHtml = await playlistAuthorResponse.text();
|
||||
const { title: authorPageTitle } = await getMetaData({
|
||||
html: authorPageHtml
|
||||
});
|
||||
// const authorPageHtml = await playlistAuthorResponse.text();
|
||||
// const { title: authorPageTitle } = await getMetaData({
|
||||
// html: authorPageHtml
|
||||
// });
|
||||
|
||||
authorName = authorPageTitle as string;
|
||||
}
|
||||
// authorName = authorPageTitle as string;
|
||||
// }
|
||||
|
||||
const playlistMeta = (description || '')
|
||||
.split(' · ')
|
||||
.filter((text) => text !== 'Playlist')
|
||||
.concat(authorName as string);
|
||||
// const playlistMeta = (description || '')
|
||||
// .split(' · ')
|
||||
// .filter((text) => text !== 'Playlist')
|
||||
// .concat(authorName as string);
|
||||
|
||||
details = playlistMeta.join(' · ');
|
||||
// details = playlistMeta.join(' · ');
|
||||
details = (
|
||||
title +
|
||||
' · ' +
|
||||
description!.replace('Playlist · ', '')
|
||||
)
|
||||
.replace(/\s+/g, ' ')
|
||||
.trim();
|
||||
}
|
||||
|
||||
numProcessedEntries++;
|
||||
|
Loading…
Reference in New Issue
Block a user