Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mjishnu committed Jan 21, 2024
1 parent 2efe2b5 commit fdd2484
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions pypdl/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import requests
from reprint import output

from utls import (
from .utls import (
Multidown,
Simpledown,
combine_files,
Expand Down Expand Up @@ -36,7 +36,6 @@ class Downloader:
"""

def __init__(self, **kwargs):
# private attributes
self._segement_table = {}
self._workers = []
self._threads = []
Expand All @@ -47,7 +46,6 @@ def __init__(self, **kwargs):
"allow_redirects": True,
} # kwargs that are passed to request module

# public attributes
self.size = inf
self.progress = 0
self.speed = 0
Expand Down Expand Up @@ -104,8 +102,8 @@ def _downloader(self, url, file_path, segments, display, multithread, etag):
start_time = time.time()

kwargs = self._kwargs.copy()
del kwargs["params"]
head = requests.head(url, kwargs)
kwargs.pop("params", None)
head = requests.head(url, **kwargs)

if head.status_code != 200:
self._error.set()
Expand All @@ -122,7 +120,7 @@ def _downloader(self, url, file_path, segments, display, multithread, etag):
if size := int(header.get("content-length", 0)):
self.size = size

if self.size is inf or header.get("accept-ranges") is None:
if not multithread or self.size is inf or header.get("accept-ranges") is None:
multithread = False
sd = Simpledown(url, file_path, self._stop, self._error, **self._kwargs)
th = threading.Thread(target=sd.worker)
Expand Down

0 comments on commit fdd2484

Please sign in to comment.