コード例 #1
0
 def addSongs(self, paths, cwd='.'):
     for path in paths:
         path = normpath(join(cwd, path))
         if isfile(path):
             ext = extension(path).lower()
             if ext in mediaFileExtensions:
                 self.songs += [path]
             elif ext == '.m3u':
                 with fopen(path) as playlist:
                     lines = [l.strip() for l in playlist.readlines()]
                     self.addSongs(
                         [l for l in lines if l and l[0] != '#'],
                         head(path)
                     )
             elif exists(path):
                 if not self.quiet:
                     #print("%s: skipping descriptor of unknown type." % path)
                     pass
             else:
                 if not self.quiet:
                     print("%s: no such file or directory." % path)
         elif isdir(path):
             self.addSongs(sorted(ls(path=path)))
コード例 #2
0
 def writePlaylist(self, filename):
     with fopen(filename, 'w') as playlist:
         playlist.write('\n'.join(self.songs))