diff options
author | jan <jan@ruken.pw> | 2016-01-16 07:52:16 (UTC) |
---|---|---|
committer | jan <jan@ruken.pw> | 2016-01-16 07:52:16 (UTC) |
commit | 6049d382d0b75df46b0d0b330e4297246984ffe0 (patch) | |
tree | 8e88ddb269a7829c13b0eb1c849966041d8e74a2 /modules/grils | |
parent | 928ab739e2b4b40077610a7913adb0cf086f2ee1 (diff) |
anilist als datasource hinzugefĆ¼gt, imagepath angepasst
Diffstat (limited to 'modules/grils')
-rw-r--r-- | modules/grils/gril.go | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/modules/grils/gril.go b/modules/grils/gril.go index af84d04..7cc1e4b 100644 --- a/modules/grils/gril.go +++ b/modules/grils/gril.go | |||
@@ -15,7 +15,8 @@ type DataSource int | |||
15 | 15 | ||
16 | const ( | 16 | const ( |
17 | DataSourceACD DataSource = iota | 17 | DataSourceACD DataSource = iota |
18 | DataSourceAniDB | 18 | DataSourceAniDB DataSource = iota |
19 | DataSourceAnilist DataSource = iota | ||
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 | } |