soundcloud albums can use download archive

This commit is contained in:
jbannon 2022-04-12 00:44:23 +00:00
parent 5a63d80ca5
commit f7f469c970
4 changed files with 18 additions and 12 deletions

View file

@ -31,7 +31,9 @@ class SoundcloudDownloader(Downloader):
artist_albums_url = f"{self.artist_url(artist_name)}/albums" artist_albums_url = f"{self.artist_url(artist_name)}/albums"
info = self.extract_info(url=artist_albums_url) info = self.extract_info(url=artist_albums_url)
return [SoundcloudAlbum(**e) for e in info["entries"]] albums = [SoundcloudAlbum(**e) for e in info["entries"]]
return [album for album in albums if album.track_count > 0]
def download_tracks(self, artist_name) -> List[SoundcloudTrack]: def download_tracks(self, artist_name) -> List[SoundcloudTrack]:
""" """

View file

@ -13,7 +13,7 @@ from ytdl_subscribe.validators.config.overrides.overrides_validator import Overr
@dataclass @dataclass
class PlaylistMetadata: class PlaylistMetadata:
order_index: int playlist_index: int
playlist_id: str playlist_id: str
playlist_extractor: str playlist_extractor: str

View file

@ -83,7 +83,7 @@ class SoundcloudAlbumTrack(SoundcloudTrack):
@property @property
def track_number(self) -> int: def track_number(self) -> int:
"""Returns the entry's track number""" """Returns the entry's track number"""
return self._playlist_metadata.order_index return self._playlist_metadata.playlist_index
@property @property
def album(self) -> str: def album(self) -> str:
@ -96,7 +96,7 @@ class SoundcloudAlbumTrack(SoundcloudTrack):
return self._album_year return self._album_year
@classmethod @classmethod
def from_soundcloud_entry( def from_soundcloud_track(
cls, cls,
album: str, album: str,
album_year: int, album_year: int,
@ -129,21 +129,24 @@ class SoundcloudAlbum(Entry):
Returns all tracks in the album represented as album-tracks. They will share the Returns all tracks in the album represented as album-tracks. They will share the
same album name, have ordered track numbers, and a shared album year. same album name, have ordered track numbers, and a shared album year.
""" """
tracks = [SoundcloudTrack(**entry) for entry in self.kwargs("entries")] tracks = [
track
if skip_premiere_tracks: for track in self._single_tracks
tracks = [track for track in tracks if not track.is_premiere] if not (skip_premiere_tracks and track.is_premiere)
]
album_tracks = [ album_tracks = [
SoundcloudAlbumTrack.from_soundcloud_entry( SoundcloudAlbumTrack.from_soundcloud_track(
album=self.title, album=self.title,
album_year=self.album_year, album_year=self.album_year,
soundcloud_track=track, soundcloud_track=track,
playlist_metadata=PlaylistMetadata( playlist_metadata=PlaylistMetadata(
playlist_id=self.uid, playlist_extractor=self.extractor, order_index=i + 1 playlist_id=self.uid,
playlist_extractor=self.extractor,
playlist_index=track.kwargs("playlist_index"),
), ),
) )
for i, track in enumerate(tracks) for track in tracks
] ]
return album_tracks return album_tracks

View file

@ -71,7 +71,8 @@ class DownloadArchive:
def to_file(self, file_path: str) -> "DownloadArchive": def to_file(self, file_path: str) -> "DownloadArchive":
with open(file_path, "w", encoding="utf8") as file: with open(file_path, "w", encoding="utf8") as file:
file.writelines(self._download_archive_lines) for line in self._download_archive_lines:
file.write(f"{line}\n")
return self return self
def contains(self, entry_id: str) -> bool: def contains(self, entry_id: str) -> bool: