Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…to dev
  • Loading branch information
xnetcat committed Jan 5, 2024
2 parents ff952d3 + 18b44f3 commit 62b91dc
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 8 deletions.
22 changes: 18 additions & 4 deletions spotdl/providers/lyrics/synced.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

from typing import Dict, List, Optional

import requests
import syncedlyrics

from spotdl.providers.lyrics.base import LyricsProvider
Expand Down Expand Up @@ -46,7 +47,7 @@ def extract_lyrics(self, url: str, **kwargs) -> Optional[str]:

raise NotImplementedError

def get_lyrics(self, name: str, artists: List[str], **_) -> Optional[str]:
def get_lyrics(self, name: str, artists: List[str], **kwargs) -> Optional[str]:
"""
Try to get lyrics using syncedlyrics
Expand All @@ -59,6 +60,19 @@ def get_lyrics(self, name: str, artists: List[str], **_) -> Optional[str]:
- The lyrics of the song or None if no lyrics were found.
"""

lyrics = syncedlyrics.search(f"{name} - {artists[0]}", allow_plain_format=True)

return lyrics
try:
lyrics = syncedlyrics.search(
f"{name} - {artists[0]}",
allow_plain_format=kwargs.get("allow_plain_format", True),
)
return lyrics
except requests.exceptions.SSLError:
# Max retries reached
return None
except TypeError:
# Error at syncedlyrics.providers.musixmatch L89 -
# Because `body` is occasionally an empty list instead of a dictionary.
# We get this error when allow_plain_format is set to True,
# and there are no synced lyrics present
# Because its empty, we know there are no lyrics
return None
18 changes: 14 additions & 4 deletions spotdl/utils/ffmpeg.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
},
"darwin": {
"x86_64": "https://github.com/eugeneware/ffmpeg-static/releases/download/b4.4/darwin-x64",
"arm": "https://github.com/eugeneware/ffmpeg-static/releases/download/b4.4/darwin-arm64",
"arm64": "https://github.com/eugeneware/ffmpeg-static/releases/download/b4.4/darwin-arm64",
},
}

Expand Down Expand Up @@ -215,17 +215,27 @@ def download_ffmpeg() -> Path:

os_name = platform.system().lower()
os_arch = platform.machine().lower()
ffmpeg_url: Optional[str] = None

# if platform.system() == "Darwin" and (
# platform.processor() == "arm"
# or subprocess.run(["sysctl", "-n", "sysctl.proc_translated"], check=False)
# ):
# ffmpeg_url = FFMPEG_URLS["darwin"]["arm"]
# else:
# ffmpeg_url = FFMPEG_URLS.get(os_name, {}).get(os_arch)

ffmpeg_url = FFMPEG_URLS.get(os_name, {}).get(os_arch)

if ffmpeg_url is None:
raise FFmpegError("FFmpeg binary is not available for your system.")

ffmpeg_path = Path(
os.path.join(
get_spotdl_path(), "ffmpeg" + (".exe" if os_name == "windows" else "")
)
)

if ffmpeg_url is None:
raise FFmpegError("FFmpeg binary is not available for your system.")

# Download binary and save it to a file in spotdl directory
ffmpeg_binary = requests.get(ffmpeg_url, allow_redirects=True, timeout=10).content
with open(ffmpeg_path, "wb") as ffmpeg_file:
Expand Down

0 comments on commit 62b91dc

Please sign in to comment.