2019-06-26 22:02:31 +03:00
|
|
|
package media
|
|
|
|
|
2019-06-30 01:02:05 +03:00
|
|
|
// Playlist holds an array of videos capable of sorting by Timestamp.
|
2019-06-26 22:02:31 +03:00
|
|
|
type Playlist []*Video
|
|
|
|
|
2019-06-30 01:02:05 +03:00
|
|
|
// Len returns length of array (for sorting).
|
2019-06-26 22:02:31 +03:00
|
|
|
func (p Playlist) Len() int {
|
|
|
|
return len(p)
|
|
|
|
}
|
|
|
|
|
2019-06-30 01:02:05 +03:00
|
|
|
// Swap swaps two values in array by index (for sorting).
|
2019-06-26 22:02:31 +03:00
|
|
|
func (p Playlist) Swap(i, j int) {
|
|
|
|
p[i], p[j] = p[j], p[i]
|
|
|
|
}
|
|
|
|
|
2019-06-30 01:02:05 +03:00
|
|
|
// Less returns true if p[i] Timestamp is after p[j] (for sorting).
|
2019-06-26 22:02:31 +03:00
|
|
|
func (p Playlist) Less(i, j int) bool {
|
2019-06-29 06:50:59 +03:00
|
|
|
return p[i].Timestamp.After(p[j].Timestamp)
|
2019-06-26 22:02:31 +03:00
|
|
|
}
|