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
feat(coverart): coverart builder to make specific queries to coverart api #45
Conversation
Hello @ritiek I won't have time to review this before next week. Also I had a message from Yvan telling me that we need to give sign of life if we want to continue in the gsoc program. I will contact you next week. |
I see. Hope you're doing fine. Is there anything else you'd specifically want to me to work on until then? Otherwise I plan on implementing auto-retries for now as this feels something I wouldn't require much consulting on.
Totally understandable where this is coming from. |
Everything is fine, I am just super busy these days. Go for auto-retries ! |
Good to know! Alright. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will work but it will allow to build invalid requests. For instance I could write :
Release::fetch_coverart()
.id("1234")
.back()
.front()
.res_1200()
.res_500();
I see several ways to solve this :
- Wrapping the request in an intermediate builder returned by the
front
andback
. This builder would implement theres_
functions. - An alternative is to push the parameters (front, back and res) as some enum variant and check just before sending the request if all params are compatible.
I think I prefer the second approach because it allows to produce a detailed error message while being simple to implement and easy to extend.
Sounds good. How should I validate the request before sending it? Should I create another method ( |
Calling a validate() function as part of execute would do it, I don't think you need to check how method call are ordered since we can reorder everything when building the request. You only need to check for repetition. |
f7d23c8
to
19dbdfa
Compare
Alright. I've pushed new changes. What do you think? |
Also we need to update the readme. |
Ok. Should I mention about the coverart feature in the features section in readme? And is it okay if I do this in a later PR? I'll also cover about |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also we need to update the readme.
Ok. Should I mention about the coverart feature in the features section in readme? And is it okay if I do this in a later PR? I'll also cover about
get_coverart
method and anything else worth mentioning about (retries?) in a later dedicated PR, if it's alright to you.
Sure it's fine
src/lib.rs
Outdated
|
||
pub fn res_1200(&mut self) -> &mut Self { | ||
if self.0.target.img_res.is_some() { | ||
panic!("coverart resolution is already set"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need to panic here, we could just emit a warning to the standard output saying the call to res_xxx
has been ignored
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I pushed a new commit to print these messages to stdout instead of panicking.
src/lib.rs
Outdated
HTTP_CLIENT.get(&self.0.path).send()?.json() | ||
pub fn front(&mut self) -> &mut Self { | ||
if self.0.target.img_type.is_some() { | ||
panic!("coverart type is already set"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here we shall just emit a warning, and ignore the additional image type, don't panic :)
Is there anything else that needs to be addressed? Otherwise, this should be good to merge! |
Ideally this will allow us to make specific calls to the coverart api. Such as to fetch front coverart for some release in 500px:
I'm not sure what the return type in our library should be here. The coverart api simply returns an image for this query.
Should we also return an image (maybe through the
image
crate), or maybe just return the redirect url from the original query (which looks likehttps://ia802607.us.archive.org/32/items/mbid-76df3287-6cda-33eb-8e9a-044b5e15ffdd/mbid-76df3287-6cda-33eb-8e9a-044b5e15ffdd-829521842_thumb500.jpg
)?Also, currently
FetchCoverartQuery::execute()
expects response content to be in json, but making these specific coverart calls does not return json. Not sure what the best way to deal with this in our library is.