aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrtz12 <koenig@fagott.pw>2016-10-12 20:33:24 (UTC)
committerrtz12 <koenig@fagott.pw>2016-10-12 20:33:24 (UTC)
commit6fba92d36432d28e3ad62e6b3da5a3b807011482 (patch)
tree6899ce02203466fe4efd079f773650d445aa9a76
parentcaa0e61762511c32e45caf0df4e9dca4d4670849 (diff)
Mal wieder Jans Suppe ausgeloeffelt
-rw-r--r--models/tag.go (renamed from modules/tags/tag.go)2
-rw-r--r--tools/animeimporter/ACDv2Reader.go4
-rw-r--r--tools/animeimporter/main.go9
-rw-r--r--tools/importer/ACDReader.go6
-rw-r--r--tools/importer/ACDv2Reader.go15
-rw-r--r--tools/importer/main.go9
6 files changed, 21 insertions, 24 deletions
diff --git a/modules/tags/tag.go b/models/tag.go
index 026df0f..9ecd73c 100644
--- a/modules/tags/tag.go
+++ b/models/tag.go
@@ -1,4 +1,4 @@
1package tags 1package models
2 2
3type TagType int 3type TagType int
4 4
diff --git a/tools/animeimporter/ACDv2Reader.go b/tools/animeimporter/ACDv2Reader.go
index 36564e4..38162d6 100644
--- a/tools/animeimporter/ACDv2Reader.go
+++ b/tools/animeimporter/ACDv2Reader.go
@@ -7,7 +7,7 @@ import (
7 "strconv" 7 "strconv"
8 "strings" 8 "strings"
9 9
10 "fagott.pw/grilist/modules/grils" 10 "fagott.pw/grilist/models"
11) 11)
12 12
13func ifErrExit(err error) { 13func ifErrExit(err error) {
@@ -55,5 +55,5 @@ func (r *ACDv2Reader) Read(path string) WrappedSeries {
55} 55}
56 56
57func (r *ACDv2Reader) ID() int { 57func (r *ACDv2Reader) ID() int {
58 return int(grils.DataSourceACD) 58 return int(models.DataSourceACD)
59} 59}
diff --git a/tools/animeimporter/main.go b/tools/animeimporter/main.go
index 81ba516..17da658 100644
--- a/tools/animeimporter/main.go
+++ b/tools/animeimporter/main.go
@@ -8,8 +8,7 @@ import (
8 "path/filepath" 8 "path/filepath"
9 9
10 "fagott.pw/grilist/grilist" 10 "fagott.pw/grilist/grilist"
11 "fagott.pw/grilist/modules/series" 11 "fagott.pw/grilist/models"
12 "fagott.pw/grilist/modules/tags"
13) 12)
14 13
15var path string 14var path string
@@ -20,7 +19,7 @@ var db *sql.DB
20var r SeriesReader 19var r SeriesReader
21 20
22type WrappedSeries struct { 21type WrappedSeries struct {
23 Series series.Series 22 Series models.Series
24 Image string 23 Image string
25} 24}
26 25
@@ -104,7 +103,7 @@ func InsertTags(dbID int, s WrappedSeries, taglist map[string]int) {
104 } 103 }
105 var id int 104 var id int
106 row := db.QueryRow("INSERT INTO grilist.tags (name, type) VALUES ($1, $2) RETURNING id;", 105 row := db.QueryRow("INSERT INTO grilist.tags (name, type) VALUES ($1, $2) RETURNING id;",
107 v, tags.TagTypeSeries) 106 v, models.TagTypeSeries)
108 row.Scan(&id) 107 row.Scan(&id)
109 taglist[v] = id 108 taglist[v] = id
110 fmt.Printf("Inserted tag %s as %d\n", v, id) 109 fmt.Printf("Inserted tag %s as %d\n", v, id)
@@ -167,7 +166,7 @@ func main() {
167 } 166 }
168 167
169 taglist := make(map[string]int) 168 taglist := make(map[string]int)
170 rows, err := db.Query("SELECT id, name FROM grilist.tags WHERE type = $1;", tags.TagTypeSeries) 169 rows, err := db.Query("SELECT id, name FROM grilist.tags WHERE type = $1;", models.TagTypeSeries)
171 LogErr(err) 170 LogErr(err)
172 for rows.Next() { 171 for rows.Next() {
173 var id int 172 var id int
diff --git a/tools/importer/ACDReader.go b/tools/importer/ACDReader.go
index 694087e..1d5e8c9 100644
--- a/tools/importer/ACDReader.go
+++ b/tools/importer/ACDReader.go
@@ -9,7 +9,7 @@ import (
9 "strconv" 9 "strconv"
10 "strings" 10 "strings"
11 11
12 "fagott.pw/grilist/modules/grils" 12 "fagott.pw/grilist/models"
13) 13)
14 14
15var tagRegex = regexp.MustCompile(`\<a.*?\>(.+)\<\/a\>`) 15var tagRegex = regexp.MustCompile(`\<a.*?\>(.+)\<\/a\>`)
@@ -31,7 +31,7 @@ func toInt(s string) int {
31 31
32func (r *ACDReader) Read(path string) WrappedGril { 32func (r *ACDReader) Read(path string) WrappedGril {
33 g := WrappedGril{} 33 g := WrappedGril{}
34 g.Gril = grils.Gril{} 34 g.Gril = models.Gril{}
35 data, err := ioutil.ReadFile(path) 35 data, err := ioutil.ReadFile(path)
36 ifErrExit(err) 36 ifErrExit(err)
37 var jObj interface{} 37 var jObj interface{}
@@ -77,5 +77,5 @@ func (r *ACDReader) Read(path string) WrappedGril {
77} 77}
78 78
79func (r *ACDReader) ID() int { 79func (r *ACDReader) ID() int {
80 return int(grils.DataSourceACD) 80 return int(models.DataSourceACD)
81} 81}
diff --git a/tools/importer/ACDv2Reader.go b/tools/importer/ACDv2Reader.go
index 4dab3c0..f34dd15 100644
--- a/tools/importer/ACDv2Reader.go
+++ b/tools/importer/ACDv2Reader.go
@@ -6,8 +6,7 @@ import (
6 "path/filepath" 6 "path/filepath"
7 "strings" 7 "strings"
8 8
9 "fagott.pw/grilist/modules/grils" 9 "fagott.pw/grilist/models"
10 "fagott.pw/grilist/modules/series"
11) 10)
12 11
13const failMsg = "Offenbar war meine Annahme bzgl. der Traits nicht ganz korrekt" 12const failMsg = "Offenbar war meine Annahme bzgl. der Traits nicht ganz korrekt"
@@ -45,7 +44,7 @@ type ACDv2Gril struct {
45 44
46func (r *ACDv2Reader) Read(path string) WrappedGril { 45func (r *ACDv2Reader) Read(path string) WrappedGril {
47 g := WrappedGril{} 46 g := WrappedGril{}
48 g.Gril = grils.Gril{} 47 g.Gril = models.Gril{}
49 data, err := ioutil.ReadFile(path) 48 data, err := ioutil.ReadFile(path)
50 ifErrExit(err) 49 ifErrExit(err)
51 var jObj ACDv2Gril 50 var jObj ACDv2Gril
@@ -61,7 +60,7 @@ func (r *ACDv2Reader) Read(path string) WrappedGril {
61 for _, v := range jObj.Tags { 60 for _, v := range jObj.Tags {
62 g.Gril.Tags = append(g.Gril.Tags, v.Name) 61 g.Gril.Tags = append(g.Gril.Tags, v.Name)
63 } 62 }
64 g.Gril.Traits = make([]grils.Trait, 0) 63 g.Gril.Traits = make([]models.Trait, 0)
65 if len(jObj.Traits.Official) != len(jObj.Traits.Indexed) { 64 if len(jObj.Traits.Official) != len(jObj.Traits.Indexed) {
66 panic(failMsg) 65 panic(failMsg)
67 } 66 }
@@ -69,16 +68,16 @@ func (r *ACDv2Reader) Read(path string) WrappedGril {
69 if jObj.Traits.Official[i].Name != jObj.Traits.Indexed[i].Name { 68 if jObj.Traits.Official[i].Name != jObj.Traits.Indexed[i].Name {
70 panic(failMsg) 69 panic(failMsg)
71 } 70 }
72 t := grils.Trait{ 71 t := models.Trait{
73 Name: jObj.Traits.Official[i].Name, 72 Name: jObj.Traits.Official[i].Name,
74 Value: jObj.Traits.Indexed[i].Value, 73 Value: jObj.Traits.Indexed[i].Value,
75 OfficialValue: jObj.Traits.Official[i].Value, 74 OfficialValue: jObj.Traits.Official[i].Value,
76 } 75 }
77 g.Gril.Traits = append(g.Gril.Traits, t) 76 g.Gril.Traits = append(g.Gril.Traits, t)
78 } 77 }
79 g.Gril.Series = make([]series.Series, 0) 78 g.Gril.Series = make([]models.Series, 0)
80 for _, v := range jObj.Assignments { 79 for _, v := range jObj.Assignments {
81 s := series.Series{ 80 s := models.Series{
82 ID: v, 81 ID: v,
83 } 82 }
84 g.Gril.Series = append(g.Gril.Series, s) 83 g.Gril.Series = append(g.Gril.Series, s)
@@ -87,5 +86,5 @@ func (r *ACDv2Reader) Read(path string) WrappedGril {
87} 86}
88 87
89func (r *ACDv2Reader) ID() int { 88func (r *ACDv2Reader) ID() int {
90 return int(grils.DataSourceACD) 89 return int(models.DataSourceACD)
91} 90}
diff --git a/tools/importer/main.go b/tools/importer/main.go
index 8c60ef7..284ef44 100644
--- a/tools/importer/main.go
+++ b/tools/importer/main.go
@@ -8,8 +8,7 @@ import (
8 "path/filepath" 8 "path/filepath"
9 9
10 "fagott.pw/grilist/grilist" 10 "fagott.pw/grilist/grilist"
11 "fagott.pw/grilist/modules/grils" 11 "fagott.pw/grilist/models"
12 "fagott.pw/grilist/modules/tags"
13 12
14 _ "github.com/lib/pq" 13 _ "github.com/lib/pq"
15) 14)
@@ -22,7 +21,7 @@ var db *sql.DB
22var r GrilReader 21var r GrilReader
23 22
24type WrappedGril struct { 23type WrappedGril struct {
25 Gril grils.Gril 24 Gril models.Gril
26 Image string 25 Image string
27 Thumb string 26 Thumb string
28} 27}
@@ -113,7 +112,7 @@ func InsertTags(dbID int, g WrappedGril, taglist map[string]int) {
113 } 112 }
114 var id int 113 var id int
115 row := db.QueryRow(`INSERT INTO grilist.tags (name, type) VALUES 114 row := db.QueryRow(`INSERT INTO grilist.tags (name, type) VALUES
116 ($1, $2) RETURNING id;`, v, tags.TagTypeGril) 115 ($1, $2) RETURNING id;`, v, models.TagTypeGril)
117 row.Scan(&id) 116 row.Scan(&id)
118 taglist[v] = id 117 taglist[v] = id
119 fmt.Printf("Inserted tag %s as %d\n", v, id) 118 fmt.Printf("Inserted tag %s as %d\n", v, id)
@@ -242,7 +241,7 @@ func main() {
242 } 241 }
243 242
244 taglist := make(map[string]int) 243 taglist := make(map[string]int)
245 rows, _ := db.Query("SELECT id, name FROM grilist.tags WHERE type = $1;", tags.TagTypeGril) 244 rows, _ := db.Query("SELECT id, name FROM grilist.tags WHERE type = $1;", models.TagTypeGril)
246 for rows.Next() { 245 for rows.Next() {
247 var id int 246 var id int
248 var name string 247 var name string