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.
New shows airing today script

With the fall TV season about to start I wanted a better way to keep track of when new episodes of my favorite shows are airing. This little script displays the series and title of new episodes airing today.
It uses thetvdb.com's new shows rss feed and compares it to the api feed of shows you've selected as favorites on the site.
You can find your account id at the bottom of your account settings on thetvdb.com.

It uses the feedparser python lib to handle the rss. You can download that here. (very easy to install)

thetvdb.com new shows list is only updated once a day, so please make sure to set your refresh rate to once a day so it doesn't cause too much traffic for the site. They are an underfunded project so it's important to avoid unnecessary hits.

Code:
#!/usr/bin/env python
import feedparser, urllib2
from xml.etree import ElementTree as ET
# =========== CONFIG =============
# Insert your account id here. You can find it at 
# the bottom of your account settings page on thetvdb.com
ACCOUNTID = 'C2920FF6804FD948'
# ================================

new_shows = feedparser.parse('http://thetvdb.com/rss/newtoday.php')
favorites_feed = urllib2.urlopen('http://thetvdb.com/api/User_Favorites.php?accountid='+ACCOUNTID)
favorites = ET.XML(favorites_feed.read())
shows_list = []

for new_show in new_shows.entries:
	new_show_series = new_show.links[0].href
	new_show_series_id = new_show_series[new_show_series.find("seriesid=")+9:new_show_series.find("&seasonid")]
	for favorite in favorites:
		if(favorite.text == new_show_series_id):
			shows_list.append(new_show.title)

print "New episodes of favorite shows airing today:"			
if (len(shows_list)>0):
	for shows in shows_list:
		print "* "+shows
else:
	print "* No new shows today"
Cheers!

More of my scripts can be found at: http://blog.scottmcclung.com
 
Last edited:
Help..

Can someone pleas tell me how i can rotate Shells.. Do u need to script it, or is there some way i just can select how much i wanna rotate the shell?

Thanks to anyone who can help me :) trying to get my desktop finished, but just need the rotation..
 
Anyone? I would be happy with anything at all really : / Really frustrating to not understand this after so many hours. Just a hint would do!
 
Can someone pleas tell me how i can rotate Shells.. Do u need to script it, or is there some way i just can select how much i wanna rotate the shell?

Thanks to anyone who can help me :) trying to get my desktop finished, but just need the rotation..

Don't think you can rotate the shells. What I do for my month (it's rotated) is create an image with the text of each month and then have a Python script control copying the correct month file to a temporary image file that Nerdtool/Geektool can display.
 
geektool doesn't display anything

ok...i've just downloaded geektool and i've tried typing some simple code like this:

date +%A

and geektool just keep showing me nothing but the failure image...

i've tried to google for some answer, but after 2 hours i gave up. it was completely useless! Please help me!!!! i'm going a little crazy....:mad:

i'm running geektool v3.0 on a mac osx 10.6.

ps: since english is not my mother language, also any grammatical help will be fully appreciated!!! :) thanks a lot!!!
 
Don't think you can rotate the shells. What I do for my month (it's rotated) is create an image with the text of each month and then have a Python script control copying the correct month file to a temporary image file that Nerdtool/Geektool can display.


Thx. I thought of it, but wondered if there was any easier way to do it, but i guess not. ill just do it like u do, but thx again
 
I set up a stock market ticker and am wondering what I should set the refresh rate to as I don't want Google to block me.

I have mine update every hour since I don't really care about the minute to minute details of the stock market, but then again, I'm never home during the day, so it only updates when I get my MacBook out of sleep mode.
 
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 [

Got a script for you that works for me, all you have to do is put your feed url in between the quotes in the FEEDURL variable in the script.

Code:
#!/usr/bin/env python

""" DROPBOX_FEED_GRABBER
 ROBERT WOLTERMAN (xtacocorex) - 2010

 PULLS THE CURRENT FEED FROM YOUR DROPBOX ACCOUNT
 
"""

# DROPBOX FEED - VERSION 1
# ROBERT WOLTERMAN - 2011
# PULLS THE CURRENT FEED FROM YOUR DROPBOX ACCOUNT

# CHANGELOG
# 08 SEPTEMBER 2011:
#  - INITIAL WRITE

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

# DEFINE URL HERE
FEEDURL = ""

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

# GET THE FEED - UPDATE TO CMD LINE ARGUMENT
dom = xml.dom.minidom.parse(urllib.urlopen(FEEDURL))

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

# THE FOLLOWING TWO FUNCTIONS ARE FROM:
# http://love-python.blogspot.com/2008/07/strip-html-tags-using-python.html
# THEY WORK PERFECTLY
def remove_html_tags(data):
    p = re.compile(r'<.*?>')
    return p.sub('', data)    

def remove_extra_spaces(data):
    p = re.compile(r'\s+')
    return p.sub(' ', data)

# 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,dboxFeedItems):
    items = feed.getElementsByTagName("item")
    handleNewsItem(items,dboxFeedItems)

def handleNewsItem(items,dboxFeedItems):
    for item in items:
        # CREATE TEMPORARY TODO
        tmpCls = dboxItem()
        # GET THE DATA FROM THE CURRENT ITEM
        title = item.getElementsByTagName("title")[0]
        link = item.getElementsByTagName("link")[0]
        pubdate = item.getElementsByTagName("pubDate")[0]
        # DESCRIPTION USES CDATA INSIDE TO CONTAIN HTML ELEMENTS
        desc = item.getElementsByTagName("description")[0].firstChild.wholeText
        # GET THE VALUES FROM THE TAGS
        tmpCls.title = getText(title.childNodes).strip()
        tmpCls.link = getText(link.childNodes).strip()
        tmpCls.pubdate = getText(pubdate.childNodes).strip()
        # DESCRIPTION IS DIFFERENT BECAUSE OF THE CDATA USE
        tmpCls.desc = remove_extra_spaces(remove_html_tags(desc))
        # APPEND TEMP DROPBOX NEWS CLASS TO DROP BOX NEWS LIST
        dboxFeedItems.append(tmpCls)
        
# HANDLE THE XML
handleFeed(dom,dboxFeedItems)

# PRINT OUT THE DROPBOX NEWS
# THIS IS CUSTOMIZABLE
for i in range(len(dboxFeedItems)):
    # PRINT OUT THE DATA HOWEVER YOU WANT
    # DATA STORED IN EACH dboxFeedItems SEGMENT
    # dboxFeedItems[i].title   = TITLE OF THE NEWS ITEM
    # dboxFeedItems[i].desc    = DESCRIPTION OF THE NEWS ITEM
    # dboxFeedItems[i].link    = NEWS ITEM LINK
    # dboxFeedItems[i].pubdate = DATE THE NEWS ITEM WAS PUBLISHED
    print dboxFeedItems[i].desc

Same use as always, chmod +x the file.

If this looks remarkably similar to the Digg news feed, it is, but it isn't. I had to strip HTML tags in the description since it'll screw up the output in the shell.
 
I have mine update every hour since I don't really care about the minute to minute details of the stock market, but then again, I'm never home during the day, so it only updates when I get my MacBook out of sleep mode.

I set it to 120 seconds, and so far so good. I guess I will see over time.
 
ok...i've just downloaded geektool and i've tried typing some simple code like this:

date +%A

and geektool just keep showing me nothing but the failure image...

i've tried to google for some answer, but after 2 hours i gave up. it was completely useless! Please help me!!!! i'm going a little crazy....:mad:

i'm running geektool v3.0 on a mac osx 10.6.

ps: since english is not my mother language, also any grammatical help will be fully appreciated!!! :) thanks a lot!!!

Do you have the encoding for the shell properly? Are you using a shell geeklet? What is the refresh rate? If the refresh rate is too large, it won't automatically populate the geeklet with text.
 
How do I make this a Five day forecast?

How do I modify this for a five day forecast?

Code:
#!/bin/sh
#
# These variables have been commented out because you need to get the correct zip code of where you live for this to work if you are in the states
# otherwise you will have to get the correct yahoo weather xml link with corresponding Fahrenheit and Celsius parts of the URL.

# Once you have those URLS correctly placed inside this script, you must then uncomment the script by removing the hash symbols (#) from infront
# of the three lines below. Then your script should work properly.


forecast=`curl --silent "http://xml.weather.yahoo.com/forecastrss?p=USNJ0165&u=f" | grep -E '(High:)' | sed -e 's/<BR \/>//' -e 's/<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' -e 's/<br \/>//'`
myweather=`curl --silent "http://xml.weather.yahoo.com/forecastrss?p=USNJ0165&u=f" | grep -E '(Current Conditions:|F<BR)' | sed -e 's/Current Conditions://' -e 's/<br \/>//' -e 's/
<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' -e 's/<description>//'
 -e 's/<\/description>//'`
#myweatherc=`curl --silent "http://xml.weather.yahoo.com/forecastrss?p=USNJ0165&u=f" | grep -E '(Current Conditions:|C<BR)' | sed -e 's/Current Conditions://' -e 's/<br \/>//' -e 's/<b>//' -e 's/<\/b>//' -e 's/<BR \/>//' -e 's/<description>//' -e 's/<\/description>//' |  sed -e '/^$/d' | cut -d "," -f 2`

echo "$forecast"
$myweather -$myweatherc"
 
Do you have the encoding for the shell properly? Are you using a shell geeklet? What is the refresh rate? If the refresh rate is too large, it won't automatically populate the geeklet with text.

The refresh rate is 0. I think it's the exact opposite of 'large'! :)
Yes, i'm using a shell geeklet, and, No! I don't really know if i've the encoding for the shell properly! :) How can I check?
 
Refresh Rate

I believe a refresh rate of 0 means never. Try 1 second to get it to update the first time then set it to something more reasonable.
 
Here's my current desktop.

Just discovered Geektool yesterday, and I'm having such a blast tinkering around with it! What a fabulous program, even for those with limited technical knowledge.

 
Last edited by a moderator:
Got a script for you that works for me, all you have to do is put your feed url in between the quotes in the FEEDURL variable in the script.
Marry me? :D
Works perfect. Only one little modification, if you have time and you actually can, would be to be able to change the number of lines...
Thank you!
 
@ flo90p
i've tried changing from 0 to 1...but never happened...other ideas???
Maybe the classic mistake of black text on a black background. Been there done that, oops.:eek:
 
Help Fixing five day weather Geeklet

The following Geeklet produces funky html characters among the proper info. Can someone please fix it and remove the problem? Thanks. Original code by Ryan Knapper.

PHP:
curl --silent -o /tmp/weather.html http://weather.yahoo.com/united-states/oregon/portland-23424682/;

curl --silent -o /tmp/weather.png $(grep "div\ class=\"forecast-icon\"\ style=\"background:url" /tmp/weather.html| awk -F"'" '{ printf $2 }');for NUM in $(grep -n "<li><strong>.*\n" /tmp/weather.html|cut -d":" -f1); do TARGET=$((NUM+1)) ; sed -n "$NUM"p /tmp/weather.html|sed 's|<li><strong>||g'|sed 's|</strong>||g'| sed 's/^[\t]*//'; sed -n "$TARGET"p /tmp/weather.html ;

Here is the code without PHP wrap:
curl --silent -o /tmp/weather.html http://weather.yahoo.com/united-states/oregon/portland-23424682/;

curl --silent -o /tmp/weather.html http://weather.yahoo.com/united-states/oregon/portland-23424682/; curl --silent -o /tmp/weather.png $(grep "div\ class=\"forecast-icon\"\ style=\"background:url" /tmp/weather.html| awk -F"'" '{ printf $2 }');for NUM in $(grep -n "<li><strong>.*\n" /tmp/weather.html|cut -d":" -f1); do TARGET=$((NUM+1)) ; sed -n "$NUM"p /tmp/weather.html|sed 's|<li><strong>||g'|sed 's|</strong>||g'| sed 's/^[\t]*//'; sed -n "$TARGET"p /tmp/weather.html ; done
 
Last edited:
@ flo90p

Maybe the classic mistake of black text on a black background. Been there done that, oops.:eek:

Do you have the encoding for the shell properly? Are you using a shell geeklet? What is the refresh rate? If the refresh rate is too large, it won't automatically populate the geeklet with text.

i've tried the simple command :

echo "ciao" and it works...i tried again with date +%A and it came back to the annoying red failure image.

i read quite every post or tutorial on the subject. no one was even a little bit helpful! maybe i don't really have the right encoding for shell command, but i don't know how to check...
 
i've tried the simple command :

echo "ciao" and it works...i tried again with date +%A and it came back to the annoying red failure image.

i read quite every post or tutorial on the subject. no one was even a little bit helpful! maybe i don't really have the right encoding for shell command, but i don't know how to check...

I notice you're in Italy, you probably have the shell set to ascii and your computer is most likely set to unicode.

Change the shell encoding from ascii to unicode and you should get the day of the week.

----------

Marry me? :D
Works perfect. Only one little modification, if you have time and you actually can, would be to be able to change the number of lines...
Thank you!

Totally possible (on the script change, my wife probably wouldn't like the whole marriage thing with another person) , will work on that sometime soon here. Just got a new Logitech Wireless Trackball so I'm playing with that. :)

The script will output up to and including the max number of lines you specify.
 
Status
Not open for further replies.
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.