I'm a music producer looking to start up my own music livestream on my Youtube channel.
My tracks are all free to download and I'm curious if it'd be possible through NightBot to create a custom command in which when a certain track plays and a viewer types !download, NightBot would reply with a download link for that particular track.
As recommended I've searched the forums trying to find someone who has adressed this but couldn't find anything.
Any help/tips would be much appreciated.
All the best. x Ikson
35 replies
Polar Cat
Hey @Fizzy Shrimp!
Quick question, what do you use to play your songs, from which source are they played?
Fizzy Shrimp
Hi @Polar Cat ! I haven't actually started my stream yet so that's not decided, figured I'd ask here before I actually dedicate some time to starting it up; I'm open to using whatever source that could possibly enable this feature.
Polar Cat
Well, I can see a solution, but your songs will have to be on Spotify. If they're not, I can recommend Distrokid, where you can publish all of your songs everywhere for only $20/year. I'm not sponsored, the link isn't affiliated either, it's just that after extensive research I chose to go with them to release my own songs once I'll have some ready, haha!
The next step would be to create an account on Last.fm, then go to: Settings > Applications > Spotify Scrobbling > Connect And also make sure Hide recent listening information isn't ticked in: Settings > Privacy > Recent listening
Then head over to Pastebin, create an account so you can come back to add new songs later on. Create a new paste, make sure it's set to never expire and that it's unlisted. Here's how the paste should look like:
Title#1|DownloadLink#1|
Title#2|DownloadLink#2|
...
Title#n|DownloadLink#n
The songs titles must match the style of the titles on Spotify (capitalization, parenthesis, etc.)
And finally here's the command:
$(eval a=`$(lastfm LASTFM_USERNAME "{{artist}}|{{title}}")`.split(`|`); d=`$(urlfetch json https://pastebin.com/raw/XXXXXXXX)`.split(`|`); if(a[0].toLowerCase()==`YOUR_ARTIST_NAME`.toLowerCase()){if(d.includes(a[1])){`Download ${a[1]} here: ${d[d.indexOf(a[1])+1]}`}else{`There is no link to download ${a[1]} yet.`}}else{`This song isn't from YOUR_ARTIST_NAME.`})
Make sure to replace the following fields: • LASTFM_USERNAME: your Last.fm username • XXXXXXXX: the paste ID • YOUR_ARTIST_NAME: must match your artist name style on Spotify (capitalization, spacing, etc.)
Fizzy Shrimp
Awesome ! I've actually released all my music through a distributor called Amuse. They have a free app (and now on desktop as well) and you get to keep 100% royalty of your earning. I can definitely recommend them; they deliver to all major streaming services/stores.
I'm with you in the guide to the point where you are talking about the Title#1|DownloadLink#1| and the command. Would I paste that in somewhere on the NightBot website?
Is: Title#1|DownloadLink#1| / a reference for the command, so that when someone asks/writes !download in chat the command can look in the Paste to see what download link to send to the viewer who requested it?
Also if this works out I'll be happy to give you a shoutout in the video description of the live stream, as this feature would be really beneficial to the experience
Polar Cat
Oh yeah, I know about Amuse as well. Anyway, that's great if you have your stuff on Spotify, that's what we need!
For the command, you can add it via the dashboard or via the chat by typing:
!addcom !download $(eval a=`$(lastfm LASTFM_USERNAME "{{artist}}|{{title}}")`.split(`|`); d=`$(urlfetch json https://pastebin.com/raw/XXXXXXXX)`.split(`|`); if(a[0].toLowerCase()==`YOUR_ARTIST_NAME`.toLowerCase()){if(d.includes(a[1])){`Download ${a[1]} here: ${d[d.indexOf(a[1])+1]}`}else{`There is no link to download ${a[1]} yet.`}}else{`This song isn't from YOUR_ARTIST_NAME.`})
As for the paste, yes, it's a reference Nightbot will look into, basically, the command looks if the artist playing is you, then it looks in the paste if it has a download link for the playing title, and gives the link if it does.
Fizzy Shrimp
How do I add the command via dashboard though, do I copy paste it into 'Message'?
Also - Are the hashtags in the: Title#1|DownloadLink#1| important or can they be removed?
Polar Cat
Yes, to add the command via the dashboard, you simply have to paste the code into Message (without the !addcom !download part).
The # are just to indicate "number", so no, they're not important. What's important are the |.
Fizzy Shrimp
Tried a fast stream tonight. The command didn't seem to be working so something's evidently off
Polar Cat
When it looks like that, it's because the command code has been cut if half, I didn't know you were planning to stream on YouTube, where the chat has a lower character limit than Twitch's chat (which is my default go to), therefore adding the command via the chat wasn't the right option, however, you can add it from the dashboard, just copy and paste the following, I updated it with your information.
$(eval a=`$(lastfm IksonOfficial "{{artist}}|{{title}}")`.split(`|`); d=`$(urlfetch json https://pastebin.com/raw/K4eyYK2y)`.split(`|`); if(a[0].toLowerCase()==`Ikson`.toLowerCase()){if(d.includes(a[1])){`Download ${a[1]} here: ${d[d.indexOf(a[1])+1]}`}else{`There is no link to download ${a[1]} yet.`}}else{`This song isn't from Ikson.`})
Also, for the songs you don't have a downloading link for yet, don't add them into the paste, if the bot can't find the song it'll say: "There is no link to download SONG yet."
Fizzy Shrimp
Okay I see, happy mistake because that's good to know actually; So just copy paste that new code into the Message section of the same custom command and that should make the track titles/download links show up correctly ones !download is written by viewers in chat ? Based on presumption that I have added the name/link to the Pastebin that is, which I have.
P.s I appreciate that you added that last message in, that was very thoughtful as it might take me some time to add in all of the links.
Polar Cat
Yes, just copy the new code above in the Message field and it'll work. And regarding the "no link yet" message, I had to think of every outcome possible, it's simply error handling, so you can remove every songs that don't have a download link yet, otherwise it'll say: "Download SONG here: DownloadLink#1" instead, haha!
At the time I post this reply I just updated the code in every message I sent on this topic, turns out it had a major flaw, and I only noticed it now because I didn't have time to test it before this evening, I found the error and fixed it.
Fizzy Shrimp
It didn't. I just pasted your last message in the into the message command of my Nightbot custom command, doesn't display link in Live chat on Youtube. Might something be off about my Pastebin?
Fizzy Shrimp
Fizzy Shrimp
Polar Cat said: download
Polar Cat
This isn't the code from the previous message at the time we were talking, as you can see the LASTFM_USERNAME, XXXXXXXX, and YOUR_ARTIST_NAME fields aren't filled in the command you have in your chat, plus there is !addcom !download at the front of it. I can understand the confusion, there were quite a few commands shared during our conversation, I'll repost your command here so you don't do the same mistake again. Copy this in the Message field:
$(eval a=`$(lastfm IksonOfficial "{{artist}}|{{title}}")`.split(`|`); d=`$(urlfetch json https://pastebin.com/raw/K4eyYK2y)`.split(`|`); if(a[0].toLowerCase()==`Ikson`.toLowerCase()){if(d.includes(a[1])){`Download ${a[1]} here: ${d[d.indexOf(a[1])+1]}`}else{`There is no link to download ${a[1]} yet.`}}else{`This song isn't from Ikson.`})
When you update the command, make sure the end of the command isn't cut in half by editing the command a second time and having a look at the end of the Message field. If it is, check what you copied, it should end with }). If it does and the command in the Message field is still cut in half, this might be due to YouTube characters restrictions... It's just a guess because YouTube isn't my field of expertise at all, but in case you confirm this might be it, I think I have a fix. Let me know how it goes.
I'm sure the command works, at least on Twitch, have a look at my tests:
Fizzy Shrimp
Hey where do you test that?? :D I'm currently starting up my live stream again and again to test...lol
Fizzy Shrimp
Trying this rn! Thanks. Will let you know.
Fizzy Shrimp
Fizzy Shrimp
Custom command lenght should be similar in nightbot regardless of Streaming destination, or do you mean that because I'm connected to my Youtube channel it detects that and stops me from writing longer messages?
Polar Cat
It's Twitch's chat in full page, haha! On YouTube your stream has to be launched for Nightbot to watch your chat, this isn't the case on Twitch.
If you want you can come test your command in my chat, however you'll need a Twitch account. I added the !download command with your data in case you come in. To test it: 1. play a song that isn't yours on Spotify 2. call !download, it should answer: This song isn't from Ikson. 3. play a song that is yours on Spotify, but for which you don't have a download link for yet 4. call !download, it should answer: There is no link to download SONG yet. 5. play a song of yours on Spotify for which you have a download link 6. all !download, it should answer: Download SONG here: LINK
Polar Cat
Yup, we're hitting the characters limit... Ugh... The characters limit is different for Twitch and YouTube, and Nightbot's Message field reflects that so users can't add commands that are longer than the character limit, to make sure the message is sent. Since most people only write text in the Message field it's a nifty feature, however, when you work with JS, this can be very limiting as it limits the length of your code, which in most cases isn't the length of the message Nighbot will post.
I'll test the way to bypass the limitation before posting an update here.
Fizzy Shrimp
Ah okay got you, I'm starting to understand the issue. Perhaps there's some kind of tool that can shorten the text whilst keeping the information? Like an url shortener or similar
Replace XXXXXXXX with the paste ID of the new paste we'll create, it should include:
if(a[0].toLowerCase()==`Ikson`.toLowerCase()){if(d.includes(a[1])){`Download ${a[1]} here: ${d[d.indexOf(a[1])+1]}`}else{`There is no link to download ${a[1]} yet.`}}else{`This song isn't from Ikson.`}
That makes the main command under 200 characters, 184 to be exact, which is under the YouTube chat character limit, to compare, for Twitch it's 500, but Nightbot is capped at 400.
Now regarding the issue we have with Lastfm, first make sure your username is IksonOfficial, because by looking at Ikson Official, we in fact look at Ikson as Nightbot ditches the second part, that's why we're getting a song you never played before. I think it's IksonOfficial because I went on Lastfm and when I go to your profile that's the URL I get. But Lastfm still returns an error, so I would suggest to double check your Privacy Settings on Lastfm and make sure Hide recent listening information isn’t ticked in: Settings > Privacy > Recent listening.
Fizzy Shrimp
Just pasted: $(eval a=$(lastfm Iksonofficial "{{artist}}|{{title}}").split(|); d=$(urlfetch json https://pastebin.com/raw/K4eyYK2y).split(|); $(urlfetch https://pastebin.com/raw/PpGCpXNS)) to the message window. But changed the capitalized O as it should be Iksonofficial
Fizzy Shrimp
Polar Cat
Yes, and it should work now! However, create your own paste as PpGCpXNS will expire tomorrow.
Fizzy Shrimp
Ok what's the purpose of the second paste? I know the first one included is the one I created.
Polar Cat
The second paste includes all the extra code needed to give the different answers, since we have to bypass the 200 characters limit somehow.
Polar Cat said: Replace XXXXXXXX with the paste ID of the new paste we’ll create, it should include:
``` if(a[0].toLowerCase()==Ikson.toLowerCase()){if(d.includes(a[1])){Download ${a[1]} here: ${d[d.indexOf(a[1])+1]}}else{There is no link to download ${a[1]} yet.}}else{This song isn't from Ikson.} ```
Jump to the message I'm talking about by clicking on the arrow pointing towards the top at the top right of the embed.
Just did that and made sure to get the raw paste as well. Will try this now and report back. Thanks !
Polar Cat
You can make sure the command works properly by doing the following
Polar Cat said: 1. play a song that isn’t yours on Spotify 2. call !download , it should answer: This song isn't from Ikson. 3. play a song that is yours on Spotify, but for which you don’t have a download link for yet 4. call !download , it should answer: There is no link to download SONG yet. 5. play a song of yours on Spotify for which you have a download link 6. all !download , it should answer: Download SONG here: LINK
Fizzy Shrimp
Worked now! Thanks a ton for the help! Anything I can shoutout in the description for you?
There's actually a few other features I'm looking to integrate as well, like voting for track changing etc. But I think that'll be easier to find on Google. No one had done this specific thing from what I could find so, complicated things :)
Polar Cat
Awesome! You're very much welcome, the pleasure is mine! It was really exciting to work on this as it was something new and an idea that I found really interesting since I could use something like that in the future as well! When it comes to the shoutout, I appreciate the thought, but my SoundCloud is totally private for now, and I have yet to upload on Spotify either, I'm looking forward finishing a few tracks I like before starting to release some stuff again. Anyway, my artist name is the one I use on Twitch or here.
Regarding your other features, feel free to look on the forums, or open another topic if you don't find any answering your needs. For example I think a vote to skip a track was already done, or can be done, I'm just not sure yet how I would go about it, but other people on the forum might have an idea.
Didn't find your answer? The community is on Discord.