feat: complte media store

This commit is contained in:
Rogee
2024-12-06 15:06:15 +08:00
parent 43bde1e62a
commit 7d446b46c2
10 changed files with 199 additions and 226 deletions

View File

@@ -14,7 +14,24 @@ type Store []VideoInfo
type VideoInfo struct {
Hash string
Name string
Duration uint
Duration int64
}
// Price
func (info VideoInfo) Price() int64 {
min := int64(10)
// if duration is less than 300 seconds, return 10
if info.Duration < 5*60 {
return min * 100
}
// 每多一分钟,价格加 3 如果余数大于 30 秒,按一分钟计算
cells := (info.Duration - 5*30) / 60
if info.Duration%60 > 30 {
cells++
}
return (min + cells*3) * 100
}
func NewStore(path string) (Store, error) {