Skip to content

Commit

Permalink
Do not rely on reported file size when downloading stream (fixes #14)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank de Lange committed Jul 20, 2022
1 parent 50b545c commit baccdad
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 3 deletions.
Binary file removed dist/spodcast-0.5.1.tar.gz
Binary file not shown.
Binary file added dist/spodcast-0.5.2.tar.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = spodcast
version = 0.5.1
version = 0.5.2
description = A caching Spotify podcast to RSS proxy.
long_description = file:README.md
long_description_content_type = text/markdown
Expand Down
6 changes: 4 additions & 2 deletions spodcast/podcast.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,10 @@ def download_stream(stream, filepath):
time_start = time.time()
downloaded = 0
with open(filepath, 'wb') as file:
for _ in range(int(size / Spodcast.CONFIG.get_chunk_size()) + 1):
data = stream.input_stream.stream().read(Spodcast.CONFIG.get_chunk_size())
data = b""
while data := stream.input_stream.stream().read(Spodcast.CONFIG.get_chunk_size()):
if data == b"":
break
file.write(data)
downloaded += len(data)
if Spodcast.CONFIG.get_download_real_time():
Expand Down

0 comments on commit baccdad

Please sign in to comment.