diff --git a/packages/api/src/controllers/asset.ts b/packages/api/src/controllers/asset.ts index 1f1ea3741..8118ce584 100644 --- a/packages/api/src/controllers/asset.ts +++ b/packages/api/src/controllers/asset.ts @@ -418,7 +418,26 @@ function getDownloadUrl( os.id !== vodObjectStoreId ? os.publicUrl : pathJoin(ingest, "asset"); const source = asset.files?.find((f) => f.type === "source_file"); if (source) { - return pathJoin(base, asset.playbackId, source.path); + const formatToFileExtension: Map = new Map([ + ["mpegts", "ts"], + ["mp4", "mp4"], + ["mov", "mov"], + ["matroska", "mkv"], + ["avi", "avi"], + ]); + + if ( + source.path != "video" || + !formatToFileExtension.has(asset.videoSpec.format) + ) { + return pathJoin(base, asset.playbackId, source.path); + } + return pathJoin( + base, + asset.playbackId, + source.path, + "download." + formatToFileExtension.get(asset.videoSpec.format), + ); } return pathJoin(base, asset.playbackId, "video"); } diff --git a/packages/api/src/schema/api-schema.yaml b/packages/api/src/schema/api-schema.yaml index 376f76feb..435067a2b 100644 --- a/packages/api/src/schema/api-schema.yaml +++ b/packages/api/src/schema/api-schema.yaml @@ -1059,7 +1059,7 @@ components: downloadUrl: readOnly: true type: string - example: "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video" + example: "https://livepeercdn.com/asset/eaw4nk06ts2d0mzb/video/download.mp4" description: >- The URL to directly download the asset, e.g. `https://livepeercdn.com/asset/eawrrk06ts2d0mzb/video`. It is not