Skip to content

Commit

Permalink
Fix encoding for m3u links (#339).
Browse files Browse the repository at this point in the history
  • Loading branch information
DYefremov committed Jul 10, 2024
1 parent 5f4122b commit e834d79
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions usr/lib/hypnotix/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def get_playlist(self, provider, refresh=False) -> bool:
'Referer': self.settings.get_string("http-referer")
}
try:
response = requests.get(provider.url, headers=headers, timeout=(5,120), stream=True)
response = requests.get(provider.url, headers=headers, timeout=(5, 120), stream=True)

# If there is an answer from the remote server
if response.status_code == 200:
Expand All @@ -179,14 +179,9 @@ def get_playlist(self, provider, refresh=False) -> bool:
# Set stream blocks
block_bytes = int(4 * 1024 * 1024) # 4 MB

response.encoding = response.apparent_encoding
# try:
# source = response.content.decode("UTF-8")
# except UnicodeDecodeError as e:
# source = response.content.decode("latin1")
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):
for data in response.iter_content(block_bytes, decode_unicode=True):
downloaded_bytes += block_bytes
print("{} bytes".format(downloaded_bytes))
file.write(str(data))
Expand Down

0 comments on commit e834d79

Please sign in to comment.