Eubolist's Blog

about IT, Linux, the web and much more

Posts Tagged ‘Python

MythNetTV-Status Page

leave a comment »

I wrote a little script the other day so I could sporadically check on the progress and last downloaded shows of mythnettv on my mythtv-box.  The package “mythnettv-gui” sets up a nice cronjob that creates a log file, which my script uses to deliver the information. You can download the script here.

All you have to do is put the script in place and tell your system with crontab -e to execute it every now and then:

# m h  dom mon dow   command

* * * * * /usr/local/bin/

For the lazy reader here is a complete set of commands, just copy-paste in a terminal to download and set everything up:

wget && mv && unzip && sudo mv /usr/local/bin && sudo cp var/www/mythnettv-status /var/www && rm -Rf var && crontab -l > cron.tmp && echo “* * * * * /usr/local/bin/” >> cron.tmp && crontab cron.tmp && rm cron.tmp

Written by eubolist

2010/12/24 at 12:36

Python Script: Merge and sort multiple RSS Feed items in one Feed

with 3 comments

In my first blog post a while back I wrote about showrss and how to concatenate multiple tv-shows into one personalized rss feed.

I’ve been using their service for about a year now and am quite happy with it. Sadly though, despite multiple requests, they haven’t included National Geographic and Discovery Channel documentaries yet. So today I took the time and wrote customfeed, a little python script that is able to fetch multiple feeds, sort the items and concatenate them in the right order to a new feed. Although I wrote the script for use with ezRSS feeds, it should work just as well with any other feeds (might need some little modifications or tweaks though).

The script depends on python-feedparser, so make sure you have that one installed:

sudo aptitude install python-feedparser


sudo easy_install feedparser

The most convenient way is to set up a cronjob that executes every few hours or so. Mine looks like this:

24 */6 * * * /usr/local/bin/

Written by eubolist

2010/12/24 at 02:12

A simple way to enable .py Python CGI scripts on Lighttpd (“Lighty”) webserver on Ubuntu

leave a comment »

After multiple, failed, attempts with mod_fastcgi I found a simple three step solution to enable python scripts on my webserver:

  1. sudo ln -s /etc/lighttpd/conf-available/10-cgi.conf /etc/lighttpd/conf-enabled/
  2. Add the following section to your /etc/lighttpd/lighttpd.conf file:
    ### Python Config ###
    cgi.assign = (

    “.py” => “/usr/bin/python”
  3. Restart lighty: sudo /etc/init.d/lighttpd restart

That should do the trick. As it says in the title, this is a simple and painless way to enable Python CGI scripts on lighty.

Written by eubolist

2010/06/13 at 15:06

AnkiMiniSync Version 0.1, an ‘offline’ sync script for AnkiMini (on the iPad)

with one comment

Since I didn’t want to use the Anki Online service to sync AnkiMini on my jailbroken iPad and Anki on my Laptop I always had to copy the recent version from/to my iPad over ssh (sshfs). To automate that task a bit and save me some time I wrote this little sync script. It basically compares the two .anki decks in the local and the remote folder and replaces the older with the newer version. It does however -NOT- read the .anki file and merge the files properly. That means you can only work on one machine and then have to sync before you start working on the other one. It also means working on more than one mobile device is not possible (well, it’s possible but you’ll lose data through the sync process).
There are still some restrictions in this first version:
-Your username and directory where the Anki deck is stored must not contain any whitespaces (will be hopefully be solved in v.0.2)
-You can only sync one deck at a time (functionality to sync whole folders is planned for v.0.2)
-The .anki folder must be directly in the mounted directory of the sshfs volume
-You should have public key authentification turned on
-As far as I know this script only works on *nix systems, I have only tested it on OSX so far
If you encounter any bugs or problems besides the above don’t hesitate and write a comment! Don’t write any bug reports in the Anki support forums or to the developers of Anki (or AnkiMini), they have nothing to do with this.
Contributions to the code are always welcome of course. You are also allowed to use the code or parts of the code anywhere else, though it’d be nice to notify me somewhere along the way.
AnkiMiniSync IconLink to

Anki: An Intelligent Study Card System For Any OS

with 3 comments

A month ago I was looking for a new computer-based method to improve my study schedule. After a bit of searching in the endless depth of the web I discovered Anki, a flash card application that has several very useful features:

  • It is written in Python and available for Windows, Linux, Mac OS X and FreeBSD – which means it runs on virtually any computer.
  • There are a lot of  “Decks” (=sets of flashcards built by other users) already available on the web
  • The interface is really nice and intuitive, adding sound, video or pictures to your cards is very easy, thus can be accomplished by people with little experience with computers. Also there are many options to adjust the program to your study habits.
  • Anki uses spaced repetition. After each card you have to say how well you remembered it – based on that Anki will set the interval after which the card will be brought up again. With this technique facts will be pushed into your long-term memory. That means you won’t experience black outs in exams anymore as the hormone cortisol, released by your body in situations of psychological stress, only affects the short term but not the long term memory.

If that made you curious, why don’t you give it a try! Here are the download links:


Ubuntu (you can also install it with apt-get/aptitude, but the version in the repositories is pretty old)




Written by eubolist

2010/03/14 at 21:10

Set up LIRC to control your Ubuntu/MythTV Box with a Microsoft Media Center Edition (MCE) infrared remote control

with one comment

I wanted to control my MythTV-Box like I used to control my old receiver with a good old fashioned IR remote rather than with keyboard and mouse. That’s why I went to eBay and bought myself a cheap MCE remote, you can have them shipped from China for less than 20 bucks:

I didn’t know whether the device was Linux compatible, so I just plugged it in and took it from there:

~$ lsusb

Bus 003 Device 002: ID 045e:006d Microsoft Corp. eHome Remote Control Keyboard keys

Looks good. Let’s install the latest version of lirc:

~$ sudo aptitude update && sudo aptitude install lirc

Then let’s check whether lirc picks up correct signals from our remote:

~$ irw

Then press the OK or any other button and the output should look somewhat like this:

000000037ff07bdd 00 OK mceusb

If it does: Congratulations, you’ve got a lirc compatible infrared remote! Exit irw by pressing [Ctrl + C].

LIRC normally runs at system start as a daemon (=runs in background). It reads a file called “.lircrc” in your home directory, in this file you can specify a command for each button. You can even specify custom keybindings for different programs, let’s have a look at my .lircrc file:

~$ cat .lircrc

include /home/eubolist/.mythtv/lircrc                             –> Here we specify which configuration
include /home/eubolist/.lircfiles/vlc                                       files to include in addition to this one
include /home/eubolist/.lircfiles/rhythmbox

prog = irexec                –> irexec means that lirc will
button = Home                   pick up your command no matter which program is running
config = python /home/eubolist/ir-scripts/ 

prog = irexec
button = TV
config = python /home/eubolist/ir-scripts/

prog = irexec
button = Videos
config = python /home/eubolist/ir-scripts/

prog = irexec
button = Music
config = python /home/eubolist/ir-scripts/

prog = irexec
button = Power
config = python /home/eubolist/ir-scripts/

Now you may ask yourself why I have some Python scripts specified as actions when I press certain buttons. The reason is simple, let’s have a look at

import commands
import os
import sys
import subprocess

output = commands.getoutput(‘ps -A’)

## Check whether vlc is running:              –> As I usually don’t need multiple instances of the same
if ‘vlc’ in output:                                    program running I want to check whether it’s already open

## If yes: either shut the process down
#       os.system(‘/usr/bin/killall vlc’)

## or do nothing:

## If not: Open vlc and end this script:

else: pid = subprocess.Popen(‘/usr/bin/vlc’).pid       –> If you just use os.system() again here the
sys.exit(0)                                        script will just stay open and keep irexec busy, if you press the button again it woud get queued and run again once you exit vlc

Now have fun toying around with Ubuntu and your ir remote control. If you have any questions, thoughts or criticism you are welcome to write a comment.