soundcloud albums can use download archive
This commit is contained in:
parent
5a63d80ca5
commit
f7f469c970
4 changed files with 18 additions and 12 deletions
|
|
@ -31,7 +31,9 @@ class SoundcloudDownloader(Downloader):
|
|||
artist_albums_url = f"{self.artist_url(artist_name)}/albums"
|
||||
|
||||
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]:
|
||||
"""
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ from ytdl_subscribe.validators.config.overrides.overrides_validator import Overr
|
|||
|
||||
@dataclass
|
||||
class PlaylistMetadata:
|
||||
order_index: int
|
||||
playlist_index: int
|
||||
playlist_id: str
|
||||
playlist_extractor: str
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ class SoundcloudAlbumTrack(SoundcloudTrack):
|
|||
@property
|
||||
def track_number(self) -> int:
|
||||
"""Returns the entry's track number"""
|
||||
return self._playlist_metadata.order_index
|
||||
return self._playlist_metadata.playlist_index
|
||||
|
||||
@property
|
||||
def album(self) -> str:
|
||||
|
|
@ -96,7 +96,7 @@ class SoundcloudAlbumTrack(SoundcloudTrack):
|
|||
return self._album_year
|
||||
|
||||
@classmethod
|
||||
def from_soundcloud_entry(
|
||||
def from_soundcloud_track(
|
||||
cls,
|
||||
album: str,
|
||||
album_year: int,
|
||||
|
|
@ -129,21 +129,24 @@ class SoundcloudAlbum(Entry):
|
|||
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.
|
||||
"""
|
||||
tracks = [SoundcloudTrack(**entry) for entry in self.kwargs("entries")]
|
||||
|
||||
if skip_premiere_tracks:
|
||||
tracks = [track for track in tracks if not track.is_premiere]
|
||||
tracks = [
|
||||
track
|
||||
for track in self._single_tracks
|
||||
if not (skip_premiere_tracks and track.is_premiere)
|
||||
]
|
||||
|
||||
album_tracks = [
|
||||
SoundcloudAlbumTrack.from_soundcloud_entry(
|
||||
SoundcloudAlbumTrack.from_soundcloud_track(
|
||||
album=self.title,
|
||||
album_year=self.album_year,
|
||||
soundcloud_track=track,
|
||||
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
|
||||
|
|
|
|||
|
|
@ -71,7 +71,8 @@ class DownloadArchive:
|
|||
|
||||
def to_file(self, file_path: str) -> "DownloadArchive":
|
||||
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
|
||||
|
||||
def contains(self, entry_id: str) -> bool:
|
||||
|
|
|
|||
Loading…
Reference in a new issue