MusicBot icon indicating copy to clipboard operation
MusicBot copied to clipboard

[Feature Request] Automated Historic Playlist?

Open ghost opened this issue 7 years ago • 6 comments

Just wondering is it possible to add a feature so that your bot stores the urls in a file and automatically plays the songs audio cache when nothing is queued. Similar to the autoplaylist function without the hassle of making a playlist file, it just keeps a running list of URLs paired with audio files cached

ghost avatar Mar 12 '17 21:03 ghost

I should also add that keeping url pairs to cache files that auto update may be more annoying to do if users fiddle with the files in the cache, but since i notice the urls are still used to name the audio cache files, would it be simpler to have a !UpdateCachePlaylist which simply sniffs urls from the files currently stored in the audio cache, i feel this is a simpler task.

it may be a good idea to scrap the video name from the file, currently seems to be "youtube-[URL Code]-[VIDEO NAME].webm" . I dont know is unique character delimiters are possible which is why i say this, if they are replace "-" with something else maybe?

ghost avatar Mar 13 '17 21:03 ghost

at writing of the earlier comment i didnt realise youtube ids were 11 characters commonly(until otherwise), so i just wrote a script to do it for me, never mind guys =] feel like it still be a nice feature. Feel free to use code if you want (very naive, assumes all sorts of paths, also rip original list)

#!/usr/bin/python  

import os

userName = # $USER$
path = "/Users/"+userName+"/MusicBot/audio_cache/"
files = os.listdir(path)
listTrimmed = []

for i in range(1,len(files)):
	songID = (files[i])[8:19]
	listTrimmed.append("https://www.youtube.com/watch?v="+songID)
	
f = open("/Users/"+userName+"/MusicBot/config/autoplaylist.txt","w")

for i in range(len(listTrimmed)):
	f.write(listTrimmed[i]+'/\n')

f.close()

ghost avatar Mar 13 '17 22:03 ghost

How do I go about using that script? Sorry, new to linux. Running Ubuntu

Morne-le-Roux avatar May 06 '17 22:05 Morne-le-Roux

Hey, so this is a python script, so you need to copy the text save it in a "scriptName.py" for instance and in terminal type "chmod +x scriptName.py" then you should be able to run it by typing "./scriptName.py". Fyi this goes for any python script.

Also as mentioned before i assume a lot of things about where you have downloaded the bot folder. So if you saved the music bot in your home directory ,for you the path would look like, "/home/ ______ /MusicBot/audio_cache/" and simarly the other path as well , where the underscores represent your username, basically just replacing the word "Users" for "home" because this was on osx not ubuntu.

I should mention you still have to turn on the random music player from the config, all this does is replace the random bunch of urls with urls of the songs you have played before from the cache.

ghost avatar May 07 '17 01:05 ghost

Thanks! Got it up and running. Thanks for the great tutorial!

Morne-le-Roux avatar May 07 '17 08:05 Morne-le-Roux

Kind of along the same lines, I thought it would be nice to have a way to store tracks to a playlist file, and then run specific playlists using commands, you could do things like make a rock music playlist and then type !play 'rock' to clear the queue, and add all the music in the playlist called 'rock' to it, then play the first song.

Emraldis avatar Feb 17 '18 18:02 Emraldis