2017-01-15 6 views
0

재생 목록의 트랙을 반복하는 스크립트가 있습니다. 이미 mp3 인 경우 iPod에 추가 (duplicate currentTrack to ipod_lib)하고 재생 목록에서 삭제합니다.이 부분은 정상적으로 작동합니다. 그러나 무손실 인 경우 mp3로 변환하여 iPod에 추가하려고합니다. 크기가 너무 크기 때문에 무손실 파일을 직접 추가하지 않아도됩니다. duplicate convertedTrack to ipod_lib 다음과 같은 오류가 발생합니다 라인 ...iTunes에서 변환 된 트랙 사용하기 AppleScript

오류 "iTunes가있어 오류 :에 소스 ID 235166의 라이브러리 재생 목록 ID 270897를 설정할 수 없습니다 {소스 ID의 라이브러리 재생 목록 ID 38702의 파일 트랙 ID 322339 68} . " locateiPods 코드가 http://dougscripts.com/

에서 스크립트에서 가져 235166

소스 ID의 라이브러리 재생 목록 ID 270897에서 번호 -10006 정말 내가 ... 여기에 잘못하고 있어요하지 않도록 어떤

on locateiPods() 
    set the volumes_directory to "/Volumes/" as POSIX file as alias 
    set the volume_names to list folder volumes_directory without invisibles 
    set mounted_iPods to {} 
    repeat with i from 1 to the count of volume_names 
     try 
      set this_name to item i of volume_names 
      set this_disk to ("/Volumes/" & this_name & "/") as POSIX file as alias 
      set these_items to list folder this_disk 
      if "iPod_Control" is in these_items then 
       set the end of the mounted_iPods to this_disk 
      end if 
     end try 
    end repeat 

    -- check for iPod count 
    if the mounted_iPods is {} then 
    -- 
     try 
      display dialog "iPod is not mounted." buttons {"Cancel"} with icon 0 giving up after 15 
     on error 
      error number -128 
     end try 

    else if the (count of the mounted_iPods) is greater than 1 then 
     -- choose iPod 
     set the ipod_names to {} 
     repeat with i from 1 to the count of the mounted_iPods 
      set this_iPod to item i of the mounted_iPods 
      tell application "Finder" 
       set the end of the ipod_names to the name of this_iPod 
      end tell 
     end repeat 
     tell application "iTunes" 
      activate 
      set this_name to (choose from list ipod_names with prompt "Pick the iPod to use:") as string 
     end tell 
     if this_name is "false" then error number -128 
      repeat with i from 1 to the count of the ipod_names 
       if item i of the ipod_names is this_name then 
        set this_iPod to item i of the mounted_iPods 
        exit repeat 
       end if 
      end repeat 
    else 
     set this_iPod to item 1 of the mounted_iPods 
    end if 
    return this_iPod 
end locateiPods 

tell application "iTunes" 
    set allTracks to every track in user playlist "TEST" 
    set the_iPod to my locateiPods() -- this is a path 
    set the_iPod_name to text 1 thru -2 of (the_iPod as string) 
    set ipod_src to some source whose name is the_iPod_name 
    set ipod_lib to library playlist 1 of ipod_src 

    repeat with i from 1 to count of allTracks 
     set currentTrack to item i of allTracks 
     set fileType to kind of currentTrack as string 
     if fileType is "MPEG audio file" then 
      duplicate currentTrack to ipod_lib 
      tell playlist "TEST" to delete contents of currentTrack 
     end if 
     if fileType is "Apple Lossless audio file" then 
      set convertedTrack to convert currentTrack 
      duplicate convertedTrack to ipod_lib 
     end if 
    end repeat 
end tell 

다음과 같이하면 convertedTracktrack이 아니란 것을 알 수 있습니다.

답변

0

나는 항상 트랙 목록에 "convert"를 사용하고 결과는 트랙 목록입니다. 그런데 각 트랙을 변환하기 위해 루프를 수행하는 대신 트랙 목록을 변환하는 것이 훨씬 빠릅니다. 종류가 무손실 인 모든 트랙을 먼저 선택해야 할 수도 있습니다.

convert에 대해서도 convert가 iTunes 환경 설정에서 설정된 형식으로 변환을 수행한다는 점을 명심하십시오. 그런 다음 스크립트는 이러한 환경 설정에 따라 달라집니다. 보다 안전하고, 현재 환경 설정을 저장하고, MP3를 원하는 형식으로 변환 모드를 설정 한 다음 이전에 설정 한 내용을 다시 설정하는 것이 좋습니다. 자바 스크립트를 사용할 수 있습니다 :

-- get & save current encoder 
tell application "iTunes" to set Encoder_Base to name of current encoder 

-- change encoder to MP3 
tell application "iTunes" to set current encoder to (get first encoder whose name contains "MP3") 

또한, 마운트 된 볼륨을 찾는 대신 소스 방법을 사용하여 iPod 서브 루틴을 최적화 할 수 있습니다. iTunes 소스는 효율적인 방법을 제공합니다 :

-- kind of source could be : library, iPod, audio CD, MP3 CD, radio tuner, shared library, iTunes Store 
tell application "iTunes" 
set myList to every source whose kind is iPod 
if myList is {} then 
    display alert "no ipod connected" 
    return 
else -- I assume if one iPod found, there is only 1 connected !! 
    set SourceName to name of first item of myList 
    set SourceID to id of first item of myList 
end if 
end tell 

나는 그것이 도움이되기를 바랍니다.