Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. on textualcmd(cmd)
  2.     set AppleScript's text item delimiters to ""
  3.     set itunes_active to false
  4.     set theString to "/debug itunes ain't runnin' bro"
  5.    
  6.     tell application "Finder"
  7.         if (get name of every process) contains "iTunes" then set itunes_active to true
  8.     end tell
  9.    
  10.     if itunes_active then
  11.        
  12.         set got_track to false
  13.         tell application "iTunes"
  14.             if player state is playing then
  15.                 set theTrack to name of the current track
  16.                 set theArtist to artist of the current track
  17.                 set theAlbum to album of the current track
  18.                 set theTime to time of the current track
  19.                 set theBitrate to bit rate of the current track
  20.                 set theGenre to genre of the current track
  21.                 set playCount to played count of the current track
  22.                 set got_track to true
  23.             end if
  24.         end tell
  25.        
  26.         set theString to "/m is listening to nothing"
  27.        
  28.         (*
  29.         if theRating = 10 then set theRating to "½"
  30.             end if
  31.             if theRating = 20 then set theRating to "★"
  32.             end if
  33.             if theRating = 30 then set theRating to "★½"
  34.             end if
  35.             if theRating = 40 then set theRating to "★★"
  36.             end if
  37.             if theRating = 50 then set theRating to "★★½"
  38.             end if
  39.             if theRating = 60 then set theRating to "★★★"
  40.             end if
  41.             if theRating = 70 then set theRating to "★★★½"
  42.             end if
  43.             if theRating = 80 then set theRating to "★★★★"
  44.             end if
  45.             if theRating = 90 then set theRating to "★★★★½"
  46.             end if
  47.             if theRating = 100 then set theRating to "★★★★★"
  48.             end if
  49.             *)
  50.            
  51.         set rating_string to "("
  52.         set fullstar to "★"
  53.         set emptystar to "☆"
  54.         set halfstar to "½"
  55.        
  56.         if stars is equal to 0 then
  57.             set rating_string to ""
  58.         else
  59.             repeat with i from 1 to stars
  60.                 set rating_string to rating_string & fullstar
  61.             end repeat
  62.             repeat with i from stars to 4
  63.                 set rating_string to rating_string & emptystar
  64.             end repeat
  65.             set rating_string to rating_string & ")"
  66.         end if
  67.     else
  68.         set rating_string to ""
  69.     end if
  70.        
  71.         if got_track then
  72.             set theContents to "is listening to [ " & theTrack & " .::. " & theArtist & " .::. " & theAlbum & " .::. " & theTime & " .::. " & theBitrate & "Kbps .::. " & theGenre & " .::. played " & playCount & " times .::. " & rating_string & " ]"
  73.             set theString to "/me " & theContents
  74.         end if -- end of we have track info
  75.        
  76.     end if -- end of itunes being active
  77.    
  78.     return theString
  79. end textualcmd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement