Advertisement
EliteAnax17

SSWP

Jul 1st, 2015
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.30 KB | None | 0 0
  1. # Stupid Simple Winamp Player (SSWP) v0.25, written by ProjectRevoTPP
  2.  
  3.  
  4. '''
  5. Future improvements:
  6.  
  7. -Display Game name, year released, and system name similar to how TPP userbar displays it
  8. -fix subprocess hang if winamp does not immediately launch
  9. '''
  10.  
  11. import winamp
  12. import yaml
  13. import re
  14. import sys
  15. import time
  16. import os
  17.  
  18. w = winamp.Winamp()
  19.  
  20. print "Starting program."
  21.  
  22. winamppath = raw_input('Please input the path to your winamp.exe: ')
  23. musicpath = raw_input('Now input the path to your music locations (where the Other, N64, SNES, and other folders are): ')
  24.  
  25. print "Beginning main program."
  26.  
  27. #winamppath = r"C:/Program Files (x86)/Winamp/winamp.exe" #put your path to winamp.exe here
  28. #musicpath = r"C:/PBRmusic" #use forward slashes or it'll break, no slash after the last folder
  29.  
  30. def get_song_path(meta, game_id, song_id): #function written by valkyrie, thanks man
  31.     for game in meta:
  32.         if game_id == game["id"]:
  33.             songs = game["songs"]
  34.             for song in songs:
  35.                 if song_id == song["id"]:
  36.                     return game["path"] + "/" + song["path"]
  37.     return ""
  38.  
  39. if (os.path.isfile("metadata.txt")):
  40.     print "metadata.txt found.. continuing"
  41.     with open('metadata.txt', 'r') as metadata:
  42.         mdata = yaml.load(metadata)
  43. else:
  44.     print "Cannot find metadata. Exiting in three seconds.."
  45.     time.sleep(3)
  46.     raise
  47. while 1:
  48.     fullid = raw_input ('Enter the full ID of the song you want to play: ') #test
  49.     try:
  50.         gameid, songid = fullid.split('-', 1)
  51.     except:
  52.         print "Error: No dash detected - cannot split full ID. Trying again in three seconds.."
  53.         time.sleep(3)
  54.         continue
  55.     print "gameID: ", gameid
  56.     print "songID: ", songid
  57.     songpath = get_song_path(mdata, gameid, songid)
  58.     gamepath = musicpath + "/" + songpath
  59.     fullpath = '"' + winamppath + '" "' + gamepath + '"'
  60.     if (os.path.isfile(gamepath)):
  61.         print "Playing " + songid + ".."
  62.         w.playSoloFile(fullpath)
  63.     else:
  64.         print "File does not exist. Returning in three seconds.."
  65.         time.sleep(3)
  66.         continue
  67.  
  68. '''
  69. Add this to pywinamp library manually (winamp.py):
  70.  
  71.     def playSoloFile(self, filePath):
  72.         self.stop()
  73.         self.clearPlaylist()
  74.  
  75.         subprocess.call(filePath)    # I don't really like using a subprocess and may improve this in the future
  76. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement