Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3b23ff356c | |||
| 94b57fc327 | |||
| 36607b43ab | |||
| b466157cd0 | |||
| d9a979b782 |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
gropple
|
||||
release
|
||||
dist
|
||||
.env
|
||||
.env
|
||||
dist/
|
||||
|
||||
@@ -1,13 +1,3 @@
|
||||
# This is an example .goreleaser.yml file with some sensible defaults.
|
||||
# Make sure to check the documentation at https://goreleaser.com
|
||||
|
||||
# The lines below are called `modelines`. See `:help modeline`
|
||||
# Feel free to remove those if you don't want/need to use them.
|
||||
# yaml-language-server: $schema=https://goreleaser.com/static/schema.json
|
||||
# vim: set ts=2 sw=2 tw=0 fo=cnqoj
|
||||
|
||||
version: 1
|
||||
|
||||
before:
|
||||
hooks:
|
||||
# You may remove this if you don't use go modules.
|
||||
@@ -27,7 +17,7 @@ archives:
|
||||
# this name template makes the OS and Arch compatible with the results of `uname`.
|
||||
name_template: >-
|
||||
{{ .ProjectName }}_
|
||||
{{- title .Os }}_
|
||||
{{- .Os }}_
|
||||
{{- if eq .Arch "amd64" }}x86_64
|
||||
{{- else if eq .Arch "386" }}i386
|
||||
{{- else }}{{ .Arch }}{{ end }}
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
|
||||
All notable changes to this project will be documented in this file.
|
||||
|
||||
## [v1.1.2] - 2024-03-16
|
||||
|
||||
- Fix a crash for a certain pattern of log line
|
||||
|
||||
## [v1.1.1] - 2023-12-08
|
||||
|
||||
- Fix bug where a brand-new config was created with an out-of-date version
|
||||
|
||||
@@ -319,7 +319,8 @@ func (cs *ConfigService) LoadConfig() error {
|
||||
func (cs *ConfigService) WriteConfig() {
|
||||
s, err := yaml.Marshal(cs.Config)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Printf("error writing config: %s", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
path := cs.ConfigPath
|
||||
|
||||
@@ -429,8 +429,6 @@ func (dl *Download) updateMetadata(s string) {
|
||||
p, err := strconv.ParseFloat(matches[1], 32)
|
||||
if err == nil {
|
||||
dl.Percent = float32(p)
|
||||
} else {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -317,7 +317,7 @@ func TestUpdateMetadataSingle(t *testing.T) {
|
||||
[youtube] 2WoDQBhJCVQ: Downloading android player API JSON
|
||||
[info] 2WoDQBhJCVQ: Downloading 1 format(s): 137+140
|
||||
[info] Writing video metadata as JSON to: The Greatest Shot In Television [2WoDQBhJCVQ].info.json
|
||||
[download] Destination: The Greatest Shot In Television [2WoDQBhJCVQ].f137.mp4
|
||||
[debug] Invoking hlsnative downloader on "https://example.org/urls/1.2.3.4%
|
||||
[download] 0.0% of 12.82MiB at 510.94KiB/s ETA 00:26
|
||||
[download] 0.0% of 12.82MiB at 966.50KiB/s ETA 00:13
|
||||
[download] 0.1% of 12.82MiB at 1.54MiB/s ETA 00:08
|
||||
|
||||
2
main.go
2
main.go
@@ -15,7 +15,7 @@ import (
|
||||
|
||||
func main() {
|
||||
versionInfo := &version.Manager{
|
||||
VersionInfo: version.Info{CurrentVersion: "v1.1.1"},
|
||||
VersionInfo: version.Info{CurrentVersion: "v1.1.2"},
|
||||
}
|
||||
log.Printf("Starting gropple %s - https://github.com/tardisx/gropple", versionInfo.GetInfo().CurrentVersion)
|
||||
|
||||
|
||||
65
web/web.go
65
web/web.go
@@ -92,7 +92,10 @@ func homeHandler(cs *config.ConfigService, vm *version.Manager, dm *download.Man
|
||||
|
||||
t, err := template.ParseFS(webFS, "data/templates/layout.tmpl", "data/templates/menu.tmpl", "data/templates/index.tmpl")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Printf("error: %s", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
type Info struct {
|
||||
@@ -113,7 +116,10 @@ func homeHandler(cs *config.ConfigService, vm *version.Manager, dm *download.Man
|
||||
defer dm.Lock.Unlock()
|
||||
err = t.ExecuteTemplate(w, "layout", info)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Printf("error: %s", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -149,12 +155,18 @@ func configHandler() func(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
t, err := template.ParseFS(webFS, "data/templates/layout.tmpl", "data/templates/menu.tmpl", "data/templates/config.tmpl")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Printf("error: %s", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
err = t.ExecuteTemplate(w, "layout", nil)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Printf("error: %s", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -167,7 +179,10 @@ func configRESTHandler(cs *config.ConfigService) func(w http.ResponseWriter, r *
|
||||
log.Printf("Updating config")
|
||||
b, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Printf("error: %s", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
err = cs.Config.UpdateFromJSON(b)
|
||||
|
||||
@@ -221,7 +236,10 @@ func fetchInfoOneRESTHandler(cs *config.ConfigService, dm *download.Manager) fun
|
||||
|
||||
b, err := io.ReadAll(r.Body)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Printf("error: %s", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
err = json.Unmarshal(b, &thisReq)
|
||||
@@ -271,7 +289,10 @@ func fetchInfoRESTHandler(dm *download.Manager) func(w http.ResponseWriter, r *h
|
||||
|
||||
b, err := dm.DownloadsAsJSON()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Printf("error: %s", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
_, err = w.Write(b)
|
||||
if err != nil {
|
||||
@@ -307,14 +328,20 @@ func fetchHandler(cs *config.ConfigService, vm *version.Manager, dm *download.Ma
|
||||
|
||||
t, err := template.ParseFS(webFS, "data/templates/layout.tmpl", "data/templates/popup.tmpl")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Printf("error: %s", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
templateData := map[string]interface{}{"dl": dl, "config": cs.Config, "canStop": download.CanStopDownload, "Version": vm.GetInfo()}
|
||||
|
||||
err = t.ExecuteTemplate(w, "layout", templateData)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Printf("error: %s", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
return
|
||||
} else if method == "POST" {
|
||||
@@ -389,13 +416,19 @@ func fetchHandler(cs *config.ConfigService, vm *version.Manager, dm *download.Ma
|
||||
|
||||
t, err := template.ParseFS(webFS, "data/templates/layout.tmpl", "data/templates/popup_create.tmpl")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Printf("error: %s", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
templateData := map[string]interface{}{"config": cs.Config, "url": url[0], "Version": vm.GetInfo()}
|
||||
|
||||
err = t.ExecuteTemplate(w, "layout", templateData)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Printf("error: %s", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
@@ -412,13 +445,19 @@ func bulkHandler(cs *config.ConfigService, vm *version.Manager, dm *download.Man
|
||||
|
||||
t, err := template.ParseFS(webFS, "data/templates/layout.tmpl", "data/templates/menu.tmpl", "data/templates/bulk.tmpl")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Printf("error: %s", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
templateData := map[string]interface{}{"config": cs.Config, "Version": vm.GetInfo()}
|
||||
|
||||
err = t.ExecuteTemplate(w, "layout", templateData)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Printf("error: %s", err)
|
||||
w.WriteHeader(http.StatusInternalServerError)
|
||||
w.Write([]byte(err.Error()))
|
||||
return
|
||||
}
|
||||
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user