PyMediaServer
 

Abstract

PyMediaServer is a UPnP Media Server for use with a Netgear MP101 Digital Music Player and was designed to provide a Linux alternative to the Windows-based Media Server provided by the Netgear. If you're disappointed with the media server provided by TwonkyMedia, you've come to the right place.


Features

PyMediaServer is slowly becoming more feature-rich with each release. Is still remains however a basic UPnP media server implementation that works well enough for me to enjoy my Netgear MP101 when the PC is booted into Linux.

PyMediaServer currently:

  • Supports the Netgear MP101 (and has not been tested with any other UPnP client devices)
  • Supports browsing MP3s (only MP3s at this point) via the UPnP ContentDirectory service
  • Supports ordering MP3s found in a given folder via track number if those track numbers are available via ID3v2
  • Supports organization by Artist
  • Supports organization by Album
  • Supports organization by Genre
  • Supports organization by Playlist (Graphical Mode Only)
  • Supports playing MP3s via RTSP and RTP/UDP to the MP101
  • Supports loading content via an Amarok database

Additional features I'd like to include are:

  • Internet Radio support
  • Improved Installer
  • WMA support
  • Additional Media Player support

Make sure and hit the Feature Requests page and submit your request.


Dependencies

PyMediaServer is written in Python and was developed using Python 2.4.3 on a Fedora Core 5 and Fedora Core 6 Linux machine. It makes use of the Twisted event-driven networking framework as well as other additional Python modules.

The following Python modules are required by PyMediaServer:

Installation of these packages/modules first are required for proper operation.

For graphical support and playlist editing with version 0.3.0 and greater, the following packages are also required.

For support of using the Amarok database as your media content the following additional modules are required:

The Amarok 1.4.4 database format is supported with both MySQL and SQLLite support.

The latest version, 0.6.0, includes a syscheck.py script that can be used to determine if you have all of the prerequisite modules installed. Execute syscheck.py and it will inform you of the modules you might be missing.

Additional Notes on Dependencies

Only Twisted 2.4.0 is currently supported - higher versions of Twisted have apparently broken compatability with Twisted Web2. Do not use PyMediaServer with any Twisted version higher than 2.4.0 until this is resolved.

Python 2.5 contains support for the sqlite database and can be used with an Amarok installation using sqlite. To use the sqlite database with Amarok use the >--use-amarok-sqlitedb option. Since sqlite database support is not included in Python 2.4, this option will not work with Python 2.4.

I personally use Fedora Core 6 and do not have any other installations available at this time. For those using other installations please be aware that there may be incompatibilities such as:

  • the network interface name is something other than eth0, if this is the case for your installation please use the --network-interface option to change to yours
  • the default Python installation may be different, anything less than Python 2.4.0 may not work
  • anything else I can't think of may be different - if you are having issues feel free to contact me but remember I may not have access to a configuration identical to yours

Network Security

For those systems that have relatively strict firewall rules installed you will need to open the following ports:

  • 1900/udp - Used for SSDP discovery (how the Netgear MP101 finds PyMediaServer on the network)
  • 7000/udp - Used for RTSP messages (how the Netgear MP101 tells the PyMediaServer to start or stop streaming)
  • 49152/tcp - Used for UPnP messages (how the Netgear MP101 browses the content served by PyMediaServer)

The procedure for enabling these ports is dependent on your Linux installation. For Fedora Core systems I used system-config-securitylevel and added the ports in the "Other Ports" pane.


Download

The current version is 0.6.0 and is submitted as the mainline (trunk) to Subversion.

Downloading via HTTP

The current version can be downloaded via HTTP at http://prdownloads.sourceforge.net/pymediaserver/pymediaserver-0.6.0.tar.gz?download.

Downloading via Subversion

You should be able to use:

  svn co https://pymediaserver.svn.sourceforge.net/svnroot/pymediaserver/trunk pymediaserver
  

to download the current released version at all times. Development will be ongoing in the branches directory of the project, and tagged versions will be present in the tags directory.

Feel free to browse the Subversion repository for PyMediaServer.


Installing

The installation process at the moment is straightforward, though there are some noted issues with it.

In a nutshell I recommend downloading the source to /usr/src or /usr/local/src and then running install.sh in the pymediaserver directory. This merely creates a link from /usr/bin/pymediaserver to the MediaServer.py file. You will have to edit install.sh if you want the link created in a different bin directory.


Running

Running pymediaserver can be done in one of several modes:

  • Loading new MP3 content by specifying a directory path
  • Loading MP3 content from an Amarok database
  • Loading previously saved MP3 content with no command-line arguments
  • Graphical mode (which can be used in conjunction with the two above) for editing playlists

Command Line Only Mode

Specifying a Media Directory

  pymediaserver --media-directory=/path/to/mp3s
  

will scan the directory /path/to/mp3s looking for MP3s and directories containing MP3s to present to the MP101.

Using the Amarok Database

  pymediaserver --use-amarok-database=dbname,userid,passwd
  

will attempt to connect to a MySQL database of 'dbname' with the userid and password given and read it as an Amarok database of media content.

Obviously, the MySQL server must be configured and running properly, the database must exist, and the userid/password combination must allow access to the database.

For the security sensitive, the commandline options are displayed in a process listing or /proc directory, keep that in mind if you are concerned about using a sensitive password.

  pymediaserver --use-amarok-sqlite
  

can be used to load an Amarok sqlite-based database.

Reload Existing Saved Content

With no arguments,

  pymediaserver 
  

will load a previously saved content set. If there was no previously saved content the server will exit.

Graphical Mode

Specifying --graphical=1 with any of the above options (but only one) will bring up the graphical playlist editor.

Additional Options

    --network-interface - If the system happens to be using a network interface
                          other than eth0, specify it here.  Currently I don't
                          know of an elegant way to obtain the IP address of
                          the machine that is portable.

                          For example, if your machine is connected via a 
                          wireless LAN you might use:

                          --network-interface wlan0

    --log-level  - For those curious to see what PyMediaServer is doing,
                   setting to the DEBUG level will print out the XML 
                   UPnP messages exchanged between the MP101 and the server

    --log-file   - Sends log messages to the filename given, logging defaults
                   to standard output

    --help       - Prints out a help message
  


Bugs

As of 0.6.0 there are two issues that I know that should be worked on:

  • MP3s downloaded from Emusic.com contain ID3 tags that are incompatible with the pytagger software that PyMediaServer uses. MP3s downloaded from Emusic.com may not work properly at this time.
  • Files that are in stored dictionaries or playlists that disappear (such as a lost NFS mount) aren't handled well (as in, a server exit).
  • Some foreign (foreign as in not used in United States English) characters in filenames or tags wreak havoc, this should be fixed in the next version

As of May 31, 2008, I have started a Bugzilla project for pymediaserver at http://thegang.selfip.net:8080/bugzilla/. Please help in improving this software by logging bug reports and feature requests here.

For those interested in reviewing the Python code and helping in finding defects let me know by sending me an e-mail. My personal web server hosts an installation of Code Collaborator (TM) from SmartBear that allows individuals to inspect and mark code defects.


Contact

I can be reached via mojojoseph@users.sourceforge.net. I am particularly interested in usability comments, feature requests, and folks testing the server out with a media client other than the MP101.


History & Disclaimer

This project came about by my desire to use my Netgear MP101 box when my home PC was booted into Linux. As the packaged software only supports Windows I went out to the web to search for a UPnP-based media server that would support the MP101 adequately. Although I came across TwonkyMedia's player as well as the gmediaserver software, neither of them satisifed me. Not to mention TwonkyMedia's player expired after 30 days.

Although a C++ software developer by trade, I typically loathe writing any personal software in C++ because I find it particularly painful. I remain a big fan of Perl for text-processing chores, but for this project decided to learn the Python language. By luck I came across the Twisted event-driven networking framework and it seemed particularly suited for what I wanted to accomplish.

Since this is a home project and was cobbled together while learning Python, XML, Twisted, RTP, RTSP, etc., I can't be held responsible for the "cleanliness" of the code or whether it maintains the high standard for "Pythonic" programming practices. For example, if you do go reading through the code you can see where I was trying to figure out what Python XML library to use: MediaServer.py uses xml.dom whereas ContentDirectory.py uses ElementTree. Over time I will be rearchitecting it quite a bit to get rid of the cruft as well as streamline it.



Contents
Abstract
Features
Screenshot
Dependencies
Download
Installing
Running
Bugs
Contact
History & Disclaimer






Last modified by mojojoseph on
This site is © 2008 Joseph Bell, All Rights Reserved.

and brought to you by
SourceForge.net Logo
Web templates