From 9ce113fc9042ba41b8f78aae1e8d8e9728e5249a Mon Sep 17 00:00:00 2001 From: Timon Ringwald Date: Mon, 15 Aug 2022 14:23:39 +0200 Subject: [PATCH] String() methods added for ParsedTorrent and Resolution --- parsed_torrent.go | 17 ++++++++++++++++- resolution.go | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/parsed_torrent.go b/parsed_torrent.go index 174605e..b487c12 100644 --- a/parsed_torrent.go +++ b/parsed_torrent.go @@ -1,6 +1,11 @@ package model -import "git.milar.in/milarin/anilist" +import ( + "fmt" + "strings" + + "git.milar.in/milarin/anilist" +) type ParsedTorrent struct { // parsed data @@ -15,3 +20,13 @@ type ParsedTorrent struct { Torrent *Torrent Parser *Parser } + +func (t ParsedTorrent) String() string { + return fmt.Sprintf("title: %s | episode: %d | resolution: %s | languages: %s | subtitles: %s", + t.Anime.Title.Native, + t.Episode, + t.Resolution, + strings.Join(t.Languages, ", "), + strings.Join(t.Subtitles, ", "), + ) +} diff --git a/resolution.go b/resolution.go index 2fac7d6..bcefe03 100644 --- a/resolution.go +++ b/resolution.go @@ -1,6 +1,7 @@ package model import ( + "fmt" "strconv" "strings" ) @@ -30,3 +31,20 @@ func ParseResolution(str string) (Resolution, error) { return Resolution(v), err } } + +func (r Resolution) String() string { + switch r { + case Resolution4K: + return "4K" + case ResolutionQuadHD: + return "1440p" + case ResolutionFullHD: + return "1080p" + case ResolutionHD: + return "HD" + case ResolutionSD: + return "SD" + default: + return fmt.Sprintf("%sp", r) + } +}