Files
Musify/backend/Hosts/Musify.Api/AppSettings.json
T
Admin 356e5c1101 Add anonymous playback with an optional Spotify-style preview cap
New Playback:AllowAnonymousListening / Playback:AnonymousFragmentSeconds
settings control whether a request without a session can stream at all,
and if so, whether it's limited to a fragment instead of the full track:

- GET /tracks/{id}/stream and GET /youtube/tracks/{videoId}/stream no
  longer require authorization outright; the handlers gate on the config
  instead, so both keep working exactly as before when it's off (the
  default).
- The fragment cap is enforced by the Streaming Gateway, not the client:
  the stream ticket now carries an optional maxBytes claim (computed from
  AnonymousFragmentSeconds and the transcoder's known bitrate), and
  TicketValidationMiddleware clamps the Range it forwards to SeaweedFS to
  stay under it — synthesizing one if the request didn't send one, and
  answering 416 outright if the requested range starts past the cap.
- A YouTube track that hasn't been provisioned server-side yet streams
  straight from YouTube's CDN, bypassing the Gateway entirely — there's no
  way to cap that, so an anonymous request for one is refused (409) instead
  of silently handing out an uncapped stream.
- ListeningHistory has a non-nullable UserId, so anonymous plays simply
  don't get recorded rather than trying to force a row through the FK.

Also fixes a real, pre-existing bug this surfaced: the AppSettings.Development.json
of the Api, Worker, and StreamingGateway all pointed StreamTicket/Workers
paths at "../../deploy/..." — one directory short of deploy/'s actual
location at the repo root relative to each project's own folder. Docker
never hit this (it mounts an absolute /keys path), so it had apparently
never been exercised via `dotnet run` before.
2026-09-10 09:56:57 +02:00

146 lines
4.3 KiB
JSON

{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"Authentication": {
"MetadataAddress": "",
"IssuerAddress": "",
"AudienceAddress": "",
"ClientId": "",
"AuthorizationEndpoint": "",
"TokenEndpoint": "",
"Scopes": [],
"ScalarRedirectUri": "",
"RequireHttpsMetadata": true
},
"Database": {
"ConnectionString": ""
},
"MassTransit": {
"Address": "",
"Username": "",
"Password": ""
},
"InfrastructureStorage": {
"Address": "",
"AccessKey": "",
"SecretAccessKey": "",
"ForcePathStyle": false,
"UseHttp": false
},
"ApplicationStorage": {
"Bucket": ""
},
"StreamGateway": {
"PublicBaseUrl": "",
"AudioFileName": "audio.m4a"
},
"StreamTicket": {
"PrivateKeyPath": "",
"Audience": "media-gateway",
"Issuer": "musify-webapi",
"TicketTtlSeconds": 3600
},
"OpenTelemetry": {
"OtlpEndpoint": ""
},
"Playback": {
"AllowAnonymousListening": false,
"AnonymousFragmentSeconds": 0,
"EstimatedAudioBytesPerSecond": 16000
},
"YouTube": {
"Enabled": true,
"GeographicalLocation": "US",
"StreamUrlCacheSeconds": 1800,
"SearchContinuationCacheSeconds": 600,
"SearchResultsCacheSeconds": 900,
"SongInfoCacheSeconds": 86400,
"ThumbnailSize": 240,
"ArtworkSize": 544
},
"Mix": {
"ArtistMixCount": 3,
"ItemsPerMix": 12,
"SeedArtistCount": 3,
"YouTubeResultsPerSeed": 12
},
"PlayList": {
"Routes": {
"UploadsFolder": "uploads",
"ParentFolders": "PlayLists",
"OriginalPicturesFolder": "OriginalPictures",
"SmallPicturesFolder": "SmallPictures",
"MediumPicturesFolder": "MediumPictures",
"LargePicturesFolder": "LargePictures"
},
"PicturesSizes": {
"SmallPictureWidth": 128,
"SmallPictureHeight": 128,
"MediumPictureWidth": 256,
"MediumPictureHeight": 256,
"LargePictureWidth": 512,
"LargePictureHeight": 512
}
},
"Track": {
"Routes": {
"UploadsFolder": "uploads",
"ParentFolder": "Tracks",
"OriginalPicturesFolder": "OriginalPictures",
"SmallPicturesFolder": "SmallPictures",
"MediumPicturesFolder": "MediumPictures",
"LargePicturesFolder": "LargePictures",
"PresetOriginalPicture": "PresetOriginalPicture.webp",
"PresetSmallPicture": "PresetSmallPicture.webp",
"PresetMediumPicture": "PresetMediumPicture.webp",
"PresetLargePicture": "PresetLargePicture.webp",
"OriginalAudiosFolder": "OriginalAudios",
"ProcessedAudioFolder": "ProcessedAudios"
},
"PicturesSizes": {
"SmallPictureWidth": 128,
"SmallPictureHeight": 128,
"MediumPictureWidth": 256,
"MediumPictureHeight": 256,
"LargePictureWidth": 512,
"LargePictureHeight": 512
}
},
"AudioTranscoder": {
"TranscodingTimeout": "00:05:00",
"Ffmpeg": {
"ExecutableName": "ffmpeg",
"OutputFileName": "audio.m4a",
"AudioCodec": "aac",
"AudioBitrate": "128k",
"AudioChannels": 2,
"AudioSampleRate": 48000,
"AudioProfile": "aac_low",
"AdditionalArguments": ""
}
},
"UploadIntent": {
"UploadUrlExpiresInSeconds": 120,
"MaxActiveUploadIntentsPerUser": 5,
"MaxActiveUploadBytesPerUser": 209715200,
"MaxUploadBytes": 104857600,
"DefaultExpectedPictureSizeBytes": 10485760,
"DefaultExpectedAudioSizeBytes": 104857600,
"ExpirationJobIntervalSeconds": 300,
"ExpiredIntentsRetentionDays": 7,
"TempRootPrefix": "temp",
"TempUploadsRetentionDays": 3,
"TempCleanupJobIntervalSeconds": 3600
},
"Workers": {
"Routes": {
"TemporaryFilesDirectory": ""
}
}
}