Adding Season field support
This commit is contained in:
parent
e5d984849e
commit
a1e2b5e683
|
@ -79,6 +79,7 @@ type Episode struct {
|
||||||
|
|
||||||
Slug sql.NullString `sql:"not null;unique_index"`
|
Slug sql.NullString `sql:"not null;unique_index"`
|
||||||
Name sql.NullString `sql:"not null"`
|
Name sql.NullString `sql:"not null"`
|
||||||
|
Season sql.NullInt64 `sql:"not null"`
|
||||||
Episode sql.NullInt64 `sql:"not null"`
|
Episode sql.NullInt64 `sql:"not null"`
|
||||||
ThumbS sql.NullString
|
ThumbS sql.NullString
|
||||||
ThumbB sql.NullString
|
ThumbB sql.NullString
|
||||||
|
@ -258,6 +259,7 @@ func (e *Episode) BeforeSave() (err error) {
|
||||||
}
|
}
|
||||||
e.Votes.Valid = true
|
e.Votes.Valid = true
|
||||||
e.Episode.Valid = true
|
e.Episode.Valid = true
|
||||||
|
e.Season.Valid = true
|
||||||
if e.Votes.Int64 == 0 {
|
if e.Votes.Int64 == 0 {
|
||||||
e.Rating.Valid = false
|
e.Rating.Valid = false
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -96,6 +96,7 @@ func ParseEpisode(i int, s *goquery.Selection) {
|
||||||
log.Printf("WAR EP %s: Name does not match RegEx", slug)
|
log.Printf("WAR EP %s: Name does not match RegEx", slug)
|
||||||
EP.Episode.Int64 = 0
|
EP.Episode.Int64 = 0
|
||||||
}
|
}
|
||||||
|
EP.Season.Int64 = 1
|
||||||
doc.Find(".article > p").Each(func(i int, s *goquery.Selection) {
|
doc.Find(".article > p").Each(func(i int, s *goquery.Selection) {
|
||||||
EP.Descr.String += s.Text() + "\n"
|
EP.Descr.String += s.Text() + "\n"
|
||||||
})
|
})
|
||||||
|
|
|
@ -106,6 +106,7 @@ func ParseFeedEpisode(u string) {
|
||||||
log.Printf("WAR RSS %s: Name does not match RegEx", slug)
|
log.Printf("WAR RSS %s: Name does not match RegEx", slug)
|
||||||
EP.Episode.Int64 = 0
|
EP.Episode.Int64 = 0
|
||||||
}
|
}
|
||||||
|
EP.Season.Int64 = 1
|
||||||
doc.Find(".article > p").Each(func(i int, s *goquery.Selection) {
|
doc.Find(".article > p").Each(func(i int, s *goquery.Selection) {
|
||||||
EP.Descr.String += s.Text() + "\n"
|
EP.Descr.String += s.Text() + "\n"
|
||||||
})
|
})
|
||||||
|
|
|
@ -200,6 +200,9 @@ func PostAdminEpisode(c *gin.Context) {
|
||||||
}
|
}
|
||||||
EP.Slug.String = c.PostForm("slug")
|
EP.Slug.String = c.PostForm("slug")
|
||||||
EP.Name.String = c.PostForm("name")
|
EP.Name.String = c.PostForm("name")
|
||||||
|
if se, err := strconv.ParseInt(c.PostForm("season"), 10, 64); err == nil {
|
||||||
|
EP.Season.Int64 = se
|
||||||
|
}
|
||||||
if ep, err := strconv.ParseInt(c.PostForm("episode"), 10, 64); err == nil {
|
if ep, err := strconv.ParseInt(c.PostForm("episode"), 10, 64); err == nil {
|
||||||
EP.Episode.Int64 = ep
|
EP.Episode.Int64 = ep
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,9 @@
|
||||||
<label>
|
<label>
|
||||||
Name <input type="text" name="name" value="{{ .EP.Name.String }}">
|
Name <input type="text" name="name" value="{{ .EP.Name.String }}">
|
||||||
</label>
|
</label>
|
||||||
|
<label>
|
||||||
|
Season <input type="text" name="season" value="{{ .EP.Season.Int64 }}">
|
||||||
|
</label>
|
||||||
<label>
|
<label>
|
||||||
Episode <input type="text" name="episode" value="{{ .EP.Episode.Int64 }}">
|
Episode <input type="text" name="episode" value="{{ .EP.Episode.Int64 }}">
|
||||||
</label>
|
</label>
|
||||||
|
|
Loading…
Reference in a new issue