Skip to content

Commit

Permalink
black/isort code
Browse files Browse the repository at this point in the history
  • Loading branch information
xnetcat committed Sep 1, 2023
1 parent b1a48de commit 2a615ff
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
4 changes: 2 additions & 2 deletions spotdl/providers/audio/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def search(self, song: Song, only_verified: bool = False) -> Optional[str]:
)

return isrc_result.url

logger.debug(
"[%s] Have to filter results: %s", song.song_id, self.filter_results
)
Expand Down Expand Up @@ -327,7 +327,7 @@ def get_best_result(self, results: Dict[Result, float]) -> Tuple[Result, float]:
# return the one with the highest score
# and most views
if len(best_results) > 1:
views = []
views: List[int] = []
for best_result in best_results:
if best_result[0].views:
views.append(best_result[0].views)
Expand Down
3 changes: 2 additions & 1 deletion spotdl/providers/audio/ytmusic.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ class YouTubeMusic(AudioProvider):

SUPPORTS_ISRC = True
GET_RESULTS_OPTS: List[Dict[str, Any]] = [
{"filter": "songs", "ignore_spelling": True, "limit": 50}
{"filter": "songs", "ignore_spelling": True, "limit": 50},
{"filter": "videos", "ignore_spelling": True, "limit": 50},
]

def __init__(self, *args: Any, **kwargs: Any) -> None:
Expand Down
2 changes: 1 addition & 1 deletion spotdl/types/album.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def get_metadata(url: str) -> Tuple[Dict[str, Any], List[Song]]:
album_artist=album_metadata["artists"][0]["name"],
disc_number=track["disc_number"],
disc_count=int(album_metadata["tracks"]["items"][-1]["disc_number"]),
duration=track["duration_ms"]/1000,
duration=track["duration_ms"] / 1000,
year=release_date[:4],
date=release_date,
track_number=track["track_number"],
Expand Down
14 changes: 12 additions & 2 deletions spotdl/utils/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,15 +130,25 @@ def get_simple_songs(
request = re.sub(r"\/intl-\w+\/", "/", request)

if (
("watch?v=" in request or "youtu.be/" in request or "soundcloud.com/" in request or "bandcamp.com/" in request)
(
"watch?v=" in request
or "youtu.be/" in request
or "soundcloud.com/" in request
or "bandcamp.com/" in request
)
and "open.spotify.com" in request
and "track" in request
and "|" in request
):
split_urls = request.split("|")
if (
len(split_urls) <= 1
or not ("watch?v=" in split_urls[0] or "youtu.be" in split_urls[0] or "soundcloud.com/" in split_urls[0] or "bandcamp.com/" in split_urls[0])
or not (
"watch?v=" in split_urls[0]
or "youtu.be" in split_urls[0]
or "soundcloud.com/" in split_urls[0]
or "bandcamp.com/" in split_urls[0]
)
or "spotify" not in split_urls[1]
):
raise QueryError(
Expand Down
4 changes: 2 additions & 2 deletions spotdl/utils/spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ def _get(self, url, args=None, payload=None, **kwargs):
raise exc

if use_cache and cache_key is not None:
logger.debug("Adding song to cache... (%s)",cache_key)
logger.debug("Adding song to cache... (%s)", cache_key)
self.cache[cache_key] = response

return response
Expand All @@ -222,7 +222,7 @@ def save_spotify_cache(cache: Dict[str, Optional[Dict]]):
cache = {
key: value
for key, value in cache.items()
if value is not None and 'tracks/' in key
if value is not None and "tracks/" in key
}

with open(cache_file_loc, "w", encoding="utf-8") as cache_file:
Expand Down

0 comments on commit 2a615ff

Please sign in to comment.