Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions api/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ func NewApiServer(config config.Config) *ApiServer {
g.Post("/tracks/:trackId/reposts", app.requireAuthMiddleware, app.requireWriteScope, app.postV1TrackRepost)
g.Delete("/tracks/:trackId/reposts", app.requireAuthMiddleware, app.requireWriteScope, app.deleteV1TrackRepost)
g.Get("/tracks/:trackId/stems", app.v1TrackStems)
g.Get("/tracks/:trackId/stems/download", app.v1TrackStemsDownload)
g.Get("/tracks/:trackId/favorites", app.v1TrackFavorites)
g.Post("/tracks/:trackId/favorites", app.requireAuthMiddleware, app.requireWriteScope, app.postV1TrackFavorite)
g.Delete("/tracks/:trackId/favorites", app.requireAuthMiddleware, app.requireWriteScope, app.deleteV1TrackFavorite)
Expand Down
60 changes: 60 additions & 0 deletions api/swagger/swagger-v1.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4381,6 +4381,66 @@ paths:
application/json:
schema:
$ref: "#/components/schemas/stems_response"
/tracks/{track_id}/stems/download:
get:
tags:
- tracks
summary: Download a track's stems as one zip
description:
Streams every stem the requester may download, and optionally the
parent track, as a single uncompressed zip with a known
Content-Length. Files that can't be downloaded are left out.
operationId: Download Track Stems
security:
- {}
- OAuth2:
- read
parameters:
- name: track_id
in: path
description: A Track ID
required: true
schema:
type: string
- name: include_parent
in: query
description: Optional - also include the parent track's file
schema:
type: boolean
default: false
- name: user_id
in: query
description: The user ID of the user making the request
schema:
type: string
- name: user_signature
in: query
description:
Optional - signature from the requesting user's wallet. Needed
for gated stems and for an artist downloading their own files.
schema:
type: string
- name: user_data
in: query
description:
Optional - data which was used to generate the optional signature
argument.
schema:
type: string
responses:
"200":
description: Success
content:
application/zip: {}
"403":
description: Not allowed to download any of the stems
content: {}
"404":
description: Track not found, or no downloadable stems
content: {}
"429":
description: Too many downloads in progress
content: {}
/tracks/{track_id}/shares:
post:
tags:
Expand Down
14 changes: 8 additions & 6 deletions api/v1_track_inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"fmt"
"net/http"
"time"

"api.audius.co/api/dbv1"
"api.audius.co/rendezvous"
Expand All @@ -22,27 +23,28 @@ type inspectResponse struct {
}

func inspectTrack(track dbv1.Track, original bool) (*inspectResponse, error) {
var cid string
if original {
cid = track.OrigFileCid.String
} else {
cid = track.TrackCid.String
return inspectCid(track.OrigFileCid.String)
}
return inspectCid(track.TrackCid.String)
}

var inspectClient = &http.Client{Timeout: 10 * time.Second}

func inspectCid(cid string) (*inspectResponse, error) {
hosts := rendezvous.GlobalHasher.Rank(cid)

var info blobInspect
var lastErr error

for _, host := range hosts {
client := &http.Client{}
req, err := http.NewRequest("GET", fmt.Sprintf("%s/internal/blobs/info/%s", host, cid), nil)
if err != nil {
lastErr = err
continue
}

resp, err := client.Do(req)
resp, err := inspectClient.Do(req)
if err != nil {
lastErr = err
continue
Expand Down
Loading
Loading