-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
128 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package media | ||
|
||
import ( | ||
"github.com/matishsiao/goInfo" | ||
"github.com/rs/zerolog/log" | ||
"html/template" | ||
"media-roller/src/utils" | ||
"net/http" | ||
"regexp" | ||
"strings" | ||
) | ||
|
||
var aboutIndexTmpl = template.Must(template.ParseFiles("templates/media/about.html")) | ||
|
||
var newlineRegex = regexp.MustCompile("\r?\n") | ||
|
||
func AboutIndex(w http.ResponseWriter, _ *http.Request) { | ||
pythonVersion := utils.RunCommand("python3", "--version") | ||
if pythonVersion == "" { | ||
pythonVersion = utils.RunCommand("python", "--version") | ||
} | ||
|
||
gi, _ := goInfo.GetInfo() | ||
|
||
data := map[string]interface{}{ | ||
"ytDlpVersion": CachedYtDlpVersion, | ||
"goVersion": strings.TrimPrefix(utils.RunCommand("go", "version"), "go version "), | ||
"pythonVersion": strings.TrimPrefix(pythonVersion, "Python "), | ||
"ffmpegVersion": newlineRegex.Split(utils.RunCommand("ffmpeg", "-version"), -1), | ||
"os": gi.OS, | ||
"kernel": gi.Kernel, | ||
"core": gi.Core, | ||
"platform": gi.Platform, | ||
"hostname": gi.Hostname, | ||
"cpus": gi.CPUs, | ||
} | ||
|
||
if err := aboutIndexTmpl.Execute(w, data); err != nil { | ||
log.Error().Msgf("Error rendering template: %v", err) | ||
http.Error(w, "Internal error", http.StatusInternalServerError) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package utils | ||
|
||
import ( | ||
"bytes" | ||
"github.com/rs/zerolog/log" | ||
"os" | ||
"os/exec" | ||
"strings" | ||
) | ||
|
||
func RunCommand(name string, args ...string) string { | ||
cmd := exec.Command(name, args...) | ||
|
||
var s bytes.Buffer | ||
cmd.Stdout = &s | ||
cmd.Stderr = os.Stderr | ||
|
||
if err := cmd.Run(); err != nil { | ||
log.Error().Err(err).Msgf("Error running command " + strings.Join(args, " ")) | ||
} | ||
|
||
return strings.TrimSpace(s.String()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>about - media-roller</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<link rel="stylesheet" type="text/css" href="/static/css//bootstrap.min.css"> | ||
<link rel="stylesheet" type="text/css" href="/static/css/style.css"> | ||
</head> | ||
<body> | ||
<div class="container d-flex flex-column text-light"> | ||
<div class="flex-grow-1"></div> | ||
<div class="jumbotron bg-transparent flex-grow-1"> | ||
<h1 class="display-4"><a class="text-light" href="/">media roller</a></h1> | ||
<div> | ||
{{ .details }} | ||
<table> | ||
<tbody> | ||
<tr> | ||
<td style="width:110px;">Source</td> | ||
<td><a href="https://github.com/rroller/media-roller">https://github.com/rroller/media-roller</a> | ||
</td> | ||
</tr> | ||
<tr> | ||
<td><a href="https://github.com/yt-dlp/yt-dlp">yt-dlp</a></td> | ||
<td>{{ $.ytDlpVersion }}</td> | ||
</tr> | ||
<tr> | ||
<td><a href="https://go.dev/doc/install">Golang</a></td> | ||
<td>{{ $.goVersion }}</td> | ||
</tr> | ||
<tr> | ||
<td><a href="https://www.python.org/downloads/">Python</a></td> | ||
<td>{{ $.pythonVersion }}</td> | ||
</tr> | ||
<tr><td>os</td><td>{{ $.os }}</td></tr> | ||
<tr><td>kernel</td><td>{{ $.kernel }}</td></tr> | ||
<tr><td>core</td><td>{{ $.core }}</td></tr> | ||
<tr><td>platform</td><td>{{ $.platform }}</td></tr> | ||
<tr><td>hostname</td><td>{{ $.hostname }}</td></tr> | ||
<tr><td>cpus</td><td>{{ $.cpus }}</td></tr> | ||
<tr> | ||
<td style="vertical-align: top"><a href="https://www.ffmpeg.org/download.html">ffmpeg</a></td> | ||
<td>{{range $element := .ffmpegVersion}}{{ $element }}<br>{{end}}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</div> | ||
<footer> | ||
<div> | ||
</div> | ||
</footer> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters