From d637f4d0111f35eda35674bb27e7856f605d9c96 Mon Sep 17 00:00:00 2001 From: Vincent Boutour Date: Tue, 17 Sep 2024 14:44:40 +0200 Subject: [PATCH] refactor: Rename vith to vignet Signed-off-by: Vincent Boutour --- README.md | 14 +++++------ compose.yaml | 50 +++++++++++++++++++------------------- go.mod | 2 +- go.sum | 4 +-- infra/web.yaml | 2 +- pkg/provider/provider.go | 4 +-- pkg/thumbnail/amqp.go | 4 +-- pkg/thumbnail/event.go | 2 +- pkg/thumbnail/generate.go | 14 +++++------ pkg/thumbnail/stream.go | 20 +++++++-------- pkg/thumbnail/thumbnail.go | 32 ++++++++++++------------ pkg/thumbnail/utils.go | 8 ++---- 12 files changed, 76 insertions(+), 80 deletions(-) diff --git a/README.md b/README.md index a398199f..a033256c 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Fibr creates a `.fibr` folder in _root folder_ for storing its metadata: shares' ### Sidecars -Fibr generates thumbnails of images, PDF and videos when these [mime-types are detected](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types) and sidecars are provided. Sidecars are [ViBiOh/vith](https://github.com/vibioh/vith) and [ViBiOh/exas](https://github.com/vibioh/exas). Thumbnails are generated in [WebP](https://developers.google.com/speed/webp/) format, in their animated format for video thumbnail. +Fibr generates thumbnails of images, PDF and videos when these [mime-types are detected](https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types) and sidecars are provided. Sidecars are [ViBiOh/vignet](https://github.com/vibioh/vignet) and [ViBiOh/exas](https://github.com/vibioh/exas). Thumbnails are generated in [WebP](https://developers.google.com/speed/webp/) format, in their animated format for video thumbnail. You can refer to these projects for installing and configuring them and set `-thumbnailURL` and `-exifURL` options. @@ -47,9 +47,9 @@ Sidecars may have constraints regarding concurrent work (e.g. HLS conversion is #### HTTP Live Streaming -Fibr has a special treatment for videos, that can be very large sometimes. With the help of the `vith` sidecar, it can convert a video to its [HLS version](https://en.wikipedia.org/wiki/HTTP_Live_Streaming). It keeps the original video as is, and stores streamable version in the metadatas directory. It's a basic conversion into the appropriate format: no resolution, frame-per-second or any quality specifications are changed. Conversion is done where this two requirements are met altogether: +Fibr has a special treatment for videos, that can be very large sometimes. With the help of the `vignet` sidecar, it can convert a video to its [HLS version](https://en.wikipedia.org/wiki/HTTP_Live_Streaming). It keeps the original video as is, and stores streamable version in the metadatas directory. It's a basic conversion into the appropriate format: no resolution, frame-per-second or any quality specifications are changed. Conversion is done where this two requirements are met altogether: -- `vith` is configured with direct access to the filesystem (see [`vith`documentation about configuring `WorkDir`](https://github.com/vibioh/vith#usage) and [`fibr` configuration](#usage) for enabling it). Direct access disable large file transfer in the network. +- `vignet` is configured with direct access to the filesystem (see [`vignet`documentation about configuring `WorkDir`](https://github.com/vibioh/vignet#usage) and [`fibr` configuration](#usage) for enabling it). Direct access disable large file transfer in the network. - the video bitrate is above [`thumbnailMinBitrate (default 80000000)`](#usage) ### Chunk upload @@ -289,13 +289,13 @@ Usage of fibr: --thumbnailAmqpExchange string [thumbnail] AMQP Exchange Name ${FIBR_THUMBNAIL_AMQP_EXCHANGE} (default "fibr") --thumbnailAmqpStreamRoutingKey string [thumbnail] AMQP Routing Key for stream ${FIBR_THUMBNAIL_AMQP_STREAM_ROUTING_KEY} (default "stream") --thumbnailAmqpThumbnailRoutingKey string [thumbnail] AMQP Routing Key for thumbnail ${FIBR_THUMBNAIL_AMQP_THUMBNAIL_ROUTING_KEY} (default "thumbnail") - --thumbnailDirectAccess [thumbnail] Use Vith with direct access to filesystem (no large file upload, send a GET request, Basic Auth recommended) ${FIBR_THUMBNAIL_DIRECT_ACCESS} (default false) + --thumbnailDirectAccess [thumbnail] Use Vignet with direct access to filesystem (no large file upload, send a GET request, Basic Auth recommended) ${FIBR_THUMBNAIL_DIRECT_ACCESS} (default false) --thumbnailLargeSize uint [thumbnail] Size of large thumbnail for story display (thumbnail are always squared). 0 to disable ${FIBR_THUMBNAIL_LARGE_SIZE} (default 800) --thumbnailMaxSize int [thumbnail] Maximum file size (in bytes) for generating thumbnail (0 to no limit). Not used if DirectAccess enabled. ${FIBR_THUMBNAIL_MAX_SIZE} (default 209715200) --thumbnailMinBitrate uint [thumbnail] Minimal video bitrate (in bits per second) to generate a streamable version (in HLS), if DirectAccess enabled ${FIBR_THUMBNAIL_MIN_BITRATE} (default 80000000) - --thumbnailPassword string [thumbnail] Vith Thumbnail Basic Auth Password ${FIBR_THUMBNAIL_PASSWORD} - --thumbnailURL string [thumbnail] Vith Thumbnail URL ${FIBR_THUMBNAIL_URL} (default "http://vith:1080") - --thumbnailUser string [thumbnail] Vith Thumbnail Basic Auth User ${FIBR_THUMBNAIL_USER} + --thumbnailPassword string [thumbnail] Vignet Thumbnail Basic Auth Password ${FIBR_THUMBNAIL_PASSWORD} + --thumbnailURL string [thumbnail] Vignet Thumbnail URL ${FIBR_THUMBNAIL_URL} (default "http://vignet:1080") + --thumbnailUser string [thumbnail] Vignet Thumbnail Basic Auth User ${FIBR_THUMBNAIL_USER} --title string Application title ${FIBR_TITLE} (default "fibr") --url string [alcotest] URL to check ${FIBR_URL} --userAgent string [alcotest] User-Agent for check ${FIBR_USER_AGENT} (default "Alcotest") diff --git a/compose.yaml b/compose.yaml index eb4cccb8..17ba3b37 100644 --- a/compose.yaml +++ b/compose.yaml @@ -1,22 +1,22 @@ --- -version: '3.9' +version: "3.9" services: service: image: vibioh/fibr environment: - FIBR_AUTH_USERS: '${BASIC_USERS}' - FIBR_AMQP_URI: 'amqp://guest:guest@rabbit:5672/' - FIBR_AMQP_WAIT_TIMEOUT: '30s' - FIBR_CHUNK_UPLOAD: 'true' - FIBR_EXIF_DIRECT_ACCESS: 'true' + FIBR_AUTH_USERS: "${BASIC_USERS}" + FIBR_AMQP_URI: "amqp://guest:guest@rabbit:5672/" + FIBR_AMQP_WAIT_TIMEOUT: "30s" + FIBR_CHUNK_UPLOAD: "true" + FIBR_EXIF_DIRECT_ACCESS: "true" FIBR_REDIS_ADDRESS: redis:6379 - FIBR_THUMBNAIL_DIRECT_ACCESS: 'true' + FIBR_THUMBNAIL_DIRECT_ACCESS: "true" ports: - - '1080:1080/tcp' + - "1080:1080/tcp" volumes: - - '${DATA_DIR}:/data' - - '/tmp:/tmp' + - "${DATA_DIR}:/data" + - "/tmp:/tmp" entrypoint: - /wait - -timeout @@ -30,7 +30,7 @@ services: depends_on: - redis - rabbit - user: '${DATA_USER_ID}' + user: "${DATA_USER_ID}" read_only: true redis: @@ -46,12 +46,12 @@ services: exas: image: vibioh/exas environment: - EXAS_AMQP_URI: 'amqp://guest:guest@rabbit:5672/' - EXAS_AMQP_WAIT_TIMEOUT: '30s' - EXAS_GEOCODE_URL: 'https://nominatim.openstreetmap.org' - EXAS_STORAGE_FILE_SYSTEM_DIRECTORY: '/data' + EXAS_AMQP_URI: "amqp://guest:guest@rabbit:5672/" + EXAS_AMQP_WAIT_TIMEOUT: "30s" + EXAS_GEOCODE_URL: "https://nominatim.openstreetmap.org" + EXAS_STORAGE_FILE_SYSTEM_DIRECTORY: "/data" volumes: - - '${DATA_DIR}:/data' + - "${DATA_DIR}:/data" entrypoint: - /wait - -timeout @@ -62,17 +62,17 @@ services: - /exas depends_on: - rabbit - user: '${DATA_USER_ID}' + user: "${DATA_USER_ID}" read_only: true - vith: - image: vibioh/vith + vignet: + image: vibioh/vignet environment: - VITH_AMQP_URI: 'amqp://guest:guest@rabbit:5672/' - VITH_AMQP_WAIT_TIMEOUT: '30s' - VITH_STORAGE_FILE_SYSTEM_DIRECTORY: '/data' + VIGNET_AMQP_URI: "amqp://guest:guest@rabbit:5672/" + VIGNET_AMQP_WAIT_TIMEOUT: "30s" + VIGNET_STORAGE_FILE_SYSTEM_DIRECTORY: "/data" volumes: - - '${DATA_DIR}:/data' + - "${DATA_DIR}:/data" entrypoint: - /wait - -timeout @@ -80,9 +80,9 @@ services: - -address - tcp:service:1080 - -next - - /vith + - /vignet depends_on: - rabbit - image - user: '${DATA_USER_ID}' + user: "${DATA_USER_ID}" read_only: true diff --git a/go.mod b/go.mod index c7a771be..ebaa4de2 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/ViBiOh/exas v0.8.1 github.com/ViBiOh/flags v1.6.0 github.com/ViBiOh/httputils/v4 v4.80.6 - github.com/ViBiOh/vith v0.6.0 + github.com/ViBiOh/vignet v0.0.1 github.com/rabbitmq/amqp091-go v1.10.0 github.com/redis/go-redis/v9 v9.6.1 github.com/rs/xid v1.6.0 diff --git a/go.sum b/go.sum index cd06e998..4d603cb4 100644 --- a/go.sum +++ b/go.sum @@ -10,8 +10,8 @@ github.com/ViBiOh/flags v1.6.0 h1:f69V4ROK5XHAV71cL1yVP2UC/8xKiKJvunvgrtW/qsg= github.com/ViBiOh/flags v1.6.0/go.mod h1:sbFyRQ7u5xzCssqGHn/hLSTlxmMYKe09WaPneJxHveA= github.com/ViBiOh/httputils/v4 v4.80.6 h1:jhguNnarSEevpHZbP93Ix+qPfIDlue8HAdM7iAZnq2U= github.com/ViBiOh/httputils/v4 v4.80.6/go.mod h1:uEOrzMewNPhnks4jcuPgjV+OkbrFMSscAMODZ2ysj2s= -github.com/ViBiOh/vith v0.6.0 h1:bdLmwgqUEWi3ivShtAhtM9gOZlWQzvZi2Z5b0BRSB1U= -github.com/ViBiOh/vith v0.6.0/go.mod h1:eRqtDU2uB8g85vll4spbnCV93DHyHNAYwXCMIBH1GuQ= +github.com/ViBiOh/vignet v0.0.1 h1:gKTh9FJBJ7+ZWZFvAXsefcPoi9QmBoaZXUiL5DKNK1M= +github.com/ViBiOh/vignet v0.0.1/go.mod h1:DCeiKdWswm6bhWIs3WAeuKIcs5v85Y06skW1R+kW5Vs= github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= diff --git a/infra/web.yaml b/infra/web.yaml index 3764cc59..1bb31bcc 100644 --- a/infra/web.yaml +++ b/infra/web.yaml @@ -76,7 +76,7 @@ spec: FIBR_THUMBNAIL_DIRECT_ACCESS: "true" FIBR_THUMBNAIL_LARGE_SIZE: "1000" FIBR_THUMBNAIL_MIN_BITRATE: "30000000" - FIBR_THUMBNAIL_URL: http://vith + FIBR_THUMBNAIL_URL: http://vignet OTEL_RESOURCE_ATTRIBUTES: env=production,git.repository_url=github.com/ViBiOh/fibr secrets: FIBR_AMQP_URI: AgA9cvt+WxhWbE0BhP+LdNOgUWVNaLr8BBpi1BSVmHByUsUkRwM2rrN6wncgPTfJGW2nRzah+tYfgs2A31d3eNpi1UuG4ndH6IRSxrUJqA5FUXha8NlN5jzpqALFcIaEP0zavkef5U9YmuO3UdUT9o/thHwwJzy+au0DI44qtImIsEtOsVzq4fwBGIt2A+z5QqmeZK0TMcao630QqwLoksY0C0ZR+XomxuaGUCdR7xgiuQnHKeSp9idXoQc5sa84EEuoix+FCXuMwKn26dSytqLgeYpND2Ryj0WeRX6zl4Mf5V65PDBMqPxNvn9l+QxoKbM4HB++6N8oAvfkHQTCIqKH8lsrznpguYt1dYDEZwkMK6ho1Xy/ZVPGdKAELKdt+SYWoaZ9DV4A/sj4SkRFuGvPkoAc8raS/bxyWGbLWtwvCYSr0P99M7zTSDiNzEqy+3zjS0Q6vYE+JPKvAHwMrpAjWzB2hT0en10LPPnjNDNcSRPo118mzpopik752t6Ejx3JzAVU2OI08eSxxoejh/ZabuPocaZIseBRvWxHYoXVbLMgbmuEmvYc0PXm+/FNUsj/d7gs7aEsl5OUDwgpjDUtaq90eW5aUZb6OrGp2sKc3OmXDGq4IWDdqbBV7mzt/sjTvULBe9LwunneZN9OUJvYj5+r5107qaxzOQYmwYx8Qvs7GECbxcXofKg1lfWKUzbnFn9ekbqPegOSTQ5XD/y3LHimvaKtnpKHRXkAW5Si9krBExtljW8WHpTsW2nP9Rhf diff --git a/pkg/provider/provider.go b/pkg/provider/provider.go index 70ee32bd..beb1fa42 100644 --- a/pkg/provider/provider.go +++ b/pkg/provider/provider.go @@ -26,8 +26,8 @@ var ( // ThumbnailExtensions contains extensions of file eligible to thumbnail ThumbnailExtensions = map[string]bool{".jpg": true, ".jpeg": true, ".png": true, ".gif": true, ".tiff": true, ".webp": true, ".pdf": true, ".mp4": true, ".mov": true, ".avi": true, ".ogg": true, ".mkv": true, ".heic": true} - // VithExtensions contains extensions of file eligible to thumbnail generation by vith - VithExtensions = map[string]bool{".jpg": true, ".jpeg": true, ".png": true, ".gif": true, ".tiff": true, ".webp": true, ".mp4": true, ".mov": true, ".avi": true, ".ogg": true, ".mkv": true, ".heic": true} + // VignetExtensions contains extensions of file eligible to thumbnail generation by vignet + VignetExtensions = map[string]bool{".jpg": true, ".jpeg": true, ".png": true, ".gif": true, ".tiff": true, ".webp": true, ".mp4": true, ".mov": true, ".avi": true, ".ogg": true, ".mkv": true, ".heic": true} ) func MetadataDirectory(item absto.Item) string { diff --git a/pkg/thumbnail/amqp.go b/pkg/thumbnail/amqp.go index 1587dc64..f4450cca 100644 --- a/pkg/thumbnail/amqp.go +++ b/pkg/thumbnail/amqp.go @@ -7,7 +7,7 @@ import ( absto "github.com/ViBiOh/absto/pkg/model" "github.com/ViBiOh/httputils/v4/pkg/telemetry" - vith "github.com/ViBiOh/vith/pkg/model" + vignet "github.com/ViBiOh/vignet/pkg/model" amqp "github.com/rabbitmq/amqp091-go" ) @@ -15,7 +15,7 @@ func (s Service) AMQPHandler(ctx context.Context, message amqp.Delivery) (err er ctx, end := telemetry.StartSpan(ctx, s.tracer, "amqp") defer end(&err) - var req vith.Request + var req vignet.Request if err := json.Unmarshal(message.Body, &req); err != nil { return fmt.Errorf("decode: %w", err) } diff --git a/pkg/thumbnail/event.go b/pkg/thumbnail/event.go index f89bd732..5d01e0ca 100644 --- a/pkg/thumbnail/event.go +++ b/pkg/thumbnail/event.go @@ -10,7 +10,7 @@ import ( ) func (s Service) EventConsumer(ctx context.Context, e provider.Event) { - if s.vithRequest.IsZero() && s.amqpClient == nil { + if s.vignetRequest.IsZero() && s.amqpClient == nil { return } diff --git a/pkg/thumbnail/generate.go b/pkg/thumbnail/generate.go index 186bd9b2..202e6aea 100644 --- a/pkg/thumbnail/generate.go +++ b/pkg/thumbnail/generate.go @@ -10,8 +10,8 @@ import ( absto "github.com/ViBiOh/absto/pkg/model" "github.com/ViBiOh/fibr/pkg/provider" "github.com/ViBiOh/httputils/v4/pkg/request" - "github.com/ViBiOh/vith/pkg/model" - vith "github.com/ViBiOh/vith/pkg/model" + "github.com/ViBiOh/vignet/pkg/model" + vignet "github.com/ViBiOh/vignet/pkg/model" ) const ( @@ -26,7 +26,7 @@ func (s Service) generate(ctx context.Context, item absto.Item, scale uint64) (e itemType := typeOfItem(item) var resp *http.Response - resp, err = s.requestVith(ctx, item, itemType, scale) + resp, err = s.requestVignet(ctx, item, itemType, scale) if err != nil { s.increaseMetric(ctx, itemType.String(), "error") return fmt.Errorf("request thumbnailer: %w", err) @@ -54,19 +54,19 @@ func (s Service) generate(ctx context.Context, item absto.Item, scale uint64) (e return err } -func (s Service) requestVith(ctx context.Context, item absto.Item, itemType model.ItemType, scale uint64) (*http.Response, error) { +func (s Service) requestVignet(ctx context.Context, item absto.Item, itemType model.ItemType, scale uint64) (*http.Response, error) { outputName := s.PathForScale(item, scale) if s.amqpClient != nil { s.increaseMetric(ctx, itemType.String(), "publish") - return nil, s.amqpClient.PublishJSON(ctx, vith.NewRequest(item.Pathname, outputName, itemType, scale), s.amqpExchange, s.amqpThumbnailRoutingKey) + return nil, s.amqpClient.PublishJSON(ctx, vignet.NewRequest(item.Pathname, outputName, itemType, scale), s.amqpExchange, s.amqpThumbnailRoutingKey) } s.increaseMetric(ctx, itemType.String(), "request") if s.directAccess { - return s.vithRequest.Method(http.MethodGet).Path("%s?type=%s&scale=%d&output=%s", item.Pathname, itemType, scale, outputName).Send(ctx, nil) + return s.vignetRequest.Method(http.MethodGet).Path("%s?type=%s&scale=%d&output=%s", item.Pathname, itemType, scale, outputName).Send(ctx, nil) } - return provider.SendLargeFile(ctx, s.storage, item, s.vithRequest.Method(http.MethodPost).Path("?type=%s&scale=%d", itemType, scale)) + return provider.SendLargeFile(ctx, s.storage, item, s.vignetRequest.Method(http.MethodPost).Path("?type=%s&scale=%d", itemType, scale)) } diff --git a/pkg/thumbnail/stream.go b/pkg/thumbnail/stream.go index bdf15013..aae76a85 100644 --- a/pkg/thumbnail/stream.go +++ b/pkg/thumbnail/stream.go @@ -11,7 +11,7 @@ import ( absto "github.com/ViBiOh/absto/pkg/model" "github.com/ViBiOh/httputils/v4/pkg/request" - "github.com/ViBiOh/vith/pkg/model" + "github.com/ViBiOh/vignet/pkg/model" ) func (s Service) HasStream(ctx context.Context, item absto.Item) bool { @@ -19,7 +19,7 @@ func (s Service) HasStream(ctx context.Context, item absto.Item) bool { return err == nil } -func (s Service) handleVithResponse(ctx context.Context, err error, body io.ReadCloser) error { +func (s Service) handleVignetResponse(ctx context.Context, err error, body io.ReadCloser) error { if err != nil { s.increaseMetric(ctx, "stream", "error") return fmt.Errorf("send request: %w", err) @@ -39,13 +39,13 @@ func (s Service) shouldGenerateStream(ctx context.Context, item absto.Item) (boo s.increaseMetric(ctx, "stream", "bitrate") - resp, err := s.vithRequest.Method(http.MethodHead).Path("%s?type=%s", item.Pathname, typeOfItem(item)).Send(ctx, nil) + resp, err := s.vignetRequest.Method(http.MethodHead).Path("%s?type=%s", item.Pathname, typeOfItem(item)).Send(ctx, nil) if err != nil { s.increaseMetric(ctx, "stream", "error") return false, fmt.Errorf("retrieve metadata: %w", err) } - rawBitrate := resp.Header.Get("X-Vith-Bitrate") + rawBitrate := resp.Header.Get("X-Vignet-Bitrate") if len(rawBitrate) == 0 { return false, nil } @@ -84,20 +84,20 @@ func (s Service) generateStream(ctx context.Context, item absto.Item) error { s.increaseMetric(ctx, "stream", "request") - resp, err := s.vithRequest.Method(http.MethodPut).Path("%s?output=%s", input, url.QueryEscape(output)).Send(ctx, nil) - return s.handleVithResponse(ctx, err, resp.Body) + resp, err := s.vignetRequest.Method(http.MethodPut).Path("%s?output=%s", input, url.QueryEscape(output)).Send(ctx, nil) + return s.handleVignetResponse(ctx, err, resp.Body) } func (s Service) renameStream(ctx context.Context, old, new absto.Item) error { s.increaseMetric(ctx, "stream", "rename") - resp, err := s.vithRequest.Method(http.MethodPatch).Path("%s?to=%s&type=%s", getStreamPath(old), url.QueryEscape(getStreamPath(new)), typeOfItem(old)).Send(ctx, nil) - return s.handleVithResponse(ctx, err, resp.Body) + resp, err := s.vignetRequest.Method(http.MethodPatch).Path("%s?to=%s&type=%s", getStreamPath(old), url.QueryEscape(getStreamPath(new)), typeOfItem(old)).Send(ctx, nil) + return s.handleVignetResponse(ctx, err, resp.Body) } func (s Service) deleteStream(ctx context.Context, item absto.Item) error { s.increaseMetric(ctx, "stream", "delete") - resp, err := s.vithRequest.Method(http.MethodDelete).Path("%s?type=%s", getStreamPath(item), typeOfItem(item)).Send(ctx, nil) - return s.handleVithResponse(ctx, err, resp.Body) + resp, err := s.vignetRequest.Method(http.MethodDelete).Path("%s?type=%s", getStreamPath(item), typeOfItem(item)).Send(ctx, nil) + return s.handleVignetResponse(ctx, err, resp.Body) } diff --git a/pkg/thumbnail/thumbnail.go b/pkg/thumbnail/thumbnail.go index 88ac3285..e13d0a16 100644 --- a/pkg/thumbnail/thumbnail.go +++ b/pkg/thumbnail/thumbnail.go @@ -25,7 +25,7 @@ import ( "github.com/ViBiOh/httputils/v4/pkg/redis" "github.com/ViBiOh/httputils/v4/pkg/request" "github.com/ViBiOh/httputils/v4/pkg/telemetry" - "github.com/ViBiOh/vith/pkg/model" + "github.com/ViBiOh/vignet/pkg/model" "go.opentelemetry.io/otel/metric" "go.opentelemetry.io/otel/trace" ) @@ -50,18 +50,18 @@ type Service struct { amqpExchange string amqpStreamRoutingKey string - sizes []uint64 - vithRequest request.Request - largeSize uint64 - maxSize int64 - minBitrate uint64 - directAccess bool + sizes []uint64 + vignetRequest request.Request + largeSize uint64 + maxSize int64 + minBitrate uint64 + directAccess bool } type Config struct { - VithURL string - VithUser string - VithPass string + VignetURL string + VignetUser string + VignetPass string AmqpExchange string AmqpStreamRoutingKey string @@ -77,11 +77,11 @@ type Config struct { func Flags(fs *flag.FlagSet, prefix string) *Config { var config Config - flags.New("URL", "Vith Thumbnail URL").Prefix(prefix).DocPrefix("thumbnail").StringVar(fs, &config.VithURL, "http://vith:1080", nil) - flags.New("User", "Vith Thumbnail Basic Auth User").Prefix(prefix).DocPrefix("thumbnail").StringVar(fs, &config.VithUser, "", nil) - flags.New("Password", "Vith Thumbnail Basic Auth Password").Prefix(prefix).DocPrefix("thumbnail").StringVar(fs, &config.VithPass, "", nil) + flags.New("URL", "Vignet Thumbnail URL").Prefix(prefix).DocPrefix("thumbnail").StringVar(fs, &config.VignetURL, "http://vignet:1080", nil) + flags.New("User", "Vignet Thumbnail Basic Auth User").Prefix(prefix).DocPrefix("thumbnail").StringVar(fs, &config.VignetUser, "", nil) + flags.New("Password", "Vignet Thumbnail Basic Auth Password").Prefix(prefix).DocPrefix("thumbnail").StringVar(fs, &config.VignetPass, "", nil) - flags.New("DirectAccess", "Use Vith with direct access to filesystem (no large file upload, send a GET request, Basic Auth recommended)").Prefix(prefix).DocPrefix("thumbnail").BoolVar(fs, &config.DirectAccess, false, nil) + flags.New("DirectAccess", "Use Vignet with direct access to filesystem (no large file upload, send a GET request, Basic Auth recommended)").Prefix(prefix).DocPrefix("thumbnail").BoolVar(fs, &config.DirectAccess, false, nil) flags.New("MaxSize", "Maximum file size (in bytes) for generating thumbnail (0 to no limit). Not used if DirectAccess enabled.").Prefix(prefix).DocPrefix("thumbnail").Int64Var(fs, &config.MaxSize, 1024*1024*200, nil) flags.New("MinBitrate", "Minimal video bitrate (in bits per second) to generate a streamable version (in HLS), if DirectAccess enabled").Prefix(prefix).DocPrefix("thumbnail").Uint64Var(fs, &config.MinBitrate, 80*1000*1000, nil) @@ -113,7 +113,7 @@ func New(ctx context.Context, config *Config, storage absto.Storage, redisClient } service := Service{ - vithRequest: request.New().URL(config.VithURL).BasicAuth(config.VithUser, config.VithPass).WithClient(provider.SlowClient), + vignetRequest: request.New().URL(config.VignetURL).BasicAuth(config.VignetUser, config.VignetPass).WithClient(provider.SlowClient), maxSize: config.MaxSize, minBitrate: config.MinBitrate, @@ -283,7 +283,7 @@ func (s Service) generateImageThumbnail(ctx context.Context, item absto.Item, pa for _, size := range s.sizes { var req *http.Request - req, err = s.vithRequest.Method(http.MethodPost).Path("?type=%s&scale=%d", itemType, size).Build(ctx, io.NopCloser(bytes.NewReader(payload))) + req, err = s.vignetRequest.Method(http.MethodPost).Path("?type=%s&scale=%d", itemType, size).Build(ctx, io.NopCloser(bytes.NewReader(payload))) if err != nil { err = fmt.Errorf("build %d: %w", size, err) return diff --git a/pkg/thumbnail/utils.go b/pkg/thumbnail/utils.go index ef68b24f..87816ad4 100644 --- a/pkg/thumbnail/utils.go +++ b/pkg/thumbnail/utils.go @@ -8,7 +8,7 @@ import ( "github.com/ViBiOh/fibr/pkg/provider" "github.com/ViBiOh/fibr/pkg/version" "github.com/ViBiOh/httputils/v4/pkg/telemetry" - "github.com/ViBiOh/vith/pkg/model" + "github.com/ViBiOh/vignet/pkg/model" ) func (s Service) CanHaveThumbnail(item absto.Item) bool { @@ -16,7 +16,7 @@ func (s Service) CanHaveThumbnail(item absto.Item) bool { } func (s Service) CanGenerateThumbnail(item absto.Item) bool { - return !item.IsDir() && provider.VithExtensions[item.Extension] && (s.maxSize == 0 || item.Size() < s.maxSize || s.directAccess) + return !item.IsDir() && provider.VignetExtensions[item.Extension] && (s.maxSize == 0 || item.Size() < s.maxSize || s.directAccess) } func (s Service) HasLargeThumbnail(ctx context.Context, item absto.Item) bool { @@ -76,10 +76,6 @@ func typeOfItem(item absto.Item) model.ItemType { itemType = model.TypeImage } - if _, ok := provider.PdfExtensions[item.Extension]; ok { - itemType = model.TypePDF - } - return itemType }