| Author: | Marc 'BlackJack' Rintsch |
|---|---|
| Contact: | marc@rintsch.de |
| Date: | 2004-12-03 |
| Version: | 0.5 |
| Copyright: | This document has been placed in the public domain. |
mkplaylist.py -- creates playlists from directory trees.
mkplaylist.py [-h|--help|--version] mkplaylist.py [options] directory [directory ...]
The directories are the ones where the scripts starts to search for media files.
The script scans the given directories for media files with known file name extensions and writes the names into a playlist file in M3U or extended M3U format. Those very simple formats are used or at least understood by the vast majority of media players on different platforms.
Symlinks to directories are not scanned to avoid running into cycles.
The script searches for the following file name extensions (case insensitive):
| Extension | Format |
|---|---|
| ac3 | ATSC A/52 |
| flac | Free Lossless Audio Codec |
| it | Impulse Tracker |
| mod | Amiga MOD |
| mp3 | MPEG 2 Layer 3 |
| ogg | Ogg Vorbis |
| s3m | Scream Tracker III |
| wav | Wave |
The script requires Python version 2.3 or higher.
For reading meta data from media files some third party modules are needed. The program will run without those modules, but doesn't generate meta information output for those formats ofcourse.
The MAD MP3 decoder and its python bindings are used to read the length of MP3 files.
| MAD: | http://www.underbit.com/products/mad/ |
|---|---|
| pyMAD: | http://spacepants.org/src/pymad/ |
For reading the information from ID3 tags the script at http://id3-py.sourceforge.net/ is used. Installation is quite easy: just put ID3.py into the directory where mkplaylist.py resides.
Beside the Ogg Vorbis codecs you will need Andrew Chatham's python bindings for them: http://www.andrewchatham.com/pyogg
--version show program's version number and exit -h, --help show this help message and exit -oOUTFILE, --output=OUTFILE name of the output file or '-' for stdout (default) -fOUTPUT_FORMAT, --output-format=OUTPUT_FORMAT format of the output ['extm3u', 'm3u'] (default: extm3u) --shuffle shuffle the playlist before saving it.
Scan the directory /data/music and write all media files into a (sorted) playlist named playlist.m3u:
./mkplaylist.py -o playlist.m3u /data/music
Scan the directories /data/music/Various and /data/Music/Soundtracks and write a shuffled playlist without meta information to standard output:
./mkplaylist.py -f m3u --shuffle /data/music/Various \
/data/music/Soundtracks
A very simple playlist format which just lists all media file names in a text file with one file name per row.
The M3U format extended with meta information for each file. There's an extra line which contains the playing time and a formatted name to be displayed by the player application.
Many thanks to Oliver Pütz for sharing patches and thoughts.
Finally meta data is extracted from MP3 and Ogg Vorbis files so this thingy does actually more than the find-based Bash script I used before for the job.
The script became a little bit more "silent" -- only directory names are printed and not every discovered media file.
The playlist is sorted now and can be shuffled with an option (--shuffle). It's possible to give more than one directory name at the command line.
There are many changes under the surface to allow extensions to read meta data from the media files and to support different output formats too. That's the reason for the new -f and --output-format options which are not very useful at the moment because the only allowed value is m3u which happens to be the default anyway.
None known yet. If you find some please send me a mail.
Copyright © 2004 Marc 'BlackJack' Rintsch <marc@rintsch.de>
This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.