Misc soundcloud issues fixed

This commit is contained in:
Nathan Thomas 2023-12-24 11:43:03 -08:00
parent bde9f7adec
commit 5ad725569d
4 changed files with 12 additions and 4 deletions

View file

@ -48,7 +48,7 @@ class Downloadable(ABC):
await self._download(path, callback)
async def size(self) -> int:
if self._size is not None:
if hasattr(self, "_size") and self._size is not None:
return self._size
async with self.session.head(self.url) as response:
@ -290,6 +290,7 @@ class SoundcloudDownloadable(Downloadable):
async def _download_original(self, path: str, callback):
downloader = BasicDownloadable(self.session, self.url, "flac")
await downloader.download(path, callback)
self.size = downloader.size
engine = converter.FLAC(path)
await engine.convert(path)

View file

@ -93,6 +93,9 @@ class SoundcloudClient(Client):
}
resp, status = await self._api_request(f"search/{media_type}s", params=params)
assert status == 200
if media_type == "track":
for item in resp["collection"]:
item["id"] = self._get_custom_id(item)
return [resp]
async def get_downloadable(self, item_info: str, _) -> SoundcloudDownloadable:

View file

@ -18,7 +18,10 @@ logger = logging.getLogger("streamrip")
def remove_artwork_tempdirs():
logger.debug("Removing dirs %s", _artwork_tempdirs)
for path in _artwork_tempdirs:
shutil.rmtree(path)
try:
shutil.rmtree(path)
except FileNotFoundError:
pass
async def download_artwork(

View file

@ -224,7 +224,8 @@ class AlbumMetadata:
safe_get(track, "publisher_metadata", "explicit", default=False),
bool,
)
genre = typed(track["genre"], str)
genre = typed(track["genre"], str | None)
genres = [genre] if genre is not None else []
artist = typed(safe_get(track, "publisher_metadata", "artist"), str | None)
artist = artist or typed(track["user"]["username"], str)
albumartist = artist
@ -259,7 +260,7 @@ class AlbumMetadata:
album_title,
albumartist,
year,
genre=[genre],
genre=genres,
covers=covers,
albumcomposer=None,
comment=None,