Added track_count to SoundCloudAlbum (#12)
This commit is contained in:
parent
1e2cf14cdf
commit
fa19e0d0c0
5 changed files with 30 additions and 1 deletions
5
.gitignore
vendored
5
.gitignore
vendored
|
|
@ -6,6 +6,11 @@ __pycache__/
|
||||||
# C extensions
|
# C extensions
|
||||||
*.so
|
*.so
|
||||||
|
|
||||||
|
# VSCODE files
|
||||||
|
.vscode
|
||||||
|
# Build files
|
||||||
|
tmp/
|
||||||
|
|
||||||
# Distribution / packaging
|
# Distribution / packaging
|
||||||
.Python
|
.Python
|
||||||
build/
|
build/
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ class PlaylistMetadata:
|
||||||
playlist_index: int
|
playlist_index: int
|
||||||
playlist_id: str
|
playlist_id: str
|
||||||
playlist_extractor: str
|
playlist_extractor: str
|
||||||
|
playlist_count: int
|
||||||
|
|
||||||
|
|
||||||
class BaseEntry(ABC):
|
class BaseEntry(ABC):
|
||||||
|
|
|
||||||
|
|
@ -51,6 +51,11 @@ class SoundcloudAlbumTrack(SoundcloudTrack):
|
||||||
"""Returns the entry's album name, fetched from its internal album"""
|
"""Returns the entry's album name, fetched from its internal album"""
|
||||||
return self._album
|
return self._album
|
||||||
|
|
||||||
|
@property
|
||||||
|
def track_count(self) -> int:
|
||||||
|
"""Returns the entry's total tracks in album for singles this is 1"""
|
||||||
|
return self._playlist_metadata.playlist_count
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def album_year(self) -> int:
|
def album_year(self) -> int:
|
||||||
"""Returns the entry's album year, fetched from its internal album"""
|
"""Returns the entry's album year, fetched from its internal album"""
|
||||||
|
|
@ -127,6 +132,7 @@ class SoundcloudAlbum(Entry):
|
||||||
playlist_id=self.uid,
|
playlist_id=self.uid,
|
||||||
playlist_extractor=self.extractor,
|
playlist_extractor=self.extractor,
|
||||||
playlist_index=track.kwargs("playlist_index"),
|
playlist_index=track.kwargs("playlist_index"),
|
||||||
|
playlist_count=self.track_count,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
for track in tracks
|
for track in tracks
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,15 @@ class SoundcloudVariables(EntryVariables):
|
||||||
"""
|
"""
|
||||||
return f"{self.track_number:02d}"
|
return f"{self.track_number:02d}"
|
||||||
|
|
||||||
|
@property
|
||||||
|
def track_count(self) -> int:
|
||||||
|
"""
|
||||||
|
Returns
|
||||||
|
-------
|
||||||
|
The total tracks in album. For singles, it will always be 1.
|
||||||
|
"""
|
||||||
|
return 1
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def album(self) -> str:
|
def album(self) -> str:
|
||||||
"""
|
"""
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,11 @@ def track_number_padded():
|
||||||
return "01"
|
return "01"
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def track_count():
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
@pytest.fixture
|
@pytest.fixture
|
||||||
def url():
|
def url():
|
||||||
return "soundcloud.com/artist/track-asdfasdf"
|
return "soundcloud.com/artist/track-asdfasdf"
|
||||||
|
|
@ -31,6 +36,7 @@ def mock_soundcloud_track_to_dict(
|
||||||
track_number,
|
track_number,
|
||||||
track_number_padded,
|
track_number_padded,
|
||||||
is_premiere,
|
is_premiere,
|
||||||
|
track_count,
|
||||||
):
|
):
|
||||||
return dict(
|
return dict(
|
||||||
mock_entry_to_dict,
|
mock_entry_to_dict,
|
||||||
|
|
@ -40,6 +46,7 @@ def mock_soundcloud_track_to_dict(
|
||||||
"album": title,
|
"album": title,
|
||||||
"sanitized_album": title,
|
"sanitized_album": title,
|
||||||
"album_year": upload_year,
|
"album_year": upload_year,
|
||||||
|
"track_count": track_count,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -62,6 +69,7 @@ def validate_soundcloud_track_properties(
|
||||||
track_number,
|
track_number,
|
||||||
track_number_padded,
|
track_number_padded,
|
||||||
is_premiere,
|
is_premiere,
|
||||||
|
track_count,
|
||||||
):
|
):
|
||||||
def _validate_soundcloud_track_properties(soundcloud_track: SoundcloudTrack):
|
def _validate_soundcloud_track_properties(soundcloud_track: SoundcloudTrack):
|
||||||
assert validate_entry_properties(soundcloud_track)
|
assert validate_entry_properties(soundcloud_track)
|
||||||
|
|
@ -70,7 +78,7 @@ def validate_soundcloud_track_properties(
|
||||||
assert soundcloud_track.album == title
|
assert soundcloud_track.album == title
|
||||||
assert soundcloud_track.sanitized_album == title
|
assert soundcloud_track.sanitized_album == title
|
||||||
assert soundcloud_track.album_year == upload_year
|
assert soundcloud_track.album_year == upload_year
|
||||||
|
assert soundcloud_track.track_count == track_count
|
||||||
assert soundcloud_track.is_premiere() == is_premiere
|
assert soundcloud_track.is_premiere() == is_premiere
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue