Jump to content

iTunes auto import help


Recommended Posts

hello

i am trying to make a auto import script for itunes

but i am getting this errors

---------------------------

AutoIt Error

---------------------------

Line 114 (File "C:\Users\Koos\Documents\AutoIt\scripts\iTunes.au3"):

$Library_Playlist.AddTrack($path)

$Library_Playlist.AddTrack($path)^ ERROR

Error: The requested action with this object has failed.

and later

---------------------------

AutoIt Error

---------------------------

Line 83 (File "C:\Users\Koos\Documents\AutoIt\scripts\iTunes.au3"):

$Playlist_Handle.ItemByName($PlayList_Name).AddTrack($sng_nm)

$Playlist_Handle.ItemByName($PlayList_Name).AddTrack($sng_nm)^ ERROR

Error: The requested action with this object has failed.

i am using iTunes UDF

my code is

#include <File.au3>
#include <Array.au3>
#include "iTunes.au3"
$sPath="C:\Users\Public\Music\Sample Music"
$input= " "
$PlayListName="top 40"
Local $FileList = _FileListToArray($sPath ,"*.mp3",0); get all mp3 files in the map
If @error = 1 Then
    MsgBox(0, "", "No Folders Found.")
    Exit
EndIf
If @error = 4 Then
    MsgBox(0, "", "No Files Found.")
    Exit
EndIf
_iTunes_Start()
;For $i=1 To $FileList[0]    ;$FileList [0] is the amount of mp3 files in the folder
;$path=$sPath&"\"&$FileList[$i] ;at the file name to the path
;_iTunes_Library_AddTrack($path)   ; import the file to itunes
;Next
For $i=1 to $FileList[0]     ; remove te .mp3 extrention so the song name remains
   $RemoveText= ''
   $input = $FileList[$i]
   $Input = StringReplace ($Input, ".mp3", $RemoveText)  ;Scans $Input for .mp3 and replaces it with $RemoveText
  
Next
For $i=1 to $FileList[0]
  MsgBox ('0', "test", $FileList[$i])
  _iTunes_PlayList_Add($PlayListName, $FileList[$i])   ;at the songs i just importet to my playlist
  
Next
Exit

could it be that iTunes UDF to old is and no longer works

(sorry for bad English)

greetings Loek

Link to comment
Share on other sites

Just use _iTunes_Library_AddTrack() with a full path to a file by itself and see if you can get the function working at all... like this:

_iTunes_Library_AddTrack("C:UsersPublicMusicSample MusicSampleSong.mp3")

If that works then add a line after "$path = $sPath & "" & $FileList[$i]" to output the contents of $path before you try to use the _iTunes_Library_AddTrack() method on it:

ConsoleWrite("$path = " & $path & @CRLF) or MsgBox(0, "$path", $path)

Link to comment
Share on other sites

putting the full path in the function didn't work

although if i use msgbox and 1 cop the path and launch it it will work

it think the iTunes udf is broken

i am now going to try it by launching the path with shellexecute

Link to comment
Share on other sites

although if i use msgbox and 1 cop the path and launch it it will work

What's that mean?

it think the iTunes udf is broken

I just downloaded the COM documentation and it hasn't changed in two years. Though possible, it seems unlikely that Apple broken the underlying function that the UDF uses.

i am now going to try it by launching the path with shellexecute

Launching what exactly? You mean associate MP3 files with iTunes then launch the MP3 so that iTunes automatically imports it?
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...