From b86cf683416499173d673f7b3bf9961ee063e681 Mon Sep 17 00:00:00 2001 From: Thomas Vander Stichele Date: Sun, 22 May 2011 11:12:16 +0000 Subject: [PATCH] * morituri/rip/cd.py: Factor out function to write .m3u lines. --- ChangeLog | 5 +++++ morituri/rip/cd.py | 25 +++++++++++++------------ 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7baad40..bb8c472 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2011-05-22 Thomas Vander Stichele + + * morituri/rip/cd.py: + Factor out function to write .m3u lines. + 2011-05-22 Thomas Vander Stichele patch by: Loïc Minier diff --git a/morituri/rip/cd.py b/morituri/rip/cd.py index 116b498..ec9aa4f 100644 --- a/morituri/rip/cd.py +++ b/morituri/rip/cd.py @@ -274,13 +274,17 @@ See http://sourceforge.net/tracker/?func=detail&aid=604751&group_id=2171&atid=1 m3uPath = u'%s.m3u' % discName handle = open(m3uPath, 'w') handle.write(u'#EXTM3U\n') + + def writeFile(handle, path, length): + u = u'#EXTINF:%d,%s\n' % (length, os.path.basename(path)) + handle.write(u.encode('utf-8')) + u = '%s\n' % os.path.basename(path) + handle.write(u.encode('utf-8')) + + if htoapath: - u = u'#EXTINF:%d,%s\n' % ( - itable.getTrackStart(1) / common.FRAMES_PER_SECOND, - os.path.basename(htoapath)) - handle.write(u.encode('utf-8')) - u = '%s\n' % os.path.basename(htoapath) - handle.write(u.encode('utf-8')) + writeFile(handle, htoapath, + itable.getTrackStart(1) / common.FRAMES_PER_SECOND) for i, track in enumerate(itable.tracks): if not track.audio: @@ -288,12 +292,9 @@ See http://sourceforge.net/tracker/?func=detail&aid=604751&group_id=2171&atid=1 path = prog.getPath(prog.outdir, self.options.track_template, mbdiscid, i + 1) + '.' + profile.extension - u = u'#EXTINF:%d,%s\n' % ( - itable.getTrackLength(i + 1) / common.FRAMES_PER_SECOND, - os.path.basename(path)) - handle.write(u.encode('utf-8')) - u = '%s\n' % os.path.basename(path) - handle.write(u.encode('utf-8')) + writeFile(handle, path, + itable.getTrackLength(i + 1) / common.FRAMES_PER_SECOND) + handle.close() # verify using accuraterip