Skip to content
This repository has been archived by the owner on Jan 22, 2022. It is now read-only.

Using classes to determine result types #550

Open
scj643 opened this issue May 18, 2017 · 5 comments
Open

Using classes to determine result types #550

scj643 opened this issue May 18, 2017 · 5 comments

Comments

@scj643
Copy link

scj643 commented May 18, 2017

The api can get confusing and making results be just straight up dictionaries means keeping track of stuff is hard. I purpose using different classes for different result types.

Like songs would be it's own class that the object itself can be passed to get the stream url.

@simon-weber
Copy link
Owner

It's a reasonable idea, though I don't think it's something I'm likely to get to any time soon. And unless we want to make a breaking change, we'd need to keep the dict interface on whatever we moved to.

Is the pain point specifically around being able to check the type of a result (eg playlist vs station, etc)? It'd be relatively straightforward to wrap the dicts and add that.

@thebigmunch
Copy link
Contributor

The last part of your comment sounds more like turning everything into an object, rather than just search results. That's what would be required to provide a consistent API. This is something that I've done in an unreleased experiment, similar to the API and implementation of github3.py. It's not exactly easy for the author there, and the GitHub API is a well-documented, consistent REST API. I found many more pain points and shelved my experiment in favor of other things. It's something that I might poke back around to in the future. But, like Simon, it's unlikely to be soon, if ever.

@scj643
Copy link
Author

scj643 commented May 19, 2017

Couldn't we just provide a dict attribute to all the classes so that results would still be compatible with code that expects dicts.

@simon-weber
Copy link
Owner

Yup, that's what I was picturing in my earlier comment. I'm not sure what beyond that is needed to address the pain point from the OP, though.

@scj643
Copy link
Author

scj643 commented May 19, 2017

Another solution would be a key standard to all results that is a string with the key type

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants