fixed nasty bug, where musify just returned 404 al lthe time
This commit is contained in:
parent
fa7efbe2c8
commit
82ddc4f5d6
@ -53,7 +53,7 @@ def real_download():
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
music_kraken.cli(genre="test", command_list=[
|
music_kraken.cli(genre="test", command_list=[
|
||||||
# "https://musify.club/release/molchat-doma-etazhi-2018-1092949",
|
"https://musify.club/release/molchat-doma-etazhi-2018-1092949",
|
||||||
"https://musify.club/release/ghost-bath-self-loather-2021-1554266",
|
# "https://musify.club/release/ghost-bath-self-loather-2021-1554266",
|
||||||
"ok"
|
"ok"
|
||||||
])
|
])
|
||||||
|
@ -50,7 +50,7 @@ class Connection:
|
|||||||
return {
|
return {
|
||||||
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
|
"user-agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
|
||||||
"Connection": "keep-alive",
|
"Connection": "keep-alive",
|
||||||
"Host": self.HOST.netloc,
|
# "Host": self.HOST.netloc,
|
||||||
"Referer": self.base_url(),
|
"Referer": self.base_url(),
|
||||||
**header_values
|
**header_values
|
||||||
}
|
}
|
||||||
@ -92,9 +92,6 @@ class Connection:
|
|||||||
|
|
||||||
parsed_url = urlparse(url)
|
parsed_url = urlparse(url)
|
||||||
|
|
||||||
print(url)
|
|
||||||
print(parsed_url)
|
|
||||||
|
|
||||||
headers = self._update_headers(
|
headers = self._update_headers(
|
||||||
headers=headers,
|
headers=headers,
|
||||||
refer_from_origin=refer_from_origin,
|
refer_from_origin=refer_from_origin,
|
||||||
@ -103,32 +100,30 @@ class Connection:
|
|||||||
|
|
||||||
request_url = parsed_url.geturl() if not raw_url else url
|
request_url = parsed_url.geturl() if not raw_url else url
|
||||||
|
|
||||||
retry = False
|
connection_failed = False
|
||||||
try:
|
try:
|
||||||
r: requests.Response = request(url=request_url, timeout=timeout, headers=headers, **kwargs)
|
r: requests.Response = request(request_url, timeout=timeout, headers=headers, **kwargs)
|
||||||
except requests.exceptions.Timeout:
|
|
||||||
self.LOGGER.warning(f"Request timed out at \"{request_url}\": ({try_count}-{self.TRIES})")
|
|
||||||
retry = True
|
|
||||||
except requests.exceptions.ConnectionError:
|
|
||||||
self.LOGGER.warning(f"Couldn't connect to \"{request_url}\": ({try_count}-{self.TRIES})")
|
|
||||||
retry = True
|
|
||||||
|
|
||||||
if not retry:
|
|
||||||
if self.SEMANTIC_NOT_FOUND and r.status_code == 404:
|
|
||||||
self.LOGGER.warning(f"Couldn't find url (404): {request_url}")
|
|
||||||
print(r.headers)
|
|
||||||
print(r.request.headers)
|
|
||||||
return
|
|
||||||
if r.status_code in accepted_response_code:
|
if r.status_code in accepted_response_code:
|
||||||
return r
|
return r
|
||||||
|
|
||||||
if not retry:
|
if self.SEMANTIC_NOT_FOUND and r.status_code == 404:
|
||||||
|
self.LOGGER.warning(f"Couldn't find url (404): {request_url}")
|
||||||
|
return None
|
||||||
|
|
||||||
|
except requests.exceptions.Timeout:
|
||||||
|
self.LOGGER.warning(f"Request timed out at \"{request_url}\": ({try_count}-{self.TRIES})")
|
||||||
|
connection_failed = True
|
||||||
|
except requests.exceptions.ConnectionError:
|
||||||
|
self.LOGGER.warning(f"Couldn't connect to \"{request_url}\": ({try_count}-{self.TRIES})")
|
||||||
|
connection_failed = True
|
||||||
|
|
||||||
|
if not connection_failed:
|
||||||
self.LOGGER.warning(f"{self.HOST.netloc} responded wit {r.status_code} "
|
self.LOGGER.warning(f"{self.HOST.netloc} responded wit {r.status_code} "
|
||||||
f"at {url}. ({try_count}-{self.TRIES})")
|
f"at {url}. ({try_count}-{self.TRIES})")
|
||||||
self.LOGGER.debug(r.content)
|
self.LOGGER.debug(r.content)
|
||||||
|
|
||||||
self.rotate()
|
self.rotate()
|
||||||
print(r.headers)
|
|
||||||
|
|
||||||
return self._request(
|
return self._request(
|
||||||
request=request,
|
request=request,
|
||||||
@ -155,11 +150,11 @@ class Connection:
|
|||||||
try_count=0,
|
try_count=0,
|
||||||
accepted_response_code=accepted_response_codes or self.ACCEPTED_RESPONSE_CODES,
|
accepted_response_code=accepted_response_codes or self.ACCEPTED_RESPONSE_CODES,
|
||||||
url=url,
|
url=url,
|
||||||
stream=stream,
|
|
||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
refer_from_origin=refer_from_origin,
|
|
||||||
raw_url=raw_url,
|
raw_url=raw_url,
|
||||||
|
refer_from_origin=refer_from_origin,
|
||||||
|
stream=stream,
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
if r is None:
|
if r is None:
|
||||||
@ -186,9 +181,9 @@ class Connection:
|
|||||||
timeout=timeout,
|
timeout=timeout,
|
||||||
headers=headers,
|
headers=headers,
|
||||||
refer_from_origin=refer_from_origin,
|
refer_from_origin=refer_from_origin,
|
||||||
|
raw_url=raw_url,
|
||||||
json=json,
|
json=json,
|
||||||
stream=stream,
|
stream=stream,
|
||||||
raw_url=raw_url,
|
|
||||||
**kwargs
|
**kwargs
|
||||||
)
|
)
|
||||||
if r is None:
|
if r is None:
|
||||||
|
@ -1039,7 +1039,7 @@ class Musify(Page):
|
|||||||
|
|
||||||
cls.LOGGER.warning(f"The source has no audio link. Falling back to {endpoint}.")
|
cls.LOGGER.warning(f"The source has no audio link. Falling back to {endpoint}.")
|
||||||
|
|
||||||
r = cls.CONNECTION.get(endpoint, stream=True, allow_redirects=True, headers={"Connection": "https://musify.club/"}, raw_url=True)
|
r = cls.CONNECTION.get(endpoint, stream=True, raw_url=True)
|
||||||
if r is None:
|
if r is None:
|
||||||
return DownloadResult(error_message=f"couldn't connect to {endpoint}")
|
return DownloadResult(error_message=f"couldn't connect to {endpoint}")
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user