stash/pkg/api/urlbuilders/scene.go

65 lines
1.7 KiB
Go
Raw Normal View History

2019-02-09 12:30:49 +00:00
package urlbuilders
import (
"fmt"
"strconv"
"time"
)
2019-02-09 12:30:49 +00:00
type SceneURLBuilder struct {
2019-02-09 12:30:49 +00:00
BaseURL string
SceneID string
APIKey string
2019-02-09 12:30:49 +00:00
}
func NewSceneURLBuilder(baseURL string, sceneID int) SceneURLBuilder {
return SceneURLBuilder{
2019-02-09 12:30:49 +00:00
BaseURL: baseURL,
SceneID: strconv.Itoa(sceneID),
}
}
func (b SceneURLBuilder) GetStreamURL() string {
var apiKeyParam string
if b.APIKey != "" {
apiKeyParam = fmt.Sprintf("?apikey=%s", b.APIKey)
}
return fmt.Sprintf("%s/scene/%s/stream%s", b.BaseURL, b.SceneID, apiKeyParam)
2019-02-09 12:30:49 +00:00
}
func (b SceneURLBuilder) GetStreamPreviewURL() string {
2019-02-09 12:30:49 +00:00
return b.BaseURL + "/scene/" + b.SceneID + "/preview"
}
func (b SceneURLBuilder) GetStreamPreviewImageURL() string {
2019-02-09 12:30:49 +00:00
return b.BaseURL + "/scene/" + b.SceneID + "/webp"
}
func (b SceneURLBuilder) GetSpriteVTTURL() string {
2019-02-09 12:30:49 +00:00
return b.BaseURL + "/scene/" + b.SceneID + "_thumbs.vtt"
}
func (b SceneURLBuilder) GetSpriteURL() string {
return b.BaseURL + "/scene/" + b.SceneID + "_sprite.jpg"
}
func (b SceneURLBuilder) GetScreenshotURL(updateTime time.Time) string {
return b.BaseURL + "/scene/" + b.SceneID + "/screenshot?" + strconv.FormatInt(updateTime.Unix(), 10)
2019-02-09 12:30:49 +00:00
}
func (b SceneURLBuilder) GetChaptersVTTURL() string {
2019-02-09 12:30:49 +00:00
return b.BaseURL + "/scene/" + b.SceneID + "/vtt/chapter"
}
func (b SceneURLBuilder) GetSceneMarkerStreamURL(sceneMarkerID int) string {
return b.BaseURL + "/scene/" + b.SceneID + "/scene_marker/" + strconv.Itoa(sceneMarkerID) + "/stream"
2019-02-09 12:30:49 +00:00
}
func (b SceneURLBuilder) GetSceneMarkerStreamPreviewURL(sceneMarkerID int) string {
return b.BaseURL + "/scene/" + b.SceneID + "/scene_marker/" + strconv.Itoa(sceneMarkerID) + "/preview"
2019-02-09 12:30:49 +00:00
}
func (b SceneURLBuilder) GetFunscriptURL() string {
return b.BaseURL + "/scene/" + b.SceneID + "/funscript"
}