Nerixyz / ttv-tools

Tools for twitch
GNU General Public License v3.0
54 stars 0 forks source link

Invalid gql requests when not logged in #5

Closed pixeltris closed 3 years ago

pixeltris commented 3 years ago

All of the gql requests result in 401 Unauthorized - The "Authorization" token is invalid.

This is because when not logged in the following code will result in an Authorization value of Authorization: OAuth undefined.

https://github.com/Nerixyz/ttv-tools/blob/095682007c4dea00056aba51ba4616269fd86288/src/background/utilities/request.utilities.ts#L4


Slightly unrelated to the above, but when stripping all segments (as-in the case of preroll ads) the web browser will spam the m3u8 until a valid result is returned (i.e. one with segments).

Additionally I think completely stripping all segments can cause issues on both prerolls and midrolls where the player will break (error code 2000?) where the sequencing is messed up due to the removed segments. Though I think your player reloads might sort of fix this.

Nerixyz commented 3 years ago

when stripping all segments (as-in the case of preroll ads) the web browser will spam the m3u8 until a valid result is returned (i.e. one with segments),

That's expected. I don't want to see ads.

can cause issues on both prerolls and midrolls where the player will break (error code 2000?) where the sequencing is messed up due to the removed segments.

I never had such an error.

pixeltris commented 3 years ago

It's possible to avoid ads without sending hundreds of m3u8 requests, but it does increase the effort so yea if it's not something you care for then fair enough.

And ah OK, I was just speculating based on previous issues that Twitch-HLS-AdBlock had some years ago when using the same ad removal method. I think the updateUrl should stop that error from ever occurring (if such error even still exists). I had some error 2000's but I assume that's a side effect from the 401's.

Nerixyz commented 3 years ago

It's possible to avoid ads without sending hundreds of m3u8 requests, but it does increase the effort so yea if it's not something you care for then fair enough.

I know. That's why I put Possibly parse playlist in the readme under TODO. I'll open an issue to track the progress.

pixeltris commented 3 years ago

Thanks for the quick fix and updated xpi.

I notice that in the background script I'm always getting the fallback X-Device-Id of PogO which differs to one in the initial PlaybackAccessToken request sent by the regular Twitch code. This results in the ad skipping code from invoking on every stream which adds about 1-2 seconds of initial load per stream.

I'm not sure if this is just an issue on my end? Does the background getCookie function return the cookie from the browser session, or from the background context? Might be worth looking at. (though I guess one nice side effect of this is that everyone using the extension would essentially be using PogO which would reduce ads).

Nerixyz commented 3 years ago

Does the background getCookie function return the cookie from the browser session, or from the background context?

It uses cookies.get. This could be improved by getting the cookies from the current tab's cookie-store.

Btw: you can just try the function getCookie in the extension console.

pixeltris commented 3 years ago

Ah yea I guess it's definitely getting the extension background cookie then, which wouldn't ever be assigned in this case.

I actually think a static X-Device-Id like PogO is actually a good idea for as long as Twitch accepts it, due to the fact that it should reduce ads if enough people use it (assuming they don't combine it with an IP check).

Nerixyz commented 3 years ago

Ah yea I guess it's definitely getting the extension background cookie then, which wouldn't ever be assigned in this case.

No. Have you read the docs?

pixeltris commented 3 years ago

Oh right, I made an assumption based on my results. I was testing in incognito which obviously doesn't share the same cookies so they were always empty. Works as expected in the regular browser session, but PogO (or whatever is left in the cookie store) in incognito.