ルビーからiTunesのトラックのパスを更新したいのですが、動作させることができません。何らかの理由で、track.setLocation()を呼び出しても何も起こりません。これが私が使用しているスクリプトです:
require 'osx/cocoa'
include OSX
OSX.require_framework 'ScriptingBridge'
def getSourceLibrary(iTunes)
iTunes.sources.each do |source|
if (source.kind == 1800169826) # TV Kind
return source
end
end
return nil
end
iTunes = SBApplication.applicationWithBundleIdentifier:'com.apple.iTunes'
library=getSourceLibrary(iTunes)
libraryPlaylists=library.libraryPlaylists
libraryPlaylists[0].fileTracks.each do | track |
if (track.videoKind==1800823892)
loc = track.location.to_s
puts "Before: #{loc}"
loc = loc.gsub(/\/mounts\/TVShows/,'/mounts/TV')
loc = loc.gsub(/\/mounts\/incoming/,'/mounts/TV')
track.setLocation(loc)
puts "After: #{track.location.to_s}"
end
end
スクリプトはiTunesライブラリを反復処理し、パスを変更しようとします。ただし、前後は同じです!正規表現の検索と置換は機能しましたが。これに関する助けをいただければ幸いです。