jdf76 / plugin.video.youtube

Kodi's Youtube Plugin -- Please Check the forums before submitting an issue
https://ytaddon.page.link/forum
390 stars 116 forks source link

Personal API Keys are required #736

Open feuille2lune opened 4 years ago

feuille2lune commented 4 years ago

Since today I'm unable to playing any video on Corelec 9.2.1.

It seems that this youtube extension project is on the way to be deleted in Google's API access.

there is the traceback when I lanch a video :

                                        Traceback (most recent call last):
                                          File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/default.py", line 15, in <module>
                                            runner.run(__provider__)
                                          File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/kodion/runner.py", line 60, in run
                                            __RUNNER__.run(provider, context)
                                          File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/kodion/impl/xbmc/xbmc_runner.py", line 33, in run
                                            results = provider.navigate(context)
                                          File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/kodion/abstract_provider.py", line 99, in navigate
                                            result = method(context, re_match)
                                          File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/kodion/register_provider_path.py", line 19, in wrapper
                                            return func(*args, **kwargs)
                                          File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/youtube/provider.py", line 749, in on_play
                                            return yt_play.play_video(self, context)
                                          File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/youtube/helper/yt_play.py", line 86, in play_video
                                            use_play_data=playback_history)
                                          File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/youtube/helper/utils.py", line 411, in update_play_info
                                            video_data = resource_manager.get_videos([video_id])
                                          File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/youtube/helper/resource_manager.py", line 138, in get_videos
                                            result.update(self._update_videos(list_of_50, live_details))
                                          File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/youtube/helper/resource_manager.py", line 121, in _update_videos
                                            if self.handle_error(json_data):
                                          File "/storage/.kodi/addons/plugin.video.youtube/resources/lib/youtube_plugin/youtube/helper/resource_manager.py", line 240, in handle_error
                                            raise Exception(error_message)
                                        Exception: Error reason: |accessNotConfigured| with message: |Project 294899064488 has been scheduled for deletion and cannot be used for API calls. Visit https://console.developers.google.com/iam-admin/projects?pendingDeletion=true to undelete the project.|
                                        -->End of Python script error report<--

2020-02-17 19:19:46.590 T:4092208976 ERROR: Playlist Player: skipping unplayable item: 0, path [plugin://plugin.video.youtube/play/?video_id=dMvn1D5aTY8]

anxdpanic commented 4 years ago

No worries at all, it's mentioned https://github.com/jdf76/plugin.video.youtube/wiki/Personal-API-Keys#configure-the-add-on as Method 1

I prefer the web page method (Method 2) the results page can be bookmarked (with keys), so it can be used to automatically re-add the keys if needed. Of course it's suggested to disable the web page access when not needed.

doko-desuka commented 4 years ago

Not sure what you are suggesting? You can add the keys in Settings dialog under API, you can enable the web page and add them, you can add it to the settings.xml or api_keys.json. You can also send text to Kodi using a remote app or using the web interface.

Question 1: can you explain to me the following behavior (on Kodi 17.6)...

Question 2:
How difficult would it be for you to create a new API key and add it to the default set of keys in here?

anxdpanic commented 4 years ago

@doko-desuka

  1. They should be saved in userdata/addon_data/plugin.video.youtube/api_keys.json when input through settings, or try a different method.

  2. See https://github.com/jdf76/plugin.video.youtube/issues/736#issuecomment-587836438, the short answer, if I added a new default set they would be useless in hours.

doko-desuka commented 4 years ago

@anxdpanic thank you, will take a look. PS: And get better soon, good luck.

kadogo commented 4 years ago

Hello @anxdpanic

Just to confirm, would it work to only add an api key (not the client_id/cient_secret) if we not use the login feature?

doko-desuka commented 4 years ago

@kadogo while you wait for an official response, from looking at the code I think it always expects the three credentials to be valid (api key, client id and client secret):
https://github.com/jdf76/plugin.video.youtube/blob/master/resources/lib/youtube_plugin/youtube/client/__config__.py#L46

If any of them are empty, it defaults to the supplied sets (which don't work anymore).

kadogo commented 4 years ago

@doko-desuka thanks, maybe it explain that it still not work, maybe I mess something related to the client_id/client_secret.

It would be usefull that for people that not need the login part to maybe just use another api key directly?

doko-desuka commented 4 years ago

@kadogo okay, here's what you can do: put in a valid API key that you created from your Google Developer Console, but for the Client ID and Client Secret values, just put "0" (it's not an empty string, it's just the character zero). You're putting "0" because you're not going to use the login feature, just standard searching. If you do need to use login then put in a valid Client ID and Client Secret values of course, otherwise just put "0" on each.

Edited for clarity: On the /resources/settings.xml file inside the latest ZIP file, I first set the default value of youtube.api.enable to "true", then put my API key and the "0" client creds. directly as the default values on the lines below, then rezipped the folder back and installed in Kodi.
But note that this requires first that you uninstall the Youtube add-on and then delete the Kodi/userdata/addon_data/plugin.video.youtube folder as well so you can install from your modified ZIP file and the add-on can start fresh, taking values from the settings.xml inside the ZIP and not the one already present in /userdata/.

So that part of my settings.xml inside the plugin.video.youtube/resources/ folder inside the zip file looks like this (api key omitted), note how youtube.api.enable was changed to "true" and .api.key and .api.id and .api.secret were changed as well:

<!-- personal api key -->
<category label="30200">
    <setting id="youtube.api.enable" type="bool" label="30204" default="true"/>
    <setting id="youtube.api.key" type="text" label="30201" default="############ MY API KEY ###############" visible="eq(-1,true)"/>
    <setting id="youtube.api.id" type="text" label="30202" default="0" visible="eq(-2,true)"/>
    <setting id="youtube.api.secret" type="text" label="30203" default="0" visible="eq(-3,true)"/>
    <setting id="youtube.api.key.switch" type="enum" label="30205" values="0|1|2|3|4|5" visible="eq(-4,false)" default="1"/>
    <setting id="youtube.allow.dev.keys" type="bool" label="30608" default="true"/>
    <setting id="youtube.api.config.address" type="lsep" label="30633" visible="eq(1,true)"/>
    <setting id="youtube.api.config.page" type="bool" label="30632" default="false"/>
</category>

And I repeat, delete your /userdata/addon_data/plugin.video.youtube folder or else it won't ever read these changes since a preexisting settings.xml file already exists in there.

anxdpanic commented 4 years ago
kadogo commented 4 years ago

@doko-desuka thanks for your explain I will test that when I'm at home with the pi.

@anxdpanic thanks also for the other link I still use the search in the addon directly but it could be an idea to use the phone instead too.

the-isz commented 4 years ago

Hi everyone,

I've followed the guide to set up the Personal API keys, but I'm running into a problem. I'm using Method 3 to configure the plugin, i.e. shutting down Kodi and editing api_keys.json manually.

However, the changes get reverted right after I start Kodi again, resulting in a keyExpired error when I launch the YouTube addon.

https://github.com/jdf76/plugin.video.youtube/issues/736#issuecomment-588140190 indicates that one of my settings might be broken, but I don't know how that could be possible since I followed the guide exactly.

I noticed that my Client ID is much longer than the one the addon came with because it ends in ".apps.googleusercontent.com". This hasn't been noted in this thread before, so I also tried cutting off that suffix, but it doesn't change the behavior I'm seeing.

Has anyone else had that problem or have a hint for me what else I could try?

Thanks in advance!

Bruceforce commented 4 years ago

@the-isz

Yes I had the same problems. Copy pasted all keys into api_keys.json and they were gone after reboot.

I then used Yatse on my Android phone and copy pasted the keys from my phone to Kodi using the GUI and it immediately worked.

Maybe just connect a keyboard to your Kodi device and add the key manually. It's annoying but you only have to do it once and it will be faster than trying to fix your mentioned issue.

radasbona commented 4 years ago

@the-isz @Bruceforce Methode 3 worked for me. I used an sftp client (filezilla) and edited my json file while kodi was running. Works. Even with ".apps.googleusercontent.com" in my ID.

dreamcat4 commented 4 years ago

right... because the way that didnt work for me was to edit the json file while kodi was shutdown and not running... it got overwritten. This was not something mentioned in the previous recent instructions..

the-isz commented 4 years ago

@Bruceforce, @radasbona, @dreamcat4:

Thank you all for your input! Turns out method 3 really doesn't work on my setup, whether Kodi is running or not, the changes get reverted when the YouTube addon starts.

I followed @Bruceforce's suggestion, copied the keys to my phone via Google Keep, then copied them to Kodi via Yatse. It worked immediately: The error was gone and I was able to complete the Sign-in process.

Again, thanks for your help and thanks to the developers for this great addon!

webmeister commented 4 years ago

Different solution not requiring any keys, at least for playback: https://github.com/webmeister/plugin.video.youtube.channels/commit/23ffc2486690950a9032f644ff4156155b90c9e6

Milliw commented 4 years ago

@webmeister Thx for your alternative. Tried it, but doesn´t work. Can´t create an issue in your repo?!

@anxdpanic Thanks for your hint on a different solution. But that doesn´t seem to work (for me) either because I use degoogled ROM on my phone and staying away from it as good as I can. I simply need to share videos from (mostly Android) to Kodi. The Kodi Kore app integrates this feature as NewPipe does. I guess at least Kore/Kodi devs won´t be really lucky this doesn´t work anymore now?!

For now I´m using NewPipe with "external player" setting and AllCast (Premium) app to directly cast to Kodi. But that´s not really convenient nor using my Sky Ticket TV Stick with the YouTube app...

Can you tell, IF there will be some development to "fix" this issue? Or will I have to look for something else than Kodi from now on to use YouTube on my TV?

develroo commented 4 years ago

OK I generated my own keys and it works. I don't sign into Youtube anyway so never had to face the sign in prompt. But browsing, searching and playback of channels works ok as far as I can tell.

Thanks.

doko-desuka commented 4 years ago

@MarcoWilli I "share" videos from my phone or notebook to my TV box by adding them to a public but unlisted playlist of my Youtube account, then accessing that playlist from a simple add-on: https://github.com/doko-desuka/plugin.video.myyoutubeplaylist

You need the plugin.video.youtube add-on to read the playlist, but you do not need to be logged in (no client-id or client-secret needed, only api key).

When you open that simple add-on it creates a directory item which leads to your playlist. You can add this item to your favorites to have an easy way of accessing that playlist.

carlosgonz0 commented 4 years ago

Any real solutions of not requiring any keys for end user? Why youtube is forbidding the api for this client?

webmeister commented 4 years ago

@webmeister Thx for your alternative. Tried it, but doesn´t work. Can´t create an issue in your repo?!

It's not really an active project in the usual sense, just some code I found several years ago and kept working because I use it myself. I've enabled the Issue functionality for now, maybe I can help you.

johndoe71rus commented 4 years ago

Sorry for another question. I want to clarify the situation for myself. I used the plugin without a Google account, it suited me like that. Now the rules have changed and the plugin needs keys to work. Keys that compromise google account. You can recommend a similar plugin just to view youtube, just as I can watch in a browser without limits.

dreamcat4 commented 4 years ago

Tried again today, this time entering my 3 api keys via the web interface... same result as before

This app isn't verified

And this is the broken link that goes nowhere....

Go to YouTube Add-on - Personal (unsafe)

Again I would like to know how to get around this very last final step. Because this instruction does not give enough information where to allow my app!

Sign In

During the add-on Sign in process you'll be asked to Connect a device twice.

The second time you Connect a device, you will be prompted with:

This app isn't verified This app hasn't been verified by Google yet. Only proceed if you know and trust the developer.

From there clicking Advanced and Go to <your project name> (unsafe) allows you to complete the process.

This is part is still broken for me.

peno64 commented 4 years ago

You must press the "Go to YouTube Add-on - Personal (unsafe)" link to continue.

dreamcat4 commented 4 years ago

Finally it worked... . Thank you.

johndoe71rus commented 4 years ago

"google has'n reviewed this app yet ..." One application and many developer Personal-API-Keys. Could this be a problem in the future?

dreamcat4 commented 4 years ago

The thing is that google's whole APIs system is so complicated it's difficult for me to be completely certain what exactly was the issue here.

However (for me) the solutoin may have been inside the 'Edit App' page.... This was navigated from this page by clicking on the little blue hyperlink at the top that says 'Edit App'...

Edit App - OAuth Consent Screen

However in my finished new project, I had recently gone back to find that some of those necessary settings had 'mysteriously gone missing'. That is to say I definitely remember adding and saving these extra permissions access roles (for youtube api) the first time around. During the project creation. Following the instructions to the letter. I am certain that I did that. However when I went back again recently to check what was written inside this 'Edit App' page.... This was navigated from this page by clicking on the little blue hyperlink at the top that says 'Edit App' in the screenshot above ^^.

Possible solution

So perhaps there was an issue saving the setting, applying the setting. Or otherwise youtube removed them without my knowledge. Or there was some glitch / bug in the youtube server. I am really none the wiser the reason for that happening. It's just my best guess.

jEsuSdA commented 4 years ago

https://github.com/jdf76/plugin.video.youtube/issues/736#issuecomment-587179143

* BAM! it works

I can confirm it works for me. Thanks a lot for the help! ;)

webmeister commented 4 years ago

@webmeister Thx for your alternative. Tried it, but doesn´t work. Can´t create an issue in your repo?!

It's not really an active project in the usual sense, just some code I found several years ago and kept working because I use it myself. I've enabled the Issue functionality for now, maybe I can help you.

Someone else reported their issues and I fixed everything I could reproduce. Please try again :)

carlosgonz0 commented 4 years ago

@webmeister Thx for your alternative. Tried it, but doesn´t work. Can´t create an issue in your repo?!

It's not really an active project in the usual sense, just some code I found several years ago and kept working because I use it myself. I've enabled the Issue functionality for now, maybe I can help you.

Someone else reported their issues and I fixed everything I could reproduce. Please try again :)

Thank you you are a hero!

DavidHenryThoreau commented 4 years ago

@webmeister

It's works :) => https://github.com/webmeister/plugin.video.youtube.channels Thanks for good work !

Questions : 1/ Is that possible to stream video during playing ? I mean something like that : mpv -cookies --cookies-file=/tmp/cookie.txt $(youtube-dl --prefer-free-formats -g -f "${qual}" --cookies /tmp/cookie.txt "${url}" --sub-lang "en,fr") I'm using this command on shell in order to stream during playing, it might be better. 2/ Some characters seems not to be supported éèêà.. on search

anxdpanic commented 4 years ago

I've update https://github.com/jdf76/plugin.video.youtube/releases/tag/6.7.0-dev and the testing repositories with 6.7.0~alpha1.

[add] send PlaybackStarted notification containing video_id of the playing video
[fix] allow playback regardless of API status
- fixes playback for strm, playlists, other add-ons, and sharing videos from devices
[fix] fix possible loop due to invalid keys and login information
[fix] fix playback of mpeg-dash streams if HTTP Server - Listen on IP is blank
[upd] use a dialog to notify users of API key requirements with link to wiki
- https://ytaddon.page.link/keys

With 6.7.0~alpha1 playback will work regardless of api key/login status. Some video may be still be unavailable without login information, but the majority should work.

dreamcat4 commented 4 years ago

[fix] fix playback of mpeg-dash streams if HTTP Server - Listen on IP is blank

@anxdpanic Hey there! If you know anything about DASH playback, just to let you know that the helper plugin youtube-download-control cannot download videos with DASH enabled. Instead it retrieves a 4kb XML file here is example. Which in turn contains some other separate links for the audio and video to stuff together into a container file. By processing on the client side.

In case you are interested in developing this feature in the future. Otherwise downloading a video from youtube is limited to maximum of 720.

anxdpanic commented 4 years ago

@webmeister With the alpha1 you'll be able to use plugin://plugin.video.youtube/play/?video_id= again to have hd, or you can also use https://github.com/jdf76/plugin.video.youtube/blob/master/resources/lib/youtube_resolver.py by using the youtube add-on as a required module. I didn't realize it until this update but using the add-on as a module to resolve was never broken and has been working this whole time.

anxdpanic commented 4 years ago

@dreamcat4 Thanks, we already create our own mpeg-dash manifest to achieve 1080 or greater playback-->1080 & hdr have been available for quite a while now--, it also has to be served from an http service for multiple reasons. And with alpha1 playback works fine again, even with the expired api keys.

dreamcat4 commented 4 years ago

So it is a missing feature for the other plugin to implement then... to copy that existing routines from this plugin. There other missing feature is to get the subtitles into the downloaded file... needs raise these issues on other gitthub project.

manijak commented 4 years ago

If you have added correct api-key, api-id, api-secret and are still having issues in opening youtube (error 401), even after reboot. Remove the YouTube addon and delete all settings. Re-install the addon and re-authenticate, add the keys again, and it should work.

Milliw commented 4 years ago

@webmeister Thx for your alternative. Tried it, but doesn´t work. Can´t create an issue in your repo?!

It's not really an active project in the usual sense, just some code I found several years ago and kept working because I use it myself. I've enabled the Issue functionality for now, maybe I can help you.

Thx for your work. It seems like the addon is now doing what it´s supposed to do. No error messages. Interesting, that Kodi can play YT videos without YT addon. Though not for my use case (sharing videos from Android to Kodi) - but that´s much OT I guess.

anxdpanic commented 4 years ago

@MarcoWilli Using youtube-dl will only get 720p max (all videos) and 360p max on some videos, and it's slower.

Playback is possible without keys using the YouTube add-on, it just required some changes which were posted 2 days ago. The alpha version below should fix sharing videos without requiring API key creation. See: https://github.com/jdf76/plugin.video.youtube/releases/tag/6.7.0-dev https://github.com/jdf76/plugin.video.youtube/wiki/Installation#in-development-versions

kadogo commented 4 years ago

Hello @anxdpanic

So now If I remove everything from the addon I checked in .kodi/addons/ and .kodi/userdata/ I add the dev repo and installed the plugin again.

I have the plugin version 6.7.0-alpha1 but I stil cannot use the "search". It let me type my search terms and after vaildate it show me an empty screen (like no result).

I also tried to uninstall, remove the folders that look related an install back and it still not works.

anxdpanic commented 4 years ago

@kadogo Until I get it resolved, try Settings - Advanced - Remote friendly search

kadogo commented 4 years ago

Hello @anxdpanic

I activate "remote friendly search", it's asking for making personal api key. Same for search it's mandatory?

anxdpanic commented 4 years ago

Yea, for all functions other than playback require API keys. So without API I'd use the latest alpha, with either TubeCast, Yatse, or Kore to share videos with Kodi.

kadogo commented 4 years ago

Hello @anxdpanic Thanks for the suggestion about Kore, I'm using newpipe so Tubecast isn't working. I just did few test with Kore and it look like it's working.

Now hoping that newpipe will not have issues ^^

adietish commented 4 years ago

@kadogo thx for the updated binary! I can confirm that youtube playback works fine without further changes when using Alpha2.

Milliw commented 4 years ago

Installed the alpha version. Playback via share from Android NewPipe works. But only when disabling MPEG Dash. When enabled it just doesn´t do anything, no error also. Is that to be expected? Maybe we should report feedback somewhere else as this is kind of OT?!

anxdpanic commented 4 years ago

@MarcoWilli Please open a new issue, and include a debug log trying to play mpeg-dash from newpipe and I'll see if I can get it fixed.

goldmojo commented 4 years ago

Using a personal key worked perfectly, thank you !

Modifyinc commented 4 years ago

Using personal keys works great, but why will trailers still not play? When you click to play a trailer, nothing happens, no error, not even in the logs.

anxdpanic commented 4 years ago

@Modifyinc please open a new issue with a copy of the log with debug logging enabled.