package main
import (
"regexp"
"strings"
)
const InnerTubeBase = "https://music.youtube.com/youtubei/v1"
type Artist struct {
ID string
Name string
ReleaseCount int
}
type Release struct {
MPREID string
OLAKID string
Title string
Artist string
TrackCount int
Tracks []Track
}
type Track struct {
Index int
Title string
VideoID string
}
var (
reChannelID = regexp.MustCompile(`UC[a-zA-Z0-9_-]{22}`)
reMPREID = regexp.MustCompile(`MPREb_[a-zA-Z0-9_-]+`)
reOLAKID = regexp.MustCompile(`OLAK5uy_[a-zA-Z0-9_-]+`)
reTitle = regexp.MustCompile(`"text"\s*:\s*"((?:[^"\\]|\\.)*)"`)
reHeaderTag = regexp.MustCompile(`"musicImmersiveHeaderRenderer"`)
reStrapline = regexp.MustCompile(`"straplineTextOne":\{"runs":\[\{"text":"((?:[^"\\]|\\.)*)"`)
)
var windowsIllegal = strings.NewReplacer(
"<", "_",
">", "_",
":", "_",
"\"", "_",
"/", "_",
"\\", "_",
"|", "_",
"?", "_",
"*", "_",
)
func sanitizePath(name string) string {
s := windowsIllegal.Replace(name)
s = strings.TrimSpace(s)
if len(s) > 100 {
s = s[:100]
}
return s
}