【问题标题】:Splitting recording in Audio Hijack Pro on spotify track change (Applescript)在 Spotify 轨道更改(Applescript)上拆分音频劫持 Pro 中的录音
【发布时间】:2012-01-23 23:08:21
【问题描述】:

这类似于:Monitoring Spotify track change in Applescript? 但我不想在咆哮通知中显示音轨变化,而是让 Audio Hijack Pro 拆分其当前录音。 Audio Hijack Pro 也支持 Applescript,命令是“分割录音”。所以我不需要任何关于正在播放哪首歌的信息,但轨道变化是一个事件,可以准确地触发“分割录音”。我想从一些东西开始,但我对一般脚本知之甚少,对 Applescript 更是知之甚少。任何帮助,将不胜感激!提前致谢。

【问题讨论】:

    标签: audio split applescript spotify


    【解决方案1】:

    这是一个更好的脚本。 它将专辑名称和曲目名称放入文件名中,并在检测到正在播放的新曲目时自动分割曲目。

    发现于:http://joonix.se/post/25716608379/spotify-offline-playlist 这是一个 Applescript,应使用扩展名 .scpt 保存

    property update_delay : 0.1
    
    tell application "Audio Hijack Pro"
        activate
        -- Create a new session "Spotify" if it doesn't already exist
        try
            set spotify_session to first session whose name is "Spotify"
            if output name format of spotify_session is not "%tag_artist - %tag_title" then
                display dialog "The existing profile for \"Spotify\" does not utilize %tag_artist and %tag_title in the output name format option. Please add this if you want your files to be named automatically or delete/rename your existing \"Spotify\" session."
            end if
        on error number -1719
            tell application "Finder"
                set spotify_path to POSIX path of (application file id "spty" as alias)
            end tell
            set spotify_session to make new application session at end of sessions
            set targeted application of spotify_session to spotify_path
            set output folder of spotify_session to "~/Desktop"
            set output name format of spotify_session to "%tag_artist - %tag_title"
            set recording format of spotify_session to {encoding:MP3, bit rate:320, channels:Stereo, style:VBR}
        end try
        set name of spotify_session to "Spotify"
    
        -- (Re-)start hijacking and recording on the spotify session
        if hijacked of spotify_session is true then
            stop hijacking spotify_session
        end if
        start hijacking spotify_session relaunch yes
    end tell
    
    tell application "Spotify"
        if not running then activate
        if player state is playing then pause
    
        display dialog "Start playing the tracks that you want to rip with Audio Hijack, quit spotify when done."
        if repeating then display dialog "Please notice that you have repeating enabled in Spotify!"
    
        set has_started to false -- Whether spotify have been playing yet
    
        -- Check for changes to current track until spotify exits
        repeat until application "Spotify" is not running
            -- Changed track
            if has_started and id of current track is not recording_id then
                tell application "Audio Hijack Pro" to stop recording spotify_session
                set has_started to false
            end if
    
            -- Started playing
            if has_started is not true and player state is playing then
                set has_started to true
                set recording_id to id of current track
    
                -- Get the metadata
                set track_name to name of current track
                set track_artist to artist of current track
                set track_album to album of current track
    
                tell application "Audio Hijack Pro"
                    set title tag of spotify_session to track_name
                    set artist tag of spotify_session to track_artist
                    set album tag of spotify_session to track_album
    
                    start recording spotify_session
                end tell
            end if
    
            -- Stopped playing
            if has_started and player state is not playing then
                tell application "Audio Hijack Pro" to stop recording spotify_session
                set has_started to false
            end if
    
            delay update_delay
        end repeat
    
        tell application "Audio Hijack Pro" to stop recording spotify_session
    end tell
    

    【讨论】:

    • TX.像魅力一样工作!
    • 好剧本!有没有可能修改它以与 iTunes Radio 一起使用?
    • ps:脚本已经更新,因此也可以撕掉曲目号和其他元数据:joonix.se/post/42126024780/…
    【解决方案2】:

    您需要反复轮询当前播放的曲目,当曲目名称发生变化时,向 Audio Hijack Pro 发送命令。

    这可能可以通过 Spotify 中的事件来完成。我会检查文档。与此同时……

    告诉应用程序“Spotify” 将 currentTrack 设置为(当前曲目的名称) 重复 如果 currentTrack 不等于(当前曲目的名称) 将 currentTrack 设置为(当前曲目的名称) 告诉应用程序“Audio Hijack Pro” 拆分录制会话 结束告诉 万一 结束重复 结束告诉

    事实上,我刚刚提交了一个可能对https://gist.github.com/3604106有帮助的要点

    希望对你有帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-10-16
      • 2014-10-08
      • 1970-01-01
      • 2015-11-23
      • 1970-01-01
      • 2020-08-10
      • 2020-03-27
      相关资源
      最近更新 更多