Created
December 6, 2013 22:19
-
-
Save mateuszgachowski-snippets/7833114 to your computer and use it in GitHub Desktop.
Revisions
-
mateuszgachowski-snippets revised this gist
Dec 8, 2013 . 1 changed file with 0 additions and 11 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,8 +22,6 @@ showHelp () { echo " prev = Go to the previous track."; echo " mute = Mute iTunes' volume."; echo " unmute = Unmute iTunes' volume."; echo " vol # = Set iTunes' volume to # [0-100]"; echo " albums = Shows the list of albums with IDs"; echo " search = Search for a given album name and tries to play it"; @@ -80,15 +78,6 @@ while [ $# -gt 0 ]; do break ;; "vol" ) echo "Changing iTunes volume level."; if [ $2 -gt 0 ]; then newvol=$2; fi -
mateuszgachowski-snippets revised this gist
Dec 8, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -16,7 +16,7 @@ showHelp () { echo "Options:"; echo " status = Shows iTunes' status, current artist and track."; echo " start = Starts iTunes' if not yet running."; echo " play = Start playing iTunes."; echo " pause = Pause iTunes."; echo " next = Go to the next track."; echo " prev = Go to the previous track."; -
mateuszgachowski-snippets revised this gist
Dec 8, 2013 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -152,6 +152,7 @@ while [ $# -gt 0 ]; do osascript -e 'tell application "iTunes"' -e 'if (exists playlist "temp_playlist") then' -e 'delete playlist "temp_playlist"' -e 'end if' -e 'set name of (make new playlist) to "temp_playlist"' -e 'set theseTracks to every track of playlist "Library" whose artist contains "'"$2"'"' -e 'repeat with thisTrack in theseTracks' -e 'duplicate thisTrack to playlist "temp_playlist"' -e 'end repeat' -e 'set theseTracks to every track of playlist "Library" whose album contains "'"$2"'"' -e 'repeat with thisTrack in theseTracks' -e 'duplicate thisTrack to playlist "temp_playlist"' -e 'end repeat' -e 'set theseTracks to every track of playlist "Library" whose name contains "'"$2"'"' -e 'repeat with thisTrack in theseTracks' -e 'duplicate thisTrack to playlist "temp_playlist"' -e 'end repeat' -e 'play playlist "temp_playlist"' -e 'end tell' fi break;; "stop" ) echo "Stopping iTunes."; osascript -e 'tell application "iTunes" to stop'; break ;; -
mateuszgachowski-snippets revised this gist
Dec 7, 2013 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -44,6 +44,12 @@ while [ $# -gt 0 ]; do artist=`osascript -e 'tell application "iTunes" to artist of current track as string'`; track=`osascript -e 'tell application "iTunes" to name of current track as string'`; echo "Current track $artist: $track"; echo; tracks=`osascript -e 'tell application "iTunes" to get name of every track in current playlist'`; export IFS=',' for t in ${tracks[@]}; do echo "$t"; done fi break ;; 'start' ) echo 'Launching iTunes' -
mateuszgachowski-snippets revised this gist
Dec 7, 2013 . 1 changed file with 14 additions and 12 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -4,6 +4,7 @@ # iTunes Command Line Control v1.0 # written by David Schlosnagle # created 2001.11.08 # @edited Mateusz Gachowski #################################### showHelp () { @@ -14,7 +15,8 @@ showHelp () { echo; echo "Options:"; echo " status = Shows iTunes' status, current artist and track."; echo " start = Starts iTunes' if not yet running."; echo " play (#) = Start playing iTunes. If # set, plays the given album"; echo " pause = Pause iTunes."; echo " next = Go to the next track."; echo " prev = Go to the previous track."; @@ -23,6 +25,8 @@ showHelp () { echo " vol up = Increase iTunes' volume by 10%"; echo " vol down = Increase iTunes' volume by 10%"; echo " vol # = Set iTunes' volume to # [0-100]"; echo " albums = Shows the list of albums with IDs"; echo " search = Search for a given album name and tries to play it"; echo " stop = Stop iTunes."; echo " quit = Quit iTunes."; } @@ -46,14 +50,7 @@ while [ $# -gt 0 ]; do osascript -e 'tell application "iTunes" to launch'; break;; "play" ) echo "Playing iTunes."; osascript -e 'tell application "iTunes" to play'; break ;; "pause" ) echo "Pausing iTunes."; @@ -92,9 +89,9 @@ while [ $# -gt 0 ]; do osascript -e "tell application \"iTunes\" to set sound volume to $newvol"; break ;; "albums" ) id=`osascript -e "tell application \"iTunes\" to (get database ID of every track in playlist \"Library\")"` album=`osascript -e "tell application \"iTunes\" to (get album of every track in playlist \"Library\")"` #split IDs based on ',' export IFS="," @@ -144,6 +141,11 @@ while [ $# -gt 0 ]; do break;; "search" ) echo 'Searching albums...'; if [ $# -eq 2 ]; then osascript -e 'tell application "iTunes"' -e 'if (exists playlist "temp_playlist") then' -e 'delete playlist "temp_playlist"' -e 'end if' -e 'set name of (make new playlist) to "temp_playlist"' -e 'set theseTracks to every track of playlist "Library" whose artist contains "'"$2"'"' -e 'repeat with thisTrack in theseTracks' -e 'duplicate thisTrack to playlist "temp_playlist"' -e 'end repeat' -e 'set theseTracks to every track of playlist "Library" whose album contains "'"$2"'"' -e 'repeat with thisTrack in theseTracks' -e 'duplicate thisTrack to playlist "temp_playlist"' -e 'end repeat' -e 'set theseTracks to every track of playlist "Library" whose name contains "'"$2"'"' -e 'repeat with thisTrack in theseTracks' -e 'duplicate thisTrack to playlist "temp_playlist"' -e 'end repeat' -e 'play playlist "temp_playlist"' -e 'end tell' fi break;; "stop" ) echo "Stopping iTunes."; osascript -e 'tell application "iTunes" to stop'; break ;; -
mateuszgachowski-snippets revised this gist
Dec 6, 2013 . 1 changed file with 63 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -42,9 +42,18 @@ while [ $# -gt 0 ]; do echo "Current track $artist: $track"; fi break ;; 'start' ) echo 'Launching iTunes' osascript -e 'tell application "iTunes" to launch'; break;; "play" ) echo "Playing iTunes."; if [ $# -eq 2 ]; then track_id=$2 echo 'Play track with ID' $track_id osascript -e "tell application \"iTunes\" to play ((first track of current playlist) whose database ID is $track_id)" else osascript -e 'tell application "iTunes" to play'; fi break ;; "pause" ) echo "Pausing iTunes."; @@ -83,6 +92,58 @@ while [ $# -gt 0 ]; do osascript -e "tell application \"iTunes\" to set sound volume to $newvol"; break ;; "album" ) id=`osascript -e "tell application \"iTunes\" to (get database ID of every track in current playlist)"` album=`osascript -e "tell application \"iTunes\" to (get album of every track in current playlist)"` #split IDs based on ',' export IFS="," #get database ID of tracks i=0 for id in $id do id_a[$i]=`echo $id` i=$((i+1)) done echo "Total number of songs in current playlist:" ${#id_a[@]} echo "\tFor every album in DB, display album name and first track ID of album." #disable separator export IFS="" ALBUM=( ) for (( i = 0 ; i < ${#id_a[@]} ; i++ )) do NEW_ALBUM=`osascript -e "tell application \"iTunes\" to get album of (every track where database ID is ${id_a[$i]})"` if [ ${#ALBUM[@]} -eq 0 ]; then ALBUM=( "${ALBUM[@]}" "$NEW_ALBUM" ) else MARK=1 for j in ${ALBUM[@]}; do if [[ $j == "$NEW_ALBUM" ]] ; then MARK=0 break fi done if [ $MARK -ne 0 ]; then ALBUM=( "${ALBUM[@]}" "$NEW_ALBUM" ) echo ${id_a[$i]} $NEW_ALBUM fi fi done break;; "stop" ) echo "Stopping iTunes."; osascript -e 'tell application "iTunes" to stop'; break ;; -
mateuszgachowski-snippets created this gist
Dec 6, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,98 @@ #!/bin/sh # #################################### # iTunes Command Line Control v1.0 # written by David Schlosnagle # created 2001.11.08 #################################### showHelp () { echo "-----------------------------"; echo "iTunes Command Line Interface"; echo "-----------------------------"; echo "Usage: `basename $0` <option>"; echo; echo "Options:"; echo " status = Shows iTunes' status, current artist and track."; echo " play = Start playing iTunes."; echo " pause = Pause iTunes."; echo " next = Go to the next track."; echo " prev = Go to the previous track."; echo " mute = Mute iTunes' volume."; echo " unmute = Unmute iTunes' volume."; echo " vol up = Increase iTunes' volume by 10%"; echo " vol down = Increase iTunes' volume by 10%"; echo " vol # = Set iTunes' volume to # [0-100]"; echo " stop = Stop iTunes."; echo " quit = Quit iTunes."; } if [ $# = 0 ]; then showHelp; fi while [ $# -gt 0 ]; do arg=$1; case $arg in "status" ) state=`osascript -e 'tell application "iTunes" to player state as string'`; echo "iTunes is currently $state."; if [ $state = "playing" ]; then artist=`osascript -e 'tell application "iTunes" to artist of current track as string'`; track=`osascript -e 'tell application "iTunes" to name of current track as string'`; echo "Current track $artist: $track"; fi break ;; "play" ) echo "Playing iTunes."; osascript -e 'tell application "iTunes" to play'; break ;; "pause" ) echo "Pausing iTunes."; osascript -e 'tell application "iTunes" to pause'; break ;; "next" ) echo "Going to next track." ; osascript -e 'tell application "iTunes" to next track'; break ;; "prev" ) echo "Going to previous track."; osascript -e 'tell application "iTunes" to previous track'; break ;; "mute" ) echo "Muting iTunes volume level."; osascript -e 'tell application "iTunes" to set mute to true'; break ;; "unmute" ) echo "Unmuting iTunes volume level."; osascript -e 'tell application "iTunes" to set mute to false'; break ;; "vol" ) echo "Changing iTunes volume level."; vol=`osascript -e 'tell application "iTunes" to sound volume as integer'`; if [ $2 = "up" ]; then newvol=$(( vol+10 )); fi if [ $2 = "down" ]; then newvol=$(( vol-10 )); fi if [ $2 -gt 0 ]; then newvol=$2; fi osascript -e "tell application \"iTunes\" to set sound volume to $newvol"; break ;; "stop" ) echo "Stopping iTunes."; osascript -e 'tell application "iTunes" to stop'; break ;; "quit" ) echo "Quitting iTunes."; osascript -e 'tell application "iTunes" to quit'; exit 1 ;; "help" | * ) echo "help:"; showHelp; break ;; esac done