Jump to content

Togethertube music script for shuffling playlist


rcareno
 Share

Recommended Posts

Hello All,

I have a working script I use to load music into a website playlist togethertube.com.  While not a perfect script, I'm hoping to get some feedback about how I could possibly clean up the code as if I expand my playlist to say 50 songs, the script is going to be very long.  Here's the code:

 

#include <Array.au3>
sleep(5000)
$z=0

Local $array[3]

$array[0]= "slipknot wait and bleed"
$array[1] = "Daft Punk - Harder, Better, Faster, Stronger"
$array[2] = "Marilyn Manson - The Beautiful People"

_ArrayShuffle($array)


sleep(500)
    send($array[0])
    sleep(3000)
    send ("{TAB}")
    sleep (200)
    send ("{TAB}")
    sleep (200)
    send ("{SPACE}")
    sleep (200)
    send ("{SHIFTDOWN}")
    sleep (200)
    send ("{TAB}")
    sleep (200)
    send ("{TAB}")
    sleep (200)
    send ("{SHIFTUP}")
    sleep (200)
    send ("{DELETE}") 
    
sleep(500)
    send($array[1])
    sleep(3000)
    send ("{TAB}")
    sleep (200)
    send ("{TAB}")
    sleep (200)
    send ("{SPACE}")
    sleep (200)
    send ("{SHIFTDOWN}")
    sleep (200)
    send ("{TAB}")
    sleep (200)
    send ("{TAB}")
    sleep (200)
    send ("{SHIFTUP}")
    sleep (200)
    send ("{DELETE}")


sleep(500)
    send($array[2])
    sleep(3000)
    send ("{TAB}")
    sleep (200)
    send ("{TAB}")
    sleep (200)
    send ("{SPACE}")
    sleep (200)
    send ("{SHIFTDOWN}")
    sleep (200)
    send ("{TAB}")
    sleep (200)
    send ("{TAB}")
    sleep (200)
    send ("{SHIFTUP}")
    sleep (200)
    send ("{DELETE}")

When you create a channel in togethertube, you have to start the script, then click into the "search box" and the script auto-fills the songs and adds them to the playlist.

 

Any feedback welcome.  I've used AutoIT a bit in the past, but I feel like my code is still "beginner" level.

 

Thanks

Link to comment
Share on other sites

Hi rcareno

Instead of inserting the entire set of commands for every single array element, I would go through the array in a loop like this:

 

#include <Array.au3>
sleep(5000)
$z=0

Local $array[3]

$array[0]= "slipknot wait and bleed"
$array[1] = "Daft Punk - Harder, Better, Faster, Stronger"
$array[2] = "Marilyn Manson - The Beautiful People"

_ArrayShuffle($array)


For $i = 0 To UBound($array) -1

sleep(500)

    send($array[$i])
    sleep(3000)
    send ("{TAB}")
    sleep (200)
    send ("{TAB}")
    sleep (200)
    send ("{SPACE}")
    sleep (200)
    send ("{SHIFTDOWN}")
    sleep (200)
    send ("{TAB}")
    sleep (200)
    send ("{TAB}")
    sleep (200)
    send ("{SHIFTUP}")
    sleep (200)
    send ("{DELETE}")

Next

 

Edited by david1337
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...