Skip to content

Commit

Permalink
Change client type to ANDROID_APP (#531)
Browse files Browse the repository at this point in the history
  • Loading branch information
DevilXD authored Aug 7, 2024
2 parents 415233b + f92b855 commit 25ead72
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion twitch.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ def __init__(self, settings: Settings):
self._drops: dict[str, TimedDrop] = {}
self._mnt_triggers: deque[datetime] = deque()
# Client type, session and auth
self._client_type: ClientInfo = ClientType.MOBILE_WEB
self._client_type: ClientInfo = ClientType.ANDROID_APP
self._session: aiohttp.ClientSession | None = None
self._auth_state: _AuthState = _AuthState(self)
# GUI
Expand Down

2 comments on commit 25ead72

@uniquoo
Copy link

@uniquoo uniquoo commented on 25ead72 Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technical background question: Does switching up the client version change anything in terms of communication with Twitch backend? Just wondering about this what the fuck moment ;-)

@DevilXD
Copy link
Owner Author

@DevilXD DevilXD commented on 25ead72 Aug 7, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Twitch has several clients, that can access the site. These include:

Since all of these need to access Twitch features in a different way, Twitch decided to use different Client IDs for each of those. It's a simple string of characters, that identifies the client to Twitch as of particular type. Besides that, the main URL is different, as shown above.

Here are all of the clients defined:

class ClientType:
WEB = ClientInfo(
URL("https://www.twitch.tv"),
"kimne78kx3ncx6brgo4mv6wki5h1ko",
(
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
),
)
MOBILE_WEB = ClientInfo(
URL("https://m.twitch.tv"),
"r8s4dac0uhzifbpu9sjdiwzctle17ff",
[
# Chrome versioning is done fully on android only,
# other platforms only use the major version
(
"Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/126.0.6478.110 Mobile Safari/537.36"
),
(
"Mozilla/5.0 (Linux; Android 13; SM-A205U) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/126.0.6478.110 Mobile Safari/537.36"
),
(
"Mozilla/5.0 (Linux; Android 13; SM-A102U) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/126.0.6478.110 Mobile Safari/537.36"
),
(
"Mozilla/5.0 (Linux; Android 13; SM-G960U) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/126.0.6478.110 Mobile Safari/537.36"
),
(
"Mozilla/5.0 (Linux; Android 13; SM-N960U) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/126.0.6478.110 Mobile Safari/537.36"
),
(
"Mozilla/5.0 (Linux; Android 13; LM-Q720) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/126.0.6478.110 Mobile Safari/537.36"
),
(
"Mozilla/5.0 (Linux; Android 13; LM-X420) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/126.0.6478.110 Mobile Safari/537.36"
),
]
)
ANDROID_APP = ClientInfo(
URL("https://www.twitch.tv"),
"kd1unb4b3q4t58fwlpcbzcbnm76a8fp",
(
"Dalvik/2.1.0 (Linux; U; Android 7.1.2; SM-G977N Build/LMY48Z) "
"tv.twitch.android.app/16.8.1/1608010"
),
)
SMARTBOX = ClientInfo(
URL("https://android.tv.twitch.tv"),
"ue6666qo983tsx6so1t0vnawi233wa",
(
"Mozilla/5.0 (Linux; Android 7.1; Smart Box C1) AppleWebKit/537.36 "
"(KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
),
)

When Twitch blocks something on one client, they usually don't do so on the other client. We can juggle between them to get around Twitch messing up the miner's access.

Please sign in to comment.