aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrtz12 <koenig@fagott.pw>2016-10-09 19:27:58 (UTC)
committerrtz12 <koenig@fagott.pw>2016-10-09 19:27:58 (UTC)
commitc8ae06da6bc68e6a259d98ae1657174993f65ab4 (patch)
tree20ad2e4236e676ffdf739e8e17c1e8f215b4db7d
parent82385f50d12492bd980b6f88a138a8821f597efd (diff)
parent9c572b524bbc2f17792321485e53e819d06d278e (diff)
Merge branch 'master' of projekte.fagott.pw:grilist
-rw-r--r--modules/grils/gril.go35
1 files changed, 4 insertions, 31 deletions
diff --git a/modules/grils/gril.go b/modules/grils/gril.go
index 0462e86..7b54ab1 100644
--- a/modules/grils/gril.go
+++ b/modules/grils/gril.go
@@ -3,7 +3,6 @@ package grils
3import ( 3import (
4 "database/sql" 4 "database/sql"
5 "fmt" 5 "fmt"
6 "os"
7 "strconv" 6 "strconv"
8 "strings" 7 "strings"
9 "time" 8 "time"
@@ -52,37 +51,11 @@ func (g *Gril) Slug() string {
52 strings.Replace(g.RomajiName, " ", "", -1)) 51 strings.Replace(g.RomajiName, " ", "", -1))
53} 52}
54 53
55func ImagePath(id int, prioritizeThumbnail bool) string { 54func ImagePath(id int, useThumbnail bool) string {
56 // Image Priority 55 if useThumbnail {
57 // without prioritizeThumbnail: Anilist > ACD (big) > ACD (thumbnail) 56 return fmt.Sprintf("http://img.grilist.moe/gril/thumb/%d.jpg", id)
58 // with prioritizeThumbnail: Anilist > ACD (thumbnail) > ACD (big)
59
60 anilistPath := fmt.Sprintf("assets/img/gril/%d/%d.jpg", DataSourceAnilist, id)
61 if _, err := os.Stat(anilistPath); err == nil {
62 return fmt.Sprintf(anilistPath)
63 }
64
65 var big string
66 exts := []string{"png", "jpg", "gif", "jpeg"}
67 for _, ext := range exts {
68 path := fmt.Sprintf("assets/img/gril/%d/%d/0.%s", DataSourceACD, id, ext)
69 if _, err := os.Stat(path); err == nil {
70 if prioritizeThumbnail {
71 big = path
72 } else {
73 return path
74 }
75 }
76 } 57 }
77 58 return fmt.Sprintf("http://img.grilist.moe/gril/full/%d.jpg", id)
78 for _, ext := range exts {
79 path := fmt.Sprintf("assets/img/gril/%d/%d/1.%s", DataSourceACD, id, ext)
80 if _, err := os.Stat(path); err == nil {
81 return path
82 }
83 }
84
85 return big
86} 59}
87 60
88func (g *Gril) ImagePath(prioritizeThumbnail bool) string { 61func (g *Gril) ImagePath(prioritizeThumbnail bool) string {