Advertisement
Guest User

Untitled

a guest
Jul 9th, 2017
67
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 "/me is listening to silence."
  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 theKind to kind of the current track
  21.                 set theGenre to genre of the current track
  22.                 set playCount to played count of the current track
  23.                 set stars to rating of the current track
  24.                 set theStream to current stream title
  25.                 set got_track to true
  26.             end if
  27.         end tell
  28.        
  29.         set theString to "/me is listening to nothing"
  30.        
  31.         set rating_string to "("
  32.         set fullstar to "★"
  33.         set emptystar to "☆"
  34.         set halfstar to "½"
  35.         set stars to stars / 20
  36.        
  37.         if stars is equal to 0 then
  38.             set rating_string to "Not Rated Yet"
  39.         else
  40.             #repeat with i from 0.5 to stars
  41.             #   set rating_string to rating_string & halfstar
  42.             #end repeat
  43.             repeat with i from 1 to stars
  44.                 set rating_string to rating_string & fullstar
  45.             end repeat
  46.             repeat with i from stars to 4
  47.                 set rating_string to rating_string & emptystar
  48.             end repeat
  49.             set rating_string to rating_string & ")"
  50.         end if
  51.     else
  52.         set rating_string to ""
  53.        
  54.     end if -- end of itunes being active
  55.    
  56.     if theKind contains "MPEG" then set theKind to "MP3"
  57.     if theKind contains "AAC" then set theKind to "AAC"
  58.     if theKind contains "WAV" then set theKind to "WAV"
  59.     if theKind contains "Apple Lossless" then set theKind to "Apple Lossless"
  60.    
  61.     if got_track then
  62.         set theContents to "is listening to " & theTrack & " by " & theArtist & " [ " & theAlbum & " .::. " & theTime & " .::. " & theBitrate & "Kbps " & theKind & " .::. played " & playCount & " times.::. " & rating_string & " ]"
  63.         set theString to "/me " & theContents
  64.     end if -- end of we have track info
  65.    
  66.     return theString
  67. end textualcmd
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement