Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions MediaController.py
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ def thumbnail(self, player_name: str = None) -> list[str]:
continue
if path.startswith("https"):
path = self.get_web_thumnail(path)
if not path:
thumbnails.append(None)
continue
path = path.replace("file://", "")
thumbnails.append(path)
except (KeyError, IndexError) as e:
Expand Down Expand Up @@ -334,8 +337,12 @@ def download_file(self, url: str, path: str = "", file_name: str = None) -> str:
path (str): The path of the downloaded file.
"""

response = requests.get(url, stream=True)

try:
response = requests.get(url, stream=True)
except requests.exceptions.RequestException as e:
log.error(f"An error occurred during the request: {e}")
return None

if file_name is None:
file_name = self.get_file_name_from_url(url)

Expand All @@ -349,6 +356,6 @@ def download_file(self, url: str, path: str = "", file_name: str = None) -> str:
os.makedirs(os.path.dirname(path), exist_ok=True)

with open(path, "wb") as f:
f.write(requests.get(url).content)
f.write(response.content)

return path
return path