Menu
Index

Contact
Atom Feed
Comments Atom Feed

Similar Articles

2011-06-25 12:33
Dovecot stats on Cacti (via SNMP)
2008-11-25 08:27
Ping, ping, ping....
2016-03-12 15:33
PHP Zend opcache on Cacti via SNMP
2011-06-15 09:34
Universal Log Analyser and snmpd extension scripts
2012-02-15 11:14
Filesystems & Fragmentation

Recent Articles

2019-07-28 16:35
git http with Nginx via Flask wsgi application (git4nginx)
2018-05-15 16:48
Raspberry Pi Camera, IR Lights and more
2017-04-23 14:21
Raspberry Pi SD Card Test
2017-04-07 10:54
DNS Firewall (blackhole malicious, like Pi-hole) with bind9
2017-03-28 13:07
Kubernetes to learn Part 4

Glen Pitt-Pladdy :: Blog

Nokia 5800 ExpressMusic M3U Playlists - Unix tricks

Like most people in the world of Unix, I automate anything that I do routinely. One thing is syncing music to my phone, a Nokia 5800 ExpressMusic.

Transferring Music

Like many Nokia phones this is great for Unix / Linux people since it can be connected as a standard USB storage device (disk), and to transfer music all you do is drop the files on the phone as you would with any disk. Even better, rsync the files to the phone. The catch is that the SD card has a FAT32 filesystem which has several deficiencies and it doesn't play nice with rsync defaults orientated to a fully featured Unix filesystem.

It's a good idea to backup everything before doing stuff like this since if the command it slightly wrong it could delete other data. You may also like to add the --dry-run option to test before running the rsync command for real.

The basic command I use in my scripts is:

rsync -rtv --modify-window=1 \
    --delete --delete-excluded \
    --exclude="cover.jpg" \
    --exclude-from=/PATH/TO/EXCLUDE/LIST \
    /PATH/TO/MP3/FILES \
    /PATH/TO/Nokia5800_SDCard/Sounds/YOURMUSICDIR/

This will sync an entire directory structure, preserving times, but allow one second variance when it compares file times due to the 2 second resolution of FAT filesystems.

It also excludes cover.jpg files which may be used by some playback software for cover art, and provides a file to list patterns which you want to exclude. In my case I produce this list from low scoring files from my IMMS database.

Directory Playlists

The 5800 (and presumably other recent Symbian phones) recognise standard M3U Format playlist files (although their own playlists are in SQLite databases), but use DOS paths (ie. "\" instead of "/" for directory separators). It is relatively easy to script up making a playlist from a directory tree on the phone:

CURRENTDIR=`pwd`
cd /PATH/TO/Nokia5800_SDCard/Sounds/YOURMUSICDIR/
echo "#EXTM3U" >PLAYLISTNAME.m3u
find . -type f | grep \\.mp3$ \
    | sed 's/^\.\///g' \
    | sed 's/\//\\/g' \
    | sort \
    | uniq \
    >>PLAYLISTNAME.m3u
cd "$CURRENTDIR"

This will create a relative path playlist of all files ending .mp3 in the music directory you rsynced to. Note that rsync will nuke this each time so you may want to add this in to the script after each rsync to create a fresh playlist.

Translating Playlists

If you have an existing M3U playlist and need to strip paths (eg. absolute paths) to transfer it to the phone:

CURRENTDIR=`pwd`
cd /PATH/TO/Nokia5800_SDCard/Sounds/YOURMUSICDIR/
echo "#EXTM3U" >PLAYLISTNAME.m3u
cat /PATH/TO/SOURCE/PLAYLIST.m3u \
    | grep \\.mp3$ \
    | sed 's/^\/ABSOLUTE\/PATH\/TO\/REMOVE\///' \
    | while read LINE; do if [ -f "$LINE" ]; then echo "$LINE"; fi; done \
    | sed 's/\//\\/g' \
    | sort \
    | uniq \
    >>PLAYLISTNAME.m3u
cd "$CURRENTDIR"

This will pull in all the lines in the source playlist ending with .mp3, strip the absolute path pattern you specify, check the file exists under the destination (ie. you didn't exclude it in your rsync) and translate to DOS paths.

CSV scores to Playlist

I periodically dump my IMMS database scores to a .csv file (without quotes) in the format:

SCORE,/PATH/TO/MP3

This is easy to make into an M3U playlist cherry picking the highest scores:

CURRENTDIR=`pwd`
cd /PATH/TO/Nokia5800_SDCard/Sounds/YOURMUSICDIR/
echo "#EXTM3U" >PLAYLISTNAME.m3u
cat /PATH/TO/RATINGS.csv | grep '^\(100\|9[0-9]\),' \
    | sed 's/^[0-9]*,//' \
    | sed 's/$/.mp3/' \
    | sed 's/^\/ABSOLUTE\/PATH\/TO\/REMOVE\///' \
    | while read LINE; do if [ -f "$LINE" ]; then echo "$LINE"; fi; done \
    | sed 's/\//\\/g' \
    | sort \
    | uniq \
    >>PLAYLISTNAME.m3u
cd "$CURRENTDIR"

This will grab lines with scores of 90 to 100, removing the score, and then like before, strips the absolute path pattern, checks the file exists, and translates paths.

Comments:




Note: Identity details will be stored in a cookie. Posts may not appear immediately