gabe565 / CastSponsorSkip

⏭️ Skip YouTube ads and sponsorships on all local Google Cast devices
Apache License 2.0
286 stars 6 forks source link

Bug: skippable ads don't get skipped #12

Closed schumi4 closed 11 months ago

schumi4 commented 11 months ago

Skippable ads don't get skipped and they don't show up in log. Setup is a Chromecast Ultra, youtube vids started using cast function. Worked fine with the predecessor, so maybe worth looking into those functions.

I'm available for further testing!

chemicalstorm commented 11 months ago

I think the issue is that while an ad is playing, the state of the device is "BUFFERING". State checking is done before ad checking, and thus we never end up trying to skip the ads. One possible fix would be to check for ads before https://github.com/gabe565/CastSponsorSkip/blob/main/internal/device/watch.go#L148 but the Skipad function seems to be blocking and can take up to 1min, so I'm not really sure if it would have any other consequences.

gabe565 commented 11 months ago

@chemicalstorm Hmm that's good to know. I unfortunately have YouTube Premium and haven't had a chance to test ad skips yet. I'm working on creating a temporary Google account and resetting a Chromecast Ultra to test. That being said, it sounds like you've identified the issue! CastSponsorSkip stops processing device updates if it has a status of PLAYING. I didn't realize ads showed a BUFFERING state. I'll make some changes that should make this more reliable.

Also, the Skipad function should be fine to call often since it checks if the device state is 1081. I don't know the meaning of that number yet, but it only seems to be set if an ad is playing. If the state is not 1081, it will immediately return.

gabe565 commented 11 months ago

To be clear, does it show BUFFERING for the entire duration of the ad or only while the ad is loading?

gabe565 commented 11 months ago

I was finally able to set up another Google account and test CastSponsorSkip with ads. I found why ad skip wasn't working. Sure enough, it was due to the state being set to BUFFERING, which wasn't being considered as playing. That should be considered a play state anyways so I fixed that. I also improved the ad skip speed and made ad skip match the value of CSS_PLAYING_INTERVAL. That's currently using my go-chromecast fork until vishen/go-chromecast#168 is merged.

Please test again with v0.3.0!

schumi4 commented 11 months ago

Can confirm it works for me with 0.3.2!