peco-itunes
_itunes_list_tracks() {
osascript <<EOF
tell application "iTunes"
set accumulator to ""
repeat with t in every track
set output to "" & (id of t) & tab & "\"" & (name of t) & "\"" & tab & "\"" & (artist of t) & "\""
set trackInfo to do shell script "echo " & quoted form of output without altering line endings
set accumulator to accumulator & trackInfo
end repeat
end tell
EOF
}
_itunes_delete_playlist() {
osascript <<EOF
tell application "iTunes"
try
delete user playlist "$1"
end try
end tell
EOF
}
_itunes_add_track_to_playlist() {
osascript <<EOF
set myPlaylistName to "$2"
tell application "iTunes"
try
set myPlaylist to user playlist myPlaylistName
on error
set myPlaylist to (make new user playlist with properties {name:myPlaylistName})
end try
duplicate (every track whose id is "$1") to myPlaylist
end tell
EOF
}
_itunes_play_playlist() {
osascript <<EOF
tell application "iTunes"
play user playlist "$1"
end tell
EOF
}
peco-itunes() {
local playlistName="Peco-iTunes"
local tracks=$(_itunes_list_tracks | peco --prompt "${playlistName}>" | awk '{print $1}')
if [ -z "$tracks" ] ; then
return
fi
_itunes_delete_playlist $playlistName
local IFS=$'\n'
for track in $tracks ; do
IFS=" "; _itunes_add_track_to_playlist "$track" "$playlistName"
done
_itunes_play_playlist "$playlistName"
}
Author And Source
この問題について(peco-itunes), 我々は、より多くの情報をここで見つけました https://qiita.com/yungsang/items/9092f2e71477d97cf701著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .