Skip to content

Commit

Permalink
Show which version of yt-dlp is installed
Browse files Browse the repository at this point in the history
  • Loading branch information
rroller committed Oct 20, 2024
1 parent 03d58bf commit ff94a96
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
5 changes: 4 additions & 1 deletion src/media/fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ var downloadDir = getDownloadDir()
var idCharSet = regexp.MustCompile(`^[a-zA-Z0-9]+$`).MatchString

func Index(w http.ResponseWriter, _ *http.Request) {
if err := fetchIndexTmpl.Execute(w, nil); err != nil {
data := map[string]string{
"ytDlpVersion": GetInstalledVersion(),
}
if err := fetchIndexTmpl.Execute(w, data); err != nil {
log.Error().Msgf("Error rendering template: %v", err)
http.Error(w, "Internal error", http.StatusInternalServerError)
}
Expand Down
8 changes: 6 additions & 2 deletions src/media/updater.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,12 @@ func GetInstalledVersion() string {
cmd.Stderr = os.Stderr

if err := cmd.Run(); err != nil {
return ""
log.Error().Err(err).Msgf("Error getting installed version")
}

return strings.TrimSpace(string(s.Bytes()))
version := strings.TrimSpace(string(s.Bytes()))
if version != "" {
return version
}
return "unknown"
}
1 change: 1 addition & 0 deletions templates/media/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ <h1 class="display-4"><a class="text-light" href="/">media roller</a></h1>
</div>
<footer>
<div>
Running <a href="https://github.com/yt-dlp/yt-dlp">yt-dlp</a> version {{ $.ytDlpVersion }}<br>
<p class="text-muted">Source at <a class="text-light" href="https://github.com/rroller/media-roller">https://github.com/rroller/media-roller</a>
</p>
</div>
Expand Down

0 comments on commit ff94a96

Please sign in to comment.