Sunday, November 19, 2006

 

Creating play list for Entempo MP3 Player.



I bought Entempo Spirit 20 GB MP3 player long back. The only criteria for buying this was the price. For $99 you get and 20GB external USB hard drive, which can be used on Mac and PC. I have used this to backup Cannon RAW pictures (CR2) from my Rebel XT digital camera on the road.

The price comes with some shortcomings. Creating play list is difficult. It uses DOS short name inside mp3 play list as shown below:
#EXTM3U
#EXTINF:0,Steve-McConnell-Software-Engineering
#I:/IT_CON~1/STEVE-~1.MP3

Where I: is the entempo drive name it uses internally.

There are no media players which can create the play list in that format. I wrote a Python script to do just that.

#!/usr/bin/python
#Jun 13, 2005 04:51 PM Shankar Chakkere
#This file will create entempo style playlist,
#
#FORMAT
#
#EXTM3U
#EXTINF:0,Steve-McConnell-Software-Engineering
#I:/IT_CON~1/STEVE-~1.MP3
#
import os, re, sys

def dirwalk(dir):
for f in os.listdir(dir):
fullpath = os.path.join(dir,f)
if os.path.isdir(fullpath) and not os.path.islink(fullpath):
for x in dirwalk(fullpath): # recurse into subdir
yield x
else:
yield fullpath

if len(sys.argv) == 1:
print "No file name to match"
print "USAGE:"
print sys.argv[0]+" Pattern"
print "e.g."
print sys.argv[0]+" srenivas > playlist/pbsreenivas.m3u"
sys.exit(1)

print "#EXTM3U"
previous_file_name = ""

for file in dirwalk("."):
file = file.upper()

mp3 = re.match(".*\.MP3",file)

if mp3: #List only filenames with extension .mp3
pattern = ".*"+ sys.argv[1] # make it reqular expression by adding .*at the begining of search string
pattern = pattern.upper()
file_match = re.match(pattern,file)

if file_match:
sfile = file.split("/")
extinfo ="#EXTINF:0," + sfile[-1]
print extinfo
filename = "I:"
pathcount = 1 # 1 because we are skipping 1 in sfile

for mp3file in sfile[1:]: # Dont print the root directory i.e"\.";
mp3file_with_nospace = mp3file.replace(" ","")
pathcount = pathcount + 1
#print "pathcount :",pathcount,"len",len(sfile),"filename :",filename,"mp3file",mp3file_with_nospace,"previous",previous_file_name

if pathcount == len(sfile): # If filename
if mp3file_with_nospace[0:6] == previous_file_name:
count = count + 1
else:
count = 1
previous_file_name = mp3file_with_nospace[0:6]

if len(mp3file_with_nospace) > 8 and pathcount == len(sfile): # If filename
#print "2",len(sfile)," ",pathcount," ",mp3file_with_nospace
if len(mp3file_with_nospace) >12:

filename = filename + "/" + mp3file_with_nospace[0:6] + "~" + str(count)
else:
length = len(mp3file_with_nospace)-4 #.MP3 four bytes
filename = filename + "/" + mp3file_with_nospace[0:length]
else:
if len(mp3file_with_nospace) > 8 and pathcount != len(sfile): # If directory
filename = filename + "/" + mp3file_with_nospace[0:6] + "~1"
else:
#length = len(mp3file_with_nospace)-4 #.MP3 four bytes
#if pathcount == len(sfile):
# filename = filename + "/" + mp3file_with_nospace[0:length]
#else:
filename = filename + "/" + mp3file_with_nospace

filename = filename + ".MP3"
print filename

The DOS command dir /x was used to verify the DOS short name on Windows XP.

I use the script as shown below:

schakkere@shankar ~>cd e:
./playlist.py myselection >PLAYLIST/inter.m3u

myselection is the directory which contains MP3 files.
PLAYLIST is the directory where the play list is stored.

Note: The script is stored in the root directory of ENTEMPO.

Also the player has another shortcoming. It cannot play VBR and bitrates should be less than 48K in mp3.This batch file fixes that: It converts all the mp3 in current directory to fixed rate (48K).
@rem Oct 03, 2005 12:18 PM
@rem Shankar Chakkere
@rem This batch file will convert the mp3s to 48Kb rate so the entempo will
@rem play it. Entempo will not play VBR and higher bit rate mp3
@rem if not exist t echo " directory t does not exists"
@IF NOT EXIST t mkdir t
@for %%f in (*.mp3) do c:\djgpp\bin\lame -b 48 -mj "%%f" "t\%%f"

Note: The converted MP3 files will be in "t" subdirectory.

Labels:


Comments: Post a Comment



<< Home

This page is powered by Blogger. Isn't yours?