Democratic Underground Latest Greatest Lobby Journals Search Options Help Login
Google

A great use for Quicksilver!

Printer-friendly format Printer-friendly format
Printer-friendly format Email this thread to a friend
Printer-friendly format Bookmark this thread
Home » Discuss » DU Groups » Computers & Internet » Macintosh Users Group Donate to DU
 
mrbassman03 Donating Member (1000+ posts) Send PM | Profile | Ignore Sun Apr-03-05 01:57 AM
Original message
A great use for Quicksilver!
Edited on Sun Apr-03-05 02:01 AM by mrbassman03
For those of you using Quicksilver (if you aren't, get on the boat!)... I have a pretty cool setup to share. I routinely stream KEXP from iTunes, as it is by far the best Seattle radio station, but it doesn't reach up here in Bellingham. Anyway, I wrote (stole parts from other scripts) a nice little Applescript that goes to the KEXP site, gets the current song, strips the extra information, and displays it very nicely with Quicksilver.

This script uses Lynx, so if you don't have it, get it with darwinPorts or Fink...

I have this set up to run with a Quicksilver trigger, and it works incredibly well. The KEXP website does not update the song if they go to a station break or the DJ is talking, so if the script says a song is playing, but one is not, that is the case. The problem is with the site, not the script.

If you have any questions, do not hesitate to ask!

DarwinPorts Fink Quicksilver


Here is what it looks like:


Here is the script:

set songname to (do shell script "cd /opt/local/bin/ ; ./lynx -dump http://www.kexp.org/getsong.asp")

if text 6 through 6 of songname = "+" then
set songname to text 7 through -1 of songname
set songname to text 1 through -7 of songname
set songname to decode_text(songname)
set songname to replace_chars(songname, "+", " ")
else
set songname to text 13 through -1 of songname
set songname to text 1 through -7 of songname
set songname to decode_text(songname)
set songname to replace_chars(songname, "+", " ")
end if
on decode_chars(these_chars)
copy these_chars to {indentifying_char, multiplier_char, remainder_char}
set the hex_list to "123456789ABCDEF"
if the multiplier_char is in "ABCDEF" then
set the multiplier_amt to the offset of the multiplier_char in the hex_list
else
set the multiplier_amt to the multiplier_char as integer
end if
if the remainder_char is in "ABCDEF" then
set the remainder_amt to the offset of the remainder_char in the hex_list
else
set the remainder_amt to the remainder_char as integer
end if
set the ASCII_num to (multiplier_amt * 16) + remainder_amt
return (ASCII character ASCII_num)
end decode_chars


on decode_text(this_text)
set flag_A to false
set flag_B to false
set temp_char to ""
set the character_list to {}
repeat with this_char in this_text
set this_char to the contents of this_char
if this_char is "%" then
set flag_A to true
else if flag_A is true then
set the temp_char to this_char
set flag_A to false
set flag_B to true
else if flag_B is true then
set the end of the character_list to ¬
my decode_chars(("%" & temp_char & this_char) as string)
set the temp_char to ""
set flag_A to false
set flag_B to false
else
set the end of the character_list to this_char
end if
end repeat
return the character_list as string
end decode_text

on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars

tell application "Quicksilver" to show large type songname
Refresh | 0 Recommendations Printer Friendly | Permalink | Reply | Top
politicat Donating Member (1000+ posts) Send PM | Profile | Ignore Sun Apr-03-05 07:22 AM
Response to Original message
1. Oh! That one! I thought you meant the Neal Stephenson Tome...
Like as a monitor stand or something.

My bad....
Printer Friendly | Permalink | Reply | Top
 
mrbassman03 Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Apr-04-05 03:37 AM
Response to Original message
2. I have been updating the script, as there are some things it missed...
Here it is...

set songname to (do shell script "cd /opt/local/bin/ ; ./lynx -dump http://www.kexp.org/getsong.asp")

if text 6 through 6 of songname = "+" then
set songname to text 7 through -1 of songname
set songname to text 1 through -7 of songname
set songname to decode_text(songname)
set songname to replace_chars(songname, "+", " ")
else
set songname to text 13 through -1 of songname
set songname to text 1 through -7 of songname
set songname to decode_text(songname)
set songname to replace_chars(songname, "+", " ")
end if
if text 1 through end of songname contains "Jazz" then
set songname to text 1 through -4 of songname
else
null
end if

on decode_chars(these_chars)
copy these_chars to {indentifying_char, multiplier_char, remainder_char}
set the hex_list to "123456789ABCDEF"
if the multiplier_char is in "ABCDEF" then
set the multiplier_amt to the offset of the multiplier_char in the hex_list
else
set the multiplier_amt to the multiplier_char as integer
end if
if the remainder_char is in "ABCDEF" then
set the remainder_amt to the offset of the remainder_char in the hex_list
else
set the remainder_amt to the remainder_char as integer
end if
set the ASCII_num to (multiplier_amt * 16) + remainder_amt
return (ASCII character ASCII_num)
end decode_chars


on decode_text(this_text)
set flag_A to false
set flag_B to false
set temp_char to ""
set the character_list to {}
repeat with this_char in this_text
set this_char to the contents of this_char
if this_char is "%" then
set flag_A to true
else if flag_A is true then
set the temp_char to this_char
set flag_A to false
set flag_B to true
else if flag_B is true then
set the end of the character_list to ¬
my decode_chars(("%" & temp_char & this_char) as string)
set the temp_char to ""
set flag_A to false
set flag_B to false
else
set the end of the character_list to this_char
end if
end repeat
return the character_list as string
end decode_text

on replace_chars(this_text, search_string, replacement_string)
set AppleScript's text item delimiters to the search_string
set the item_list to every text item of this_text
set AppleScript's text item delimiters to the replacement_string
set this_text to the item_list as string
set AppleScript's text item delimiters to ""
return this_text
end replace_chars

tell application "Quicksilver" to show large type songname

Printer Friendly | Permalink | Reply | Top
 
progressiveBadger Donating Member (1000+ posts) Send PM | Profile | Ignore Mon Apr-11-05 05:36 PM
Response to Original message
3. Very nice.
I'm gonna try it out when I get home.
I'm only a casual QS user, mostly use it as a launcher. I was going to get rid of it with Tiger's spotlight, but now I might have a reason to keep it! :)
Printer Friendly | Permalink | Reply | Top
 
DU AdBot (1000+ posts) Click to send private message to this author Click to view 
this author's profile Click to add 
this author to your buddy list Click to add 
this author to your Ignore list Sun Dec 22nd 2024, 02:20 PM
Response to Original message
Advertisements [?]
 Top

Home » Discuss » DU Groups » Computers & Internet » Macintosh Users Group Donate to DU

Powered by DCForum+ Version 1.1 Copyright 1997-2002 DCScripts.com
Software has been extensively modified by the DU administrators


Important Notices: By participating on this discussion board, visitors agree to abide by the rules outlined on our Rules page. Messages posted on the Democratic Underground Discussion Forums are the opinions of the individuals who post them, and do not necessarily represent the opinions of Democratic Underground, LLC.

Home  |  Discussion Forums  |  Journals |  Store  |  Donate

About DU  |  Contact Us  |  Privacy Policy

Got a message for Democratic Underground? Click here to send us a message.

© 2001 - 2011 Democratic Underground, LLC