Skip to content

Commit

Permalink
fix(device): Fix missing video ID breaking ad skip
Browse files Browse the repository at this point in the history
Ref #27
  • Loading branch information
gabe565 committed Oct 3, 2023
1 parent 88f9e5b commit 6418104
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions internal/device/watch.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,12 @@ func (d *Device) tick() error {
default:
if castMedia.Media.ContentId == "" {
d.queryVideoId(castMedia)
if castMedia.Media.ContentId == "" {
d.changeTickInterval(config.Default.PausedInterval)
return nil
}
}

if castMedia.Media.ContentId != d.prevVideoId {
d.logger.Info("Detected video stream.", "video_id", castMedia.Media.ContentId)
if castMedia.Media.ContentId != "" {
d.logger.Info("Detected video stream.", "video_id", castMedia.Media.ContentId)
}
d.prevVideoId = castMedia.Media.ContentId
d.unmuteSegment()
d.querySegments(castMedia)
Expand Down Expand Up @@ -382,6 +380,10 @@ func (d *Device) unmuteSegment() {
}

func (d *Device) querySegments(castMedia *cast.Media) {
if castMedia.Media.ContentId == "" {
return
}

if err := util.Retry(d.ctx, 10, 500*time.Millisecond, func(try uint) (err error) {
d.segments, err = sponsorblock.QuerySegments(d.ctx, castMedia.Media.ContentId)
return err
Expand Down

0 comments on commit 6418104

Please sign in to comment.