-
Notifications
You must be signed in to change notification settings - Fork 12
/
vid.go
44 lines (35 loc) · 857 Bytes
/
vid.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
package main
import (
"fmt"
"html"
"path/filepath"
"time"
)
type ytVidInfo struct {
id string
published time.Time
title string
desc string
}
func makeYtVidInfo(id string, published time.Time, title, desc string) ytVidInfo {
return ytVidInfo{
id: id,
published: published,
title: html.UnescapeString(title),
desc: html.UnescapeString(desc),
}
}
func (vi *ytVidInfo) episodePath(fileExt string) string {
return filepath.Join(dataSubdirEpisodes, fmt.Sprint(vi.id, ".", fileExt))
}
// ------------------------------------------------------------
type vidsChronoSorter []ytVidInfo
func (v vidsChronoSorter) Len() int {
return len(v)
}
func (v vidsChronoSorter) Swap(i, j int) {
v[i], v[j] = v[j], v[i]
}
func (v vidsChronoSorter) Less(i, j int) bool {
return v[i].published.Before(v[j].published)
}