Browse Source

FIX continue downloading

boyska 3 years ago
parent
commit
2470864043
1 changed files with 5 additions and 3 deletions
  1. 5 3
      feed

+ 5 - 3
feed

@@ -398,13 +398,15 @@ def get_parser():
 
 def downloader(url, dest):
     headers = {}
+    mode='wb'
     if os.path.exists(dest):
         headers["Range"] = "bytes=%d-" % os.stat(dest).st_size
+        mode = 'ab'
     r = requests.get(url, stream=True, headers=headers)
     if r.status_code == 416:  # range not satisfiable
         return
-    with open(dest, "ab") as f:
-        for chunk in r.iter_content(chunk_size=2 << 15):
+    with open(dest, mode) as f:
+        for chunk in r.iter_content(chunk_size=1 << 16):
             f.write(chunk)
 
 
@@ -424,7 +426,7 @@ def put(audio, copy=False):
                 dest = os.path.join(destdir, fname)
                 os.makedirs(destdir, exist_ok=True)
                 downloader(url, dest)
-                print("file://%s" % os.path.realpath(fname))
+                print("file://%s" % os.path.realpath(dest))
             else:
                 # FIXME: file:// urls are just copied
                 print(url)