Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

encode file names #61

Merged
merged 5 commits into from
Oct 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,17 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Get Version
run: echo "VERSION=${GITHUB_REF_NAME}" >> $GITHUB_ENV
- 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.2'
- name: Cache Go modules
uses: actions/cache@v3
with:
Expand All @@ -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
Expand Down
15 changes: 11 additions & 4 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
10 changes: 3 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
@@ -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.19 // indirect
golang.org/x/sys v0.8.0 // indirect
golang.org/x/sys v0.13.0 // indirect
)
38 changes: 4 additions & 34 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand All @@ -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.19 h1:JITubQf0MOLdlGRuRq+jtsDlekdYPia9ZFsB8h/APPA=
github.com/mattn/go-isatty v0.0.19/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.8.0 h1:EBmGv8NaZBZTWvrbjNoL6HVt+IVy3QDQpJs7VRIw3tU=
golang.org/x/sys v0.8.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=
golang.org/x/sys v0.13.0 h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=
golang.org/x/sys v0.13.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
12 changes: 10 additions & 2 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() || '';

Expand All @@ -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;
}
Expand Down
19 changes: 13 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -85,7 +85,7 @@ func main() {
answers.MediaFiles = removeTransitionVideo(answers.TransitionVideo, answers.MediaFiles)
}

templateHTML = "<!--\nOBS Random Videos: "+version+"\nAUTO GENERATED FILE\nDON'T TOUCH\n-->\n" + templateHTML
templateHTML = "<!--\nOBS Random Videos: " + version + "\nAUTO GENERATED FILE\nDON'T TOUCH\n-->\n" + templateHTML
var outputHTML bytes.Buffer
t := template.Must(template.New("HTML").Parse(templateHTML))
err = t.Execute(&outputHTML, scripts)
Expand All @@ -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)
}
Expand Down Expand Up @@ -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))
}
Expand Down Expand Up @@ -258,4 +265,4 @@ func showQuestion(message string, defaultValueFlag bool) bool {
result = strings.ToLower(result)
time.Sleep(promptDelay)
return result == "y" || result == "yes"
}
}
Loading