2019-02-09 12:30:49 +00:00
|
|
|
package urlbuilders
|
|
|
|
|
2019-12-17 17:28:44 +00:00
|
|
|
import (
|
2021-04-12 01:05:49 +00:00
|
|
|
"fmt"
|
2019-12-17 17:28:44 +00:00
|
|
|
"strconv"
|
|
|
|
"time"
|
|
|
|
)
|
2019-02-09 12:30:49 +00:00
|
|
|
|
2019-02-14 22:53:32 +00:00
|
|
|
type SceneURLBuilder struct {
|
2019-02-09 12:30:49 +00:00
|
|
|
BaseURL string
|
|
|
|
SceneID string
|
2021-04-12 01:05:49 +00:00
|
|
|
APIKey string
|
2019-02-09 12:30:49 +00:00
|
|
|
}
|
|
|
|
|
2019-02-14 22:53:32 +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),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-02-14 22:53:32 +00:00
|
|
|
func (b SceneURLBuilder) GetStreamURL() string {
|
2021-04-12 01:05:49 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-02-14 22:53:32 +00:00
|
|
|
func (b SceneURLBuilder) GetStreamPreviewURL() string {
|
2019-02-09 12:30:49 +00:00
|
|
|
return b.BaseURL + "/scene/" + b.SceneID + "/preview"
|
|
|
|
}
|
|
|
|
|
2019-02-14 22:53:32 +00:00
|
|
|
func (b SceneURLBuilder) GetStreamPreviewImageURL() string {
|
2019-02-09 12:30:49 +00:00
|
|
|
return b.BaseURL + "/scene/" + b.SceneID + "/webp"
|
|
|
|
}
|
|
|
|
|
2019-02-14 22:53:32 +00:00
|
|
|
func (b SceneURLBuilder) GetSpriteVTTURL() string {
|
2019-02-09 12:30:49 +00:00
|
|
|
return b.BaseURL + "/scene/" + b.SceneID + "_thumbs.vtt"
|
|
|
|
}
|
|
|
|
|
2021-04-11 23:04:40 +00:00
|
|
|
func (b SceneURLBuilder) GetSpriteURL() string {
|
|
|
|
return b.BaseURL + "/scene/" + b.SceneID + "_sprite.jpg"
|
|
|
|
}
|
|
|
|
|
2019-12-17 17:28:44 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-02-14 22:53:32 +00:00
|
|
|
func (b SceneURLBuilder) GetChaptersVTTURL() string {
|
2019-02-09 12:30:49 +00:00
|
|
|
return b.BaseURL + "/scene/" + b.SceneID + "/vtt/chapter"
|
|
|
|
}
|
|
|
|
|
2019-02-14 22:53:32 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2019-02-14 22:53:32 +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
|
|
|
}
|
2021-05-24 03:34:28 +00:00
|
|
|
|
|
|
|
func (b SceneURLBuilder) GetFunscriptURL() string {
|
|
|
|
return b.BaseURL + "/scene/" + b.SceneID + "/funscript"
|
|
|
|
}
|