kopia lustrzana https://dev.funkwhale.audio/funkwhale/funkwhale
Give priority to local uploads when playing a track
rodzic
2074234acb
commit
95ba6e1b22
|
@ -255,6 +255,7 @@ def serialize_upload(upload):
|
|||
"bitrate": upload.bitrate,
|
||||
"mimetype": upload.mimetype,
|
||||
"extension": upload.extension,
|
||||
"is_local": federation_utils.is_local(upload.fid),
|
||||
}
|
||||
|
||||
|
||||
|
@ -305,7 +306,10 @@ class TrackSerializer(OptionalDescriptionMixin, serializers.Serializer):
|
|||
|
||||
def get_uploads(self, obj):
|
||||
uploads = getattr(obj, "playable_uploads", [])
|
||||
return [serialize_upload(u) for u in sort_uploads_for_listen(uploads)]
|
||||
# we put local uploads first
|
||||
uploads = [serialize_upload(u) for u in sort_uploads_for_listen(uploads)]
|
||||
uploads = sorted(uploads, key=lambda u: u["is_local"], reverse=True)
|
||||
return list(uploads)
|
||||
|
||||
def get_tags(self, obj):
|
||||
tagged_items = getattr(obj, "_prefetched_tagged_items", [])
|
||||
|
|
|
@ -354,6 +354,7 @@ def test_serialize_upload(factories):
|
|||
"mimetype": upload.mimetype,
|
||||
"extension": upload.extension,
|
||||
"duration": upload.duration,
|
||||
"is_local": False,
|
||||
}
|
||||
|
||||
data = serializers.serialize_upload(upload)
|
||||
|
|
|
@ -513,7 +513,7 @@ Upload:
|
|||
uuid:
|
||||
type: string
|
||||
format: uuid
|
||||
size:size:
|
||||
size:
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
example: 278987000
|
||||
|
@ -541,6 +541,9 @@ Upload:
|
|||
type: "string"
|
||||
format: "uri"
|
||||
description: "URL to stream the upload"
|
||||
is_local:
|
||||
type: "boolean"
|
||||
description: "Indicates if the object was initally created locally or on another server"
|
||||
|
||||
OwnedLibraryCreate:
|
||||
type: "object"
|
||||
|
|
Ładowanie…
Reference in New Issue