!currentsong Command including Lastfm songs played from itunes possible


#1

Hey folks,

as the topic is saying im looking for a script or help to get this done!

Right now if you use !currentsong in the chat you getting either

@my3d_mackknife
The YouTube Player is currently not being used, and song requests are disabled!”

or if a song is playing on youtube player

@my3d_mackknife
Current song is [Odyoung(오드영) - ONESHOT(기류)] requested by Jens from https://youtu.be/_ZiCQvaZE-A

now i wonder if this is possible im using more then 80% of the songs i listen to from my Itunes that for im using the lastfm script where i get the details from my itunes playing but i need to using a different Command to get this in the chat (!itunes <-- for lastfm)…

So the final Question is it doable for a noob in coding to get lastfm also using !currentsong command ( Both youtube player and lastfm script one command) ? Or better has someone alrdy done something like that ?

thanks folks for reading


#2

You can use this as a command

(customapijson http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=YOUR_LASTFM_USERNAME_HERE&limit=2&api_key=YOUR_LASTFM_API_KEY_HERE&format=json {Now Playing: } recenttracks.track.0.artist.#text {-} recenttracks.track.0.name)

that will post the track currently scrobling through Last.FM

Example

!addcom !itunes (customapijson http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=YOUR_LASTFM_USERNAME_HERE&limit=2&api_key=YOUR_LASTFM_API_KEY_HERE&format=json {Now Playing: } recenttracks.track.0.artist.#text {-} recenttracks.track.0.name)

Will look like this, when you type !itunes
lastfm-command


#3

Hey ,

thanks for your reply, but as i alrdy mention in the 1st post im using this script alrdy…

What im looking for is “!currentsong” command including both like the one from lastfm and the one from the youtubeplayer .

!currentsong and !itunes both working fine for now.


#4

You would need to modify the youtubePlayer.js script to do something like this. I do not have LastFM, so I cannot test this. But I think something like:

Current Code:

        // Skip all following commands, since they all need the client to be connected
        // (a.k.a. they need a current song to be active)
        if (connectedPlayerClient == null) {
            $.say($.whisperPrefix(sender) + $.lang.get('ytplayer.client.404'));
            return;
        }

New Code:

        // Skip all following commands, since they all need the client to be connected
        // (a.k.a. they need a current song to be active)
        if (connectedPlayerClient == null) {
            if (command.equalsIgnoreCase('currentsong')) {
                $.say($.tags(event, '(customapijson http://ws.audioscrobbler.com/2.0/?method=user.getrecenttracks&user=YOUR_LASTFM_USERNAME_HERE&limit=2&api_key=YOUR_LASTFM_API_KEY_HERE&format=json {Now Playing: } recenttracks.track.0.artist.#text {-} recenttracks.track.0.name)'));
                return;
            }
            $.say($.whisperPrefix(sender) + $.lang.get('ytplayer.client.404'));
            return;
        }

I put in a different (customapijson) tag to proof of concept this:

            if (command.equalsIgnoreCase('currentsong')) {
                $.say($.tags(event, '(customapijson http://quandyfactory.com/insult/json insult)'));
                return;
            }
currentsong
[05-08-2018 @ 12:22:46.526 MDT] [MUTED] Thou art a Puking, Fen-sucked Lout.

So, I am pretty sure this would work for Last FM. If the YouTube Player is not online, it would call Last FM and get the data. If the YouTube Player is online, then !currentsong would work per normal. I think that is what you are asking for?


#5

exactly this is waht i want ! Thanks for help .

Does the bot need a restart for this to working ?


#6

Yup. Even in Developer Mode when it would auto-reload the script the YouTube Script is one of those that goes sideways. You will need to restart to reload properly.


#7

just for confirmation but i guess u alrdy know this is working fine ! Thanks could be closed


#8

I wasn’t entirely sure, as I didn’t test the actual LastFM command. Glad to hear it is working!