def create_playlist_m3u(self, tracks):
args = self.args
ripper = self.ripper
name = self.get_playlist_name()
if name is not None and args.playlist_m3u:
name = sanitize_playlist_name(to_ascii(name))
_base_dir = base_dir()
playlist_path = to_ascii(
os.path.join(_base_dir, name + '.m3u'))
print(Fore.GREEN + "Creating playlist m3u file " +
playlist_path + Fore.RESET)
encoding = "ascii" if args.ascii else "utf-8"
with codecs.open(enc_str(playlist_path), 'w', encoding) as playlist:
for idx, track in enumerate(tracks):
track.load()
if track.is_local:
continue
_file = ripper.format_track_path(idx, track)
if path_exists(_file):
playlist.write(os.path.relpath(_file, _base_dir) +
"\n")
评论列表
文章目录