Restrict video to 1080p

This commit is contained in:
Carl Pearson
2024-09-14 05:30:44 -06:00
parent 8919464607
commit 6d7b38627c

View File

@@ -17,6 +17,9 @@ import (
"gorm.io/gorm" "gorm.io/gorm"
) )
var ytdlpAudioOptions = []string{"-f", "bestvideo[height<=1080]+bestaudio/best[height<=1080]"}
var ytdlpVideoOptions = []string{"-f", "bestaudio"}
func registerHandler(c echo.Context) error { func registerHandler(c echo.Context) error {
return c.Render(http.StatusOK, "register.html", nil) return c.Render(http.StatusOK, "register.html", nil)
} }
@@ -191,13 +194,11 @@ func getYtdlpMeta(url string, args []string) (Meta, error) {
} }
func getYtdlpAudioMeta(url string) (Meta, error) { func getYtdlpAudioMeta(url string) (Meta, error) {
args := []string{"-f", "bestaudio"} return getYtdlpMeta(url, ytdlpVideoOptions)
return getYtdlpMeta(url, args)
} }
func getYtdlpVideoMeta(url string) (Meta, error) { func getYtdlpVideoMeta(url string) (Meta, error) {
args := []string{"-f", "bestvideo+bestaudio/best"} return getYtdlpMeta(url, ytdlpAudioOptions)
return getYtdlpMeta(url, args)
} }
// return the length in seconds of a video file at `path` // return the length in seconds of a video file at `path`
@@ -576,9 +577,9 @@ func startDownload(originalID uint, videoURL string, audioOnly bool) {
var args []string var args []string
if audioOnly { if audioOnly {
args = []string{"-f", "bestaudio"} args = ytdlpVideoOptions
} else { } else {
args = []string{"-f", "bestvideo+bestaudio/best"} args = ytdlpAudioOptions
} }
ytdlp := "yt-dlp" ytdlp := "yt-dlp"