-
Notifications
You must be signed in to change notification settings - Fork 188
Replacing google poly integration with Icosa integration #723
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
Closed
Closed
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
a254079
Revert "removed poly references" 1e85db47f6d99d983e7198a9c55f04c11eb3…
andybak a435ae2
Replacing hardcoded references to poly.googleapis.com with icosa-api.…
Craigmoore a496cfd
Poly to Icosa
andybak 85bb2d0
Update media_resolver.ex
andybak aa39618
Replacing MediaSearchQuery to not check that the google_poly api key …
Craigmoore ee8ce21
remove api key from single asset api call
andybak 08f741e
switch resolver to api instead of front end urls
andybak dd7eed2
only ask for GLTF2
andybak 8069c31
Back to front end url but add root to non_video_root_hosts
andybak 3cea842
Sigh. Back to api urls
andybak 2e82b1f
Try moving all urls to be api urls
andybak 8bae0a6
quick fix for ".co.uk"
andybak 525a1a0
Minor fixes for resolving icosa assets
Craigmoore c8b356e
Adding temporary fix for icosa asset url
Craigmoore b9cd448
Merge branch 'Hubs-Foundation:master' into master
Craigmoore 5a1b0a7
Remove references to google_poly_api_key
andybak d6fe31e
rename another poly to icosa
andybak 59e8127
More poly > icosa renaming
andybak cb896bb
Switch from staging to production urls
andybak 4343a30
Revert "quick fix for ".co.uk""
andybak 026528c
Merge branch 'Hubs-Foundation:master' into master
andybak c975619
Merge branch 'Hubs-Foundation:master' into master
andybak bfadcb4
Only show remixable and order by "best"
andybak 653df22
Remove empty category param
andybak 05143e2
Handle redirects in the CORS proxy
andybak a636aed
mix format
andybak fc784c4
Revert "mix format"
andybak 8acf9cf
Reverts Icosa to use usual caching period, and reverts a comment
andybak facd9be
Mix format
andybak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,12 +20,14 @@ defmodule Ret.MediaResolver do | |
|
|
||
| @youtube_rate_limit %{scale: 8_000, limit: 1} | ||
| @sketchfab_rate_limit %{scale: 60_000, limit: 15} | ||
| @icosa_rate_limit %{scale: 60_000, limit: 1000} | ||
| @max_await_for_rate_limit_s 120 | ||
|
|
||
| @non_video_root_hosts [ | ||
| "sketchfab.com", | ||
| "giphy.com", | ||
| "tenor.com" | ||
| "tenor.com", | ||
| "icosa.gallery" | ||
| ] | ||
|
|
||
| @deviant_id_regex ~r/\"DeviantArt:\/\/deviation\/([^"]+)/ | ||
|
|
@@ -79,6 +81,13 @@ defmodule Ret.MediaResolver do | |
| |> resolved()} | ||
| end | ||
|
|
||
| # Necessary short circuit around google.com root_host to skip YT-DL check for Poly | ||
| def resolve(%MediaResolverQuery{url: %URI{host: "api.icosa.gallery"}} = query, root_host) do | ||
| rate_limited_resolve(query, root_host, @icosa_rate_limit, fn -> | ||
| resolve_non_video(query, root_host) | ||
| end) | ||
| end | ||
|
|
||
| def resolve(%MediaResolverQuery{} = query, root_host) when root_host in @non_video_root_hosts do | ||
| resolve_non_video(query, root_host) | ||
| end | ||
|
|
@@ -327,6 +336,46 @@ defmodule Ret.MediaResolver do | |
| {:commit, (resolved_url || uri) |> resolved(meta)} | ||
| end | ||
|
|
||
| defp resolve_non_video( | ||
DougReeder marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| %MediaResolverQuery{ | ||
| url: %URI{host: "api.icosa.gallery", path: "/v1/assets/" <> asset_id} = uri | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The value assigned to
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ... or we could rename |
||
| }, | ||
| "icosa.gallery" | ||
| ) do | ||
| # Increment stat for the request | ||
| Statix.increment("ret.media_resolver.icosa.requests") | ||
|
|
||
| # Make the API call to get the asset data | ||
| payload = | ||
| "https://api.icosa.gallery/v1/assets/#{asset_id}" | ||
| # Assuming this function sends the request and handles retries | ||
| |> retry_get_until_success() | ||
| |> Map.get(:body) | ||
| |> Poison.decode!() | ||
|
|
||
| # Create the meta information based on the payload | ||
| meta = | ||
| %{ | ||
| expected_content_type: "model/gltf", | ||
| name: payload["displayName"], | ||
| author: payload["authorName"], | ||
| license: payload["license"] | ||
| } | ||
|
|
||
| # Extract the GLTF2 format URL from the payload | ||
| uri = | ||
| payload["formats"] | ||
| |> Enum.find(&(&1["formatType"] == "GLTF2")) | ||
| |> Kernel.get_in(["root", "url"]) | ||
| |> URI.parse() | ||
|
|
||
| # Increment stat for successful resolution | ||
| Statix.increment("ret.media_resolver.icosa.ok") | ||
|
|
||
| # Return the URI and meta data for further processing | ||
| {:commit, resolved(uri, meta)} | ||
| end | ||
|
|
||
| defp resolve_non_video( | ||
| %MediaResolverQuery{url: %URI{path: "/models/" <> model_id}} = query, | ||
| "sketchfab.com" = root_host | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
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.
If there isn't a rate limit for the Icosa API, is this code needed?