Revert "show local time"

This reverts commit 9ac4cdd3c9.
This commit is contained in:
milarin 2023-01-15 19:56:47 +01:00
parent 9ac4cdd3c9
commit 29de312a3f
4 changed files with 41 additions and 15 deletions

View File

@ -2,6 +2,7 @@ package main
import (
"fmt"
"log"
"time"
"git.milar.in/milarin/adverr"
@ -10,7 +11,7 @@ import (
)
func CheckTorrents() {
fmt.Printf("%schecking torrents\n", time.Now().In(time.Local).Format("2006-01-02 15:04:05"))
log.Println("checking torrents")
start := time.Now()
torrents, err := GetTorrents()
@ -80,9 +81,5 @@ func CheckTorrents() {
downloadedTorrents,
)
fmt.Printf("%s check took %s. sleeping for %s\n",
time.Now().In(time.Local).Format("2006-01-02 15:04:05"),
duration.Truncate(time.Millisecond),
(PollRate - duration).Truncate(time.Millisecond),
)
log.Printf("check took %s. sleeping for %s\n", duration.Truncate(time.Millisecond), (PollRate - duration).Truncate(time.Millisecond))
}

16
go.sum
View File

@ -12,12 +12,12 @@ git.milar.in/milarin/slices v0.0.6 h1:AQoSarZ58WHYol9c6woWJSe8wFpPC2RC4cvIlZpfg9
git.milar.in/milarin/slices v0.0.6/go.mod h1:NOr53AOeur/qscu/FBj3lsFR262PNYBccLYSTCAXRk4=
git.milar.in/milarin/tprint v0.0.7 h1:dvm4l4BhXOie4vtnRMZii0WTLTz2wju8wyUPB/lNeVo=
git.milar.in/milarin/tprint v0.0.7/go.mod h1:UwW/B+0cTCbN5hi0bQBE9rIRgLkq+x4V751rrS2KVoI=
git.milar.in/nyaanime/logic v0.0.0-20230114105336-6bfb7dce349f h1:tc8hQpZprt8/yedVSPmkftKOI2+P7twFc7BEov5RTBc=
git.milar.in/nyaanime/logic v0.0.0-20230114105336-6bfb7dce349f/go.mod h1:cLuIBDTtpXdzprOIsz73r6ZCE5s0k+o6HA7fH9OuW/M=
git.milar.in/nyaanime/logic v0.0.0-20230113101007-e0018688e419 h1:Am9LlW/2UJuUvWsoA2c9FPBJpTZfSWjHCkWSHlAoX8M=
git.milar.in/nyaanime/logic v0.0.0-20230113101007-e0018688e419/go.mod h1:SkgdD87uNP60swIBtrDRZPBF5rLIgBLL6OetP1sETLY=
git.milar.in/nyaanime/model v0.0.0-20230113095840-5eb2822653c3 h1:mXcEA47FQQzeSDXE3UvhNfIt4fBfpDSq1/f0r+jbHpY=
git.milar.in/nyaanime/model v0.0.0-20230113095840-5eb2822653c3/go.mod h1:kPWLDvFrhc1Uf77gxsBOxNeJ5JTVF2HhVs1IdVcw0tg=
git.milar.in/nyaanime/parsers v0.0.0-20230113101942-2c9bc6925201 h1:glTG4IeuIvD4mVwJyCF5SYMawCRcZZ01pz4AUyWTEP8=
git.milar.in/nyaanime/parsers v0.0.0-20230113101942-2c9bc6925201/go.mod h1:GG4vtUIfxopZc/+Y8OAa//vWJw/m6aeoGN7fw6SLiEM=
git.milar.in/nyaanime/parsers v0.0.0-20221207192513-e7bce7c418d8 h1:vb7jasvTdan0E8VY5snnRj1Xe+60NA7Lpn+GSYE6pW0=
git.milar.in/nyaanime/parsers v0.0.0-20221207192513-e7bce7c418d8/go.mod h1:GG4vtUIfxopZc/+Y8OAa//vWJw/m6aeoGN7fw6SLiEM=
github.com/PuerkitoBio/goquery v1.8.0 h1:PJTF7AmFCFKk1N6V6jmKfrNH9tV5pNE6lZMkG0gta/U=
github.com/PuerkitoBio/goquery v1.8.0/go.mod h1:ypIiRMtY7COPGk+I/YbZLbxsxn9g5ejnI2HSMtkjZvI=
github.com/andybalholm/cascadia v1.3.1 h1:nhxRkql1kdYCc8Snf7D5/D3spOX+dBgjA6u8x004T2c=
@ -31,11 +31,11 @@ github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Ky
github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94=
github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=
github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM=
github.com/mattn/go-runewidth v0.0.14 h1:+xnbZSEeDbOIg5/mE6JF0w6n9duR1l3/WmbinWVwUuU=
github.com/mattn/go-runewidth v0.0.14/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-runewidth v0.0.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU=
github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw=
github.com/rivo/uniseg v0.4.3/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
github.com/rivo/uniseg v0.3.4 h1:3Z3Eu6FGHZWSfNKJTOUiPatWwfc7DzJRU04jFUqJODw=
github.com/rivo/uniseg v0.3.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88=
golang.org/x/net v0.0.0-20210916014120-12bc252f5db8/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220812174116-3211cb980234 h1:RDqmgfe7SvlMWoqC3xwQ2blLO3fcWcxMa3eBLRdRW7E=
golang.org/x/net v0.0.0-20220812174116-3211cb980234/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=

View File

@ -1,6 +1,7 @@
package main
import (
"fmt"
"os/exec"
"time"
@ -18,7 +19,11 @@ func main() {
panic(err)
}
logic.PrintPriorityTables()
fmt.Println("generated priority values:")
fmt.Print(Map2Table("language", logic.PreferredLanguages))
fmt.Print(Map2Table("subtitle", logic.PreferredSubtitles))
fmt.Print(Map2Table("resolution", logic.PreferredResolutions))
fmt.Println()
ticker := time.NewTicker(PollRate)
defer ticker.Stop()

24
utils.go Normal file
View File

@ -0,0 +1,24 @@
package main
import (
"sort"
"git.milar.in/milarin/tprint"
"git.milar.in/nyaanime/model"
)
func Map2Table[K comparable](title string, m map[K]int) string {
table := tprint.NewTable(title, "priority")
entries := make([]model.Pair[K, int], 0, len(m))
for name, priority := range m {
entries = append(entries, model.Pair[K, int]{First: name, Second: priority})
}
sort.Slice(entries, func(i, j int) bool { return entries[i].Second > entries[j].Second })
for _, entry := range entries {
table.AddRow(entry.First, entry.Second)
}
return table.String()
}