Skip to content

Commit

Permalink
feat: added ffmpeg download in cli (#1)
Browse files Browse the repository at this point in the history
feat: added cmds - `port`, `no-thumb`, `get-ffmpeg`
refactor: moved all pkgs to internal
chore: removed cors, upgraded go version to 1.23
  • Loading branch information
mysterion authored Sep 5, 2024
1 parent 4191a4c commit 2a0722c
Show file tree
Hide file tree
Showing 24 changed files with 1,010 additions and 900 deletions.
4 changes: 0 additions & 4 deletions .env

This file was deleted.

6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ Usage of avrp:
starts in dev mode, serves 'index.html' from current directory
-dir string
path to video files
-get-ffmpeg
downloads ffmpeg
-no-thumb
disables thumbnail generation
-port int
port to serve on (default 5000) (default 5000)
-reset
removes all configs, thumbnails & 'aframe-vr-player' files
-sha string
Expand Down
38 changes: 30 additions & 8 deletions avrp.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@ import (
"log"
"os"

"github.com/mysterion/avrp/internal/dist"
"github.com/mysterion/avrp/internal/server"
"github.com/mysterion/avrp/internal/thumbnails"
"github.com/mysterion/avrp/internal/utils"
"github.com/mysterion/avrp/thirdparty"
"github.com/mysterion/avrp/web/api"
"github.com/mysterion/avrp/web/dist"
)

func isPathValid(path string) bool {
Expand Down Expand Up @@ -46,20 +45,43 @@ func main() {
var sha string
var update bool
var reset bool
var port int
var getFfmpeg bool
var noThumb bool

flag.BoolVar(&utils.DEV, "dev", false, "starts in dev mode, serves 'index.html' from current directory")
flag.BoolVar(&update, "update", false, "checks & downloads the latest version(commit) of 'aframe-vr-player'")
flag.StringVar(&sha, "sha", "latest", "Optional - download a specific commit of aframe-vr-player")
flag.StringVar(&servDir, "dir", "", "path to video files")
flag.BoolVar(&reset, "reset", false, "removes all configs, thumbnails & 'aframe-vr-player' files")
flag.IntVar(&port, "port", 5000, "port to serve on (default 5000)")
flag.BoolVar(&getFfmpeg, "get-ffmpeg", false, "downloads ffmpeg")
flag.BoolVar(&noThumb, "no-thumb", false, "disables thumbnail generation")

flag.Parse()

utils.Init()
dist.Init()
thirdparty.Init()
thumbnails.Init()

// commands 👇

if getFfmpeg {
utils.Panic(thumbnails.DownloadFfmpeg())
return
}

if noThumb {
if thumbnails.NoFfmpeg() {
thumbnails.NoFfmpegFileRemove()
log.Println("thumbnail generation enabled👍")
} else {
thumbnails.NoFfmpegFileCreate()
log.Println("thumbnail generation disabled👎")
}
return
}

if reset {
err := os.RemoveAll(utils.ConfigDir)
if err != nil {
Expand All @@ -72,10 +94,10 @@ func main() {

if update {
dist.Update(sha)
return
}

/// do i need this anymore?
utils.GoRunGatekeeper()
// commands 👆

// running for the first time
if !dist.Valid() && !utils.DEV {
Expand All @@ -90,6 +112,6 @@ func main() {
}
}

api.Init(servDir)
api.Start(5000)
server.Init(servDir)
server.Start(port)
}
53 changes: 0 additions & 53 deletions bake

This file was deleted.

3 changes: 0 additions & 3 deletions build/thirdparty/README.md

This file was deleted.

9 changes: 0 additions & 9 deletions cmd/playground/playground.go

This file was deleted.

4 changes: 1 addition & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
module github.com/mysterion/avrp

go 1.22.3

require github.com/rs/cors v1.11.0 // indirect
go 1.23
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
github.com/rs/cors v1.11.0 h1:0B9GE/r9Bc2UxRMMtymBkHTenPkHDv0CW4Y98GBY+po=
github.com/rs/cors v1.11.0/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
74 changes: 37 additions & 37 deletions web/dist/dist.go → internal/dist/dist.go
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
package dist

import (
"log"
"os"
"path/filepath"

"github.com/mysterion/avrp/internal/utils"
)

var VersionFile string

func Init() {
VersionFile = filepath.Join(utils.ConfigDir, "VERSION")
}

// checks if dist is present
func Valid() bool {
_, err := os.Stat(filepath.Join(utils.DistDir, "index.html"))
return err == nil
}

func Delete() error {
return os.RemoveAll(utils.DistDir)
}

// returns sha of aframe-vr-player dist
func Ver() string {
d, err := os.ReadFile(VersionFile)

if err != nil {
log.Printf("WARN: while reading dist version, %v\n", err.Error())
return ""
}

return string(d)
}
package dist

import (
"log"
"os"
"path/filepath"

"github.com/mysterion/avrp/internal/utils"
)

var VersionFile string

func Init() {
VersionFile = filepath.Join(utils.ConfigDir, "VERSION")
}

// checks if dist is present
func Valid() bool {
_, err := os.Stat(filepath.Join(utils.DistDir, "index.html"))
return err == nil
}

func Delete() error {
return os.RemoveAll(utils.DistDir)
}

// returns sha of aframe-vr-player dist
func Ver() string {
d, err := os.ReadFile(VersionFile)

if err != nil {
log.Printf("WARN: while reading dist version, %v\n", err.Error())
return ""
}

return string(d)
}
Loading

0 comments on commit 2a0722c

Please sign in to comment.