mirror of
https://github.com/beetbox/beets.git
synced 2026-02-20 06:14:22 +01:00
convert: playlist: Enforce utf-8 encoding on load()
and write().
This commit is contained in:
parent
785ef1576c
commit
da01be3d93
1 changed files with 2 additions and 2 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Reference in a new issue