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"
|
2022-10-09 23:11:51 +00:00
|
|
|
"net/url"
|
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),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-09 23:11:51 +00:00
|
|
|
func (b SceneURLBuilder) GetStreamURL() *url.URL {
|
|
|
|
u, err := url.Parse(fmt.Sprintf("%s/scene/%s/stream", b.BaseURL, b.SceneID))
|
|
|
|
if err != nil {
|
|
|
|
// shouldn't happen
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
|
2021-04-12 01:05:49 +00:00
|
|
|
if b.APIKey != "" {
|
2022-10-09 23:11:51 +00:00
|
|
|
v := u.Query()
|
|
|
|
v.Set("apikey", b.APIKey)
|
|
|
|
u.RawQuery = v.Encode()
|
2021-04-12 01:05:49 +00:00
|
|
|
}
|
2022-10-09 23:11:51 +00:00
|
|
|
return u
|
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
|
|
|
}
|
|
|
|
|
2022-11-15 22:45:45 +00:00
|
|
|
func (b SceneURLBuilder) GetChaptersVTTURL() string {
|
|
|
|
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
|
|
|
|
2021-09-15 02:27:05 +00:00
|
|
|
func (b SceneURLBuilder) GetSceneMarkerStreamScreenshotURL(sceneMarkerID int) string {
|
|
|
|
return b.BaseURL + "/scene/" + b.SceneID + "/scene_marker/" + strconv.Itoa(sceneMarkerID) + "/screenshot"
|
|
|
|
}
|
|
|
|
|
2021-05-24 03:34:28 +00:00
|
|
|
func (b SceneURLBuilder) GetFunscriptURL() string {
|
|
|
|
return b.BaseURL + "/scene/" + b.SceneID + "/funscript"
|
|
|
|
}
|
2021-12-13 02:41:07 +00:00
|
|
|
|
2022-05-06 01:59:28 +00:00
|
|
|
func (b SceneURLBuilder) GetCaptionURL() string {
|
|
|
|
return b.BaseURL + "/scene/" + b.SceneID + "/caption"
|
|
|
|
}
|
|
|
|
|
2021-12-13 02:41:07 +00:00
|
|
|
func (b SceneURLBuilder) GetInteractiveHeatmapURL() string {
|
|
|
|
return b.BaseURL + "/scene/" + b.SceneID + "/interactive_heatmap"
|
|
|
|
}
|