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

Search with thumbnails #5

Merged
merged 4 commits into from
Feb 18, 2022
Merged

Search with thumbnails #5

merged 4 commits into from
Feb 18, 2022

Conversation

jemayn
Copy link
Contributor

@jemayn jemayn commented Feb 17, 2022

Since the new search endpoints return a SkyfishMediaItem which has exactly the same properties as the SkyfishVideo model I've removed the old model, kept the new and changed the GetVideo endpoint to just be for getting the embed url instead (that is also where all the weird logic was anyways).

So this works together with the changes pushed to skybrud/Skybrud.VideoPicker.Skyfish#1, and now works more like an integration package that has methods for specific functionality instead of combining a bunch of calls to return a full video object in the end.

abjerner and others added 4 commits February 11, 2022 15:48
This implementation follows the API a bit closer, and exposes a way to make more complex searches using this package.
Normally I leave it up to the packages or projects using the integration package to "interpret" the underlying API, but for the sake of this example, this could also partially be handled by a new helper class.

For one, the helper class contains the "GetVideoByMediaId" and "GetVideoByUniqueMediaId" methods. These don't really exist in the underlying API, so they are really just calling the "Search" method with the right parameters, delegating the work to the underlying parts of the package.
@jemayn jemayn requested a review from abjerner February 17, 2022 13:57
Copy link
Member

@abjerner abjerner left a comment

Choose a reason for hiding this comment

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

Hi @jemayn

I'm still not a super fan of all the logic in the client and service classes.

Right now we're also requesting a new token from inside the constructor of the SkyfishHttpClient class. Doing something like this inside a constructor is generally considered bad practice.

So at least for the token logic, we can do something like:

  • Remove _token = GetToken(); from the constructor
  • Make the GetToken method public, but move the cache logic somewhere else
  • Make the GetToken med return the SkyfishAuthResponse
  • Introduce a new static CreateWithToken(string apikey, string secretkey, string username, string password) method that initializes the client and fetches the token
  • The SkyfishAuthResponse name may also be a bit misleading, so it should probably be something like SkyfishToken instead

Like I wrote in one of the other reviews, I'm also not a big fan of having the cache in the integration package, but if we are creating a new CreateWithToken method, maybe we could also have a CreateWithTokenMemoryCached method that does the same, but with the memory cache logic (feel free to come up with some better names).

And maybe base the memory key on the username - or a hash of the four parameters. Then the code doesn't prevent us from using multiple Skyfish accounts should we need that in the future.

@abjerner
Copy link
Member

Since the changes in this PR is a bit urgent for a client project, we're merging the PR now, and then making the implementation a bit prettier later.

@abjerner abjerner merged commit 4183704 into main Feb 18, 2022
@abjerner abjerner deleted the search-with-thumbnails branch February 18, 2022 09:14
@jemayn jemayn restored the search-with-thumbnails branch February 18, 2022 13:33
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.

2 participants