Open karelrooted opened 1 year ago
Hello, thanks for raising this issue!
I try add these three cookie YTM.cookies = "SAPISID=(SAPISID); Secure-1PAPISID=(PAPISID); Secure-1PSID=(PSID1)"
Ok this should work, the procedure is currently done in Atwy here. Maybe check if their domain is .youtube.com
and not google.com
for example. Let me know if that fixes your issue.
or all the cookie in safari YouTube official website (host: MacBook)
This could not work as all of them are mixed and YouTube might interpret them in a wrong way.
also tried include some other header currently not present in the code , did it work on your end as of now ?
Yes, you can check out Atwy, this is an App To Watch YouTube, and it uses all the features of YouTubeKit.
Also make sure to activate the useCookies
option or set YTM.alwaysUseCookies
to true when you're doing the request.
the problem seems to be login YouTube with multiple account, when log in with multiple account , these three cookie (SAPISID, Secure-1PAPISID,Secure-1PSID) are the same with each account, we need to add additional cookie ( __Secure-1PSIDTS )
to choose another account other than default, the account's cookie Secure-{number}PAPISID,Secure-{number}PSID,__Secure-{number}PSIDTS need to be added, and then choose account with header x-goog-authuser = {user_number}
in my current two account setup, the value is like this:
the first account is 1PSID, x-goog-authuser =0 the second accounts 3PSID, x-goog-authuser =1
please close your youtube website tab in the browser after copy the cookie,otherwise the __Secure-1PSIDTS cookie will change in a very short time
I think I found the problem , I log in YouTube with multiple account, when log in with multiple account , these three cookie (SAPISID, Secure-1PAPISID,Secure-1PSID) are the same with each account, we need to add another three cookie to identify the current user ( LOGIN_INFO, Secure-1PSIDTS, Secure-3PSIDTS )
Very interesting, I'm also going to check later in the morning that case and try to find an solution.
What Atwy was doing in that case is just to take the first cookies if found with YouTube's domain and then process them.
Very interesting, I'm also going to check later in the morning that case and try to find a solution.
What Atwy was doing in that case is just to take the first cookies if found with YouTube's domain and then process them.
I use youtubekit to develop a player for personal use on Apple TV (to enable bilingual subtile support), I don't think there is YouTube cookie to fetch on Apple TV (webview is not allowed on Apple TV, will check it later )
I use youtubekit to develop a player for personal use on Apple TV (to enable bilingual subtile support), I don't think there is YouTube cookie to fetch on Apple TV (webview is not allowed on Apple TV, will check it later )
As your project is designed for personal use you could use the private API as https://github.com/Moballo-LLC/tvOS-Browser does, its shouldn't cause any problem (I already tested on my Apple TV and it worked fine).
You could also do a kind of shared keychain (like Atwy is going to do for its TV app), like you have a little app on your iPhone that will fetch the cookies and put them in a shared environnement (or even just in your clipboard and you enter the cookies string in a prompt of your iPhone's remote app).
I use youtubekit to develop a player for personal use on Apple TV (to enable bilingual subtile support), I don't think there is YouTube cookie to fetch on Apple TV (webview is not allowed on Apple TV, will check it later )
As your project is designed for personal use you could use the private API as https://github.com/Moballo-LLC/tvOS-Browser does, its shouldn't cause any problem (I already tested on my Apple TV and it worked fine).
You could also do a kind of shared keychain (like Atwy is going to do for its TV app), like you have a little app on your iPhone that will fetch the cookies and put them in a shared environnement (or even just in your clipboard and you enter the cookies string in a prompt of your iPhone's remote app).
if I close the YouTube website in safari , the cookie seems to work for a longer time, I will try your suggestion when cookie expire too often
by the way , to choose current user other than default (in multiple account scenario), additional header need to be added, please check my updated comment above
What do you think about new methods of YouTubeModel
that lets you select an account with a bunch of cookies provided?
I think I found the problem , I log in YouTube with multiple account, when log in with multiple account , these three cookie (SAPISID, Secure-1PAPISID,Secure-1PSID) are the same with each account, we need to add additional two cookie ( LOGIN_INFO, __Secure-1PSIDTS )
For this I just tested again and it seems to work fine, except the fact that it connects you with the first account that has been registered in the browser (and then there would be the procedure with X-Goog-AuthUser
and all of that). Did it connect you to an account when you tested only with the 3 (SAPISID, Secure-1PAPISID,Secure-1PSID) cookies?
What do you think about new methods of
YouTubeModel
that lets you select an account with a bunch of cookies provided?
sounds good, in my current two account setup:
the first account is 1PSID, x-goog-authuser =0 the second accounts 3PS1D, x-goog-authuser =1
if the order is the same in cookie and x-goog-authuser, then it should work without some additional work(auto switch account to get the account's x-good* header info, etc... )
I think I found the problem , I log in YouTube with multiple account, when log in with multiple account , these three cookie (SAPISID, Secure-1PAPISID,Secure-1PSID) are the same with each account, we need to add additional two cookie ( LOGIN_INFO, __Secure-1PSIDTS )
For this I just tested again and it seems to work fine, except the fact that it connects you with the first account that has been registered in the browser (and then there would be the procedure with
X-Goog-AuthUser
and all of that). Did it connect you to an account when you tested only with the 3 (SAPISID, Secure-1PAPISID,Secure-1PSID) cookies?
no, if only the first three cookie is provided, google response with please login (in user library request), in the two account I login (one is YouTube premium, may be something is different with premium account)
no, if only the first three cookie is provided, google response with please login (in user library request), in the two account I login (one is YouTube premium, may be something is different with premium account)
- the 1PSID is the no premium account
Are Secure-1PAPISID and Secure-3PAPISID equals on your side?
no, if only the first three cookie is provided, google response with please login (in user library request), in the two account I login (one is YouTube premium, may be something is different with premium account)
- the 1PSID is the no premium account
Are Secure-1PAPISID and Secure-3PAPISID equals on your side?
yes, they are the same
by the way: after delete login_info cookie, it still works, so the additional cookie needed is __Secure-{number}PSIDTS
yes, they are the same
by the way: after delete login_info cookie, it still works, so the additional cookie needed is __Secure-{number}PSIDTS
This is weird because when compare the cookies before and after switching __Secure-{number}PSIDTS
is still the same.
yes, they are the same by the way: after delete login_info cookie, it still works, so the additional cookie needed is __Secure-{number}PSIDTS
This is weird because when compare the cookies before and after switching
__Secure-{number}PSIDTS
is still the same.
yes, Secure-1PSIDTS and Secure-3PSIDTS are the same too, it seems when one of the account is premium, then google need this additional cookie, regardless which account we are trying to access
I try add these three cookie YTM.cookies = "SAPISID=(SAPISID); Secure-1PAPISID=(PAPISID); Secure-1PSID=(PSID1)" or all the cookie in safari YouTube official website (host: MacBook)
also tried include some other header currently not present in the code , did it work on your end as of now ?