Improve title formatting a little

This commit is contained in:
Corwin Brust 2026-05-22 10:40:18 +05:30
parent 3ef54d8169
commit 3e40fc510c

16
bot.js
View file

@ -131,10 +131,10 @@ function formatArtist(artist,album,year) {
rv = rv ? rv + ' ' + album : album;
}
if(year && album != year) {
rv = rv ? `${rv}, /${year}/` : year
rv = rv ? `${rv}, *${year}*` : year
}
if(artist) {
rv = rv ? (rv.includes('(')?`${artist}, ${rv}` : `${artist} (${rv})`) : artist;
rv = rv ? (rv.includes('(')?`__${artist}__, ${rv}` : `__${artist}__ (${rv})`) : artist;
}
return rv;
}
@ -149,12 +149,8 @@ function formatTrackTitle(meta) {
filename.replace('/spokes/gw11/storage/ftp/music/','')
);
//console.log({title:title,who:who,fileUri:fileUri,artist:artist,album:album,date:date,year:year,filename:filename});
const rv
= //'[🔗]('+ fileUri +') '
//+ ' ' +
title
+ ' '
+ formatArtist(artist,album,year||date)
// //'[🔗]('+ fileUri +') '+ '**' +
const rv = title +' '+ formatArtist(artist,album,year||date);
return [rv,fileUri];
}
const setStatus = async function() {
@ -176,7 +172,7 @@ const setStatus = async function() {
if(json) {
let [newTitle,newLink] = formatTrackTitle(Object.fromEntries( json ));
if(newTitle && newTitle != title) {
console.log("New track title: " + newTitle + ' at ' + newLink);
console.log("Playing[discord]: " + newTitle + ' at ' + newLink);
title = newTitle;
trackUri = newLink;
bot.editStatus("online", [ { name: title, type: 0, url: newLink}]);
@ -224,7 +220,7 @@ bot.on('messageCreate', async (msg) => {
// throw new Error(`Title response status: ${response.status}`);
// }
// const json = await response.json();
await msg.channel.createMessage( "Playing: " + title + "\n\nDownload: " + trackUri + "\n" );
await msg.channel.createMessage(title +"\n\n[Download/Permalink]("+ trackUri +")\n");
//setStatus();
}
} catch (err) {