Advertisement
Guest User

NowPlaying 1.1

a guest
Jul 20th, 2012
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
AutoIt 1.37 KB | None | 0 0
  1. ;~ Project name: NowPlaying
  2. ;~ Description: Simple application that fetches current track from Spotify and dumps it into a txt-file that Xsplit Broadcaster can read to automatically update your stream.
  3. ;~ Project started: 2012-05-11
  4. ;~ Last update: 2012-07-21 see changelog.txt
  5. ;~ Author: Fredrik Ivanov (numrii@gmail.com)
  6. ;~ License: Use freely but please give credit where credit is due!
  7.  
  8. ; Sets the location of the config file so you can change some stuff!
  9. Local $conf = IniRead("config.ini", "Settings", "key", "Somethings wrong with config.ini, restore your backup and try again!")
  10.  
  11. TrayTip("Success!", "NowPlaying is now loaded.", 3)
  12.  
  13. While 1
  14.  
  15.  
  16.         ; Fetch Title of Spotify window and remove "Spotify - " from the title
  17.         Local $title = StringTrimLeft(WinGetTitle("Spotify"), 10)
  18.  
  19.         ; Replace the weird "-" from spotify with a proper dash to separate Artist - Track
  20.         Local $final = StringReplace($title, " – ", " - ", 0, 0)
  21.  
  22.         ; Open File in overwrite mode - Place the spotify.txt in the same directory as this script.
  23.         Local $file = FileOpen("spotify.txt", 2)
  24.  
  25.         ; Check if file opened for writing OK
  26.         If $file = -1 Then
  27.             MsgBox(0, "Error", "Unable to open file.")
  28.             Exit
  29.         EndIf
  30.  
  31.         ; Write current track to file spotify.txt
  32.         FileWriteLine($file, $conf & $final)
  33.  
  34.         ; Close file
  35.         FileClose($file)
  36.  
  37.         ; Sleep for 10 seconds
  38.         Sleep(10000)
  39. WEnd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement