Create a gist now

Instantly share code, notes, and snippets.

@thedod /README.md
Last active Aug 29, 2015

webcomic2xbmc: feed enclosure tweak for xkcd, smbc, etc.

Some webcomics have RSS/ATOM feeds that include the images themselves. XBMC, however, require feeds to include the images as RSS enclosures. This script fetches a feed and prints an "XBMC-compliant" one to stdout. You can run a cron job that saves this to an http-accessible file on your pc. You can then use its URL as an rss picture source.

usaage: python webcomic2xbmc.py FEED_URL [IMG_URL_REGEXP]> myxbmcfeed.xml

Examples:

  • python webcomic2xbmc.py http://xkcd.com/rss.xml > ~/public_html/feeds/xkcd.xml
  • python webcomic2xbmc.py http://feeds.feedburner.com/DailyAndertoons "/toons/" > ~/public_html/feeds/andertoons.xml

In the second example, if you don't supply the "/toons/" regexp, you'll also get logos and "share this" graphic items in the feed. All cartoons are under a "/toons/" folder, so the regexp makes sure we don't get anything else.

Note that you can also use regular expression syntax: you could write "cartoon[0-9]+.png$" instead of "/toons/" and get the same results while feeling more geeky ;)

Here's how xkcd looks on my TV:

XKCD on XBMC

Feeds to try:

Please add your recommendations in the comments.

import sys,re,feedparser,PyRSS2Gen
if not (len(sys.argv) in [2,3]):
sys.stderr.write(
'usage: {0} FEED_URL [IMG_URL_REGEXP]> myxbmcfeed.xml\n'
@thedod
Owner
thedod commented Jul 7, 2014

The I has recommended Lunar Baboon (thanks).
Its feed http://www.lunarbaboon.com/comics/rss.xml has img src urls with query strings in them and that made mimetype matching go sour.

So no more mister mimetype: new [shorter] code produces enclosures with mimetype image/whadever. XBMC can deal with it. Back to the couch.
Lunar Baboon on XBMC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment