oscie57 / tiktok-voice

Simple Python script to interact with the TikTok TTS API
515 stars 74 forks source link

Two Issues : pygobject and Session ID is invalid #35

Open HamzaBenLhouari opened 1 year ago

HamzaBenLhouari commented 1 year ago

Hello, hope you are doing great, just when I'm trying to run the script I have 2 issues : first one : playsound is relying on another python subprocess. Please use pip install pygobject if you want playsound to run more efficiently.

PS : when a try to run this command : " pip install pygobject " it's complete with errors so the installation get failled

second : {'status': 'Session ID is invalid', 'status_code': 5} . PS : I have a correct session Id how to solve them? thanks in advance.

Iucasmaia commented 1 year ago

Fix:

Line 73 change "api16-normal-useast5.us.tiktokv.com" for "api16-normal-v6.tiktokv.com".

HamzaBenLhouari commented 1 year ago

Fix:

Line 73 change "api16-normal-useast5.us.tiktokv.com" for "api16-normal-v6.tiktokv.com".

I found a linke in an other prject worked fine for me ... thanks but how I get like this link if I face this problem in future ?

compakevon commented 1 year ago

Hello, hope you are doing great, just when I'm trying to run the script I have 2 issues : first one : playsound is relying on another python subprocess. Please use pip install pygobject if you want playsound to run more efficiently.

PS : when a try to run this command : " pip install pygobject " it's complete with errors so the installation get failled

second : {'status': 'Session ID is invalid', 'status_code': 5} . PS : I have a correct session Id how to solve them? thanks in advance.

Did you fix the second option?

HamzaBenLhouari commented 1 year ago

Hello, still facing the same issue we need a working link like the last one " api16-normal-v6.tiktokv.com " and tell us how do you get these links to solve this issue by ourselves. thanks

ElonGaties commented 1 year ago

I'm assuming that you just need to have proxy running on your phone to see the endpoint contacted, or emulate a phone with some sort of proxy.

szacomelli commented 12 months ago

Did anyone find a fix?

ElonGaties commented 10 months ago

Just to follow up here, in order to get a session ID you need to have a sort of MITM on your mobile device or an emulator with TikTok installed, and snatch up the session ID from a request done by the app.

The way I have done this is using mitmproxy in HTTP mode with a proxy configured on my phone, it's really simplistic if you try to do this method.

Edit: this is one method to do so, however this can be done on a computer using the TikTok web app, defined here Wiki - Obtaining Session ID, however to get the actual request API endpoint, which seems to be different in different regions, you may need to follow my method described above.

denver-code commented 10 months ago

Just to follow up here, in order to get a session ID you need to have a sort of MITM on your mobile device or an emulator with TikTok installed, and snatch up the session ID from a request done by the app.

The way I have done this is using mitmproxy in HTTP mode with a proxy configured on my phone, it's really simplistic if you try to do this method.

Edit: this is one method to do so, however this can be done on a computer using the TikTok web app, defined here Wiki - Obtaining Session ID, however to get the actual request API endpoint, which seems to be different in different regions, you may need to follow my method described above.

I couldn't get a session ID via my MITM proxy from phone, but I got api url instead, which is api31-normal-useast2a.tiktokv.com for me then I authorised in web version, and made few actions(scroll, enter comment section) and through Network explorer(basic developer tool in every browser) got my sessionID from request cookies, fun thing that I couldn't find sessionID directly in web storage

ElonGaties commented 10 months ago

I seem to be able to find it inside of the storage tab in cookies of the window, which isn't too surprising as I wouldn't they would store a (possibly) changing ID in local storage (granted cookies are pretty similar to local storage in this case), I also seem to be able to get the session ID using MITM in the request headers, but if you couldn't get it using MITM, your method is also a good way of retrieving both the endpoint and ID.

benf152 commented 7 months ago

api31-normal-useast2a.tiktokv.com

idk who you are but this worked thank you!!