diff options
author | jan <jan@ruken.pw> | 2016-01-16 18:39:28 (UTC) |
---|---|---|
committer | jan <jan@ruken.pw> | 2016-01-16 18:39:28 (UTC) |
commit | df4c2d2cd5bf222e664167abc8c91e286e5b2c3a (patch) | |
tree | fc05213e3791615d7d1ef517671311496857dafd /modules/grils | |
parent | b16c4ef8e1ef3458f186139172362a511f925043 (diff) | |
parent | 012d8130aff2bbb25fad97244a7a7a47ad2f6103 (diff) |
Merge branch 'master' of ssh://mc.telamitto.org/grilist
Diffstat (limited to 'modules/grils')
-rw-r--r-- | modules/grils/gril.go | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/modules/grils/gril.go b/modules/grils/gril.go index af84d04..7b782b3 100644 --- a/modules/grils/gril.go +++ b/modules/grils/gril.go | |||
@@ -16,6 +16,7 @@ type DataSource int | |||
16 | const ( | 16 | const ( |
17 | DataSourceACD DataSource = iota | 17 | DataSourceACD DataSource = iota |
18 | DataSourceAniDB | 18 | DataSourceAniDB |
19 | DataSourceAnilist | ||
19 | ) | 20 | ) |
20 | 21 | ||
21 | type Gril struct { | 22 | type Gril struct { |
@@ -42,10 +43,19 @@ func (g *Gril) Slug() string { | |||
42 | } | 43 | } |
43 | 44 | ||
44 | func ImagePath(id int, prioritizeThumbnail bool) string { | 45 | func ImagePath(id int, prioritizeThumbnail bool) string { |
46 | // Image Priority | ||
47 | // without prioritizeThumbnail: Anilist > ACD (big) > ACD (thumbnail) | ||
48 | // with prioritizeThumbnail: Anilist > ACD (thumbnail) > ACD (big) | ||
49 | |||
50 | anilistPath := fmt.Sprintf("assets/img/gril/%d/%d.jpg", DataSourceAnilist, id) | ||
51 | if _, err := os.Stat(anilistPath); err == nil { | ||
52 | return fmt.Sprintf(anilistPath) | ||
53 | } | ||
54 | |||
45 | var big string | 55 | var big string |
46 | exts := []string{"png", "jpg", "gif", "jpeg"} | 56 | exts := []string{"png", "jpg", "gif", "jpeg"} |
47 | for _, ext := range exts { | 57 | for _, ext := range exts { |
48 | path := fmt.Sprintf("assets/img/gril/%d/0.%s", id, ext) | 58 | path := fmt.Sprintf("assets/img/gril/%d/%d/0.%s", DataSourceACD, id, ext) |
49 | if _, err := os.Stat(path); err == nil { | 59 | if _, err := os.Stat(path); err == nil { |
50 | if prioritizeThumbnail { | 60 | if prioritizeThumbnail { |
51 | big = path | 61 | big = path |
@@ -56,7 +66,7 @@ func ImagePath(id int, prioritizeThumbnail bool) string { | |||
56 | } | 66 | } |
57 | 67 | ||
58 | for _, ext := range exts { | 68 | for _, ext := range exts { |
59 | path := fmt.Sprintf("assets/img/gril/%d/1.%s", id, ext) | 69 | path := fmt.Sprintf("assets/img/gril/%d/%d/1.%s", DataSourceACD, id, ext) |
60 | if _, err := os.Stat(path); err == nil { | 70 | if _, err := os.Stat(path); err == nil { |
61 | return path | 71 | return path |
62 | } | 72 | } |