Changeset 452


Ignore:
Timestamp:
22-05-11 13:12:16 (2 years ago)
Author:
thomas
Message:
  • morituri/rip/cd.py: Factor out function to write .m3u lines.
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/ChangeLog

    r451 r452  
     12011-05-22  Thomas Vander Stichele  <thomas at apestaart dot org> 
     2 
     3        * morituri/rip/cd.py: 
     4          Factor out function to write .m3u lines. 
     5 
    162011-05-22  Thomas Vander Stichele  <thomas at apestaart dot org> 
    27 
  • trunk/morituri/rip/cd.py

    r451 r452  
    275275        handle = open(m3uPath, 'w') 
    276276        handle.write(u'#EXTM3U\n') 
     277 
     278        def writeFile(handle, path, length): 
     279            u = u'#EXTINF:%d,%s\n' % (length, os.path.basename(path)) 
     280            handle.write(u.encode('utf-8')) 
     281            u = '%s\n' % os.path.basename(path) 
     282            handle.write(u.encode('utf-8')) 
     283 
     284 
    277285        if htoapath: 
    278             u = u'#EXTINF:%d,%s\n' % ( 
    279                 itable.getTrackStart(1) / common.FRAMES_PER_SECOND, 
    280                     os.path.basename(htoapath)) 
    281             handle.write(u.encode('utf-8')) 
    282             u = '%s\n' % os.path.basename(htoapath) 
    283             handle.write(u.encode('utf-8')) 
     286            writeFile(handle, htoapath, 
     287                itable.getTrackStart(1) / common.FRAMES_PER_SECOND) 
    284288 
    285289        for i, track in enumerate(itable.tracks): 
     
    289293            path = prog.getPath(prog.outdir, self.options.track_template,  
    290294                mbdiscid, i + 1) + '.' + profile.extension 
    291             u = u'#EXTINF:%d,%s\n' % ( 
    292                 itable.getTrackLength(i + 1) / common.FRAMES_PER_SECOND, 
    293                 os.path.basename(path)) 
    294             handle.write(u.encode('utf-8')) 
    295             u = '%s\n' % os.path.basename(path) 
    296             handle.write(u.encode('utf-8')) 
     295            writeFile(handle, path, 
     296                itable.getTrackLength(i + 1) / common.FRAMES_PER_SECOND) 
     297 
    297298        handle.close() 
    298299 
Note: See TracChangeset for help on using the changeset viewer.