【问题标题】:How can I edit itunes song lyrics from the terminal?如何从终端编辑 iTunes 歌词?
【发布时间】:2012-08-05 09:24:33
【问题描述】:

我可以通过以下方式获取歌词:

osascript -e '''tell application "iTunes" to lyrics of the current track'''

但是我该如何设置它们呢?

我正在尝试使用我的文本编辑器更正当前歌词。

【问题讨论】:

  • 你试过“设置歌词”吗?我想就是这样。

标签: applescript itunes osascript


【解决方案1】:
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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2010-11-27
    • 2012-03-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多