Skip to content

Commit 2be44fa

Browse files
authored
3.1.2: Various bug fixes (#57)
* Resolve #56 * version control goreleaser config * Resolves #47 * Typos 🙄 * fix typo in json mapping for stats display on the webserver * Resolve #52. Adjusts flex sizes so smaller screens work with the table. Make parent container to stats and datatable xl width so it resizes. * Resolve #37. Add your own timezone if you care to. UTC best timezone, learn your offset. * fix a bug with pushover's connection logic * added better logging for telegram * fixed error in example config for telegram * Resolve #50: rewrote telegram notifications This API is like trying to get blood from a stone.
1 parent bab042d commit 2be44fa

File tree

13 files changed

+209
-18
lines changed

13 files changed

+209
-18
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
dist/
33
test/
44
*.db
5-
*.yaml
5+
checkrr.yaml
6+
test-*.yaml
67
checkrr
78
.vscode
89
badfiles.csv

.goreleaser.yaml

+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
project_name: checkrr
2+
before:
3+
hooks:
4+
# You may remove this if you don't use go modules.
5+
- go mod tidy
6+
- docker pull alpine:latest
7+
- cd webserver && yarn build && cd ..
8+
builds:
9+
- env:
10+
- CGO_ENABLED=0
11+
ldflags:
12+
- -s -w
13+
- -X main.version={{.Version}}
14+
- -X main.commit={{.Commit}}
15+
- -X main.date={{.Date}}
16+
- -X main.builtBy=goreleaser
17+
tags:
18+
- osusergo
19+
- netgo
20+
goos:
21+
- linux
22+
- windows
23+
- darwin
24+
- freebsd
25+
goarch:
26+
- amd64
27+
- arm64
28+
- arm
29+
goarm:
30+
- "6"
31+
- "7"
32+
archives:
33+
- replacements:
34+
darwin: macOS
35+
linux: Linux
36+
windows: Windows
37+
freebsd: FreeBSD
38+
386: i386
39+
amd64: x86_64
40+
checksum:
41+
name_template: 'checksums.txt'
42+
snapshot:
43+
name_template: "{{ incpatch .Version }}-next"
44+
changelog:
45+
sort: asc
46+
filters:
47+
exclude:
48+
- '^docs:'
49+
- '^test:'
50+
release:
51+
github:
52+
owner: aetaric
53+
name: "{{.ProjectName}}"
54+
draft: true
55+
prerelease: auto
56+
mode: append
57+
name_template: "{{.ProjectName}}-v{{.Version}}"
58+
disable: false
59+
dockers:
60+
- image_templates:
61+
- "aetaric/{{.ProjectName}}:latest-amd64"
62+
- "aetaric/{{.ProjectName}}:{{ .Version }}-amd64"
63+
- "ghcr.io/aetaric/{{.ProjectName}}:latest-amd64"
64+
- "ghcr.io/aetaric/{{.ProjectName}}:{{ .Version }}-amd64"
65+
use: docker
66+
dockerfile: Dockerfile
67+
skip_push: "false"
68+
build_flag_templates:
69+
- "--platform=linux/amd64"
70+
- "--label=org.opencontainers.image.created={{.Date}}"
71+
- "--label=org.opencontainers.image.title={{.ProjectName}}"
72+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
73+
- "--label=org.opencontainers.image.version={{.Version}}"
74+
- --label=org.opencontainers.image.description={{ .ProjectName }}
75+
- --label=org.opencontainers.image.url=https://github.com/aetaric/{{ .ProjectName }}
76+
- --label=org.opencontainers.image.source=https://github.com/aetaric/{{ .ProjectName }}
77+
- --label=org.opencontainers.image.revision={{ .FullCommit }}
78+
- --label=org.opencontainers.image.licenses=MIT
79+
- image_templates:
80+
- "aetaric/{{.ProjectName}}:latest-arm64v8"
81+
- "aetaric/{{.ProjectName}}:{{ .Version }}-arm64v8"
82+
- "ghcr.io/aetaric/{{.ProjectName}}:latest-arm64v8"
83+
- "ghcr.io/aetaric/{{.ProjectName}}:{{ .Version }}-arm64v8"
84+
use: buildx
85+
goarch: arm64
86+
dockerfile: Dockerfile
87+
skip_push: "false"
88+
build_flag_templates:
89+
- "--platform=linux/arm64/v8"
90+
- "--label=org.opencontainers.image.created={{.Date}}"
91+
- "--label=org.opencontainers.image.title={{.ProjectName}}"
92+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
93+
- "--label=org.opencontainers.image.version={{.Version}}"
94+
- --label=org.opencontainers.image.description={{ .ProjectName }}
95+
- --label=org.opencontainers.image.url=https://github.com/aetaric/{{ .ProjectName }}
96+
- --label=org.opencontainers.image.source=https://github.com/aetaric/{{ .ProjectName }}
97+
- --label=org.opencontainers.image.revision={{ .FullCommit }}
98+
- --label=org.opencontainers.image.licenses=MIT
99+
- image_templates:
100+
- "aetaric/{{.ProjectName}}:latest-armv6"
101+
- "aetaric/{{.ProjectName}}:{{ .Version }}-armv6"
102+
- "ghcr.io/aetaric/{{.ProjectName}}:latest-armv6"
103+
- "ghcr.io/aetaric/{{.ProjectName}}:{{ .Version }}-armv6"
104+
use: buildx
105+
goarch: arm
106+
goarm: "6"
107+
dockerfile: Dockerfile
108+
skip_push: "false"
109+
build_flag_templates:
110+
- "--platform=linux/arm/v6"
111+
- "--label=org.opencontainers.image.created={{.Date}}"
112+
- "--label=org.opencontainers.image.title={{.ProjectName}}"
113+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
114+
- "--label=org.opencontainers.image.version={{.Version}}"
115+
- --label=org.opencontainers.image.description={{ .ProjectName }}
116+
- --label=org.opencontainers.image.url=https://github.com/aetaric/{{ .ProjectName }}
117+
- --label=org.opencontainers.image.source=https://github.com/aetaric/{{ .ProjectName }}
118+
- --label=org.opencontainers.image.revision={{ .FullCommit }}
119+
- --label=org.opencontainers.image.licenses=MIT
120+
- image_templates:
121+
- "aetaric/{{.ProjectName}}:latest-armv7"
122+
- "aetaric/{{.ProjectName}}:{{ .Version }}-armv7"
123+
- "ghcr.io/aetaric/{{.ProjectName}}:latest-armv7"
124+
- "ghcr.io/aetaric/{{.ProjectName}}:{{ .Version }}-armv7"
125+
use: buildx
126+
goarch: arm
127+
goarm: "7"
128+
dockerfile: Dockerfile
129+
skip_push: "false"
130+
build_flag_templates:
131+
- "--platform=linux/arm/v7"
132+
- "--label=org.opencontainers.image.created={{.Date}}"
133+
- "--label=org.opencontainers.image.title={{.ProjectName}}"
134+
- "--label=org.opencontainers.image.revision={{.FullCommit}}"
135+
- "--label=org.opencontainers.image.version={{.Version}}"
136+
- --label=org.opencontainers.image.description={{ .ProjectName }}
137+
- --label=org.opencontainers.image.url=https://github.com/aetaric/{{ .ProjectName }}
138+
- --label=org.opencontainers.image.source=https://github.com/aetaric/{{ .ProjectName }}
139+
- --label=org.opencontainers.image.revision={{ .FullCommit }}
140+
- --label=org.opencontainers.image.licenses=MIT
141+
docker_manifests:
142+
- name_template: aetaric/{{.ProjectName}}:{{ .Version }}
143+
skip_push: "false"
144+
image_templates:
145+
- aetaric/{{.ProjectName}}:{{ .Version }}-amd64
146+
- aetaric/{{.ProjectName}}:{{ .Version }}-arm64v8
147+
- aetaric/{{.ProjectName}}:{{ .Version }}-armv6
148+
- aetaric/{{.ProjectName}}:{{ .Version }}-armv7
149+
- name_template: aetaric/{{.ProjectName}}:latest
150+
skip_push: "false"
151+
image_templates:
152+
- aetaric/{{.ProjectName}}:latest-amd64
153+
- aetaric/{{.ProjectName}}:latest-arm64v8
154+
- aetaric/{{.ProjectName}}:latest-armv6
155+
- aetaric/{{.ProjectName}}:latest-armv7
156+

Dockerfile

+1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ FROM alpine:latest
22
LABEL maintainer="[email protected]"
33
COPY checkrr /checkrr
44
RUN apk add ffmpeg
5+
RUN apk add tzdata
56
WORKDIR "/"
67
ENTRYPOINT [ "/checkrr" ]

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ YOU MUST CREATE THE CONFIG AND DB FILES BEFORE STARTING. checkrr will complain i
3030
* creating empty db file: `touch checkrr.db`
3131
* creating a config file from the example: `wget https://raw.githubusercontent.com/aetaric/checkrr/main/checkrr.yaml.example -O checkrr.yaml`
3232
_make sure you edit the example config from the defaults. Remove any unused sections._
33-
While editing the example you might want to add path mappings if the path to your media is differs from arr services and checkrr.
33+
While editing the example you might want to add path mappings if the path to your media differs from arr services and checkrr.
3434

3535

3636
### Running Checkrr

checkrr.yaml.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ notifications:
8080
- endrun
8181
- reacquire
8282
telegram:
83-
token: ""
83+
apitoken: ""
8484
username: "@username" # This must start with an @ to send to a user, otherwise, list the channel name
8585
notificationtypes:
8686
- reacquire

features/stats.go

-2
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ func (s *Stats) FromConfig(config viper.Viper) {
5959
if config.Sub("influxdb2") != nil {
6060
influx := config.Sub("influxdb2")
6161
s.influxdb2 = influxdb2.NewClient(influx.GetString("url"), influx.GetString("token"))
62-
org, _ := s.influxdb2.OrganizationsAPI().FindOrganizationByName(context.Background(), influx.GetString("org"))
63-
s.influxdb2.BucketsAPI().CreateBucketWithName(context.Background(), org, influx.GetString("bucket"))
6462
s.writeAPI2 = s.influxdb1.WriteAPIBlocking(influx.GetString("org"), influx.GetString("bucket"))
6563
s.writeAPI2.EnableBatching()
6664
s.Log.WithFields(log.Fields{"startup": true, "influxdb": "enabled"}).Info("Sending data to InfluxDB 2.x")

notifications/gotify.go

+7-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/gotify/go-api-client/v2/client/message"
1111
"github.com/gotify/go-api-client/v2/gotify"
1212
"github.com/gotify/go-api-client/v2/models"
13+
log "github.com/sirupsen/logrus"
1314
"github.com/spf13/viper"
1415
)
1516

@@ -19,6 +20,7 @@ type GotifyNotifs struct {
1920
AuthToken string
2021
Connected bool
2122
AllowedNotifs []string
23+
Log log.Logger
2224
}
2325

2426
func (d *GotifyNotifs) FromConfig(config viper.Viper) {
@@ -27,18 +29,20 @@ func (d *GotifyNotifs) FromConfig(config viper.Viper) {
2729
d.AuthToken = config.GetString("authtoken")
2830
}
2931

30-
func (d *GotifyNotifs) Connect() (bool, string) {
32+
func (d *GotifyNotifs) Connect() bool {
3133
myURL, _ := url.Parse(d.URL)
3234
client := gotify.NewClient(myURL, &http.Client{})
3335
versionResponse, err := client.Version.GetVersion(nil)
3436

3537
if err != nil {
36-
return false, "Webhook does not match expected format"
38+
d.Log.Warn("unable to connect to gotify")
39+
return false
3740
}
3841
version := versionResponse.Payload
3942
d.Client = client
4043
d.Connected = true
41-
return true, fmt.Sprintf("Connected to Gotify, %s", version)
44+
d.Log.Info(fmt.Sprintf("Connected to Gotify, %s", version))
45+
return true
4246
}
4347

4448
func (d GotifyNotifs) Notify(title string, description string, notifType string, path string) bool {

notifications/notifications.go

+9
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,15 @@ func (n *Notifications) Connect() {
7676
n.EnabledServices = append(n.EnabledServices, pushover)
7777
}
7878
}
79+
80+
if n.config.Sub("gotify") != nil {
81+
gotify := GotifyNotifs{Log: *log.StandardLogger()}
82+
gotify.FromConfig(*n.config.Sub("gotify"))
83+
gotifyConnected := gotify.Connect()
84+
if gotifyConnected {
85+
n.EnabledServices = append(n.EnabledServices, gotify)
86+
}
87+
}
7988
}
8089

8190
func (n *Notifications) FromConfig(c viper.Viper) {

notifications/pushover.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ func (p *Pushover) Connect() bool {
3838
p.bot = pushover.New(p.apiToken)
3939
p.recipient = pushover.NewRecipient(p.config.GetString("recipient"))
4040
if p.bot != nil {
41-
return false
42-
} else {
41+
p.Log.Info("Connected to pushover")
4342
return true
43+
} else {
44+
p.Log.Warn("Failed to connect to pushover")
45+
return false
4446
}
4547
}
4648

notifications/telegram.go

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package notifications
22

33
import (
4+
"fmt"
5+
46
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
57
log "github.com/sirupsen/logrus"
68
"github.com/spf13/viper"
@@ -23,19 +25,37 @@ func (t Telegram) Notify(title string, description string, notifType string, pat
2325
}
2426
}
2527
if allowed {
26-
tgbotapi.NewMessageToChannel(t.username, description)
28+
var chatid int64
29+
updates, err := t.bot.GetUpdates(tgbotapi.UpdateConfig{})
30+
if err != nil {
31+
return false
32+
}
33+
for _, update := range updates {
34+
t.Log.Debug(fmt.Sprintf("User: %s", update.SentFrom().UserName))
35+
if fmt.Sprintf("@%s", update.SentFrom().UserName) == t.username {
36+
chatid = update.FromChat().ID
37+
t.Log.Debug(fmt.Sprintf("chatid: %v", chatid))
38+
break
39+
}
40+
}
41+
message := tgbotapi.NewMessage(chatid, description)
42+
t.bot.Send(message)
2743
return true
2844
}
2945
return false
3046
}
3147

3248
func (t *Telegram) Connect() bool {
3349
var err error
50+
tgbotapi.SetLogger(&t.Log)
3451
t.bot, err = tgbotapi.NewBotAPI(t.apiToken)
3552
if err != nil {
3653
log.Error(err)
54+
t.Log.WithFields(log.Fields{"Error": err, "Username": t.username, "Token": t.apiToken}).Warn("Error connecting to Telegram")
55+
return false
3756
}
38-
return false
57+
t.Log.Info("Connected to Telegram")
58+
return true
3959
}
4060

4161
func (t *Telegram) FromConfig(config viper.Viper) {

webserver/src/App.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function App() {
2222
<ThemeProvider theme={darkTheme}>
2323
<CssBaseline />
2424
<ResponsiveAppBar></ResponsiveAppBar>
25-
<Container fixed>
25+
<Container maxWidth="xl">
2626
<Container maxWidth="xl">
2727
<br/>
2828
<Stats/>

webserver/src/components/Table.jsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import DeleteIcon from '@mui/icons-material/Delete';
1212
import Typography from '@mui/material/Typography';
1313

1414
const columns = [
15-
{ field: 'id', headerName: 'ID', flex: 0.1, },
15+
{ field: 'id', headerName: 'ID', flex: 0.05, },
1616
{ field: 'path', headerName: 'Path', flex: 1},
17-
{ field: 'ext', headerName: 'File Extension', flex: 0.5,},
18-
{ field: 'reacquire', headerName: 'Reacquired', flex: 0.5},
19-
{ field: 'service', headerName: 'Service', flex: 0.6},
17+
{ field: 'ext', headerName: 'File Extension', flex: 0.15,},
18+
{ field: 'reacquire', headerName: 'Reacquired', flex: 0.15},
19+
{ field: 'service', headerName: 'Service', flex: 0.13},
2020
];
2121

2222
export default function DataTable() {

webserver/webserver.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ type badFileData struct {
242242
}
243243

244244
type Stats struct {
245-
SonarrSubmissions uint64 `json:"sonarrSubmission"`
245+
SonarrSubmissions uint64 `json:"sonarrSubmissions"`
246246
RadarrSubmissions uint64 `json:"radarrSubmissions"`
247247
LidarrSubmissions uint64 `json:"lidarrSubmissions"`
248248
FilesChecked uint64 `json:"filesChecked"`

0 commit comments

Comments
 (0)