fix: musify downloading

This commit is contained in:
Hellow 2024-04-11 20:13:12 +02:00
parent bdb4a46c1a
commit 44d1f0d7db
2 changed files with 15 additions and 5 deletions

View File

@ -145,6 +145,7 @@ class Connection:
disable_cache: bool = None, disable_cache: bool = None,
method: str = None, method: str = None,
name: str = "", name: str = "",
exclude_headers: List[str] = None,
**kwargs **kwargs
) -> Optional[requests.Response]: ) -> Optional[requests.Response]:
if method is None: if method is None:
@ -158,7 +159,6 @@ class Connection:
current_kwargs.pop("kwargs") current_kwargs.pop("kwargs")
current_kwargs.update(**kwargs) current_kwargs.update(**kwargs)
parsed_url = urlparse(url) parsed_url = urlparse(url)
if not raw_headers: if not raw_headers:
@ -195,6 +195,10 @@ class Connection:
if timeout is None: if timeout is None:
timeout = self.TIMEOUT timeout = self.TIMEOUT
for header in exclude_headers or []:
if header in headers:
del headers[header]
r = None r = None
connection_failed = False connection_failed = False
try: try:
@ -308,7 +312,7 @@ class Connection:
return DownloadResult(error_message=f"Could not establish a stream from: {url}") return DownloadResult(error_message=f"Could not establish a stream from: {url}")
target.create_path() 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 progress = 0
retry = False retry = False

View File

@ -118,7 +118,13 @@ class Musify(Page):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
self.connection: Connection = Connection( self.connection: Connection = Connection(
host="https://musify.club/", 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) 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}.") 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"])