Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ ui/v2.5/src/core/generated-*.tsx
.idea/**/dictionaries
.idea/**/shelf
.vscode
.devcontainer

# Generated files
.idea/**/contentModel.xml
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ require (
)

require (
github.com/lucasb-eyer/go-colorful v1.2.0
github.com/vearutop/statigz v1.1.6
github.com/vektah/gqlparser/v2 v2.0.1
)
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,8 @@ github.com/lib/pq v1.8.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/lib/pq v1.10.0 h1:Zx5DJFEYQXio93kgXnQ09fXNiUKsqv4OUEu2UtGcB1E=
github.com/lib/pq v1.10.0/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o=
github.com/logrusorgru/aurora v0.0.0-20200102142835-e9ef32dff381/go.mod h1:7rIyQOR62GCctdiQpZ/zOJlFyk6y+94wXzv6RNZgaR4=
github.com/lucasb-eyer/go-colorful v1.2.0 h1:1nnpGOrhyZZuNyfu1QjKiUICQ74+3FNCN69Aj6K7nkY=
github.com/lucasb-eyer/go-colorful v1.2.0/go.mod h1:R4dSotOR9KMtayYi1e77YzuveK+i7ruzyGqttikkLy0=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.1/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
github.com/magiconair/properties v1.8.5 h1:b6kJs+EmPFMYGkow9GiUyCyOvIwYetYJ3fSaWak/Gls=
Expand Down
2 changes: 2 additions & 0 deletions graphql/documents/data/config.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ fragment ConfigInterfaceData on ConfigInterfaceResult {
}
handyKey
funscriptOffset
funscriptProxy
}

fragment ConfigDLNAData on ConfigDLNAResult {
Expand Down Expand Up @@ -152,6 +153,7 @@ fragment ConfigDefaultSettingsData on ConfigDefaultSettingsResult {
markerScreenshots
transcodes
phashes
interactiveHeatmapsSpeeds
}

deleteFile
Expand Down
3 changes: 3 additions & 0 deletions graphql/documents/data/scene-slim.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ fragment SlimSceneData on Scene {
path
phash
interactive
interactive_speed
interactive_halve

file {
size
Expand All @@ -33,6 +35,7 @@ fragment SlimSceneData on Scene {
chapters_vtt
sprite
funscript
interactive_heatmap
}

scene_markers {
Expand Down
3 changes: 3 additions & 0 deletions graphql/documents/data/scene.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ fragment SceneData on Scene {
path
phash
interactive
interactive_speed
interactive_halve

file {
size
Expand All @@ -33,6 +35,7 @@ fragment SceneData on Scene {
chapters_vtt
sprite
funscript
interactive_heatmap
}

scene_markers {
Expand Down
4 changes: 4 additions & 0 deletions graphql/schema/types/config.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ input ConfigInterfaceInput {
handyKey: String
"""Funscript Time Offset"""
funscriptOffset: Int
"""Funscript Proxy Server"""
funscriptProxy: String
"""True if we should not auto-open a browser window on startup"""
noBrowser: Boolean
}
Expand Down Expand Up @@ -288,6 +290,8 @@ type ConfigInterfaceResult {
handyKey: String
"""Funscript Time Offset"""
funscriptOffset: Int
"""Funscript Proxy Server"""
funscriptProxy: String
}

input ConfigDLNAInput {
Expand Down
2 changes: 2 additions & 0 deletions graphql/schema/types/filters.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,8 @@ input SceneFilterType {
url: StringCriterionInput
"""Filter by interactive"""
interactive: Boolean
"""Filter by InteractiveSpeed"""
interactive_speed: IntCriterionInput
}

input MovieFilterType {
Expand Down
2 changes: 2 additions & 0 deletions graphql/schema/types/metadata.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ input GenerateMetadataInput {
markerScreenshots: Boolean
transcodes: Boolean
phashes: Boolean
interactiveHeatmapsSpeeds: Boolean

"""scene ids to generate for"""
sceneIDs: [ID!]
Expand Down Expand Up @@ -43,6 +44,7 @@ type GenerateMetadataOptions {
markerScreenshots: Boolean
transcodes: Boolean
phashes: Boolean
interactiveHeatmapsSpeeds: Boolean
}

type GeneratePreviewOptions {
Expand Down
4 changes: 4 additions & 0 deletions graphql/schema/types/scene.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type ScenePathsType {
chapters_vtt: String # Resolver
sprite: String # Resolver
funscript: String # Resolver
interactive_heatmap: String # Resolver
}

type SceneMovie {
Expand All @@ -39,6 +40,8 @@ type Scene {
path: String!
phash: String
interactive: Boolean!
interactive_speed: Int
interactive_halve: Boolean!
created_at: Time!
updated_at: Time!
file_mod_time: Time
Expand Down Expand Up @@ -69,6 +72,7 @@ input SceneUpdateInput {
date: String
rating: Int
organized: Boolean
interactive_halve: Boolean
studio_id: ID
gallery_ids: [ID!]
performer_ids: [ID!]
Expand Down
26 changes: 18 additions & 8 deletions pkg/api/resolver_model_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,14 @@ func (r *sceneResolver) Rating(ctx context.Context, obj *models.Scene) (*int, er
return nil, nil
}

func (r *sceneResolver) InteractiveSpeed(ctx context.Context, obj *models.Scene) (*int, error) {
if obj.InteractiveSpeed.Valid {
interactive_speed := int(obj.InteractiveSpeed.Int64)
return &interactive_speed, nil
}
return nil, nil
}

func (r *sceneResolver) File(ctx context.Context, obj *models.Scene) (*models.SceneFileType, error) {
width := int(obj.Width.Int64)
height := int(obj.Height.Int64)
Expand Down Expand Up @@ -89,16 +97,18 @@ func (r *sceneResolver) Paths(ctx context.Context, obj *models.Scene) (*models.S
spritePath := builder.GetSpriteURL()
chaptersVttPath := builder.GetChaptersVTTURL()
funscriptPath := builder.GetFunscriptURL()
interactiveHeatmap := builder.GetInteractiveHeatmapURL()

return &models.ScenePathsType{
Screenshot: &screenshotPath,
Preview: &previewPath,
Stream: &streamPath,
Webp: &webpPath,
Vtt: &vttPath,
ChaptersVtt: &chaptersVttPath,
Sprite: &spritePath,
Funscript: &funscriptPath,
Screenshot: &screenshotPath,
Preview: &previewPath,
Stream: &streamPath,
Webp: &webpPath,
Vtt: &vttPath,
ChaptersVtt: &chaptersVttPath,
Sprite: &spritePath,
Funscript: &funscriptPath,
InteractiveHeatmap: &interactiveHeatmap,
}, nil
}

Expand Down
4 changes: 4 additions & 0 deletions pkg/api/resolver_mutation_configure.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ func (r *mutationResolver) ConfigureInterface(ctx context.Context, input models.
c.Set(config.FunscriptOffset, *input.FunscriptOffset)
}

if input.FunscriptProxy != nil {
c.Set(config.FunscriptProxy, *input.FunscriptProxy)
}

if err := c.Write(); err != nil {
return makeConfigInterfaceResult(), err
}
Expand Down
1 change: 1 addition & 0 deletions pkg/api/resolver_mutation_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func (r *mutationResolver) sceneUpdate(ctx context.Context, input models.SceneUp
updatedScene.Rating = translator.nullInt64(input.Rating, "rating")
updatedScene.StudioID = translator.nullInt64FromString(input.StudioID, "studio_id")
updatedScene.Organized = input.Organized
updatedScene.InteractiveHalve = input.InteractiveHalve

if input.CoverImage != nil && *input.CoverImage != "" {
var err error
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/resolver_query_configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func makeConfigInterfaceResult() *models.ConfigInterfaceResult {
slideshowDelay := config.GetSlideshowDelay()
handyKey := config.GetHandyKey()
scriptOffset := config.GetFunscriptOffset()
funscriptProxy := config.GetFunscriptProxy()

return &models.ConfigInterfaceResult{
MenuItems: menuItems,
Expand All @@ -139,6 +140,7 @@ func makeConfigInterfaceResult() *models.ConfigInterfaceResult {
DisabledDropdownCreate: config.GetDisableDropdownCreate(),
HandyKey: &handyKey,
FunscriptOffset: &scriptOffset,
FunscriptProxy: &funscriptProxy,
}
}

Expand Down
14 changes: 14 additions & 0 deletions pkg/api/routes_scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ package api

import (
"context"
"fmt"
"net/http"
"net/url"
"strconv"
"strings"

Expand Down Expand Up @@ -38,6 +40,7 @@ func (rs sceneRoutes) Routes() chi.Router {
r.Get("/webp", rs.Webp)
r.Get("/vtt/chapter", rs.ChapterVtt)
r.Get("/funscript", rs.Funscript)
r.Get("/interactive_heatmap", rs.InteractiveHeatmap)

r.Get("/scene_marker/{sceneMarkerId}/stream", rs.SceneMarkerStream)
r.Get("/scene_marker/{sceneMarkerId}/preview", rs.SceneMarkerPreview)
Expand Down Expand Up @@ -269,10 +272,21 @@ func (rs sceneRoutes) ChapterVtt(w http.ResponseWriter, r *http.Request) {

func (rs sceneRoutes) Funscript(w http.ResponseWriter, r *http.Request) {
scene := r.Context().Value(sceneKey).(*models.Scene)
proxy := config.GetInstance().GetFunscriptProxy()
funscript := utils.GetFunscriptPath(scene.Path)
if proxy != "" && scene.InteractiveHalve {
http.Redirect(w, r, fmt.Sprintf("%s/fs-halve?fs=%s", proxy, url.QueryEscape(funscript)), http.StatusFound)
}
utils.ServeFileNoCache(w, r, funscript)
}

func (rs sceneRoutes) InteractiveHeatmap(w http.ResponseWriter, r *http.Request) {
scene := r.Context().Value(sceneKey).(*models.Scene)
w.Header().Set("Content-Type", "image/png")
filepath := manager.GetInstance().Paths.Scene.GetInteractiveHeatmapPath(scene.GetHash(config.GetInstance().GetVideoFileNamingAlgorithm()))
http.ServeFile(w, r, filepath)
}

func (rs sceneRoutes) VttThumbs(w http.ResponseWriter, r *http.Request) {
scene := r.Context().Value(sceneKey).(*models.Scene)
w.Header().Set("Content-Type", "text/vtt")
Expand Down
4 changes: 4 additions & 0 deletions pkg/api/urlbuilders/scene.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,7 @@ func (b SceneURLBuilder) GetSceneMarkerStreamScreenshotURL(sceneMarkerID int) st
func (b SceneURLBuilder) GetFunscriptURL() string {
return b.BaseURL + "/scene/" + b.SceneID + "/funscript"
}

func (b SceneURLBuilder) GetInteractiveHeatmapURL() string {
return b.BaseURL + "/scene/" + b.SceneID + "/interactive_heatmap"
}
2 changes: 1 addition & 1 deletion pkg/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (
var DB *sqlx.DB
var WriteMu sync.Mutex
var dbPath string
var appSchemaVersion uint = 28
var appSchemaVersion uint = 30
var databaseSchemaVersion uint

//go:embed migrations/*.sql
Expand Down
1 change: 1 addition & 0 deletions pkg/database/migrations/29_interactive_speed.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `scenes` ADD COLUMN `interactive_speed` int
1 change: 1 addition & 0 deletions pkg/database/migrations/30_interactive_halve.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE `scenes` ADD COLUMN `interactive_halve` boolean not null default '0';
5 changes: 5 additions & 0 deletions pkg/manager/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ const (

HandyKey = "handy_key"
FunscriptOffset = "funscript_offset"
FunscriptProxy = "funscript_proxy"

// Security
TrustedProxies = "trusted_proxies"
Expand Down Expand Up @@ -921,6 +922,10 @@ func (i *Instance) GetFunscriptOffset() int {
return i.getInt(FunscriptOffset)
}

func (i *Instance) GetFunscriptProxy() string {
return i.getString(FunscriptProxy)
}

func (i *Instance) GetDeleteFileDefault() bool {
return i.getBool(DeleteFileDefault)
}
Expand Down
Loading