convert: playlist: Use syspath()

for file read and write operations.
This commit is contained in:
J0J0 T 2022-08-22 11:23:33 +02:00 committed by J0J0 Todos
parent 7d121c390b
commit 8dc556d420

View file

@ -16,6 +16,9 @@
"""
from beets.util import syspath
class EmptyPlaylistError(Exception):
"""An error that should be raised when a playlist file without media files
is saved or loaded.
@ -41,7 +44,7 @@ class M3UFile():
def load(self):
"""Reads the m3u file from disk and sets the object's attributes.
"""
with open(self.path, "r") as playlist_file:
with open(syspath(self.path), "r") as playlist_file:
raw_contents = playlist_file.readlines()
self.extm3u = True if raw_contents[0] == "#EXTM3U\n" else False
for line in raw_contents[1:]:
@ -72,6 +75,6 @@ class M3UFile():
if not self.media_list:
raise EmptyPlaylistError
contents = header + self.media_list
with open(self.path, "w") as playlist_file:
with open(syspath(self.path), "w") as playlist_file:
playlist_file.writelines('\n'.join(contents))
playlist_file.write('\n') # Final linefeed to prevent noeol file.