WIP: refactor and release v1 #30

Draft
williamp wants to merge 16 commits from v1-refactor into master
6 changed files with 90 additions and 11 deletions
Showing only changes of commit 9345a941fb - Show all commits

26
.gitignore vendored
View File

@@ -3,4 +3,28 @@ __pycache__/
.vscode/
.env
.venv/
out/
out/
app_legacy/
# Test binary, built with `go test -c`
*.test
# Code coverage profiles and other test artifacts
*.out
coverage.*
*.coverprofile
profile.cov
# Dependency directories (remove the comment below to include it)
# vendor/
# Go workspace file
go.work
go.work.sum
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

View File

@@ -1,3 +1,12 @@
module git.dubyatp.xyz/williamp/yt-dlp-bot
go 1.25.2
require (
github.com/ProtonMail/go-crypto v1.3.0 // indirect
github.com/cloudflare/circl v1.6.1 // indirect
github.com/lrstanley/go-ytdlp v1.2.7 // indirect
github.com/ulikunitz/xz v0.5.13 // indirect
golang.org/x/crypto v0.41.0 // indirect
golang.org/x/sys v0.35.0 // indirect
)

12
app/go.sum Normal file
View File

@@ -0,0 +1,12 @@
github.com/ProtonMail/go-crypto v1.3.0 h1:ILq8+Sf5If5DCpHQp4PbZdS1J7HDFRXz/+xKBiRGFrw=
github.com/ProtonMail/go-crypto v1.3.0/go.mod h1:9whxjD8Rbs29b4XWbB8irEcE8KHMqaR2e7GWU1R+/PE=
github.com/cloudflare/circl v1.6.1 h1:zqIqSPIndyBh1bjLVVDHMPpVKqp8Su/V+6MeDzzQBQ0=
github.com/cloudflare/circl v1.6.1/go.mod h1:uddAzsPgqdMAYatqJ0lsjX1oECcQLIlRpzZh3pJrofs=
github.com/lrstanley/go-ytdlp v1.2.7 h1:YNDvKkd0OCJSZLZePZvJwcirBCfL8Yw3eCwrTCE5w7Q=
github.com/lrstanley/go-ytdlp v1.2.7/go.mod h1:38IL64XM6gULrWtKTiR0+TTNCVbxesNSbTyaFG2CGTI=
github.com/ulikunitz/xz v0.5.13 h1:ar98gWrjf4H1ev05fYP/o29PDZw9DrI3niHtnEqyuXA=
github.com/ulikunitz/xz v0.5.13/go.mod h1:nbz6k7qbPmH4IRqmfOplQw/tblSgqTqBwxkY0oWt/14=
golang.org/x/crypto v0.41.0 h1:WKYxWedPGCTVVl5+WHSSrOBT0O8lx32+zxmHxijgXp4=
golang.org/x/crypto v0.41.0/go.mod h1:pO5AFd7FA68rFak7rOAGVuygIISepHftHnr8dr6+sUc=
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=

View File

@@ -1,7 +1,18 @@
package main
import "fmt"
import (
"fmt"
"os"
)
func main() {
fmt.Println("Hello bitches")
out_dir := os.Getenv("OUT_DIR")
var url string = "https://www.youtube.com/watch?v=e_isb3YDUDA"
if out_dir == "" {
panic("No output dir specified")
}
downloadVideo(out_dir, url)
}

29
app/ytdlp.go Normal file
View File

@@ -0,0 +1,29 @@
package main
import (
"time"
"fmt"
"context"
"github.com/lrstanley/go-ytdlp"
)
func downloadVideo(out_dir, url string) {
dl := ytdlp.New().
SetWorkDir(out_dir).
FormatSort("res,ext:mp4:m4a").
RecodeVideo("mp4").
ProgressFunc(100*time.Millisecond, func(prog ytdlp.ProgressUpdate) {
fmt.Printf(
"%s @ %s [eta: %s] :: %s\n",
prog.Status,
prog.PercentString(),
prog.ETA(),
prog.Filename,
)
}).
Output("%(extractor)s - %(title)s.%(ext)s")
_, err := dl.Run(context.TODO(), url)
if err != nil {
panic(err)
}
}

View File

@@ -26,15 +26,9 @@
pkgs.virtualenv
pkgs.ffmpeg_6
pkgs.deno
pkgs.go
pkgs.yt-dlp
];
shellHook = ''
if [ ! -d .venv ]; then
echo "Creating Python virtual environment in .venv"
python3 -m venv .venv
fi
.venv/bin/pip install -r ./app/requirements.txt
source .venv/bin/activate
'';
};
});
};