diff --git a/.air.toml b/.air.toml index 0d4e933..095bf00 100644 --- a/.air.toml +++ b/.air.toml @@ -4,8 +4,8 @@ tmp_dir = "tmp" [build] args_bin = ["-l", "0.0.0.0"] -bin = "./tmp/main" -cmd = "go build -o ./tmp/main ." +bin = "./ytdl-web" +cmd = "task build" delay = 1000 exclude_dir = ["assets", "tmp", "vendor", "testdata"] exclude_file = [] diff --git a/Taskfile.yml b/Taskfile.yml index 4ae28f6..33e3086 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -1,7 +1,13 @@ version: "3" +vars: + VERSION: 1.0.0 + VERSION_PKG: go.fifitido.net/ytdl-web/version + BUILD: + sh: git rev-parse --short HEAD + tasks: deps: go mod download tidy: go mod tidy - build: go build -o ytdl-web . - dev: air \ No newline at end of file + build: go build -ldflags="-X {{.VERSION_PKG}}.Version={{.VERSION}} -X {{.VERSION_PKG}}.Build={{.BUILD}}" -o ytdl-web . + dev: air diff --git a/version/version.go b/version/version.go new file mode 100644 index 0000000..e40727f --- /dev/null +++ b/version/version.go @@ -0,0 +1,4 @@ +package version + +var Version string +var Build string diff --git a/web/serve.go b/web/serve.go index c9ec29d..c3c5ebc 100644 --- a/web/serve.go +++ b/web/serve.go @@ -9,6 +9,7 @@ import ( "github.com/samber/lo" "github.com/spf13/viper" "github.com/sujit-baniya/flash" + "go.fifitido.net/ytdl-web/version" "go.fifitido.net/ytdl-web/ytdl" "golang.org/x/exp/slog" ) @@ -19,8 +20,11 @@ func Serve() error { app.Get("/", func(c *fiber.Ctx) error { return c.Render("views/index", fiber.Map{ - "BasePath": viper.GetString("base_path"), - "Flash": flash.Get(c), + "BasePath": viper.GetString("base_path"), + "Flash": flash.Get(c), + "Version": version.Version, + "Build": version.Build, + "YtdlpVersion": ytdl.GetVersion(), }, "views/layouts/main") }) @@ -57,7 +61,13 @@ func Serve() error { }) return c.Render("views/download", fiber.Map{ - "BasePath": viper.GetString("base_path"), "Url": url, "Meta": meta, "Formats": formats, + "BasePath": viper.GetString("base_path"), + "Url": url, + "Meta": meta, + "Formats": formats, + "Version": version.Version, + "Build": version.Build, + "YtdlpVersion": ytdl.GetVersion(), }, "views/layouts/main") }) diff --git a/web/views/index.html b/web/views/index.html index 3ad3518..0d74577 100644 --- a/web/views/index.html +++ b/web/views/index.html @@ -1,6 +1,11 @@
- Download videos from many different websites using yt-dlp
+ Download videos from over a thousand websites with the help of
+ yt-dlp,
+ a fork of youtube-dl with more features and fixes.
+
+ View a complete list of supported websites
+ here.