This commit is contained in:
parent
2c10ea6f33
commit
4938f28ace
10
main.go
10
main.go
@ -29,6 +29,7 @@ var Statefile string
|
|||||||
var CurrStreamCnt int
|
var CurrStreamCnt int
|
||||||
var MostStreamCnt int
|
var MostStreamCnt int
|
||||||
var StartTime time.Time
|
var StartTime time.Time
|
||||||
|
var HolodexToken string
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
viper.SetConfigName("config")
|
viper.SetConfigName("config")
|
||||||
@ -45,6 +46,7 @@ func main() {
|
|||||||
Username = viper.GetString("username")
|
Username = viper.GetString("username")
|
||||||
Password = viper.GetString("password")
|
Password = viper.GetString("password")
|
||||||
Token = viper.GetString("access_token")
|
Token = viper.GetString("access_token")
|
||||||
|
HolodexToken = viper.GetString("api_token")
|
||||||
DimensionServer = viper.GetString("dimension")
|
DimensionServer = viper.GetString("dimension")
|
||||||
HomeserverDomain = viper.GetString("domain")
|
HomeserverDomain = viper.GetString("domain")
|
||||||
Statefile = viper.GetString("statefile")
|
Statefile = viper.GetString("statefile")
|
||||||
@ -103,6 +105,9 @@ func main() {
|
|||||||
} else {
|
} else {
|
||||||
log.Println("skipping login since token provided")
|
log.Println("skipping login since token provided")
|
||||||
}
|
}
|
||||||
|
if HolodexToken == "" {
|
||||||
|
log.Println("No holodex API token provided, unlikely to be able to get streams")
|
||||||
|
}
|
||||||
syncer := client.Syncer.(*mautrix.DefaultSyncer)
|
syncer := client.Syncer.(*mautrix.DefaultSyncer)
|
||||||
syncer.OnEventType(event.EventMessage, func(source mautrix.EventSource, evt *event.Event) {
|
syncer.OnEventType(event.EventMessage, func(source mautrix.EventSource, evt *event.Event) {
|
||||||
if evt.Sender == client.UserID {
|
if evt.Sender == client.UserID {
|
||||||
@ -211,7 +216,10 @@ func main() {
|
|||||||
rooms := roomResp.JoinedRooms
|
rooms := roomResp.JoinedRooms
|
||||||
// We're going to assume they're only stream one video at a time
|
// We're going to assume they're only stream one video at a time
|
||||||
for _, v := range vtubers {
|
for _, v := range vtubers {
|
||||||
v.Update()
|
err = v.Update(HolodexToken)
|
||||||
|
if err != nil {
|
||||||
|
log.Println(err)
|
||||||
|
}
|
||||||
if v.IsLive() {
|
if v.IsLive() {
|
||||||
|
|
||||||
for _, room := range rooms {
|
for _, room := range rooms {
|
||||||
|
@ -60,9 +60,10 @@ func (v *Vtuber) IsLive() bool {
|
|||||||
return v.CurrentStream != ""
|
return v.CurrentStream != ""
|
||||||
}
|
}
|
||||||
|
|
||||||
func (v *Vtuber) Update() error {
|
func (v *Vtuber) Update(api_key string) error {
|
||||||
url := fmt.Sprintf("https://holodex.net/api/v2/live?channel_id=%s&lang=all&sort=available_at&order=desc&limit=25&offset=0&paginated=%%3Cempty%%3E", v.ChannelID)
|
url := fmt.Sprintf("https://holodex.net/api/v2/live?channel_id=%s&lang=all&sort=available_at&order=desc&limit=25&offset=0&paginated=%%3Cempty%%3E", v.ChannelID)
|
||||||
req, err := http.NewRequest("GET", url, nil)
|
req, err := http.NewRequest("GET", url, nil)
|
||||||
|
req.Header.Set("X-APIKEY", api_key)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user