jellyfin / jellyfin-apiclient-python

Python API Client for Jellyfin
GNU General Public License v3.0
91 stars 31 forks source link

Organize API with Mixin Classes #34

Closed Erotemic closed 8 months ago

Erotemic commented 10 months ago

This builds on top of my previous PR.

The idea here is start organizing the API to make it easier to keep track of what API calls have a Python call, and which don't. Currently the change is minimal to demonstrate the idea.

Basically for each group of related functionalities the idea is to make a single "mixin" class that contains those methods. Then the API class is a nearly empty class that just inherits from all of the "mixin" classes, thus providing a backwards compatibility.

However, now we don't need comments to delineate grouping of functionality as it is implicit in the code.

As an example of what I'm trying to do, I've had a lot of success with this pattern in my CocoDataset class. I think this pattern will have value here as well.

The current group of mixins uses the same structure implied by the comments. We have:

I also added a doctest to API, which won't run, but illustrates how to create an instance of it. If the testing tools have something that can spin up a dummy server, then we could make this test actually run with xdoctest.

iwalton3 commented 9 months ago

This idea seems reasonable enough to me and would improve readability without breaking the API. I say go for it.

Erotemic commented 9 months ago

I rebased on master and dropped other commits not related to this PR. Should be good to review & merge.

Erotemic commented 8 months ago

@iwalton3 If you have any time, merging this would make it easier to me to push up new API features. I've written endpoints for exteranl provider (e.g. IMDB) identification, collection creation, and metadata editing that will have a cleaner diff once this is merged.