Applescript 如何从终端编辑itunes歌词?
我可以通过以下方式获得歌词:Applescript 如何从终端编辑itunes歌词?,applescript,itunes,osascript,Applescript,Itunes,Osascript,我可以通过以下方式获得歌词: osascript -e '''tell application "iTunes" to lyrics of the current track''' 但我如何设置它们呢 我正在尝试使用我的文本编辑器对当前歌词进行更正 osascript -e 'tell application "iTunes" to set lyrics of current track to "hoho"' 感谢regulus6633 和作为cli脚本 #!/usr/bin/env osa
osascript -e '''tell application "iTunes" to lyrics of the current track'''
但我如何设置它们呢
我正在尝试使用我的文本编辑器对当前歌词进行更正
osascript -e 'tell application "iTunes" to set lyrics of current track to "hoho"'
感谢regulus6633
和作为cli脚本
#!/usr/bin/env osascript
-- update_lyrics <track persisten ID> <lyric file>
on run argv
try
set trackPersistentID to item 1 of argv
set lyricsFile to item 2 of argv
-- use awk to strip leading empty lines
set cmdString to "cat " & lyricsFile & " | awk 'p;/^#+$/{p=1}'"
set newLyrics to do shell script cmdString
on error
return "update_lyrics <trackID> <lyricsFile>"
end try
tell application "iTunes"
set mainLibrary to library playlist 1
try
set foundTrack to (first file track of mainLibrary whose persistent ID = trackPersistentID)
set lyrics of foundTrack to newLyrics
on error err_mess
log err_mess
end try
end tell
end run
#/usr/bin/env-osascript
--更新歌词
运行argv
尝试
将trackPersistentID设置为argv的项目1
将lyricsFile设置为argv的项目2
--使用awk去除前导空行
将cmdString设置为“cat”&lyricsFile&“|awk'p;/^ 35;+$/{p=1}”
将newly词设置为执行shell脚本cmdString
论错误
返回“更新歌词”
结束尝试
告诉应用程序“iTunes”
将mainLibrary设置为库播放列表1
尝试
将foundTrack设置为(持久ID为trackPersistentID的mainLibrary的第一个文件磁道)
将foundTrack的歌词设置为NewLyps
关于错误-错误-混乱
日志错误
结束尝试
结束语
终点
您尝试过“设置歌词”吗?我想就是这样。