Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access to all the channels of an account #4

Open
karelrooted opened this issue Nov 15, 2023 · 14 comments
Open

Access to all the channels of an account #4

karelrooted opened this issue Nov 15, 2023 · 14 comments

Comments

@karelrooted
Copy link

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 ?

@b5i
Copy link
Owner

b5i commented Nov 15, 2023

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.

@karelrooted
Copy link
Author

karelrooted commented Nov 16, 2023

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

@b5i
Copy link
Owner

b5i commented Nov 16, 2023

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.

@karelrooted
Copy link
Author

karelrooted commented Nov 16, 2023

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 )

@b5i
Copy link
Owner

b5i commented Nov 16, 2023

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).

@karelrooted
Copy link
Author

karelrooted commented Nov 16, 2023

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

@b5i
Copy link
Owner

b5i commented Nov 16, 2023

What do you think about new methods of YouTubeModel that lets you select an account with a bunch of cookies provided?

@b5i
Copy link
Owner

b5i commented Nov 16, 2023

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?

@karelrooted
Copy link
Author

karelrooted commented Nov 16, 2023

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... )

  • after delete the x-goog-visitor-id header, the account is still correctly selected, so it seems we only need x-good-authuser

@karelrooted
Copy link
Author

karelrooted commented Nov 16, 2023

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)

  • the 1PSID is the no premium account

@b5i
Copy link
Owner

b5i commented Nov 16, 2023

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?

@karelrooted
Copy link
Author

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

@b5i
Copy link
Owner

b5i commented Nov 16, 2023

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.

@karelrooted
Copy link
Author

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

@b5i b5i mentioned this issue Jan 24, 2024
@b5i b5i changed the title Cookie doesn't seem to work Access to all the channels of an account Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants