Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.
Status
Not open for further replies.
Hey guys, anyone familiar with boxoh.com? Its a package tracker. Put in a tracking number, it charts it on google maps and gives you an RSS feed of the package's progress.

Could someone code up a simple script that grabs the RSS data from boxoh? Ideally it would be 1 script, with one variable that you'd need to replace (the tracking number).

The site is relatively simple. A direct link to the rss feed of any package tracked is simply:
http://boxoh.com/?rss=1&t="Tracking#".


Related to this, does anyone have any good resources for Python and how to scrape data from things like RSS feeds, removing the html formatting? I want to figure out how that all works. Thanks!

The Python XML library is useful along with urllib. I have a couple of Python XML scraper scripts you could probably use as a base.
 
Here is what mine looks like now that i have the weather stuff working. I have to figure out how to get the itunes to show paused and album artwork. The little black words are track title and artist. I cannot figure out how to but a space between the title and the artist.

I did have my flip clock working, but all of the sudden it wont let me put the time and date over the picture. o well..something to work on.

o0o I like your background :)
For album artwork, I use an app called Bowtie...works awesome!
For iTunes playing and paused, put this into Applescript Editor & then do the same with your shell command osascript...
PHP:
on run
	set info to ""
	tell application "System Events"
		set num to count (every process whose name is "iTunes")
	end tell
	if num > 0 then
		tell application "iTunes"
			if player state is playing then
				set info to "iTunes Now Playing:"
			else if player state is paused then
				set info to "iTunes Paused:"
			else
				set info to " "
			end if
		end tell
	end if
	return info
end run
For your track title and artist, post your script on here & i'll try to figure it out for you :)
With your flip-clock not working, what do you mean? What picture are you talking about?
I haven't messed with weather.com or my weather image yet. I've been busy working since Friday. If I have any problems with the weather image, i'll be coming to you about that hah :D
 
Geektool Horizontal Calendar, Almost had it!

Here is what I have so far
5xn9mr.png


The code I am using is
Code:
echo `cal`" " |
sed "s/[^0-9]$(date +%e | sed s'/ //')\([^0-9]\)/ $(date +%e | sed 's/ *\([0-9]*\)/[31m\1[0m/')\1/" |
sed s'/ $//' |
sed s'/Su Mo Tu We Th Fr Sa//g' |
sed s'/ / \ ·  /g' |
sed s'/\([a-z]\)[ ]\ ./\1/g' |
sed s'/\.[ ]*\./ /'|
sed s"/$/     $(date +%A)/"

I'm one step away from what I want. As you can see, there are two dots after 2011. I want to get rid of them, so it would mimic the other side (the 30 and Monday). Can anyone alter my code to get this to work? Thanks.
 
Last edited by a moderator:
Hi, I was wondering if someone had a script to show what week number it is? For example now is week 36 so it would be nice to have 36 in the desktop besides my calendar.

Im sorry if this question has already been answered, hard to look threw all these pages.:)

***EDIT*** I just found it out!
 
Last edited:
Your Desktop

Try this website. No downloads needed.
http://gtwthr.com/

----------

[url=http://farm7.static.flickr.com/6207/6100214973_1250f7a9b1.jpg]Image[/url]

I got most of my scripts from here: http://www.macosxtips.co.uk/geeklets/

If anyone wants the background images just respond with your email address and I'll send 'em your way.


i really like the look of your desktop, i was wondering if you could send me some of the script you used and maybe the wallpaper, really good job with that, it look excellent.! :)

----------

My take on the Geektools desktop from the appstore screenshot.

bit of a long shot i know but do you think you could send me the scripts you used to get the appstore screenshot style background as i have been looking for some time now :(
cheers.. Ell..
 
Geektool Calendar

Hey, I found Geektool a couple of days ago, and have been trying to make a custom calendar. I found a script that I have been trying to translate into norwegian, but I do have some problems with the formatting.

The code looks like this:
cal |
sed -E 's/ ([0-9])( |$)/0\1\2/g' |
awk '{ print " "$3; getline; print " Ma Ti On To Fr Lø Sø"; \
getline; if (substr($0,1,2) == "1") print "1";\
do { prevline=$0; if (getline == 0) exit; print "",\
substr(prevline,4,17) " " substr($0,1,2) " "; } while (1) ;}'

I know it can't be perfectly aligned without a monospace font, but it would be close enough if I could align the first row of dates to the right somehow! Right now it's stuck in center-ish, and no matter what I do, I can't seem to figure out what is causing it.

Also, when I try to add colour to the current date, the whole thing messes up. I guess there is som fomating conflict somewhere, but as I said, I'm completely new to this. This is the code I have been trying to implement without luck:

sed "s/[^0-9]$(date +%e | sed s'/ //')\([^0-9]\)/ $(date +%e | sed 's/ *\([0-9]*\)/\1/')\1/" |

Sorry if this seems way off the right track, but after hours of trying, I would really appreciate a push in the right direction!

The first image shows how it looks like, and the second shows what I have been trying to do:
 

Attachments

  • actual output.png
    actual output.png
    90.6 KB · Views: 1,854
  • desiredoutput.jpg
    desiredoutput.jpg
    83 KB · Views: 1,815
o0o I like your background :)
For album artwork, I use an app called Bowtie...works awesome!
For iTunes playing and paused, put this into Applescript Editor & then do the same with your shell command osascript...
PHP:
on run
	set info to ""
	tell application "System Events"
		set num to count (every process whose name is "iTunes")
	end tell
	if num > 0 then
		tell application "iTunes"
			if player state is playing then
				set info to "iTunes Now Playing:"
			else if player state is paused then
				set info to "iTunes Paused:"
			else
				set info to " "
			end if
		end tell
	end if
	return info
end run
For your track title and artist, post your script on here & i'll try to figure it out for you :)
With your flip-clock not working, what do you mean? What picture are you talking about?
I haven't messed with weather.com or my weather image yet. I've been busy working since Friday. If I have any problems with the weather image, i'll be coming to you about that hah :D

on run
set info to ""
tell application "System Events"
set num to count (every process whose name is "iTunes")
end tell
if num > 0 then
tell application "iTunes"
if player state is playing then
set who to artist of current track
set what to name of current track
set onwhat to album of current track
set stars to (rating of current track) / 20 as integer
set info to (what & who)
end if
end tell
end if
return info
end run

This works correctly there is just no space between the title and artist.

What i mean by the flip clock is that the time (hour and minuets) are not overlaying on top of the flip clock in the little squares. and i had the day and date on the flip clock as well, like you have it. For some reason it stopped working correctly and wont let me overlay the time and stuff.. it just randomly stopped working..Idk? lol and i can try to help with the weather stuff lol..it was a miracle that i got it working.. haha
 
Spotify/Itunes script

Hi!
I have just started using GeekTool, so i am pretty much the biggest noob you can get. :eek:

I tried to modify a Spotify/Itunes script so that instead of displaying: Spotify: Track - Artist - Album, i rather wanted: Spotify: Artist - Track.
But no matter what i tried it either went blank or did not change at all.
Could you guys point out the error for me?

Thanks for any help you can give.


Original Spotify/Itunes script:

DATA=$(osascript -e '
tell application "System Events"
set myList to (name of every process)
end tell

set output to ""

set i_track to ""
set i_artist to ""
set i_album to ""
set i_state to ""

set s_track to ""
set s_artist to ""
set s_album to ""
set s_state to ""

if myList contains "iTunes" then
tell application "iTunes"
if player state is stopped then
set i_state to "stop"
else
set i_track to name of current track
set i_artist to artist of current track
set i_album to album of current track
if player state is playing then
set i_state to "play"
else if player state is paused then
set i_state to "pause"
end if
end if
end tell
end if
if myList contains "Spotify" then
tell application "Spotify"
if player state is stopped then
set s_state to "stop"
else
set s_track to name of current track
set s_artist to artist of current track
set s_album to album of current track
if player state is playing then
set s_state to "play"
else if player state is paused then
set s_state to "pause"
end if
end if
end tell
else
set output to ""
end if

if s_state = "play" then
if i_state = "play" then
set output to "Spotify: " & s_track & " by " & s_artist & " (" & s_album & ")\riTunes: " & i_track & " by " & i_artist & " (" & i_album & ")"
else if i_state = "pause" then
set output to "Spotify: " & s_track & " by " & s_artist & " (" & s_album & ")\riTunes: Paused." & i_track & " by " & i_artist & " (" & i_album & ")"
else if i_state = "stop" or i_state = "" then
set output to "Spotify: " & s_track & " by " & s_artist & " (" & s_album & ")"
end if
else if s_state = "pause" then
if i_state = "play" then
set output to "iTunes: " & i_track & " by " & i_artist & " (" & i_album & ")\rSpotify: Paused. " & s_track & " by " & s_artist & " (" & s_album & ")"
else if i_state = "pause" then
set output to "iTunes: Paused. " & i_track & " by " & i_artist & " (" & i_album & ")\rSpotify: Paused. " & s_track & " by " & s_artist & " (" & s_album & ")"
else if i_state = "stop" or i_state = "" then
set output to "Spotify: Paused. " & s_track & " by " & s_artist & " (" & s_album & ")"
end if
else if s_state = "stop" or s_state = "" then
if i_state = "play" then
set output to "iTunes: " & i_track & " by " & i_artist & " (" & i_album & ")"
else if i_state = "pause" then
set output to "iTunes: Paused. " & i_track & " by " & i_artist & " (" & i_album & ")"
else if i_state = "stop" or i_state = "" then
set output to ""
end if
end if
')


echo $DATA | awk -F new_line '{print $1}'
 
error message

So Dunkm1n asked in this thread about a digg news feed reader for geektool.

I got bored and made one, here it is for everybody to use (all these readers are based off the same code, it's really trivial to get the info you need from Python).

Save the code as digg_news_grabber.py and chmod +x the file.
Code:
#!/usr/bin/env python

# MODULE IMPORTS
import xml.dom.minidom
import re

# CLASS TO HOLD THE DATA FOR A TO DO GROUP
class diggNewsItem():
    def __init__(self):
        self.title = ""
        self.link = ""
        self.desc = ""
        self.pubdate = ""
        self.dcount = ""
        self.dcategory = ""

# GET THE FEED - UPDATE TO CMD LINE ARGUMENT
# BE SURE TO HAVE THE URL REDIRECT THE URL FROM THE COMMAND LINE WITH 
# THE FOLLOWING COMMAND
# curl --silent "url goes here in quotations or else it won't work" > /tmp/digg_news_feed.xml
dom = xml.dom.minidom.parse("/tmp/digg_news_feed.xml")

# LIST TO HOLD ALL THE TASKS (toDo CLASS)
diggNews = []

# INLINE FUNCTIONS - DON'T FEEL LIKE CLASSING THIS UP
def getText(nodelist):
    rc = []
    for node in nodelist:
        if node.nodeType == node.TEXT_NODE:
            rc.append(node.data)
    return ''.join(rc)

def handleFeed(feed,diggNews):
    items = feed.getElementsByTagName("item")
    handleNewsItem(items,diggNews)

def handleNewsItem(items,diggNews):
    for item in items:
        # CREATE TEMPORARY TODO
        tmpCls = diggNewsItem()
        # GET THE DATA FROM THE CURRENT ITEM
        title = item.getElementsByTagName("title")[0]
        link = item.getElementsByTagName("link")[0]
        pubdate = item.getElementsByTagName("pubDate")[0]
        desc = item.getElementsByTagName("description")[0]
        dcount = item.getElementsByTagName("digg:diggCount")[0]
        dcat = item.getElementsByTagName("digg:category")[0]
        # GET THE VALUES FROM THE TAGS
        tmpCls.title = getText(title.childNodes).strip()
        tmpCls.link = getText(link.childNodes).strip()
        tmpCls.desc = getText(desc.childNodes).strip()
        tmpCls.pubdate = getText(pubdate.childNodes).strip()
        tmpCls.dcount = getText(dcount.childNodes).strip()
        tmpCls.dcategory = getText(dcat.childNodes).strip()
        # APPEND TEMP DIGG NEWS CLASS TO DIGG NEWS LIST
        diggNews.append(tmpCls)
        
# HANDLE THE XML
handleFeed(dom,diggNews)

# PRINT OUT THE TASKS
# THIS IS CUSTOMIZABLE
for i in range(len(diggNews)):
    # PRINT OUT THE DATA HOWEVER YOU WANT
    # DATA STORED IN EACH diggNews SEGMENT
    # diggNews[i].title   = TITLE OF THE NEWS ITEM
    # diggNews[i].desc    = DESCRIPTION OF THE NEWS ITEM
    # diggNews[i].link    = NEWS ITEM LINK
    # diggNews[i].pubdate = DATE THE NEWS ITEM WAS PUBLISHED
    # diggNews[i].dcount  = NUMBER OF DIGG COUNTS
    # diggNews[i].dcat    = CATEGORY
    # CURRENTLY SET TO PRINT THE DIGG COUNT AND THEN THE TITLE
    print "(" + diggNews[i].dcount + ") " + diggNews[i].title

For Geektool, use the following commands. Dunkm1n wanted the top news, but if you have a digg account, you could probably pull one of your feeds through, just place it between the quotes in the curl statement.
Code:
curl --silent "http://services.digg.com/2.0/story.getTopNews?type=rss" > /tmp/digg_news_feed.xml;
python /path/to/your/script/digg_news_grabber.py

Output is customizable (available variables are detailed in the script), I pulled the important information from the XML. The default output is as follows:
Code:
(103) How Science Saved My Soul [Video]
(103) 8 Great Laptops With WiMAX 4G
(102) What Are Capital Gains? (Graphic)
(106) Pervert Paid Pack of 12y/o Girls Thousands of Dollars to Fulfill His Sexual Wish List
(115) In Case You Still Don’t Understand What Happened November 2
(101) Facebook fan numbers accurately predict 81% of midterm election results
(116) It's time you wear brown ribons [Pic]
(134) Men Are So Under Appreciated (Pic)
(111) Exactly what kind of people watch Leno, Conan, and Letterman?
(102) The Top 8 Songs To Listen To While Punching Yourself in the Face
(108) Michael Douglas’ 7 Year-Old Daughter Takes Care Of Him, Makes Him Smoothies So He’ll Gain Weight!
(105) Scientists Make Breakthrough in Invisibility Clothing, Stalkers Rejoice
(111) 10 Toys That Will Permanently Screw Up Your Kid
(126) Fiscal Responsibility And Runaway Military Spending Are Not Compatible
(182) Is Xbox Kinect Racist? Not Even Close (Screw You Gamespot)
(119) Startup Turns 10,000 Lbs of Landfill-Bound Coffee Grounds into Oyster Mushrooms
(120) People who swallow foreign objects: Medical treatment is costly
(107) First look at the new 'Tron' costumes (pics)
(130) Attempted Abduction of 11-Year-Old Girl a Hoax; Girl Made Up Story
(125) Shirtless Toolbag gets Tased at a Subway (Video)
(The output is the current news when I pulled the feed down with the curl redirect)


I get following error message, any idea to solve this error?

./digg_news_grabber1.py
Traceback (most recent call last):
File "./digg_news_grabber1.py", line 60, in <module>
handleFeed(dom,diggNews)
File "./digg_news_grabber1.py", line 36, in handleFeed
handleNewsItem(items,diggNews)
File "./digg_news_grabber1.py", line 47, in handleNewsItem
dcount = item.getElementsByTagName("digg:diggCount")[0]
IndexError: list index out of range


Thanks Matthias
 
I've been trying to come up with a solution for this, but my limited knowledge of building scripts is failing me on this front!

I'm trying to find a "now playing" script for an app called Soundcloud, a music streaming service similar to spotify. It can be found on the Mac app store here (free download);
http://itunes.apple.com/gb/app/soundcloud/id412754595?mt=12

If anybody can come up with something functional I'd be reallllllly appreciative, this thing has taken over from spotify for me recently and would love to have track names on my desktop!
 
Code:
echo `cal`" " |
sed "s/[^0-9]$(date +%e | sed s'/ //')\([^0-9]\)/ $(date +%e | sed 's/ *\([0-9]*\)/\1/')\1/" |
sed s'/ $//' |
sed s'/Su Mo Tu We Th Fr Sa//g' |
sed s'/ / \ •  /g' |
sed s'/\([a-z]\)[ ]\ ./\1/g' |
sed s'/\•[ ]*\•/ /'|
sed s"/$/     $(date +%A)/"
This should work. Essentially anything with a backward slash is asking for a character to look for (regular expressions), so you need to replace all of the periods with bullets.
 
Hi all...
I've been trying to put a RSS feed of my Dropbox folder in geektool, but I have something weird happening... here's the file im using :
Code:
#!/bin/sh

URL="dropbox rss link"

if [ $# -eq 1 ] ; then
  headarg=$(( $1 * 2 ))
else
  headarg="-8"
fi

curl --silent "$URL" | grep -E '(title>|description>)' | \
  sed -n '4,$p' | \
  sed -e 's/<title>//' -e 's/<\/title>//' -e 's/<description>/   /' \
      -e 's/<\/description>//' | \
  sed -e 's/<!\[CDATA\[//g' |            
  sed -e 's/\]\]>//g' |             
  head $headarg | sed G | fmt
and I'm putting this in geektool
Code:
sh /PATH/TO/SCRIPT/file.sh -5
It works, but thats what I get... So I dont get the full lines and there's too much space between every lines.
 

Attachments

  • Screen Shot 2011-09-07 at 3.05.43 PM.png
    Screen Shot 2011-09-07 at 3.05.43 PM.png
    20.1 KB · Views: 103
Last edited:
I get following error message, any idea to solve this error?

./digg_news_grabber1.py
Traceback (most recent call last):
File "./digg_news_grabber1.py", line 60, in <module>
handleFeed(dom,diggNews)
File "./digg_news_grabber1.py", line 36, in handleFeed
handleNewsItem(items,diggNews)
File "./digg_news_grabber1.py", line 47, in handleNewsItem
dcount = item.getElementsByTagName("digg:diggCount")[0]
IndexError: list index out of range


Thanks Matthias

Matthias,

Digg changed how their feed is setup, so the script wasn't parsing things properly. I have since corrected this and added a feature; you no longer have to use the curl command to get the news feed into a temporary file. The python script now uses the url that was in the original post to grab data.

Here is the new code:
Code:
#!/usr/bin/env python

""" DIGG_NEWS_FEED_GRABBER
 ROBERT WOLTERMAN (xtacocorex) - 2010

 PULLS THE CURRENT NEWS FROM DIGG.COM
 
"""

# DIGG NEWS FEED - VERSION 2
# ROBERT WOLTERMAN - 2010
# PULLS THE CURRENT NEWS FROM DIGG.COM

# CHANGELOG
# 07 SEPTEMBER 2011:
#  - UPDATED TO WORK WITH NEW DIGG RSS FEED HIERARCHY
#  - REMOVED DEPENDENCY ON READING FROM TEMPORARY FILES
#  - ADDED:
#     - USE OF URLLIB TO GRAB HTML DATA
# 04 NOVEMBER 2010:
#  - INITIAL WRITE


# MODULE IMPORTS
import xml.dom.minidom
import re
import urllib

# DEFINE URL HERE
FEEDURL = "http://services.digg.com/2.0/story.getTopNews?type=rss"

# CLASS TO HOLD THE DATA FOR A TO DO GROUP
class diggNewsItem():
    def __init__(self):
        self.title = ""
        self.link = ""
        self.desc = ""
        self.pubdate = ""
        self.dcount = ""
        self.dcategory = ""

# GET THE FEED - UPDATE TO CMD LINE ARGUMENT
# BE SURE TO HAVE THE URL REDIRECT THE URL FROM THE COMMAND LINE WITH 
# THE FOLLOWING COMMAND
# curl --silent "url goes here in quotations or else it won't work" > /tmp/digg_news_feed.xml
#dom = xml.dom.minidom.parse("/tmp/news_feed.xml")
dom = xml.dom.minidom.parse(urllib.urlopen(FEEDURL))

# LIST TO HOLD ALL THE TASKS (toDo CLASS)
diggNews = []

# INLINE FUNCTIONS - DON'T FEEL LIKE CLASSING THIS UP
def getText(nodelist):
    rc = []
    for node in nodelist:
        if node.nodeType == node.TEXT_NODE:
            rc.append(node.data)
    return ''.join(rc)

def handleFeed(feed,diggNews):
    items = feed.getElementsByTagName("entry")
    handleNewsItem(items,diggNews)

def handleNewsItem(items,diggNews):
    for item in items:
        # CREATE TEMPORARY TODO
        tmpCls = diggNewsItem()
        # GET THE DATA FROM THE CURRENT ITEM
        title = item.getElementsByTagName("title")[0]
        link = item.getElementsByTagName("link")[0]
        pubdate = item.getElementsByTagName("updated")[0]
        desc = item.getElementsByTagName("content")[0]
        dcount = item.getElementsByTagName("digg:diggCount")[0]
        dcat = item.getElementsByTagName("digg:category")[0]
        # GET THE VALUES FROM THE TAGS
        tmpCls.title = getText(title.childNodes).strip()
        tmpCls.link = getText(link.childNodes).strip()
        tmpCls.desc = getText(desc.childNodes).strip()
        tmpCls.pubdate = getText(pubdate.childNodes).strip()
        tmpCls.dcount = getText(dcount.childNodes).strip()
        tmpCls.dcategory = getText(dcat.childNodes).strip()
        # APPEND TEMP DIGG NEWS CLASS TO DIGG NEWS LIST
        diggNews.append(tmpCls)
        
# HANDLE THE XML
handleFeed(dom,diggNews)

# PRINT OUT THE TASKS
# THIS IS CUSTOMIZABLE
for i in range(len(diggNews)):
    # PRINT OUT THE DATA HOWEVER YOU WANT
    # DATA STORED IN EACH diggNews SEGMENT
    # diggNews[i].title   = TITLE OF THE NEWS ITEM
    # diggNews[i].desc    = DESCRIPTION OF THE NEWS ITEM
    # diggNews[i].link    = NEWS ITEM LINK
    # diggNews[i].pubdate = DATE THE NEWS ITEM WAS PUBLISHED
    # diggNews[i].dcount  = NUMBER OF DIGG COUNTS
    # diggNews[i].dcat    = CATEGORY
    # CURRENTLY SET TO PRINT THE DIGG COUNT AND THEN THE TITLE
    print "(" + diggNews[i].dcount + ") " + diggNews[i].title

To use:
Code:
python /path/to/script/digg_news_grabber.py

Remember to chmod +x the file to make it executable.
 
Hi all...
I've been trying to put a RSS feed of my Dropbox folder in geektool, but I have something weird happening... here's

The problem with the news.sh file is that it assumes that all RSS feed files are equal, which they are not. (Some are more equal than others :))

I think the issue may be the regex removing fields in the description tag. I'll see what I can do in a bit, have to head in to work and do some other stuff around the house tonight.
 
Is osascript broken in 10.7(.1)? Any applescripts i've been trying to run via geektool seemingly run however they never provide any output but instead remain empty within geeklet. For example I have the following code:

Code:
echo 'Skype:'; osascript ~/Documents/Scripts/SkypeOnlineUsers.scpt | tr , "\n" | iconv -f UTF-8 -t L1

However it does not seem work correctly, neither do any of my other osascript commands for weather etc. The above script simply says 'Skype:' from it's echo command but does not display any info. Any help would be appreciated. Thanks!

I had issues with the Skype contact list with Nerdtool in Snow Leopard, so I don't think it's a OS 10.7 issue. I don't have a Lion capable machine, so I can't test my applescripts, so I can't get an idea if my iTunes one would work.
 
problems with weather geek tool

I got my city to show up but am confused on why the code is showing up.
I just want current and forecast.

Screenshot2011-09-07at103343PM.png
 
Pie Chart Clock Geeklet

Just finished a Pie Chart Clock Geeklet. Check it out here: http://blog.scottmcclung.com/2011/09/pie-chart-clock-geeklet-for-geektool.html

----------

Very cool.

I noticed in your screen shot however, that your binary clock says 03:45:48, which matches the system time, but the fuzzy clock words say "quarter to three."

Thanks. Nice catch, glad you pointed it out. I had forgotten to fix that bug on that machine. I've updated the image now.

Cheers!
 
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.