Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local url = "http://www.lozengia.com/tmas/Downloads/Minecraft/firebox/cctunes.com/"
- local list = "returnsong.php"
- local download = "download.php"
- local music = "Music/"
- local insterment = "Insterment/"
- local instrument = "Instrument/"
- function downloadSong(name)
- local music_response = http.get(url..music..name)
- local instrument_response = http.get(url..insterment..name)
- if music_response then
- local resp = music_response.readAll()
- music_response.close()
- fi = shell.resolve(music..name)
- local file = fs.open(fi, "w")
- file.write(resp)
- file.close()
- end
- if instrument_response then
- local resp = instrument_response.readAll()
- instrument_response.close()
- fi = shell.resolve(instrument..name)
- local file = fs.open(fi, "w")
- file.write(resp)
- file.close()
- end
- if music_response then
- return true
- else
- return false
- end
- end
- function getList()
- local response = http.get(url..list)
- if response then
- return textutils.unserialize(response.readAll():gsub("\\'",""))
- else
- return false
- end
- end
- function isGood(item)
- if item then
- if item.title then
- if item.title ~= "Unknown" and item.title ~= "Untitled" and item.originalauthor ~= "Daniel Ingram" and item.title ~= "" then
- return true
- else
- return false
- end
- else
- return false
- end
- else
- return false
- end
- end
- function count(list)
- local c = 0
- for i,v in pairs(list) do
- c = c + 1
- end
- return c
- end
- local list = getList()
- local count = #list
- local cleanlist = {}
- if not list then
- error("Failed to download the song list!")
- end
- print("Got "..#list.." songs from list")
- local dudcount = 0
- for i=1,count do
- if not isGood(list[i]) then
- dudcount = dudcount + 1
- list[i] = nil
- else
- table.insert(cleanlist, list[i])
- end
- end
- print("Removed "..dudcount.." duds.")
- print("Found "..#cleanlist.." good songs")
- while true do
- if fs.exists("Music") then
- fs.delete("Music")
- end
- if fs.exists("Instrument") then
- fs.delete("Instrument")
- end
- fs.makeDir("Music")
- fs.makeDir("Instrument")
- local randsong = cleanlist[math.random(1,#cleanlist)]
- downloadSong(randsong.file)
- local fi = fs.open("playlist","w")
- fi.write(randsong.file)
- fi.close()
- shell.run("musicplayer")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement