I sometimes wonder if my audience is divided. To put it simplistically, I imagine there are those who come here to read my complaints about Microsoft, and those who come to read my complaints about Bush. I sort of feel like Clifford Stoll in The Cuckoo's Egg, which tells the story of how a minor accounting error led Stoll, an astronomer turned systems administrator, to track down a group of German hackers selling information to the KGB. While I have not been involved with Soviet intelligence agents recently, this quote is pertinent:
Astronomers saw me that way. "Cliff, he's not much of an astronomer, but what a computer hacker [ed: this implied only that Stoll was particularly good with computers]!" (The computer folks, of course, had a different view: "Cliff's not much of a programmer, but what an astronomer!" At best, graduate school had taught me to keep both sides fooled.)
Unlike Stoll, I am not concerned about fooling you as much as boring you to death. While I have constantly worried about the number of "tech" entries on this site, it was never really a problem until this year, as the number of political articles decreased significantly after last November. I have tried to restore some semblance of balance by writing more about literature and music, but I am not sure if I have succeeded.
That said, if you are too scared/paranoid/selfish to write a comment below, you can always send me email at the contact page. This entry is both significantly long (more than 1500 words!) and technical (I try to explain technical terms and the like, but as I said earlier, I am feeling increasingly self-conscious about my ability to explain computing, especially when I am not conversing face-to-face with someone), so this might be a good time to complain about how you come to this website every single week and I never write anything that interests you.
Earlier, I complained about how the binary file structure of iTunes Music Library files (which have an ITL file extension) prevented me from editing the play counts in my iTunes music library. When I first noticed this problem back in May, I had assumed that the ITL file format was the same as that used in iTunesDB files, which store music library data on the iPod. Since the iTunesDB format had been reverse-engineered by various people trying to make their iPod play nicely with Linux, I figured it would be relatively easy to port their efforts into a Windows application. I envisioned using the powerful scripting language known as Python. Python looks like this:
z = 2
for i in range(37):
z = z*2
print z
The above code prints the value of 237. Programs that use Python that you may have heard of: Wirehog, PyMusique.
In June (I was busy in May with school and stuff), I actually opened an ITL file in a text editor. While I could not decipher it, it was clear than it was a different file format than iTunesDB. While iTunesDB files start with "mhbd," the ITL file started with "hdfm." This meant that if I wanted to edit the ITL file, I would somehow have to reverse-engineer it - use trial and error to find how its format. Since the contents of the file did not immediately seem to be structured in any way, I became interested in finding alternate ways to edit the file. Unfortunately, the omniscient Google had no information about the structure of ITL files. I had to assume that outside of the confines of Cupertino, every other programmer who had considered working on an ITL file editor had decided to do something easier, like solving the spam problem.
Since I figured my figuring out the ITL format was going to be difficult enough to me, I decided to stop using Python in favor of Delphi. Delphi is a programming language based on Pascal. In terms of the application I was writing, its main advantage was that I have programmed in Delphi since high school. If I was going to figure out the ITL file format before the end of the summer, I would not have time to fumble around in Python. Delphi code looks like this:
try
RegServProc := GetProcAddress(module, 'RegisterServiceProcess');
if Assigned(RegServProc) then
if Active then
Result := RegServProc(0, RSP_SIMPLE_SERVICE) = 1
else
Result := RegServProc(0, RSP_UNREGISTER_SERVICE) = 1;
finally
FreeLibrary(module);
end;
The above code attempts to register the program as a service under Windows 98/Me. Such a program would not appear in the Task Manager! Programs that use Delphi that you may have heard of: Spybot - Search & Destroy, GetDataBack.
About to give up, I emailed Apple's Developer Technical Support, not expecting to get a response saying that "The ITL file format is the exclusive intellectual property of Apple Computer, and if we told you anything about it, Apple would go bankrupt." As a result of my negative thinking, I was surprised when the first response seemed to actually be interested in answering my question. I replied back, explaining my wish to construct a program to edit play counts, which had been stymied by the heinous binary nature of the ITL file.
The next day, I received a suggestion that I should use the iTunes COM SDK. COM is a technology that allows you to write Windows programs that interact and control with other Windows programs. The implication was that I could write a program that would then tell iTunes to change the play counts. Since I had looked at the iTunes COM SDK back in May (and again in June, just in case anything changed) and decided that it was impossible to use it to edit play counts, I was a bit nonplussed. However, just to be fair, I decided to take another look at the help file before writing an angry email to Apple.
Unlike the previous two times I had looked, this time the existence of the PlayedCount variable, which could be used to get or set the number of times a track could be played. To be frank, I felt very stupid at that moment. I was happy that my task was possible, but far happier that I had restrained myself from responding immediately to the email.
All that remained was to actually write the program. Since it was likely I would get distracted with other projects if the program's creation took more than a day, I was interested in creating it as quickly as possible. Since I was going to be using COM, I decided to switch programming languages again to C#. C# code looks like this:
if(XReader.IsStartElement("item")){
currFeed.items[currFeed.num_items] = new RSSItem();
int item_depth = XReader.Depth;
while(XReader.Depth == item_depth){ // we have come for your children nodes
XReader.Read();
}
The above code came from a RSS aggregator that I wrote back in June 2003 (which, incidentally, took at least two weeks to write - when I realized the strange bugs I was experiencing were a result of fundamental flaws in its design). While I know of programs made with C#, I do not actually use any of them (except, of course, the ones I have written myself).
Since I have not done any C# development since last summer, my first task was to install an IDE to help me with designing the application's interface (where the buttons are, etc.). While my previous C# development took place under the aegis of Microsoft's Visual Studio .NET, I decided against using it. First, installing Visual Studio takes at least a couple of hours, during which time I would be unable to use the computer, but would be forced to sit at the computer swapping CDs in and out (the three computer tasks will consistently put me to sleep are installing Windows, compiling Linux kernels, and installing Visual Studio; they also all take long periods of time and have the tendency to fail in esoteric ways). Also, if you install Visual Studio .NET before Office 2003 and attempt to install it later, the installation will fail (the only remedy in such a case is to spend an hour uninstalling Visual Studio, install Office, and spend more hours reinstalling Visual Studio). Since I had heard good things about the open-source IDE SharpDevelop, I decided to give it a try. The most problematic part of the installation was downloading the .NET Framework SDK in order to get documentation and a debugger - at over 100 megabytes, my unstable wireless connection forced me to download it to this website (using the Unix utility wget) before downloading it using FTP (if the wireless connection dropped, Firefox annihilates your downloads about half of the time; FTP clients, on the other hand, allow you to resume download easily). Of course, if I had installed Visual Studio, it also would have made me download the .NET Framework SDK, so it is unfair to count the time spent against SharpDevelop.
Anyway, the program was almost ridiculously simple to write. Since I was more interested in getting it done than making it look pretty, it is rather ugly (hence the lack of screenshots). It does, however, change play counts in iTunes. I am content.
The iTunes COM documentation is interesting enough that I might make some more applications before the end of the summer. If you have ideas for programs that interact with iTunes, feel free to submit them.
iTunes Music Library File Format
I previously wrote about my fruitless search to find the file format of iTunes Music Library files, and how I was able to use the iTunes COM Windows SDK to bypass this lack of knowledge.
If you do a search on Google for "hdfm itunes", my …
Hi! this post is very interesting… i'm trying to find out a way to keep up-to-date the itunes library between tu users on a same PC with WinXP… so, i'm going to take a look at the itunes COM SDK…
uh, i'm going to write code in C# too (only because i work with this :P)
Bye!
Jack
Ok, if you're still interested in programs to interact with iTunes, I have one. When you download tv shows from iTunes and put them on the new video ipod, they are labeled Tv Shows, and of couse are placed in the Tv Shows section on the iPod. Now say I have a file I recorded from my tv capture software, convert it, and now I would like to label that file Tv Shows and place that into the Tv Show section on the iPod. Thats where my dilemma comes in. The only two choices for when you import video files into iTunes is Movies, and Music Videos. And chosing either of those will place that file on your iPod in the appropriate section. But I don't want it in the Movie or Music Video section…I need it in the Tv Show section. I would think that if you could edit the .itl you could do this easily…but we all know that isn't going to happen. So I'm either stuck, or someone is kind enough to write a program to do this via iTunes. Anyway, just figured if someone was looking for more programs to write, there's an idea for one that would be really useful to others as well.
Thanks.
Good post. This little app you've cooked up sounds just like what I'm after… Since I installed iTunes 6.0.2 on XP, a lot of my album artwork went missing on my 60GB iPod photo. I tried the recommended disable/re-enable artwork on iPod settings but now I have no artwork at all and when I try to re-enable artwork I get an "iPod cannot be updated. Error -50" message. From what I can tell, it seems the easiest way to get around this is to delete the music off my iPod and re-copy it all over, as that seems to re-initialize the artworkDB file. But since I use manual sync, I'll lose my playcounts. And although it would be a slow, arduous task to edit playcounts for every track, I've already tried a few other arduous methods to try and solve the problem so one more won't hurt much.
Basically, what I'm getting at is, I'm not asking for tech support, I just want to know if is there anywhere I can get this app? I couldn't find a link anywhere in the entry, unless I missed it, and I sure as hell ain't no programmer so I couldn't do it myself.
I have not used this application in a while, so I have no idea whether it works with iTunes 6.0.2, although it should. Also, since I never really meant to release this application, the user interface is clunky. That said, you can download it at http://www.marteydodoo.com/projects/iMeta.zip.
It seems that there is still no way to change the Date Added and Date Modified Fields from outside of iTunes proper.
How to lose your Date Modified/Date Added fields (blank the itl file forcing an import from the xml file)
Someone recently getting upbraided for assuming the date fields weren't readonly:
At the end of this one another scripter fails to molest the date fields.
Not *positive* this still applies to iT7.0 that came out this week but for anyone interested in slicing up that binary hunk in the future, here is good reason!
I would love to see a program that allows windows users to add chapter frames to song files (such as those found in Audible.com downloads).
Unfortunately for you, I use neither Windows nor Audible. Some other programmer will have to write this.
I am struggling to find lost files in itunes. I have not found a program out there that can do it. So, I have taken matters in my uneducated hands. For whatever reason, itunes now does not find ~ 8,000 of the 11,500 songs in my library. It appears that the m4a files are the problem.
When I open the xml file in Notepad, it appears as though I can do a simple find & replace to correct the path on a large number of these errors. After saving the xml file & reopening itunes, the files are still not found. When I reopen the xml file… the originally incorrect paths are reinstated.
Any thoughts???
Scott, the difference between the ITL and XML versions of the iTunes libraries was explained earlier. The ITL file is what iTunes uses and modifies - the XML file is only for exporting the library to other applications.
It has been about 2 years since I have looked at iTunes' COM interface, but I think it might be possible to create a program to do the find & replace operation that you need.
Hi, I just downloaded the program from the link in the comment above. I extracted it and tried to run it, but got this error message:
"Application has generated an exception that could not be handled.
Process id=0×2df8 (11768), Thread id=0×2f8c (12172)."
I realize it has probably been awhile since you worked with this program, but and help you could give me with getting this to run would be greatly appreciated.
*any, not and.
Also, I am running iTunes 7.1.0.59 on Windows XP.