Skip to content

Instantly share code, notes, and snippets.

@sahilgupta
Created October 15, 2011 02:27
Show Gist options
  • Select an option

  • Save sahilgupta/1288915 to your computer and use it in GitHub Desktop.

Select an option

Save sahilgupta/1288915 to your computer and use it in GitHub Desktop.

Revisions

  1. sahilgupta revised this gist Oct 15, 2011. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions itunes_shuffle.py
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,8 @@
    #TODO: Add threading to avoid blocking
    #TODO: Create a windows service out of this
    #TODO: Start the Track somewhere in the middle instead of the very start!


    import win32com.client
    import random
    import time
  2. @invalid-email-address Anonymous created this gist Oct 15, 2011.
    18 changes: 18 additions & 0 deletions itunes_shuffle.py
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    import win32com.client
    import random
    import time

    itunes= win32com.client.Dispatch("iTunes.Application")
    mainLibrary = itunes.LibrarySource.Playlists.ItemByName('Music')

    tracks = mainLibrary.Tracks
    numTracks = tracks.Count

    while True:
    print "Sleep over"
    tnumber = random.randint(1, numTracks)
    print tnumber
    currTrack = tracks.Item(tnumber)
    currTrack.Play()
    time.sleep(currTrack.Duration
    /3)