fix: musify downloading
This commit is contained in:
parent
bdb4a46c1a
commit
44d1f0d7db
@ -145,6 +145,7 @@ class Connection:
|
||||
disable_cache: bool = None,
|
||||
method: str = None,
|
||||
name: str = "",
|
||||
exclude_headers: List[str] = None,
|
||||
**kwargs
|
||||
) -> Optional[requests.Response]:
|
||||
if method is None:
|
||||
@ -158,7 +159,6 @@ class Connection:
|
||||
current_kwargs.pop("kwargs")
|
||||
current_kwargs.update(**kwargs)
|
||||
|
||||
|
||||
parsed_url = urlparse(url)
|
||||
|
||||
if not raw_headers:
|
||||
@ -195,6 +195,10 @@ class Connection:
|
||||
if timeout is None:
|
||||
timeout = self.TIMEOUT
|
||||
|
||||
for header in exclude_headers or []:
|
||||
if header in headers:
|
||||
del headers[header]
|
||||
|
||||
r = None
|
||||
connection_failed = False
|
||||
try:
|
||||
@ -308,7 +312,7 @@ class Connection:
|
||||
return DownloadResult(error_message=f"Could not establish a stream from: {url}")
|
||||
|
||||
target.create_path()
|
||||
total_size = int(r.headers.get('content-length'))
|
||||
total_size = int(r.headers.get('content-length', r.headers.get('Content-Length', chunk_size)))
|
||||
progress = 0
|
||||
|
||||
retry = False
|
||||
|
@ -118,7 +118,13 @@ class Musify(Page):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.connection: Connection = Connection(
|
||||
host="https://musify.club/",
|
||||
logger=self.LOGGER
|
||||
logger=self.LOGGER,
|
||||
)
|
||||
|
||||
self.stream_connection: Connection = Connection(
|
||||
host="https://musify.club/",
|
||||
logger=self.LOGGER,
|
||||
semantic_not_found=False,
|
||||
)
|
||||
|
||||
super().__init__(*args, **kwargs)
|
||||
@ -1121,4 +1127,4 @@ class Musify(Page):
|
||||
|
||||
self.LOGGER.warning(f"The source has no audio link. Falling back to {endpoint}.")
|
||||
|
||||
return self.connection.stream_into(endpoint, target, raw_url=True)
|
||||
return self.stream_connection.stream_into(endpoint, target, raw_url=True, exclude_headers=["Host"])
|
||||
|
Loading…
Reference in New Issue
Block a user