@@ -13,6 +13,7 @@ import (
1313 "net/url"
1414 "strconv"
1515 "strings"
16+ "time"
1617
1718 "github.com/RoyXiang/plexproxy/common"
1819 "github.com/jrudio/go-plex-client"
@@ -23,6 +24,8 @@ type PlexConfig struct {
2324 BaseUrl string
2425 Token string
2526 PlaxtUrl string
27+ StaticCacheTtl string
28+ DynamicCacheTtl string
2629 RedirectWebApp string
2730 DisableTranscode string
2831 NoRequestLogs string
@@ -32,6 +35,9 @@ type PlexClient struct {
3235 proxy * httputil.ReverseProxy
3336 client * plex.Plex
3437
38+ staticCacheTtl time.Duration
39+ dynamicCacheTtl time.Duration
40+
3541 plaxtUrl string
3642 redirectWebApp bool
3743 disableTranscode bool
@@ -72,6 +78,15 @@ func NewPlexClient(config PlexConfig) *PlexClient {
7278 plaxtUrl = u .String ()
7379 }
7480
81+ staticCacheTtl , err := time .ParseDuration (config .StaticCacheTtl )
82+ if err != nil {
83+ staticCacheTtl = time .Hour
84+ }
85+ dynamicCacheTtl , err := time .ParseDuration (config .DynamicCacheTtl )
86+ if err != nil {
87+ dynamicCacheTtl = time .Second * 5
88+ }
89+
7590 var redirectWebApp , disableTranscode , noRequestLogs bool
7691 if b , err := strconv .ParseBool (config .RedirectWebApp ); err == nil {
7792 redirectWebApp = b
@@ -93,6 +108,8 @@ func NewPlexClient(config PlexConfig) *PlexClient {
93108 proxy : proxy ,
94109 client : client ,
95110 plaxtUrl : plaxtUrl ,
111+ staticCacheTtl : staticCacheTtl ,
112+ dynamicCacheTtl : dynamicCacheTtl ,
96113 redirectWebApp : redirectWebApp ,
97114 disableTranscode : disableTranscode ,
98115 NoRequestLogs : noRequestLogs ,
0 commit comments