mirror of
https://github.com/stashapp/stash.git
synced 2026-05-09 05:05:29 +02:00
68 lines
1.5 KiB
Go
68 lines
1.5 KiB
Go
// TODO(audio): updaqte this file
|
|
|
|
package urlbuilders
|
|
|
|
import (
|
|
"fmt"
|
|
"net/url"
|
|
"strconv"
|
|
|
|
"github.com/stashapp/stash/pkg/models"
|
|
)
|
|
|
|
type AudioURLBuilder struct {
|
|
BaseURL string
|
|
AudioID string
|
|
UpdatedAt string
|
|
}
|
|
|
|
func NewAudioURLBuilder(baseURL string, audio *models.Audio) AudioURLBuilder {
|
|
return AudioURLBuilder{
|
|
BaseURL: baseURL,
|
|
AudioID: strconv.Itoa(audio.ID),
|
|
UpdatedAt: strconv.FormatInt(audio.UpdatedAt.Unix(), 10),
|
|
}
|
|
}
|
|
|
|
func (b AudioURLBuilder) GetStreamURL(apiKey string) *url.URL {
|
|
u, err := url.Parse(fmt.Sprintf("%s/audio/%s/stream", b.BaseURL, b.AudioID))
|
|
if err != nil {
|
|
// shouldn't happen
|
|
panic(err)
|
|
}
|
|
|
|
if apiKey != "" {
|
|
v := u.Query()
|
|
v.Set("apikey", apiKey)
|
|
u.RawQuery = v.Encode()
|
|
}
|
|
return u
|
|
}
|
|
|
|
func (b AudioURLBuilder) GetStreamPreviewURL() string {
|
|
return b.BaseURL + "/audio/" + b.AudioID + "/preview"
|
|
}
|
|
|
|
func (b AudioURLBuilder) GetStreamPreviewImageURL() string {
|
|
return b.BaseURL + "/audio/" + b.AudioID + "/webp"
|
|
}
|
|
|
|
func (b AudioURLBuilder) GetSpriteVTTURL(checksum string) string {
|
|
return b.BaseURL + "/audio/" + checksum + "_thumbs.vtt"
|
|
}
|
|
|
|
func (b AudioURLBuilder) GetSpriteURL(checksum string) string {
|
|
return b.BaseURL + "/audio/" + checksum + "_sprite.jpg"
|
|
}
|
|
|
|
func (b AudioURLBuilder) GetScreenshotURL() string {
|
|
return b.BaseURL + "/audio/" + b.AudioID + "/screenshot?t=" + b.UpdatedAt
|
|
}
|
|
|
|
func (b AudioURLBuilder) GetFunscriptURL() string {
|
|
return b.BaseURL + "/audio/" + b.AudioID + "/funscript"
|
|
}
|
|
|
|
func (b AudioURLBuilder) GetCaptionURL() string {
|
|
return b.BaseURL + "/audio/" + b.AudioID + "/caption"
|
|
}
|