Jump to content

Zahir Yu

Member
  • Posts

    1
  • Joined

  • Last visited

Everything posted by Zahir Yu

  1. hello there, i saw the randyH's conversation. so i edited here. just copy to paste this :D first. this is "run script" # Check for proper input value if [[ "{query}" =~ ^[0-5]\.* ]]; then # Check if iTunes is running and playing a song if [ $(osascript -e 'if application "Music" is running then return true') ]; then iTunesPlaying=$(osascript -e 'tell application "Music" to if player state is playing then return true') fi if [[ $iTunesPlaying == true ]]; then # Grab interesting data for Notification infoline=$(osascript -e 'tell application "Music" to "" & album of current track & " by " & artist of current track') track=$(osascript -e 'tell application "Music" to name of current track') # Get "stars" from numerical value case "{query}" in 0.*) stars="½☆☆☆☆"; rating=10 ;; 1) stars="★☆☆☆☆"; rating=20 ;; 1.*) stars="★½☆☆☆"; rating=30 ;; 2) stars="★★☆☆☆"; rating=40 ;; 2.*) stars="★★½☆☆"; rating=50 ;; 3) stars="★★★☆☆"; rating=60 ;; 3.*) stars="★★★½☆"; rating=70 ;; 4) stars="★★★★☆"; rating=80 ;; 4.*) stars="★★★★½"; rating=90 ;; 5) stars="★★★★★"; rating=100 ;; 5.*) stars="★★★★★"; rating=100 ;; *) stars="• • • • •"; rating=0 ;; esac # Set rating of the current track to user input osascript -e "tell application \"Music\" to set rating of current track to $rating" echo "$track $stars" echo "$infoline" fi else echo "❌ Rating not Valid Nothing modified" fi second. for "script filter" ## Check if iTunes is running and playing a song if [ $(osascript -e 'if application "Music" is running then return true') ]; then iTunesPlaying=$(osascript -e 'tell application "Music" to if player state is playing then return true') fi ## If iTunes is playing, start grabbing the data if [[ $iTunesPlaying == true ]]; then valid="yes" title=$(osascript -e 'tell application "Music" to "" & artist of current track & " - " & name of current track') rating=$(osascript -e 'tell application "Music" to rating of current track') ## Convert to star ratings case $rating in 10) stars="½☆☆☆☆";; 20) stars="★☆☆☆☆" ;; 30) stars="★½☆☆☆" ;; 40) stars="★★☆☆☆" ;; 50) stars="★★½☆☆" ;; 60) stars="★★★☆☆" ;; 70) stars="★★★½☆" ;; 80) stars="★★★★☆" ;; 90) stars="★★★★½" ;; 100) stars="★★★★★" ;; *) stars="• • • • •" ;; esac subtitle="Current rating: $stars" else title="No song playing" subtitle="" valid="no" fi ## XML to Alfred echo '<?xml version="1.0"?><items>' echo "<item arg=\"{query}\" uid=\"rating\" valid=\"$valid\">" echo "<title>$title</title>" echo "<subtitle>$subtitle</subtitle>" echo "<icon>info.png</icon></item></items>" echo "</items>" that's all. have for fun!
×
×
  • Create New...