mirror of
https://github.com/beetbox/beets.git
synced 2026-12-01 06:38:04 -06:00
convert: playlist: Enforce utf-8 encoding on load()
and write().
This commit is contained in:
+2
-2
@@ -39,7 +39,7 @@ class M3UFile():
|
||||
|
||||
def load(self):
|
||||
"""Reads the m3u file from disk and sets the object's attributes."""
|
||||
with open(syspath(self.path), "r") as playlist_file:
|
||||
with open(syspath(self.path), "r", encoding="utf-8") 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:]:
|
||||
@@ -70,6 +70,6 @@ class M3UFile():
|
||||
if not self.media_list:
|
||||
raise EmptyPlaylistError
|
||||
contents = header + self.media_list
|
||||
with open(syspath(self.path), "w") as playlist_file:
|
||||
with open(syspath(self.path), "w", encoding="utf-8") as playlist_file:
|
||||
playlist_file.writelines('\n'.join(contents))
|
||||
playlist_file.write('\n') # Final linefeed to prevent noeol file.
|
||||
|
||||
Reference in New Issue
Block a user