superjohan / ifm

Intergalactic FM for iPhone
1 stars 2 forks source link

Use real artwork for "now playing" #28

Open tijmenb opened 10 months ago

tijmenb commented 10 months ago

It would be nice if we could show the original artwork for the track in the Now playing thing. It's visible on the site, but not the tracks API. Would there be a way to get it?

Screenshot 2024-01-31 at 10 13 19
superjohan commented 10 months ago

If nothing else, we could show the artwork for the currently selected station at least.

alepar666 commented 2 months ago

It's true that no API provides that information at the moment. I can provide you what I did in JavaScript to extract the last playing song from the website itself, in case can be useful.

const NOW_PLAYING_PICTURE_DEFAULT = 'https://www.intergalactic.fm/sites/default/files/covers/blanco.png';
const NOW_PLAYING_PICTURE_REQUEST_PREFIX = 'https://www.intergalactic.fm/channel-content/';
var selectedChannel;// 1, 2 or 3

async function extractCoverFromChannelContent() {
    var extractedCoverUrl = NOW_PLAYING_PICTURE_DEFAULT;
    var response = await fetch(NOW_PLAYING_PICTURE_REQUEST_PREFIX + selectedChannel);
    var body = await response.text();
    var startOfCoverImgIndex = body.indexOf('<img');
    var endOfCoverImgIndex = body.indexOf('alt=""/>') + 10;
    var extractedCoverHTML = body.substring(startOfCoverImgIndex, endOfCoverImgIndex);
    feedHTML(NOW_PLAYING_COVER_DIV_ID, extractedCoverHTML);
}
superjohan commented 2 months ago

Thanks! This could probably be ported over to the app.

alepar666 commented 2 months ago

here is the IFM-minimal player I developed where you can see this code in action https://intergalactic.fm/sd/