mirror of
https://github.com/abocn/TelegramBot.git
synced 2025-03-10 12:49:57 +00:00
Ignore generic image from Last.fm API
This commit is contained in:
parent
f0d8c2e62b
commit
31aa86d390
@ -66,6 +66,7 @@ module.exports = (bot) => {
|
|||||||
const userId = ctx.from.id;
|
const userId = ctx.from.id;
|
||||||
const Strings = getStrings(ctx.from.language_code);
|
const Strings = getStrings(ctx.from.language_code);
|
||||||
const lastfmUser = users[userId];
|
const lastfmUser = users[userId];
|
||||||
|
const genericImg = "https://lastfm.freetls.fastly.net/i/u/300x300/2a96cbd8b46e442fc41c2b86b821562f.png";
|
||||||
|
|
||||||
if (!lastfmUser) {
|
if (!lastfmUser) {
|
||||||
return ctx.reply(Strings.lastFmNoSet, {
|
return ctx.reply(Strings.lastFmNoSet, {
|
||||||
@ -103,11 +104,9 @@ module.exports = (bot) => {
|
|||||||
const trackName = track.name;
|
const trackName = track.name;
|
||||||
const artistName = track.artist['#text'];
|
const artistName = track.artist['#text'];
|
||||||
const nowPlaying = track['@attr'] && track['@attr'].nowplaying ? Strings.varIs : Strings.varWas;
|
const nowPlaying = track['@attr'] && track['@attr'].nowplaying ? Strings.varIs : Strings.varWas;
|
||||||
|
if (imageUrl == genericImg) {
|
||||||
|
imageUrl = "";
|
||||||
const imageExtralarge = track.image.find(img => img.size === 'extralarge');
|
}
|
||||||
const imageMega = track.image.find(img => img.size === 'mega');
|
|
||||||
const imageUrl = (imageExtralarge && imageExtralarge['#text']) || (imageMega && imageMega['#text']) || '';
|
|
||||||
|
|
||||||
const trackUrl = `https://www.last.fm/music/${encodeURIComponent(artistName)}/_/${encodeURIComponent(trackName)}`;
|
const trackUrl = `https://www.last.fm/music/${encodeURIComponent(artistName)}/_/${encodeURIComponent(trackName)}`;
|
||||||
const artistUrl = `https://www.last.fm/music/${encodeURIComponent(artistName)}`;
|
const artistUrl = `https://www.last.fm/music/${encodeURIComponent(artistName)}`;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user