add album_links to deezify, fix variable names, support number artists
This commit is contained in:
parent
f1c62b6a73
commit
57c58278ab
1 changed files with 38 additions and 11 deletions
|
|
@ -6,9 +6,9 @@ const CACHE_DIR = "./deezer_cache";
|
|||
fs.mkdirSync(CACHE_DIR, { recursive: true });
|
||||
|
||||
const artists = [
|
||||
|
||||
];
|
||||
|
||||
const album_links = [
|
||||
]
|
||||
const BAD_KEYWORDS = [
|
||||
" remix",
|
||||
"remix ",
|
||||
|
|
@ -22,6 +22,7 @@ const BAD_KEYWORDS = [
|
|||
"anniversary",
|
||||
"(remixes)",
|
||||
"(remix)",
|
||||
"(acustic)"
|
||||
];
|
||||
|
||||
function normalize(str) {
|
||||
|
|
@ -58,6 +59,7 @@ async function getArtistId(name) {
|
|||
const data = await cachedFetch(
|
||||
`https://api.deezer.com/search/artist?q=${q}`
|
||||
);
|
||||
|
||||
return data?.data?.[0]?.id ?? null;
|
||||
}
|
||||
|
||||
|
|
@ -73,7 +75,10 @@ async function getAllAlbums(artistId) {
|
|||
|
||||
return out;
|
||||
}
|
||||
|
||||
async function getAlbum(albumId) {
|
||||
const url = `https://api.deezer.com/album/${albumId}`;
|
||||
return await cachedFetch(url);
|
||||
}
|
||||
function selectBestAlbumVersions(albums) {
|
||||
const byTitle = new Map();
|
||||
|
||||
|
|
@ -99,32 +104,54 @@ function selectBestAlbumVersions(albums) {
|
|||
}
|
||||
|
||||
(async () => {
|
||||
const sex = [];
|
||||
const sex_squared = []
|
||||
const links = [];
|
||||
const displays = []
|
||||
const album_links_raw = await Promise.all(album_links.map(async z => await getAlbum(z.replace(/[^\d]*(\d*)$/gm, "$1"))));
|
||||
|
||||
for (const artist of artists) {
|
||||
console.log(`\n=== ${artist} ===`);
|
||||
|
||||
const artistId = await getArtistId(artist);
|
||||
const artistId = typeof artist == "number" ? artist : await getArtistId(artist);
|
||||
if (!artistId) {
|
||||
console.log("Artist not found");
|
||||
continue;
|
||||
}
|
||||
|
||||
const albums = await getAllAlbums(artistId);
|
||||
const albums = (await getAllAlbums(artistId));
|
||||
|
||||
const cleanAlbums = selectBestAlbumVersions(albums);
|
||||
let artistLines = [];
|
||||
let extraCount = 0;
|
||||
|
||||
for (const a of cleanAlbums) {
|
||||
console.log(
|
||||
`${a.title} | ${a.explicit_lyrics ? "EXPLICIT" : "CLEAN"} | https://www.deezer.com/en/album/${a.id}`
|
||||
);
|
||||
sex_squared.push(`+ ${artist} - ${a.title} ${a.explicit_lyrics ? "[E]" : ""}`)
|
||||
sex.push(`https://www.deezer.com/en/album/${a.id}`)
|
||||
|
||||
links.push(`https://www.deezer.com/en/album/${a.id}`);
|
||||
if (artistLines.length < 100) {
|
||||
artistLines.push(
|
||||
`+ ${typeof artist == "number" ? `No name (${artist})` : artist} - ${a.title} ${a.explicit_lyrics ? "[E]" : ""}`
|
||||
);
|
||||
} else {
|
||||
extraCount++;
|
||||
}
|
||||
}
|
||||
|
||||
if (extraCount > 0) {
|
||||
artistLines.push(`(and ${extraCount} more)`);
|
||||
}
|
||||
fs.writeFileSync("orpheus_links.txt", sex.join(" "))
|
||||
fs.writeFileSync("discord_send.txt", sex_squared.join(" \n").match(/.{1,2000}$/gms).map(z => z.trim()).join("\n\n"+'-'.repeat(15)+"\n\n"))
|
||||
|
||||
displays.push(...artistLines);
|
||||
}
|
||||
album_links_raw.forEach(z => {
|
||||
links.push(`https://www.deezer.com/en/album/${z.id}`);
|
||||
displays.push(
|
||||
`+ ${z.artist.name} - ${z.title} ${z.explicit_lyrics ? "[E]" : ""}`
|
||||
);
|
||||
})
|
||||
fs.writeFileSync("orpheus_links.txt", links.join(" "))
|
||||
fs.writeFileSync("discord_send.txt", displays.join(" \n").match(/.{1,2000}$/gms).map(z => z.trim()).join("\n\n"+'-'.repeat(15)+"\n\n"))
|
||||
|
||||
})().catch(err => {
|
||||
console.error(err);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue