@popboxgun Did you use config_flow integration or manual way.
It doesnāt show up in integration for me, so I manually created the header_auth.json
Iām guessing you might not be logged in correctly. Are there any errors in the Home Assistant logs? I was unsuccessful with various attempts myself, until I used the simplified example from the ymusicapi docs to create my header_auth.json
from.
{
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:72.0) Gecko/20100101 Firefox/72.0",
"Accept": "*/*",
"Accept-Language": "en-US,en;q=0.5",
"Content-Type": "application/json",
"X-Goog-AuthUser": "0",
"x-origin": "https://music.youtube.com",
"Cookie" : "PASTE_COOKIE"
}
With this example, I only needed to PASTE_COOKIE
where indicated.
** Update **
I went into incognito and signed in, used your headers_auth.json and everything loaded up, thanks!
I had tried that one but wasnāt getting anywhere. I did notice that my cookie starts with VISITOR_INFO1_LIVE while the screenshots on the github docs start with CONSENT. Iāll work with authentication some more.
Yes, I did get an error
File "/config/custom_components/ytube_music_player/media_player.py", line 298, in _update_sources
self._update_playlists()
File "/config/custom_components/ytube_music_player/media_player.py", line 309, in _update_playlists
self._playlists = self._api.get_library_playlists()
File "/usr/local/lib/python3.8/site-packages/ytmusicapi/mixins/library.py", line 29, in get_library_playlists
results = find_object_by_key(nav(response, SINGLE_COLUMN_TAB + SECTION_LIST),
File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 148, in nav
raise err
File "/usr/local/lib/python3.8/site-packages/ytmusicapi/parsers/utils.py", line 142, in nav
root = root[k]
KeyError: 'contents'
Hi, so to understand it correctly:
- the integration didnāt show up for you (did you refresh your browser after installation and restart?)
- since you didnāt see the integration youāve tried it directly yourself ā¦ which didnāt work ouf for whatever reason
- later the integration showed up and you were able to use the integration to create the auth-file
- now everything is good?
So ultimately nothing to change in the code?
I see it in integrations now, truthfully I probably installed the component and didnāt see that you could do it via integrations until I was already playing around with headers_auth.json. At that point it was getting errors loading the media_player because I did not format it correctly. Iāll tear it down this morning and test again, but Iād assume it is my fault.
Thanks for your work on this, playing the music worked great this morning!
I am trying to enter the cookie info, but it keeps saying: something with your cookie wasnāt right.
I first tried the method outlined on github, but I donāt have anything past āuser-agentā, I donāt see any x-google items. (using Chrome)
I then tried the smaller bit of code, and pasted the āPaste_Cookieā but still get the error.
My cookie starts with GPS=1; YSU=yTā¦ etc. should I be coping a subset of this info?
have you tried to grab it from an incognito session?
maybe on a windows pc?
Iām getting the same error when I try to setup using the config flow. However, the cookie is working fine if I setup the component manually.
Pretty sure you need to copy the whole cookie, not just a part of it. I have no idea what it means but my cookie begins with VISITOR_INFO1_LIVE
, matching what @popboxgun has reported earlier. I checked the entire string, my cookie does not have any parts being with GPS=...
or YSU=...
EDIT ā Looking through the code, I donāt see anything that is creating (saving to disk) the header_auth.json
file itself. I want to help with this but my Python skills are extremely sub-par. I think I would just be making more work for you @JKW. ( like a young child āhelpingā in the kitchen ) ā Anyways, Iām wondering if itās possible to just create/store the header_auth.json
inside the .storage
folder that is already located in the HA config directory. In the config flow, only the cookie would need to be entered.
@JKW yes, I did use Incognito on a Windows PC.
I manually set up the .json file, as suggested, and the player works for me now.
FWIW, I did keep the GPS info in my cookie (sample below), and I am in MX, so perhaps some user may need it, depending on location.
playing around with the add in, seems to be working well for the most part. However, Iām not getting the full list of my playlist, Iām only getting 18 (including āyour likesā).
anyone else have this issue, and/or know how to refresh it?
hi could you update and try again?
thx, jkw
I canāt get it to work.
Copying the grabbed text where it is requested: Something is wrong with your cookie.
Creating a file as described: The file seem to be ignored.
Now Iām off. No idea what to do.
Is there anything I have to check or to do?
How shoult the headers_auth.json look like?
Is the location ā/config/ā right or is "/config/custom_components/yTube_media_player " meant?
so much questions
Iām working on an improved version of the integration-parser ā¦ as of now: please only copy the ācookieā and āx-goog-authā (==0 for me) line ā¦ to the inputā¦ see if that works ā¦
JKW
Did it, no change.
So I might have to wait for the updated config flow.
Thank you!
@JKW the new build seems to address the playlist limit. thanks.
just curious, any reason why itās hard coded to 99? Is there an upper limit (it looks like the YT API is limited to 50 for MaxResults).
Iām just trying to find out were the upper limits might be.
no, honestly ā¦ the 25 default limit seemed reasonable to me, but hey, youāve proofed that it was to low. 99 should be high enough iād assume. I didnāt find a way to get the number upfront ā¦ so i just picked a high value.
Iāve extended the token generation process and at least that part works reasonably well for me (I can now generate header files easily with chrome / ubuntu / incognito). But I see some ānewā behavior. The youtube component is quite often not capable to generate a valid streaming url.
A few more details for those who want to know: All Iāve done is to combine two existing apis:
The first api will read the header file and can get all the information from you account as well as the songs in the playlist but ultimately wonāt return a streaming link.(or at least I donāt understand where Iād get it). It will however return a āvideoIdā
The second API will convert the videoId into a streaming link. The āproblemā that I see here is that the second API isnāt using any of the login info at all. And sometimes it is not able to return a valid link at all
Iām trying to understand the second API better and also to get into contact with the developer to see if I can use more information from api 1 (e.g. there is a cypher that already contains mostly the link but needs to be decrypted (which api 2 is doing with some sort of reverse lookup of the javascript code on the website) and less from api 2 to generate the link
jkw
tried to follow these instructions >
Basic steps for grabbing
Open the development tools (I've used google chrome) [Crtl+Shift+I]
Open the Network tab
Open https://music.youtube.com, log out, log in
Search for "/browse" (for me only one item shows up) [If you can't find it: I had issues with ubuntu, worked instantly with windows]
Go to "headers" -> "request headers" and copy everything starting at "accept: /" (mark with a mouse and copy to clipboard)
I tried the search for ā/browseā no luck ā¦ iām using chrome on window 10
Plus the āHeadersā tag is not listed under āNetworkā
any ideas ???
Regards
LeeB
Try clicking around in YouTube music web page. I didnāt get a working cookie until I browsed my library