-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtypes.go
71 lines (56 loc) · 1.78 KB
/
types.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"time"
"github.com/jinzhu/gorm"
)
type Author struct {
gorm.Model
Name string
Link string
Email string
}
type Category struct {
// gorm.Model
ID uint `gorm:"primary_key,auto_increment"`
Name string `gorm:"unique;not_null"`
// Podcasts []*Podcast `gorm:"many2many:podcast_categories;"`
// PodcastYtID string
}
type Episode struct {
// gorm.Model
ID uint `gorm:"PRIMARY_KEY;AUTO_INCREMENT"`
YtID string `gorm:"UNIQUE_INDEX;NOT_NULL"`
PodcastYtID string
Podcast Podcast
VideoID string `xml:"videoId"`
ChannelID string `xml:"channelId"`
Title string `xml:"title"`
YtLink string `xml:"link,href,attr"`
Author Author `xml:"author"`
Published time.Time `xml:"published"`
Updated string `xml:"updated"`
CoverImageLink string `xml:"group.thumbnail.url"`
Description string `xml:"group.description"`
StarRating float64 `xml:"community.starRating"`
Views int `xml:"community.statistics"`
}
type Podcast struct {
// gorm.Model
ID uint `gorm:"AUTO_INCREMENT"`
YtID string `gorm:"PRIMARY_KEY;UNIQUE_INDEX;NOT_NULL"`
Episodes []Episode
Categories []Category `gorm:"many2many:podcast_categories;"`
Nickname string `gorm:"UNIQUE_INDEX;NOT_NULL"`
Title string `xml:"title"`
Link string `xml:"link"`
AuthorName string `xml:"author.name"`
FirstPublished time.Time `xml:"published"`
Description string
Lang string
Cached time.Time
}
// sort.Sort(ByID(selectedPod.Episodes))
type ByID []Episode
func (a ByID) Len() int { return len(a) }
func (a ByID) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
func (a ByID) Less(i, j int) bool { return a[i].ID < a[j].ID }