Advertisement
EliteAnax17

SSWP

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