Re: iTunes shell
One of the biggest issues I'm having right now is querying the Library by the database_id: my $track = $remote-obj( tracks = whose(database_id = equals = $args), playlist = 1 ); This actions seems to take forever (30+seconds). Is there a better way to get the track from id? i've run into this same issue, and i've found that different things affect the response time. like is iTunes the frontmost app? faster if not. are there other apps running? it seems trivial to query, but if there's even a 30% cpu load it seems to double or triple the response time. for anything other than playing a specific track i find it faster to do some basic searching through the 42MB xml file i've got. don't build a tree of course, just line by line regexes. - brian
Re: iTunes shell
yeah ok. I'll probably try to run a few tests to see what is the fastest thing to do. Maybe just building my own little bdb, and updating it every time new songs are added would be the quickest thing to do. The only function that is effected by this is queuenum, which arguably won't be the most commonly used one. thanks, cb On Jan 5, 2005, at 8:32 AM, brian pink wrote: i've run into this same issue, and i've found that different things affect the response time. like is iTunes the frontmost app? faster if not. are there other apps running? it seems trivial to query, but if there's even a 30% cpu load it seems to double or triple the response time. for anything other than playing a specific track i find it faster to do some basic searching through the 42MB xml file i've got. don't build a tree of course, just line by line regexes. - brian
Different results using the substr command
I am having problems with the substr command. It appears under OSX Perl the length value is being ignored. This code worked under MacPerl with the old open statement being open (THEFILE ,::clientd.html);. All I changed was the open statement with a new path. When I ask Perl OSX to print $line (the full string) I get the following... html head meta http-equiv=content-type content=text/html;charset=ISO-8859-1 META HTTP-EQUIV=Pragma CONTENT=no-cache meta name=description Content=Offline titleP a u s e d/title meta name=generator content=Albert Kaltenbaeck meta http-equiv=refresh content=15 titleO f f l i n e/title /head body bgcolor=#00 IMG SRC=D:\offline.gif WIDTH=400 HEIGHT=300 ALIGN=bottom /body /html Great! it is reading the file correctly. But when I ask Perl to print $playing (using the substr command) I get the following... ntent-type content=text/html;charset=ISO-8859-1 META HTTP-EQUIV=Pragma CONTENT=no-cache meta name=description Content=Offline titleP a u s e d/title meta name=generator content=Albert Kaltenbaeck meta http-equiv=refresh content=15 titleO f f l i n e/title /head body bgcolor=#00 IMG SRC=D:\offline.gif WIDTH=400 HEIGHT=300 ALIGN=bottom /body /htm It is starting at the beginning of the file and not the 6th line. Using MacPerl I get the word Offline in the sixth line and hacking off the three characters on the end. (what I want) I have tried using 167 as the offset and -3 as the length. When I do this the starting point is correct but it does not seem to acknowledge the length value because I get the rest of the entire string. Is there an issue now because I am using Unix line breaks and not Macintosh? here is how I am using substr. $. = 0; open (THEFILE,../../../../Documents/ge/ClientD.html) or die Line 96 . (localtime) . . $! . \n\n\n; do {$line =THEFILE} until $. == 6 || eof; close (THEFILE); $playing = substr($line,35,-3); Albert
Re: Different results using the substr command
I am wondering that even if you get substr to work, you probably would have code that is too specific and hacky. You probably want to match off of some of the keywords, so that if things move your program won't break. Joe. On Jan 5, 2005, at 3:14 PM, Albert Kaltenbaeck wrote: I am having problems with the substr command. It appears under OSX Perl the length value is being ignored. This code worked under MacPerl with the old open statement being open (THEFILE ,::clientd.html);. All I changed was the open statement with a new path. When I ask Perl OSX to print $line (the full string) I get the following... html head meta http-equiv=content-type content=text/html;charset=ISO-8859-1 META HTTP-EQUIV=Pragma CONTENT=no-cache meta name=description Content=Offline titleP a u s e d/title meta name=generator content=Albert Kaltenbaeck meta http-equiv=refresh content=15 titleO f f l i n e/title /head body bgcolor=#00 IMG SRC=D:\offline.gif WIDTH=400 HEIGHT=300 ALIGN=bottom /body /html Great! it is reading the file correctly. But when I ask Perl to print $playing (using the substr command) I get the following... ntent-type content=text/html;charset=ISO-8859-1 META HTTP-EQUIV=Pragma CONTENT=no-cache meta name=description Content=Offline titleP a u s e d/title meta name=generator content=Albert Kaltenbaeck meta http-equiv=refresh content=15 titleO f f l i n e/title /head body bgcolor=#00 IMG SRC=D:\offline.gif WIDTH=400 HEIGHT=300 ALIGN=bottom /body /htm It is starting at the beginning of the file and not the 6th line. Using MacPerl I get the word Offline in the sixth line and hacking off the three characters on the end. (what I want) I have tried using 167 as the offset and -3 as the length. When I do this the starting point is correct but it does not seem to acknowledge the length value because I get the rest of the entire string. Is there an issue now because I am using Unix line breaks and not Macintosh? here is how I am using substr. $. = 0; open (THEFILE,../../../../Documents/ge/ClientD.html) or die Line 96 . (localtime) . . $! . \n\n\n; do {$line =THEFILE} until $. == 6 || eof; close (THEFILE); $playing = substr($line,35,-3); Albert
Re: Different results using the substr command
On Jan 5, 2005, at 4:14 PM, Albert Kaltenbaeck wrote: I am having problems with the substr command. No you're not. :-) You're barking in the wrong forest here - both the offset and length values you passed to substr() are being used just fine. You're getting exactly what you asked for from substr() - the contents of $line, starting at offset 35 and omitting the last three characters. The difference is that, on MacOS, $line had just that, one line from the input file. It appears here to have the whole file in it. I suspect a line ending problem - verify that the input file has UNIX line endings. PS: Now you've found out why most of us use and recommend HTML::Parser - it's much less pain than trying to parse HTML by hand. sherm-- Cocoa programming in Perl: http://camelbones.sourceforge.net Hire me! My resume: http://www.dot-app.org
Re: Different results using the substr command
At 3:14 pm -0600 5/1/05, Albert Kaltenbaeck wrote: I am having problems with the substr command. It appears under OSX Perl the length value is being ignored. This code worked under MacPerl ... Do you get the expected result when you run this ?: $f = ClientD.html; $/ = \n; open F, $f or die $!; while (F) { print $.. -- $_; } If not then you need to consider your line endings. JD
Re: Different results using the substr command
At 22:23 + 1/5/05, John Delacour wrote: If not then you need to consider your line endings. And remember that MacPerl subscribes to the MPW convention that reverses the meanings of \n and \r for the Mac. ftp://ftp.macnauchtan.com/Software/LineEnds/FixEndsFolder.sit (52 kB) ftp://ftp.macnauchtan.com/Software/LineEnds/ReadMe_fixends.txt (4 kB) might be useful. -- -- There are 10 kinds of people: those who understand binary, and those who don't --
Re: Different results using the substr command
Thank you, with all your help I have found the issue is the HTML file I am reading does not have unix lineends. That is the problem. Thanks again! Albert On Jan 5, 2005, at 3:14 PM, Albert Kaltenbaeck wrote: I am having problems with the substr command. It appears under OSX Perl the length value is being ignored. This code worked under MacPerl with the old open statement being open (THEFILE ,::clientd.html);. All I changed was the open statement with a new path. When I ask Perl OSX to print $line (the full string) I get the following... html head meta http-equiv=content-type content=text/html;charset=ISO-8859-1 META HTTP-EQUIV=Pragma CONTENT=no-cache meta name=description Content=Offline titleP a u s e d/title meta name=generator content=Albert Kaltenbaeck meta http-equiv=refresh content=15 titleO f f l i n e/title /head body bgcolor=#00 IMG SRC=D:\offline.gif WIDTH=400 HEIGHT=300 ALIGN=bottom /body /html Great! it is reading the file correctly. But when I ask Perl to print $playing (using the substr command) I get the following... ntent-type content=text/html;charset=ISO-8859-1 META HTTP-EQUIV=Pragma CONTENT=no-cache meta name=description Content=Offline titleP a u s e d/title meta name=generator content=Albert Kaltenbaeck meta http-equiv=refresh content=15 titleO f f l i n e/title /head body bgcolor=#00 IMG SRC=D:\offline.gif WIDTH=400 HEIGHT=300 ALIGN=bottom /body /htm It is starting at the beginning of the file and not the 6th line. Using MacPerl I get the word Offline in the sixth line and hacking off the three characters on the end. (what I want) I have tried using 167 as the offset and -3 as the length. When I do this the starting point is correct but it does not seem to acknowledge the length value because I get the rest of the entire string. Is there an issue now because I am using Unix line breaks and not Macintosh? here is how I am using substr. $. = 0; open (THEFILE,../../../../Documents/ge/ClientD.html) or die Line 96 . (localtime) . . $! . \n\n\n; do {$line =THEFILE} until $. == 6 || eof; close (THEFILE); $playing = substr($line,35,-3); Albert Albert Kaltenbaeck 15324 West 144th Terrace Olathe, Kansas 66062 (913) 780-3835 Home (913) 206-4579 Cell
Re: iTunes shell
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Cutter Brown) wrote: One of the biggest issues I'm having right now is querying the Library by the database_id: my $track = $remote-obj( tracks = whose(database_id = equals = $args), playlist = 1 ); This actions seems to take forever (30+seconds). Is there a better way to get the track from id? The problem is that iTunes is just very slow at whose searches. There may be another way, though I don't know how reliable it is, and it's more of a pain. Instead of getting the database ID, get the unique ID: my $id = $sometrack-get-getdata; Then: my $track = $remote-obj( track= obj_form(formUniqueID, typeLongInteger, $id), playlist = 1 ); That's very fast, assuming a. you can get the unique IDs, and b. they are reliably consistent for you. (This was somewhat documented in the Mac::Glue POD, using iPhoto as an example, for a different problem.) Good luck, -- Chris Nandor [EMAIL PROTECTED]http://pudge.net/ Open Source Development Network[EMAIL PROTECTED] http://osdn.com/
speaking of shells...
Speaking of commandline utilities for traditionally GUI things... I've been wanting to create a commandline interface to airport for a while. Something that gives access to the same functionality as that airport icon in the apple bar-- in particular the ability to turn airport on and off (for login and logout init scripts). I was wondering first if something like this is already out there? And second what process would I be sending appleevents to, i.e. what to I need to make a glue for? Or does the utility that controls such things not accept appleevents, if so is there another way to communicate with it? live well, ~wren __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail
Re: speaking of shells...
here is a command line utility to do what you want: http://www.macstumbler.com/airport.tar.gz I'm not sure if you wanted a programatic interface, but the source is open so you could make one if the binary wasn't exactly what you wanted. cb On Jan 5, 2005, at 10:31 PM, Nicholas Thornton wrote: Speaking of commandline utilities for traditionally GUI things... I've been wanting to create a commandline interface to airport for a while. Something that gives access to the same functionality as that airport icon in the apple bar-- in particular the ability to turn airport on and off (for login and logout init scripts). I was wondering first if something like this is already out there? And second what process would I be sending appleevents to, i.e. what to I need to make a glue for? Or does the utility that controls such things not accept appleevents, if so is there another way to communicate with it? live well, ~wren __ Do you Yahoo!? Yahoo! Mail - You care about security. So do we. http://promotions.yahoo.com/new_mail