Skip to content

Commit

Permalink
forced utf-8 enabled for playlist read/write (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
DYefremov authored and clefebvre committed Nov 29, 2023
1 parent 89d8cf0 commit 4a5abc8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions usr/lib/hypnotix/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ def get_playlist(self, provider, refresh=False) -> bool:
# source = response.content.decode("UTF-8")
# except UnicodeDecodeError as e:
# source = response.content.decode("latin1")
with open(provider.path, "w") as file:
with open(provider.path, "w", encoding="utf-8") as file:
# Grab data by block_bytes
for data in response.iter_content(block_bytes,decode_unicode=True):
downloaded_bytes += block_bytes
Expand All @@ -210,7 +210,7 @@ def get_playlist(self, provider, refresh=False) -> bool:
def check_playlist(self, provider):
legit = False
if os.path.exists(provider.path):
with open(provider.path, "r") as file:
with open(provider.path, "r", encoding="utf-8", errors="ignore") as file:
content = file.read()
if "#EXTM3U" in content and "#EXTINF" in content:
legit = True
Expand All @@ -220,7 +220,7 @@ def check_playlist(self, provider):
return legit

def load_channels(self, provider):
with open(provider.path, "r") as file:
with open(provider.path, "r", encoding="utf-8", errors="ignore") as file:
channel = None
group = None
groups = {}
Expand Down Expand Up @@ -293,12 +293,12 @@ def load_channels(self, provider):

def load_favorites(self):
favorites = []
with open(FAVORITES_PATH, 'r') as f:
with open(FAVORITES_PATH, 'r', encoding="utf-8", errors="ignore") as f:
for line in f:
favorites.append(line.strip())
return favorites

def save_favorites(self, favorites):
with open(FAVORITES_PATH, "w") as f:
with open(FAVORITES_PATH, "w", encoding="utf-8") as f:
for fav in favorites:
f.write(f"{fav}\n")

0 comments on commit 4a5abc8

Please sign in to comment.