From 9ac4cdd3c91f3f23021e76e6c0151c1e3898c1b1 Mon Sep 17 00:00:00 2001 From: milarin Date: Sun, 15 Jan 2023 19:49:35 +0100 Subject: [PATCH] show local time --- check_torrents.go | 9 ++++++--- go.sum | 16 ++++++++-------- main.go | 7 +------ utils.go | 24 ------------------------ 4 files changed, 15 insertions(+), 41 deletions(-) delete mode 100644 utils.go diff --git a/check_torrents.go b/check_torrents.go index 9c99fa8..ba8e833 100644 --- a/check_torrents.go +++ b/check_torrents.go @@ -2,7 +2,6 @@ package main import ( "fmt" - "log" "time" "git.milar.in/milarin/adverr" @@ -11,7 +10,7 @@ import ( ) func CheckTorrents() { - log.Println("checking torrents") + fmt.Printf("%schecking torrents\n", time.Now().In(time.Local).Format("2006-01-02 15:04:05")) start := time.Now() torrents, err := GetTorrents() @@ -81,5 +80,9 @@ func CheckTorrents() { downloadedTorrents, ) - log.Printf("check took %s. sleeping for %s\n", duration.Truncate(time.Millisecond), (PollRate - duration).Truncate(time.Millisecond)) + 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), + ) } diff --git a/go.sum b/go.sum index d19857e..2ee2ef5 100644 --- a/go.sum +++ b/go.sum @@ -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-20230113101007-e0018688e419 h1:Am9LlW/2UJuUvWsoA2c9FPBJpTZfSWjHCkWSHlAoX8M= -git.milar.in/nyaanime/logic v0.0.0-20230113101007-e0018688e419/go.mod h1:SkgdD87uNP60swIBtrDRZPBF5rLIgBLL6OetP1sETLY= +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/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-20221207192513-e7bce7c418d8 h1:vb7jasvTdan0E8VY5snnRj1Xe+60NA7Lpn+GSYE6pW0= -git.milar.in/nyaanime/parsers v0.0.0-20221207192513-e7bce7c418d8/go.mod h1:GG4vtUIfxopZc/+Y8OAa//vWJw/m6aeoGN7fw6SLiEM= +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= 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.13 h1:lTGmDsbAYt5DmK6OnoV7EuIF1wEIFAcxld6ypU4OSgU= -github.com/mattn/go-runewidth v0.0.13/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +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/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rivo/uniseg v0.3.4 h1:3Z3Eu6FGHZWSfNKJTOUiPatWwfc7DzJRU04jFUqJODw= -github.com/rivo/uniseg v0.3.4/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rivo/uniseg v0.4.3 h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw= +github.com/rivo/uniseg v0.4.3/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= diff --git a/main.go b/main.go index 3f7ef9a..7af6658 100644 --- a/main.go +++ b/main.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "os/exec" "time" @@ -19,11 +18,7 @@ func main() { panic(err) } - 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() + logic.PrintPriorityTables() ticker := time.NewTicker(PollRate) defer ticker.Stop() diff --git a/utils.go b/utils.go deleted file mode 100644 index b81f97f..0000000 --- a/utils.go +++ /dev/null @@ -1,24 +0,0 @@ -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() -}