2020-10-12 23:12:46 +00:00
|
|
|
package urlbuilders
|
|
|
|
|
|
|
|
import (
|
2021-03-13 00:49:20 +00:00
|
|
|
"github.com/stashapp/stash/pkg/models"
|
2020-10-12 23:12:46 +00:00
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
|
|
|
type ImageURLBuilder struct {
|
2021-03-13 00:49:20 +00:00
|
|
|
BaseURL string
|
|
|
|
ImageID string
|
|
|
|
UpdatedAt string
|
2020-10-12 23:12:46 +00:00
|
|
|
}
|
|
|
|
|
2021-03-13 00:49:20 +00:00
|
|
|
func NewImageURLBuilder(baseURL string, image *models.Image) ImageURLBuilder {
|
2020-10-12 23:12:46 +00:00
|
|
|
return ImageURLBuilder{
|
2021-03-13 00:49:20 +00:00
|
|
|
BaseURL: baseURL,
|
|
|
|
ImageID: strconv.Itoa(image.ID),
|
|
|
|
UpdatedAt: strconv.FormatInt(image.UpdatedAt.Timestamp.Unix(), 10),
|
2020-10-12 23:12:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b ImageURLBuilder) GetImageURL() string {
|
2021-03-13 00:49:20 +00:00
|
|
|
return b.BaseURL + "/image/" + b.ImageID + "/image?" + b.UpdatedAt
|
2020-10-12 23:12:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (b ImageURLBuilder) GetThumbnailURL() string {
|
2021-03-13 00:49:20 +00:00
|
|
|
return b.BaseURL + "/image/" + b.ImageID + "/thumbnail?" + b.UpdatedAt
|
2020-10-12 23:12:46 +00:00
|
|
|
}
|