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

Fetch playback URL for imported asset using source URL #1370

Merged
merged 4 commits into from
Oct 26, 2022

Conversation

yondonfu
Copy link
Member

What does this pull request do? Explain your changes. (required)

Supersedes #1367. This PR is also built off of #1365 which introduces a source field to the Asset entity.

This new (and simpler impl in Studio!) approach depends on livepeer/task-runner#76. Instead of allowing a user to specify arbitrary source IDs that can be used to lookup a playback URL via the /playback endpoint, Studio relies on task-runner to handle ipfs:// URLs by importing the asset using a list of trusted IPFS gateways to ensure that the asset imported matches the CID in the ipfs:// URL.

The /playback endpoint will try the following in order for a CID:

  1. Try to lookup the CID using the storage.ipfs.cid field of an asset which will be populated if the asset was exported to IPFS by Studio
  2. Try to lookup ipfs:// + CID using the source.url field of an asset which will be populated if the asset was imported from IPFS by Studio. A playback URL will only be returned if the asset's status is set to ready which indicates that the asset was actually successfully imported.

Specific updates (required)

See commit history.

  • How did you test each of these updates (required)

Updated unit tests.

Does this pull request close any open issues?

Fixes #1362

Screenshots (optional):

Checklist:

  • I have read the CONTRIBUTING document.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.

@yondonfu yondonfu requested a review from a team as a code owner October 26, 2022 20:05
@vercel
Copy link

vercel bot commented Oct 26, 2022

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated
livepeer-studio ✅ Ready (Inspect) Visit Preview Oct 26, 2022 at 10:08PM (UTC)

Copy link
Member

@0xcadams 0xcadams left a comment

Choose a reason for hiding this comment

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

LGTM, will let Victor review since he's more familiar. Excited to get this deployed.

limit: 2,
order: "coalesce((asset.data->'createdAt')::bigint, 0) ASC",
});
if (!assets || assets.length < 1) {
Copy link
Member

Choose a reason for hiding this comment

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

Same issue as discussed here

Base automatically changed from vg/feat/asset-source to master October 26, 2022 21:01
Copy link
Member

@victorges victorges left a comment

Choose a reason for hiding this comment

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

In a quick glance looks good! I can look in detail in a minute but feel free to merge as is.

@@ -47,7 +47,8 @@ const getAssetPlaybackUrl = async (
cid: boolean
) => {
const asset = cid
? await db.asset.getByIpfsCid(id)
? (await db.asset.getByIpfsCid(id)) ??
(await db.asset.getBySourceURL("ipfs://" + id))
Copy link
Member

Choose a reason for hiding this comment

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

might wanna add the ar:// here if we add support for that on task runner

Copy link
Member Author

Choose a reason for hiding this comment

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

Added in #1372

Missing asset_source_url index in expected result
@codecov
Copy link

codecov bot commented Oct 26, 2022

Codecov Report

Merging #1370 (9cb8975) into master (f6506aa) will increase coverage by 0.09649%.
The diff coverage is 100.00000%.

Impacted file tree graph

@@                 Coverage Diff                 @@
##              master       #1370         +/-   ##
===================================================
+ Coverage   52.12026%   52.21675%   +0.09649%     
===================================================
  Files             68          68                 
  Lines           4457        4466          +9     
  Branches         831         834          +3     
===================================================
+ Hits            2323        2332          +9     
  Misses          1838        1838                 
  Partials         296         296                 
Impacted Files Coverage Δ
packages/api/src/controllers/playback.ts 91.42857% <100.00000%> (+0.25210%) ⬆️
packages/api/src/store/asset-table.ts 88.23529% <100.00000%> (+4.90196%) ⬆️
packages/api/src/store/table.ts 70.06369% <100.00000%> (+0.58317%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f6506aa...9cb8975. Read the comment docs.

Impacted Files Coverage Δ
packages/api/src/controllers/playback.ts 91.42857% <100.00000%> (+0.25210%) ⬆️
packages/api/src/store/asset-table.ts 88.23529% <100.00000%> (+4.90196%) ⬆️
packages/api/src/store/table.ts 70.06369% <100.00000%> (+0.58317%) ⬆️

@yondonfu yondonfu merged commit 23ec9a7 into master Oct 26, 2022
@yondonfu yondonfu deleted the yf/feat/asset-source-uri-lookup branch October 26, 2022 22:38
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.

Support fetching playback URL for asset imported from dStorage gateway using dStorage ID
3 participants