all repos — fixyoutube-go @ e642c6324ad5251d2eebbd04f9817c35cb0dccf4

A better way to embed YouTube videos everywhere (inspired by FixTweet).

read INSTANCE var
Marco Andronaco andronacomarco@gmail.com
Fri, 20 Dec 2024 22:46:55 +0100
commit

e642c6324ad5251d2eebbd04f9817c35cb0dccf4

parent

a07abe81886576fd49175b5d58b10eba22d53029

4 files changed, 17 insertions(+), 5 deletions(-)

jump to
M .env.example.env.example

@@ -4,3 +4,4 @@ BURST_TOKENS=3

RATE_LIMIT=1 ADMIN_USER=admin ADMIN_PASS=admin +INSTANCE=
M README.mdREADME.md

@@ -8,10 +8,9 @@ https://github.com/BiRabittoh/FixYouTube/assets/26506860/e1ad5397-41c8-4073-9b3e-598c66241255

## Instructions -First of all, you should duplicate and fill your `.env` file: +First of all, you should create your `.env` file: ``` cp .env.example .env -nano .env ``` ### Docker without reverse proxy
M fixyoutube.gofixyoutube.go

@@ -5,6 +5,7 @@ "net/http"

"os" "strconv" + "github.com/birabittoh/fixyoutube-go/invidious" "github.com/joho/godotenv" "github.com/sirupsen/logrus" "golang.org/x/time/rate"

@@ -60,6 +61,8 @@ logger.SetLevel(logrus.DebugLevel)

logger.Debug("Debug mode enabled (rate limiting is disabled)") debugSwitch = true } + + invidious.Init(logLevel, os.Getenv("INSTANCE")) port := getEnvDefault("PORT", "3000") burstTokens := getEnvDefaultParse("BURST_TOKENS", "3")
M invidious/invidious.goinvidious/invidious.go

@@ -9,13 +9,22 @@ "github.com/birabittoh/rabbitpipe"

"github.com/sirupsen/logrus" ) -var logger = logrus.New() -var buffers = myks.New[VideoBuffer](time.Minute) -var RP = rabbitpipe.New("") +var logger *logrus.Logger +var buffers *myks.KeyStore[VideoBuffer] +var RP *rabbitpipe.Client type VideoBuffer struct { Buffer *bytes.Buffer Length int64 +} + +func Init(logLevel logrus.Level, instance string) { + logger = logrus.New() + logger.SetLevel(logLevel) + + buffers = myks.New[VideoBuffer](time.Minute) + + RP = rabbitpipe.New(instance) } func GetVideoURL(video rabbitpipe.Video) string {