fixed error message for anime not found
This commit is contained in:
parent
f361203c73
commit
888630126b
@ -5,16 +5,7 @@ import "git.milar.in/milarin/adverr"
|
||||
var (
|
||||
ErrNoSuitableParser = adverr.NewErrTmpl("ErrNoSuitableParser", "could not parse torrent with ID %s because no suitable parser found")
|
||||
ErrTorrentParseFailed = adverr.NewErrTmpl("ErrTorrentParseFailed", "could not parse torrent with ID %s (parsed with '%s')")
|
||||
ErrAnimeNotFound = adverr.NewErrTmpl("ErrAnimeNotFound", "could not find anime with name '%s'")
|
||||
ErrAnilistTokenNotObtainable = adverr.NewErrTmpl("ErrAnilistTokenNotObtainable", "neither ANILIST_TOKEN nor STORAGE_PATH provided")
|
||||
ErrInvalidStorageParams = adverr.NewErrTmpl("ErrInvalidStorageParams", "STORAGE_USER or STORAGE_PASS not provided")
|
||||
ErrStorageRequestFailed = adverr.NewErrTmpl("ErrStorageRequestFailed", "request to file storage could not be made")
|
||||
ErrAnimeListNotObtainable = adverr.NewErrTmpl("ErrAnimeListNotObtainable", "anime list from anilist.co not obtainable (reason: %s)")
|
||||
ErrTorrentNotObtainable = adverr.NewErrTmpl("ErrTorrentNotObtainable", "torrents from nyaa.si not obtainable (reason: %s)")
|
||||
ErrInvalidAnimeStatus = adverr.NewErrTmpl("ErrInvalidAnimeStatus", "invalid status '%s' in ANIME_STATUS (allowed: %s)")
|
||||
ErrInvalidGlobSyntax = adverr.NewErrTmpl("ErrInvalidGlobSyntax", "invalid filepath.Glob syntax: '%s'")
|
||||
ErrNoSuitableFileFound = adverr.NewErrTmpl("ErrNoSuitableFileFound", "no file found with essential properties for anime '%s' and episode %d")
|
||||
|
||||
ErrDownloadTorrentFileFailed = adverr.NewErrTmpl("ErrDownloadTorrentFileFailed", "torrent file download failed: %s")
|
||||
ErrLockFileCreationFailed = adverr.NewErrTmpl("ErrLockFileCreationFailed", "creation of lock file for anime '%s' and episode %d failed")
|
||||
ErrSaveTorrentFileFailed = adverr.NewErrTmpl("ErrSaveTorrentFileFailed", "torrent file could not be saved: %s")
|
||||
|
6
go.mod
6
go.mod
@ -8,16 +8,16 @@ require (
|
||||
git.milar.in/milarin/envvars/v2 v2.0.0
|
||||
git.milar.in/milarin/slices v0.0.6
|
||||
git.milar.in/milarin/tprint v0.0.7
|
||||
git.milar.in/nyaanime/logic v0.0.0-20230115215841-53bbded00fe6
|
||||
git.milar.in/nyaanime/logic v0.0.0-20230117155814-2819f54a35b0
|
||||
git.milar.in/nyaanime/model v0.0.0-20230117081612-d3fc649dad67
|
||||
git.milar.in/nyaanime/parsers v0.0.0-20230117093342-b57ecf49e1f5
|
||||
git.milar.in/nyaanime/parsers v0.0.0-20230117113144-375fc1faab9f
|
||||
github.com/PuerkitoBio/goquery v1.8.0
|
||||
github.com/fatih/color v1.13.0
|
||||
github.com/go-telegram-bot-api/telegram-bot-api v4.6.4+incompatible
|
||||
)
|
||||
|
||||
require (
|
||||
git.milar.in/milarin/channel v0.0.14 // indirect
|
||||
git.milar.in/milarin/channel v0.0.16 // indirect
|
||||
git.milar.in/milarin/gmath v0.0.3 // indirect
|
||||
github.com/andybalholm/cascadia v1.3.1 // indirect
|
||||
github.com/mattn/go-colorable v0.1.13 // indirect
|
||||
|
12
go.sum
12
go.sum
@ -2,8 +2,8 @@ git.milar.in/milarin/adverr v1.1.0 h1:jD9WnOvs40lfMhvqQ7cllOaRJNBMWr1f07/s9jAadp
|
||||
git.milar.in/milarin/adverr v1.1.0/go.mod h1:joU9sBb7ySyNv4SpTXB0Z4o1mjXsArBw4N27wjgzj9E=
|
||||
git.milar.in/milarin/anilist v1.5.1 h1:gW08WaAvXxC5/+P1QCjyfa5YtaiY9XvF5x/8G4orT6I=
|
||||
git.milar.in/milarin/anilist v1.5.1/go.mod h1:8PTHXFMA45JpfRFIpcdrKwDHue8fbT/wwV1BuHFn6c0=
|
||||
git.milar.in/milarin/channel v0.0.14 h1:1jBaKNNOK/mmMMgC7yVW1Cgnbb7q9aKBXZ5WnWptDek=
|
||||
git.milar.in/milarin/channel v0.0.14/go.mod h1:We83LTI8S7u7II3pD+A2ChCDWJfCkcBUCUqii9HjTtM=
|
||||
git.milar.in/milarin/channel v0.0.16 h1:gyxwUFdw2pJUusdNhgnuTb2Tmb5MQAbTYcyxa3wp494=
|
||||
git.milar.in/milarin/channel v0.0.16/go.mod h1:We83LTI8S7u7II3pD+A2ChCDWJfCkcBUCUqii9HjTtM=
|
||||
git.milar.in/milarin/envvars/v2 v2.0.0 h1:DWRQCWaHqzDD8NGpSgv5tYLuF9A/dVFPAtTvz3oiIqE=
|
||||
git.milar.in/milarin/envvars/v2 v2.0.0/go.mod h1:HkdEi+gG2lJSmVq547bTlQV4qQ0hO333bE8IrE0B9yY=
|
||||
git.milar.in/milarin/gmath v0.0.3 h1:ii6rKNItS55O/wtIFhD1cTN2BMwDZjTBmiOocKURvxM=
|
||||
@ -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-20230115215841-53bbded00fe6 h1:6GmcKt0TaHxATGbSpTgDExdRHiON5OwZlHVJCYU0gbA=
|
||||
git.milar.in/nyaanime/logic v0.0.0-20230115215841-53bbded00fe6/go.mod h1:cLuIBDTtpXdzprOIsz73r6ZCE5s0k+o6HA7fH9OuW/M=
|
||||
git.milar.in/nyaanime/logic v0.0.0-20230117155814-2819f54a35b0 h1:BDWszkp5mdjD+cq7VuR0t6j0In+NN/MRzgkOFqvHmRA=
|
||||
git.milar.in/nyaanime/logic v0.0.0-20230117155814-2819f54a35b0/go.mod h1:cLuIBDTtpXdzprOIsz73r6ZCE5s0k+o6HA7fH9OuW/M=
|
||||
git.milar.in/nyaanime/model v0.0.0-20230117081612-d3fc649dad67 h1:p69LqaWzN/2zsgw45tR1XbFxyayu9ffVlikiKE2ibRw=
|
||||
git.milar.in/nyaanime/model v0.0.0-20230117081612-d3fc649dad67/go.mod h1:kPWLDvFrhc1Uf77gxsBOxNeJ5JTVF2HhVs1IdVcw0tg=
|
||||
git.milar.in/nyaanime/parsers v0.0.0-20230117093342-b57ecf49e1f5 h1:/CdnetuL/vNwo8VsPX2n4IQt81ozYCLDScgmkPser8c=
|
||||
git.milar.in/nyaanime/parsers v0.0.0-20230117093342-b57ecf49e1f5/go.mod h1:fqiJqSWxh1YVJkKhvQql/21HmQzv4elhC3SpH/2TybI=
|
||||
git.milar.in/nyaanime/parsers v0.0.0-20230117113144-375fc1faab9f h1:6DFFgqeBeU+qi24PLOwc5trPIPKief/YmGlQfyXrpAQ=
|
||||
git.milar.in/nyaanime/parsers v0.0.0-20230117113144-375fc1faab9f/go.mod h1:fqiJqSWxh1YVJkKhvQql/21HmQzv4elhC3SpH/2TybI=
|
||||
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=
|
||||
|
@ -3,11 +3,13 @@ package main
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.milar.in/milarin/adverr"
|
||||
"git.milar.in/nyaanime/logic"
|
||||
"git.milar.in/nyaanime/model"
|
||||
"git.milar.in/nyaanime/parsers"
|
||||
"github.com/fatih/color"
|
||||
)
|
||||
|
||||
func ParseTorrent(torrent *model.Torrent) (*model.ParsedTorrent, error) {
|
||||
@ -34,8 +36,8 @@ func ParseTorrentsByAnimeEp(torrents []model.Torrent) map[model.AnimeEpisode][]*
|
||||
torrent := torrent
|
||||
parsedTorrent, err := ParseTorrent(&torrent)
|
||||
if err != nil {
|
||||
if errors.Is(err, ErrAnimeNotFound) {
|
||||
fmt.Printf("anime not found: \"%s\" (torrent ID: %s)\n", parsedTorrent.OriginalAnimeTitle, torrent.ID)
|
||||
if errors.Is(err, logic.ErrAnimeNotFound) {
|
||||
fmt.Fprintln(os.Stderr, color.RedString("torrent with ID %s could not be parsed because anime was not found: \"%s\"", torrent.ID, parsedTorrent.OriginalAnimeTitle))
|
||||
} else if !errors.Is(err, ErrNoSuitableParser) {
|
||||
adverr.Println(err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user