From e4e6c02606c8c01aaa9e5c22ab1e41a1a933f6d5 Mon Sep 17 00:00:00 2001 From: "Jared.K" <3268576+jaredkotoff@users.noreply.github.com> Date: Sun, 29 Oct 2023 14:22:20 -0700 Subject: [PATCH 1/5] Bump go and package versions --- go.mod | 4 ++-- go.sum | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/go.mod b/go.mod index c687c2b..ea2b30b 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,6 @@ require ( github.com/juju/ansiterm v1.0.0 // indirect github.com/lunixbochs/vtclean v1.0.0 // indirect github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.19 // indirect - golang.org/x/sys v0.8.0 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + golang.org/x/sys v0.13.0 // indirect ) diff --git a/go.sum b/go.sum index 855960d..5f29c22 100644 --- a/go.sum +++ b/go.sum @@ -27,8 +27,8 @@ github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA= -github.com/mattn/go-isatty v0.0.19/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/sparkdemcisin81/promptui v1.0.0 h1:GGK4vlIZP36dyM1PgKH0utVkk13kDUqOS5sy6XqeU6I= github.com/sparkdemcisin81/promptui v1.0.0/go.mod h1:RpZAFCsCFF7OVe+B1Pc4gEA1OAW0n7uQq43ck3rPpNk= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -38,8 +38,8 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= +golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= From 095e8f2ee2608c38162c4503cfa254ce9618940f Mon Sep 17 00:00:00 2001 From: "Jared.K" <3268576+jaredkotoff@users.noreply.github.com> Date: Sun, 29 Oct 2023 14:22:39 -0700 Subject: [PATCH 2/5] Bump workflow versions --- .github/workflows/build.yml | 8 ++++---- .vscode/settings.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d54d8d8..fcd32e9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -16,7 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 - name: Get Version @@ -24,9 +24,9 @@ jobs: - name: Echo Branch Name run: echo '${{ env.VERSION }}' - name: Set up Go - uses: actions/setup-go@v3 + uses: actions/setup-go@v4 with: - go-version: 1.18 + go-version: '>=1.21.3' - name: Cache Go modules uses: actions/cache@v3 with: @@ -35,7 +35,7 @@ jobs: restore-keys: | ${{ runner.os }}-go- - name: Run GoReleaser - uses: goreleaser/goreleaser-action@v3 + uses: goreleaser/goreleaser-action@v5 if: startsWith(github.ref, 'refs/tags/') with: version: latest diff --git a/.vscode/settings.json b/.vscode/settings.json index a9c979d..5b32f8b 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -16,7 +16,7 @@ "yaml.schemas": { "https://json.schemastore.org/github-workflow.json": [ "file:///Users/jared/personal/github/obs-random-videos/.github/workflows/build.yml", - "file:///Users/jared/personal/github/obs-random-videos/.github/workflows/build.yml" + "file:///Users/jared/personal/github/obs-random-videos/.github/workflows/stale.yml" ] } } \ No newline at end of file From 9f05b07362f9dfc27f0391428e813c6b6b90eaf0 Mon Sep 17 00:00:00 2001 From: "Jared.K" <3268576+jaredkotoff@users.noreply.github.com> Date: Sun, 29 Oct 2023 14:23:15 -0700 Subject: [PATCH 3/5] Properly encodeURI of file path and encodeURIComponent of file to better support special characters --- js/main.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/js/main.js b/js/main.js index 549026e..2c41151 100644 --- a/js/main.js +++ b/js/main.js @@ -77,7 +77,7 @@ function progressPlaylistState() { * next item after that * @returns {string} the next item in the playlist */ -function getNextPlaylistItem() { +function getNextPlaylistItem(returnEncoded = true) { const playlist = getPlaylist(); let mediaItem = playlist.pop() || ''; @@ -91,7 +91,15 @@ function getNextPlaylistItem() { if (localStorage.getItem(`lastPlayed-${hashKey}`) === mediaItem) { // moves the repeated item to the end so its not skipped entirely storePlaylistState([mediaItem].concat(playlist)); - mediaItem = getNextPlaylistItem(); + mediaItem = getNextPlaylistItem(false); + } + + if (returnEncoded) { + const parts = mediaItem.split('/'); + // @ts-ignore + const file = encodeURIComponent(parts.pop()); + const path = `${encodeURI(parts.join('/'))}`; + mediaItem = `${path}/${file}`; } return mediaItem; } From 5ff35507f230d9314fec1c81316da8d2220353d8 Mon Sep 17 00:00:00 2001 From: "Jared.K" <3268576+jaredkotoff@users.noreply.github.com> Date: Sun, 29 Oct 2023 14:57:49 -0700 Subject: [PATCH 4/5] Fix macos placing html file in HOME --- .github/workflows/build.yml | 2 +- README.md | 1 + go.mod | 8 ++------ go.sum | 34 ++-------------------------------- main.go | 19 +++++++++++++------ 5 files changed, 19 insertions(+), 45 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index fcd32e9..bfb04c9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,7 +26,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v4 with: - go-version: '>=1.21.3' + go-version: '>=1.21.2' - name: Cache Go modules uses: actions/cache@v3 with: diff --git a/README.md b/README.md index 948562c..32332ce 100644 --- a/README.md +++ b/README.md @@ -74,3 +74,4 @@ Notice: the VLC Source now supports "Shuffle playlist" option. - Option to HTML background color - Good for videos with weird aspect ratio - Good for audio files +- Switch to [Bubble Tea](https://github.com/charmbracelet/bubbletea) instead of `promptui` \ No newline at end of file diff --git a/go.mod b/go.mod index ea2b30b..7d53d50 100644 --- a/go.mod +++ b/go.mod @@ -1,14 +1,10 @@ module github.com/UpDownLeftDie/obs-random-videos/v2 -go 1.20 +go 1.21.2 -require github.com/sparkdemcisin81/promptui v1.0.0 +require github.com/1lann/promptui v0.8.1-0.20220708222609-81fad96dd5e1 require ( github.com/chzyer/readline v1.5.1 // indirect - github.com/juju/ansiterm v1.0.0 // indirect - github.com/lunixbochs/vtclean v1.0.0 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect golang.org/x/sys v0.13.0 // indirect ) diff --git a/go.sum b/go.sum index 5f29c22..145bdef 100644 --- a/go.sum +++ b/go.sum @@ -1,3 +1,5 @@ +github.com/1lann/promptui v0.8.1-0.20220708222609-81fad96dd5e1 h1:LejjvYg4tCW5HO7q/1nzPrprh47oUD9OUySQ29pDp5c= +github.com/1lann/promptui v0.8.1-0.20220708222609-81fad96dd5e1/go.mod h1:cnC/60IoLiDM0GhdKYJ6oO7AwpZe1IQfPnSKlAURgHw= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/logex v1.2.1 h1:XHDu3E6q+gdHgsdTPH6ImJMIp436vR6MPtH8gP05QzM= github.com/chzyer/logex v1.2.1/go.mod h1:JLbx6lG2kDbNRFnfkgvh4eRJRPX1QCoOIWomwysCBrQ= @@ -7,39 +9,7 @@ github.com/chzyer/readline v1.5.1/go.mod h1:Eh+b79XXUwfKfcPLepksvw2tcLE/Ct21YObk github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= github.com/chzyer/test v1.0.0 h1:p3BQDXSxOhOG0P9z6/hGnII4LGiEPOYBhs8asl/fC04= github.com/chzyer/test v1.0.0/go.mod h1:2JlltgoNkt4TW/z9V/IzDdFaMTM2JPIi26O1pF38GC8= -github.com/juju/ansiterm v0.0.0-20180109212912-720a0952cc2a/go.mod h1:UJSiEoRfvx3hP73CvoARgeLjaIOjybY9vj8PUPPFGeU= -github.com/juju/ansiterm v1.0.0 h1:gmMvnZRq7JZJx6jkfSq9/+2LMrVEwGwt7UR6G+lmDEg= -github.com/juju/ansiterm v1.0.0/go.mod h1:PyXUpnI3olx3bsPcHt98FGPX/KCFZ1Fi+hw1XLI6384= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.1 h1:Fmg33tUaq4/8ym9TJN1x7sLJnHVwhP33CNkpYV/7rwI= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/lunixbochs/vtclean v0.0.0-20180621232353-2d01aacdc34a/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= -github.com/lunixbochs/vtclean v1.0.0 h1:xu2sLAri4lGiovBDQKxl5mrXyESr3gUr5m5SM5+LVb8= -github.com/lunixbochs/vtclean v1.0.0/go.mod h1:pHhQNgMf3btfWnGBVipUOjRYhoOsdGqdm/+2c2E2WMI= -github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= -github.com/mattn/go-colorable v0.1.10/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/sparkdemcisin81/promptui v1.0.0 h1:GGK4vlIZP36dyM1PgKH0utVkk13kDUqOS5sy6XqeU6I= -github.com/sparkdemcisin81/promptui v1.0.0/go.mod h1:RpZAFCsCFF7OVe+B1Pc4gEA1OAW0n7uQq43ck3rPpNk= golang.org/x/sys v0.0.0-20181122145206-62eef0e2fa9b/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE= golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/main.go b/main.go index 6dd7a36..1904a97 100644 --- a/main.go +++ b/main.go @@ -16,7 +16,7 @@ import ( "text/template" "time" - "github.com/sparkdemcisin81/promptui" // using this instead of manifoldco because of weird bugs 🤷‍♂️ + "github.com/1lann/promptui" // using this instead of manifoldco because of race conditions and weird bugs 🤷‍♂️ ) //go:embed template.gohtml @@ -63,7 +63,7 @@ var ( ) func main() { - fmt.Printf("OBS Random Video: %s\n\n", version); + fmt.Printf("OBS Random Video: %s\n\n", version) mainDir, err := filepath.Abs(filepath.Dir(os.Args[0])) if err != nil { log.Fatalf("Failed to get current directory path: %v", err) @@ -85,7 +85,7 @@ func main() { answers.MediaFiles = removeTransitionVideo(answers.TransitionVideo, answers.MediaFiles) } - templateHTML = "\n" + templateHTML + templateHTML = "\n" + templateHTML var outputHTML bytes.Buffer t := template.Must(template.New("HTML").Parse(templateHTML)) err = t.Execute(&outputHTML, scripts) @@ -98,7 +98,14 @@ func main() { if err != nil { log.Fatalf("Failed compiling template final: %v", err) } - outputHTMLFile, err := os.Create(outputHTMLName) + + ex, err := os.Executable() + if err != nil { + panic(err) + } + exPath := filepath.Dir(ex) + outputHTMLFilePath := filepath.Join(exPath, outputHTMLName) + outputHTMLFile, err := os.Create(outputHTMLFilePath) if err != nil { log.Fatalf("Failed create output file: %v", err) } @@ -170,7 +177,7 @@ func createHashFromUserAnswers(answers UserAnswers) string { strings.Join(answers.MediaFiles[:], "")) // deepcode ignore InsecureHash: Not using this hash for anything sensitive - hasher := md5.New() + hasher := md5.New() hasher.Write([]byte(s)) return hex.EncodeToString(hasher.Sum(nil)) } @@ -258,4 +265,4 @@ func showQuestion(message string, defaultValueFlag bool) bool { result = strings.ToLower(result) time.Sleep(promptDelay) return result == "y" || result == "yes" -} \ No newline at end of file +} From cf20d279c584d5b703e27e0e7fa958e1bbaf3746 Mon Sep 17 00:00:00 2001 From: "Jared.K" <3268576+jaredkotoff@users.noreply.github.com> Date: Sun, 29 Oct 2023 15:12:39 -0700 Subject: [PATCH 5/5] Update goreleaser.yaml --- .goreleaser.yml | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/.goreleaser.yml b/.goreleaser.yml index 84fd03d..d732f9e 100644 --- a/.goreleaser.yml +++ b/.goreleaser.yml @@ -6,10 +6,17 @@ builds: goarch: - amd64 archives: - - replacements: - amd64: 64-bit - 386: 32-bit - darwin: macos + - id: default + name_template: >- + {{- .ProjectName }}_ + {{- .Version }}_ + {{- if eq .Os "darwin" }}macos_ + {{- else }}{{ .Os }}_{{ end }} + {{- if eq .Arch "amd64" }}64-bit + {{- else if eq .Arch "386" }}i386 + {{- else if eq .Arch "darwin" }}apple + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end -}} format_overrides: - goos: windows format: zip