Разделение записи в Audio Hijack Pro при смене трека Spotify (Applescript) - PullRequest
3 голосов
/ 20 декабря 2011

Это похоже на: Отслеживание изменений трека Spotify в Applescript? но вместо отображения изменений трека в уведомлениях рычания, я бы хотел, чтобы Audio Hijack Pro разделил свою текущую запись. Audio Hijack Pro также поддерживает Applescript, и команда будет «разделить запись». Поэтому мне не нужна информация о том, какая песня воспроизводится, но трек меняется как событие, которое запускает «разделенную запись» точно в срок. Я хотел бы начать с чего-то, но я очень мало знаю о сценариях в целом и еще меньше о Applescript. Любая помощь будет оценена! Заранее спасибо.

Ответы [ 2 ]

5 голосов
/ 30 января 2013

Это еще лучший сценарий. Он возьмет название альбома и название дорожки, введет имя файла и автоматически разделит дорожки при обнаружении новой воспроизводимой дорожки.

найдено на: 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
1 голос
/ 02 сентября 2012

Вам необходимо многократно опрашивать текущую воспроизводимую дорожку, и когда имя дорожки меняется, отправьте команду Audio Hijack Pro.

Вероятно, это можно сделать с помощью события в Spotify. Я проверю документацию. А пока ...

tell application "Spotify"
  set currentTrack to (name of current track)
  repeat
    if currentTrack is not equal to (name of current track)
      set currentTrack to (name of current track)
      tell application "Audio Hijack Pro"
        split recording theSession
      end tell
    end if
  end repeat
end tell

На самом деле, я только что представил суть, которая может помочь https://gist.github.com/3604106

Надеюсь, это поможет.

...