/
podcast.go
136 lines (104 loc) · 2.54 KB
/
podcast.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
package db
import (
"time"
)
//Podcast is
type Podcast struct {
Base
Title string
Summary string `gorm:"type:text"`
Author string
Image string
URL string
LastEpisode *time.Time
PodcastItems []PodcastItem
Tags []*Tag `gorm:"many2many:podcast_tags;"`
DownloadedEpisodesCount int `gorm:"-"`
DownloadingEpisodesCount int `gorm:"-"`
AllEpisodesCount int `gorm:"-"`
DownloadedEpisodesSize int64 `gorm:"-"`
DownloadingEpisodesSize int64 `gorm:"-"`
AllEpisodesSize int64 `gorm:"-"`
IsPaused bool `gorm:"default:false"`
}
//PodcastItem is
type PodcastItem struct {
Base
PodcastID string
Podcast Podcast
Title string
Summary string `gorm:"type:text"`
EpisodeType string
Duration int
PubDate time.Time
FileURL string
GUID string
Image string
DownloadDate time.Time
DownloadPath string
DownloadStatus DownloadStatus `gorm:"default:0"`
IsPlayed bool `gorm:"default:false"`
BookmarkDate time.Time
LocalImage string
FileSize int64
}
type DownloadStatus int
const (
NotDownloaded DownloadStatus = iota
Downloading
Downloaded
Deleted
)
type Setting struct {
Base
DownloadOnAdd bool `gorm:"default:true"`
InitialDownloadCount int `gorm:"default:5"`
AutoDownload bool `gorm:"default:true"`
AppendDateToFileName bool `gorm:"default:false"`
AppendEpisodeNumberToFileName bool `gorm:"default:false"`
DarkMode bool `gorm:"default:false"`
DownloadEpisodeImages bool `gorm:"default:false"`
GenerateNFOFile bool `gorm:"default:false"`
DontDownloadDeletedFromDisk bool `gorm:"default:false"`
BaseUrl string
MaxDownloadConcurrency int `gorm:"default:5"`
UserAgent string
}
type Migration struct {
Base
Date time.Time
Name string
}
type JobLock struct {
Base
Date time.Time
Name string
Duration int
}
type Tag struct {
Base
Label string
Description string `gorm:"type:text"`
Podcasts []*Podcast `gorm:"many2many:podcast_tags;"`
}
func (lock *JobLock) IsLocked() bool {
return lock != nil && lock.Date != time.Time{}
}
type PodcastItemStatsModel struct {
PodcastID string
DownloadStatus DownloadStatus
Count int
Size int64
}
type PodcastItemDiskStatsModel struct {
DownloadStatus DownloadStatus
Count int
Size int64
}
type PodcastItemConsolidateDiskStatsModel struct {
Downloaded int64
Downloading int64
NotDownloaded int64
Deleted int64
PendingDownload int64
}