Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added total_tracks to SoundCloudAlbum #12

Merged
merged 10 commits into from
Apr 30, 2022

Conversation

FrankieBinns
Copy link
Contributor

The property will get the total tracks of the sound cloud album via the album_tracks method. If the sound cloud album is a single it will return 1.

@jmbannon
Copy link
Owner

Thanks for the PR! We need to add this property to the following mixin as well:
https://github.com/jmbannon/ytdl-sub/blob/e8e1daaec29f39f5113f772004595a159fe4ce55/src/ytdl_sub/entries/variables/soundcloud_variables.py

This is the mixin used by SoundcloudAlbum to get properties and is also what is used to generate the docs found here:
https://ytdl-sub.readthedocs.io/en/latest/config/format_variables/soundcloud.html

(Sorry, I haven't documented this very well yet)

Please use Numpy docstring format. It's used in the mixin.

Lastly, we need to add this property into our unit tests. See https://github.com/jmbannon/ytdl-sub/blob/e8e1daaec29f39f5113f772004595a159fe4ce55/tests/unit/entries/test_soundcloud_entries.py

You can run the tests with ./tools/test, ensure it shows up in the docs by running ./tools/docs, and also run your added code through the linter with ./tools/lint

That was a lot! I plan to make this more clear somewhere for contributors to see. If you need any help I'd be happy to hop on discord or something sometime

@FrankieBinns
Copy link
Contributor Author

Still, working on it hope you don't mind just taking the time to understand the architecture.

@FrankieBinns
Copy link
Contributor Author

Ok, I've added it to the SoundCloudVariables mixin, added it to the doc, added it to the unit tests and ran the linter and tests on it and it passed.

-------
The total tracks in album. For singles, it will always be 1.
"""
if self.kwargs_contains("total_tracks"):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the kwargs here is referring to the YTDL dict returned for the soundcloud entry. I don't think total_tracks is there. We can always return 1 here just like we do with track_number

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then SoundcloudAlbumTrack will override and use its value

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, didn't release what kwargs was actually doing, changed it, to that implementation.

@@ -105,6 +112,7 @@ def album_tracks(self, skip_premiere_tracks: bool = True) -> List[SoundcloudAlbu
album=self.title,
album_year=self.album_year,
soundcloud_track=track,
total_tracks=self.track_count,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should incorporate this into the PlaylistMetadata as playlist_count. Then in total_tracks, return self._playlist_metadata.playlist_count

I think the ytdl field is 'playlist_count', i recommend using a debugger and seeing what ytdl returns in the entry dict

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would help solve this issue: #9

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea that makes sense, I've incorporated it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've also launched it in a debugger and checked the entry dict, and the field is playlist_count, this is also used in the track_count property in SoundcloudAlbum.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sweet looks great! Looks like the linter errored: https://github.com/jmbannon/ytdl-sub/runs/6236060213?check_suite_focus=true

One last nit: lets change the soundcloud variable name from total_tracks to track_count, that way it's near the other track variables via sorting in the documentation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I've fixed that linter error, and I've changed the variable name.

@@ -51,6 +51,11 @@ def album(self) -> str:
"""Returns the entry's album name, fetched from its internal album"""
return self._album

@property
def total_tracks(self) -> int:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to set this to track_count

Comment on lines 31 to 33
@pytest.fixture()
def track_count():
return 1
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dupe fixtures

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after these two small fixes it should be good to merge

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed those two problems, thanks for being patient this has been quite the pull request at least it has been enjoyable.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem, thank you for contributing! I hope my comments have been helpful and that you find this app useful

@jmbannon jmbannon merged commit fa19e0d into jmbannon:master Apr 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants