Merge pull request #299 from aberfan/main

Fixes BUG: search track on tidal fails with AttributeError #291, maybe others.
This commit is contained in:
Nathan Thomas 2022-02-17 19:41:06 -08:00 committed by GitHub
commit 76a99deccb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 39 additions and 9 deletions

17
.github/stale.yml vendored Normal file
View file

@ -0,0 +1,17 @@
# Number of days of inactivity before an issue becomes stale
daysUntilStale: 60
# Number of days of inactivity before a stale issue is closed
daysUntilClose: 7
# Issues with these labels will never be considered stale
exemptLabels:
- pinned
- security
# Label to use when marking an issue as stale
staleLabel: stale
# Comment to post when marking an issue as stale. Set to `false` to disable
markComment: >
This issue has been automatically marked as stale because it has not had
recent activity. It will be closed if no further activity occurs. Thank you
for your contributions.
# Comment to post when closing a stale issue. Set to `false` to disable
closeComment: false

View file

@ -20,7 +20,7 @@ A scriptable stream downloader for Qobuz, Tidal, Deezer and SoundCloud.
## Installation
First, ensure [Python](https://www.python.org/downloads/) (version 3.8 or greater) and [pip](https://pip.pypa.io/en/stable/installing/) are installed. Then run the following in the command line:
First, ensure [Python](https://www.python.org/downloads/) (version 3.8 or greater) and [pip](https://pip.pypa.io/en/stable/installing/) are installed. If you are on Windows, install [Microsoft Visual C++ Tools](https://docs.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170). Then run the following in the command line:
```bash
pip3 install streamrip --upgrade
@ -178,3 +178,11 @@ Thanks to Vitiko98, Sorrow446, and DashLt for their contributions to this projec
I will not be responsible for how you use `streamrip`. By using `streamrip`, you agree to the terms and conditions of the Qobuz, Tidal, and Deezer APIs.
## Donations/Sponsorship
<a href="https://www.buymeacoffee.com/nathom" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>
Consider contributing some funds [here](https://www.buymeacoffee.com/nathom), which will go towards holding
the premium subscriptions that I need to debug and improve streamrip. Thanks for your support!

View file

@ -659,21 +659,21 @@ class Track(Media):
audio[k] = v
if embed_cover and cover is None:
assert hasattr(self, "cover_path")
cover = Tracklist.get_cover_obj(
self.cover_path, self.container, self.client.source
)
) if hasattr(self,"cover_path") else None
if isinstance(audio, FLAC):
if embed_cover:
if embed_cover and cover:
audio.add_picture(cover)
audio.save()
elif isinstance(audio, ID3):
if embed_cover:
if embed_cover and cover:
audio.add(cover)
audio.save(self.path, "v2_version=3")
elif isinstance(audio, MP4):
audio["covr"] = [cover]
if cover:
audio["covr"] = [cover]
audio.save()
else:
raise ValueError(f"Unknown container type: {audio}")
@ -1530,9 +1530,9 @@ class Album(Tracklist, Media):
kwargs.get("max_artwork_width", 1e9),
kwargs.get("max_artwork_height", 1e9),
),
)
) if self.cover_urls else None
if kwargs.get("embed_cover", True): # embed by default
if cover_path and kwargs.get("embed_cover", True): # embed by default
logger.debug("Getting cover_obj from %s", cover_path)
# container generated when formatting folder name
self.cover_obj = self.get_cover_obj(

View file

@ -178,7 +178,10 @@ def tidal_cover_url(uuid, size):
"""
possibles = (80, 160, 320, 640, 1280)
assert size in possibles, f"size must be in {possibles}"
# A common occurance is a valid size but no uuid
if not uuid:
return None
return TIDAL_COVER_URL.format(uuid=uuid.replace("-", "/"), height=size, width=size)
@ -335,6 +338,8 @@ def get_cover_urls(resp: dict, source: str) -> dict:
if source == "tidal":
uuid = resp["cover"]
if not uuid:
return None
return {
sk: tidal_cover_url(uuid, size)
for sk, size in zip(COVER_SIZES, (160, 320, 640, 1280))