mps-youtube / yewtube

yewtube, forked from mps-youtube , is a Terminal based YouTube player and downloader. No Youtube API key required.
GNU General Public License v3.0
8.07k stars 648 forks source link

default api key disabled #1063

Closed pirate486743186 closed 1 year ago

pirate486743186 commented 4 years ago

It seams that google has disabled the default api key.

Youtube Error 403: Access Not Configured. YouTube Data API has not been used in project 422897895433 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=422897895433 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

celtichawk commented 4 years ago

Confirming this too, I just did a fresh install and am running into the same issue.

celtichawk commented 4 years ago

Also adding that after setting my own API V3 key, it still gives me an access not configured error as well.

thezeroalpha commented 4 years ago

Same, it seems like it could be related to caching, as after removing ~/.config/mps-youtube/cache_py*, it works for some time (haven't yet found what causes the issue to resurface).

Edit for clearer explanation of steps: when trying to start mpsyt, I get error 403. Then I remove the cache file, open mpsyt, and set api_key to my own API key. This works for some time, but later for some reason, it gives me the error again. So, I remove the cache file, and open mpsyt. At this point, api_key is set correctly, but I still get the error until I remove the cache file.

temavasilev commented 4 years ago

Same, it seems like it could be related to caching, as after removing ~/.config/mps-youtube/cache_py*, it works for some time (haven't yet found what causes the issue to resurface).

Edit for clearer explanation of steps: when trying to start mpsyt, I get error 403. Then I remove the cache file, open mpsyt, and set api_key to my own API key. This works for some time, but later for some reason, it gives me the error again. So, I remove the cache file, and open mpsyt. At this point, api_key is set correctly, but I still get the error until I remove the cache file.

Can confirm that the following steps solve the issue for me.

sokolgeo commented 4 years ago

Same issue, deleting cache_py folder leads to same error after running mpsyt

paulfertser commented 4 years ago

This bug is related to pafy issue: https://github.com/mps-youtube/pafy/issues/255

whitemind commented 4 years ago

Hello,

Same thing here,

I've deleted the cache_py but still has the fetching error below:

Error fetching data. Possible network issue. Youtube Error 403: Access Not Configured. YouTube Data API has not been used in project 422897895433 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=422897895433 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.

mpsyt --version mpsyt version : 0.2.8 notes : released 17 February 2018 pafy version : 0.5.4 (youtube-dl backend) youtube-dl version : 2020.02.16 Python version : 3.7.3 (default, Dec 20 2019, 18:57:59) [GCC 8.3.0] Processor : Machine type : x86_64 Architecture : 64bit, ELF Platform : Linux-4.19.0-8-amd64-x86_64-with-debian-10.3 sys.stdout.enc : UTF-8 default enc : utf-8 Config dir : /home/asterix/.config/mps-youtube env:TERM : xterm env:SHELL : /bin/bash env:LANG : en_US.UTF-8 env:LANGUAGE : en_US:en

Regards

mateuszr commented 4 years ago

Actually this doesn't look like pafy related bug. It's rather some change on the google side. You can make it work by creating your own app and generate new API key, see: https://github.com/mps-youtube/pafy/issues/255#issuecomment-590625421. What's important is to make sure that the new API is used and not the hardcoded "AIzaSyCIM4EzNqi1in22f4Z3Ru3iYvLaY8tc3bo" key (see https://github.com/mps-youtube/mps-youtube/issues/1061)

orbea commented 4 years ago

Can a new hardcoded key be generated for pafy? Its not possible to make your own key without a google account.

nishanmudalige commented 4 years ago

I am on a Mac running macOS 10.15 and I solved this issue by doing the following:

This solved the issue for me

oskarvid commented 4 years ago

@nishanmudalige, can confirm, this worked for me too. I think the key is to make a new project with a new api key because it wasn't until I did that that it actually worked. I only needed to edit mps_youtube/config.py and build/lib/mps_youtube/config.py to make it work. I tried to change it with set api_key at first but it wouldn't let me for some reason.

whitemind commented 4 years ago

Hello,

It's working after some steps

Here are the steps I took:

  1. Create an API project like nishanmudalige said by following the steps he mentioned.
  2. Delete the mps-youtube cache file [cache_py_3.7xxx] related to your version of python, so make sure it is the correct file located on the folder /.config/mps-youtube/ for me it was cache_py_3.7.4
  3. Go to the folder /usr/local/lib/python3.7/dist-packages/mps_youtube and open the fle config.py, make sure to do a backup of the file before making any modifications, i think if you delete the file it will automatically create a new one after executing mpsyt but you lose any configuration you might have before. Near the end of the file, there is a configuration where it has the youtube api_key, you should substitute that value with your new one previously created on point 1.
  4. Then go to the folder /.config/mps-youtube and open the file config.py and update the api_key with your new api_key.

That should work

Hope it helps Best regards

elig0n commented 4 years ago

After reading all the above I managed to solve it with steps similar to what @whitemind and @nishanthkarthik suggested but I had to start with a fresh ~/.config/mps-youtube directory because modifying the binary config file for the new api_key did not prove to work for me. The steps I followed were:

1) Create a new google api project. I called it mps-youtube but you can call it whatever. Enable Youtube v3 API and get the API Key. 2) Change the default key from python version directory's /dist-packages/pafy/g.py and /dist-packages/mps_youtube/config.py 3) Remove __pycache__/ directory content from both above mentioned pafy/ and mps_youtube/ module dirs. 4) Remove ~/.config/mps-youtube directory (you may want to backup your histories and configurations but at least for configurations I suggest you copy/reinput them manually one by one)

pirate486743186 commented 4 years ago

The REAL solution here, would be, for the person that controls the default key, to reactivate it....

kof kof @hrnr @kraetzin @ids1024 @ritiek @vn-ki

That changing the api key is actually bugged, is a different problem.

ritiek commented 4 years ago

That API key is about 5 years old and was added in https://github.com/mps-youtube/mps-youtube/commit/032cca94bc6fc30f9a1130e3112fcb4ad2782d42 by @ids1024. I don't expect @ids1024 to still remember the account information from which the key was created, after such a long time. I also don't expect it would be as easy to simply reactivate the key as API keys don't usually expire. I believe this error is probably a side effect of something else YouTube did lately.

We could also generate a new YouTube Data API key but it would easily be hitting rate limits as API keys that were generated in those old times could be used for 50 million units/day, but now has been dropped to only 1 million units/day.

cirrusUK commented 4 years ago

FWIW a similar project https://github.com/trizen/youtube-viewer recently also had their API disabled & urged all users to go create their own API key for the same reasons @ritiek suggests. IE: 'new YouTube Data API key would easily be hitting rate limits ' sadly it appears that project is now doomed because of this. the developer recently posted this https://github.com/trizen/youtube-viewer/issues/308 however in recent days he has stuck a fork in it https://github.com/trizen/youtube-viewer/issues/308#issuecomment-591063498 maybe mpsyt too could use a similar API as straw-viewer, I really hope we can find a way forward for mpsyt

thezeroalpha commented 4 years ago

Related to using our own API key -- is there any way to set the key from the environment, instead of setting it directly in the json file? I like to keep my configuration on github under version control, and I'd rather not push API keys to github.

whitemind commented 4 years ago

Hi

Yes you can,

mpsyt set api_key your_key

Regards

TalhaAkber commented 4 years ago
  1. Go to https://console.cloud.google.com, create a project, then enable Youtube Data Api V3 and create credential and get the API_KEY for public use.
  2. Then remove the cache rm ~/.config/mps-youtube/cache_py*
  3. Set the new api key mpsyt set api_key YOUR_KEY_HERE
  4. Quit mpsyt (if there are any opened mpsyt instances"
  5. Open it again and use it normally (it worked for me after following these steps)
thezeroalpha commented 4 years ago

Yes, but this writes the key into the JSON config file, AFAIK. My question is, is it possible to have the API key set to eg. the environment variable $YT_API_KEY, and have mpsyt read this variable?

ghost commented 4 years ago

Is there any way for those with no google/youtube account to use mps-yt now?

paulfertser commented 4 years ago

On Thu, Feb 27, 2020 at 01:58:09AM -0800, electronblue wrote:

Is there any way for those with no google/youtube account to use mps-yt now?

Yes, please! Can the project maintainers talk to Google about that? People can watch youtube via their web-interface without any registration (and tracking), so why should I register my own API key for mps-youtube?

-- Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software! mailto:fercerpav@gmail.com

AyoungDukie commented 4 years ago

So I looked at an alternative player to handle livestreams (as I could not get those working even prior to this API issue, haha), and came across an application using an OSS tool called invidous [ Website, Github ] (license is stated as AGPLv3); seems they have their own access API setup as well, so may be worth looking into, but also seems like a lot of retooling to point at a different site than YT proper....

sebma commented 4 years ago

I don't think average users are going to be able to do create a new API key. Can you guys please do it inside mps-youtube/pafy module instead ?

AyoungDukie commented 4 years ago

Just as a workaround for those starting to re-encounter this 403 error with their own API keys (which I started to have when I came across this open issue), some people have pointed out that the Google API can do a poor job of propogating changes to fix issues stack overflow post, so I went and fully deleted my api project, set up a new one from scratch, and created new API credentials. Once done, MPSYT was functional again with the new key.

Jeronimo17 commented 4 years ago

With own API, if I disconnect the network or delete the cache that is said in other posts, it goes well but works like 1 day

lakelord commented 4 years ago

Ok... I did all modifications and exchanged the API key for a new key. bout now....the player software does not seem to play musics.....it crashes.... I can search and get a list, but not play anything. Any guesses ?

thezeroalpha commented 4 years ago

Did you do set player? Do you have that player installed? Is mpsyt, pafy, and youtube-dl up to date? Did you remove the cache?

lakelord commented 4 years ago

everything up-to-date, using mpv as player, yes removed the cache

On Mon, Mar 2, 2020 at 2:47 PM Alex Balgavy notifications@github.com wrote:

Did you do set player? Do you have that player installed? Is mpsyt, pafy, and youtube-dl up to date? Did you remove the cache?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/mps-youtube/mps-youtube/issues/1063?email_source=notifications&email_token=ADYHP6DU2WBR5I5C2RB7VZTRFPWJZA5CNFSM4KZZRC7KYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOENQIH7Q#issuecomment-593527806, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADYHP6FOKLMODIEVKVQUT7DRFPWJZANCNFSM4KZZRC7A .

thezeroalpha commented 4 years ago

You could try running with --debug --logging and see if that gives you any info.

lakelord commented 4 years ago

the players crashes but I can still download and encode the audio some files do play audio....others crash. Don't know why

yumitsu commented 4 years ago

@TalhaAkber Thanks for the solution, it works like a charm. The only problem I faced when tried to set my own API key is that mpsyt was throwing an error about invalid key or exceeded quota until I created an OAuth client ID.

sokolgeo commented 4 years ago

I am not sure we can quite call it "solution" when each user needs creating his individual Google API key:

  1. Its relatively high effort for non-technically minded
  2. It decreases your privacy level. With one API key Google was tracking multitude of IP addresses all using the same key, but with each user creating his own key - Google will track you even better due to your key being unique ID. Before I could put mpsyt beyond Tor proxy and call it a day. Now individual API key would probably mean more work to reach the same level of privacy as before (creating fake google account just to create the individual API key which is not linked to my personality known by google). That is probably doable, still step in worse direction IMHO.

On March 3, 2020 1:03:04 AM GMT+01:00, Alex Zinchenko notifications@github.com wrote:

@TalhaAkber Thanks for the solution, it works like a charm. The only problem I faced when tried to set my own API key is that mpsyt was throwing an error about invalid key or exceeded quota until I created an OAuth client ID.

-- You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/mps-youtube/mps-youtube/issues/1063#issuecomment-593691715

Jeronimo17 commented 4 years ago

Even with my own API, I have to delete ~/.config/mps-youtube/cache_py_3.6.9 every day, or it gives 403 error when starting. pafy.util.GdataError: Youtube Error 403: Access Not Configured. YouTube Data API has not been used in project 422897895433 before or it is disabled.

lakelord commented 4 years ago

After all updates and alterations to config and cache. I still get the following results...some songs play, most do not. Seems like something on the google side but I am not sure.

lakelord commented 4 years ago

Most strangely.....downloading the non-playable files DOES work. On second thought, it must be a problem still on the mps-youtube side.

yumitsu commented 4 years ago

@sokolgeo Surely, it's more like a "hack" than a solution, but at this time it's still better that nothing (i.e. browser version of youtube).

sokolgeo commented 4 years ago

Saying goes that there is nothing more persistent than 'temporary fixes'. I'd rather stick to browser version of YouTube running via Tor browser until solution is found free from worsening Google tracking on my mpsyt usage, but its personal choice, I agree.

On March 5, 2020 1:11:12 AM GMT+01:00, Alex Zinchenko notifications@github.com wrote:

@sokolgeo Surely, it's more like a "hack" than a solution, but at this time it's still better that nothing (i.e. browser version of youtube).

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/mps-youtube/mps-youtube/issues/1063#issuecomment-594955043

T0MuX commented 4 years ago

@sokolgeo you also can use invidious :)

sebma commented 4 years ago

@T0MuX Thanks for Invidious :) and their source code is at github.

Also hoping that SMTube is going to switch from Tonvid to Invidious.

TalhaAkber commented 4 years ago

I am not sure we can quite call it "solution" when each user needs creating his individual Google API key: 1. Its relatively high effort for non-technically minded 2. It decreases your privacy level. With one API key Google was tracking multitude of IP addresses all using the same key, but with each user creating his own key - Google will track you even better due to your key being unique ID. Before I could put mpsyt beyond Tor proxy and call it a day. Now individual API key would probably mean more work to reach the same level of privacy as before (creating fake google account just to create the individual API key which is not linked to my personality known by google). That is probably doable, still step in worse direction IMHO. On March 3, 2020 1:03:04 AM GMT+01:00, Alex Zinchenko @.***> wrote: @TalhaAkber Thanks for the solution, it works like a charm. The only problem I faced when tried to set my own API key is that mpsyt was throwing an error about invalid key or exceeded quota until I created an OAuth client ID. -- You are receiving this because you commented. Reply to this email directly or view it on GitHub: #1063 (comment)

@sokolgeo I agree with you 100%, and that is exactly what I am doing right now, using fake gmail account with tor proxy. Its getting really hard for non-technically minded people to maintain their privacy and anonymity. But I guess most of the users of mps-youtube are technical because normal people might use tor browser and will not use terminal based app to browse youtube.

TalhaAkber commented 4 years ago

Even with my own API, I have to delete ~/.config/mps-youtube/cache_py_3.6.9 every day, or it gives 403 error when starting. pafy.util.GdataError: Youtube Error 403: Access Not Configured. YouTube Data API has not been used in project 422897895433 before or it is disabled.

@Jeronimo17 yeah its a real pain, deleting this stupid cache on daily basis. That's why I added an extra command on my i3 config to remove the cache every time it starts.

yumitsu commented 4 years ago

@TalhaAkber Also can be done with crontab task.

benchile55 commented 4 years ago

Even with my own API, I have to delete ~/.config/mps-youtube/cache_py_3.6.9 every day, or it gives 403 error when starting. pafy.util.GdataError: Youtube Error 403: Access Not Configured. YouTube Data API has not been used in project 422897895433 before or it is disabled.

Happens the same issue still. I also need to remove cache.py files daily.

DBX12 commented 4 years ago

A workaround to removing the cache files is truncating them and then make them readonly. So the polluting API key cannot be written to the cache. I'm no Python dev so I cannot say how big the speed up by using the cache is but I did not feel a difference. For a Linux system, this should work:

echo -n '' > ~/.config/mps-youtube/cache_py_*
chmod 444 ~/.config/mps-youtube/cache_py_*

The downside is mpsyt complaining about the cachefile not being writeable and you cannot close the program with q anymore. Sending an Ctrl-D however still closes it without writing the cache file.

ag-eitilt commented 4 years ago

I'm going to use this as an excuse to point to NewPipe again -- their crawler doesn't go through YouTube's API so while they have to write everything themselves, they don't have the problems with quotas or things expiring. With that being in Java, it's obviously not just a drop-in replacement, but if things get to the point of rewriting the entire program, they could definitely be a source of inspiration and general guidance. Personally, I'm more likely to write my own desktop wrapper for that backend than I am to give Google direct access to my view data with an API key.

seniorm0ment commented 4 years ago

Please add the ability to use Invidious (and use Invidious logins), it should solve the API issue as well. I am getting the issue on a fresh install of mps-youtube on Arch from base repos

sebma commented 4 years ago

@ag-eitilt

I'm going to use this as an excuse to point to NewPipe again -- their crawler doesn't go through YouTube's API so while they have to write everything themselves, they don't have the problems with quotas or things expiring. With that being in Java, it's obviously not just a drop-in replacement, but if things get to the point of rewriting the entire program, they could definitely be a source of inspiration and general guidance. Personally, I'm more likely to write my own desktop wrapper for that backend than I am to give Google direct access to my view data with an API key.

Unfortunatly, there is no NewPipe for Linux yet : https://github.com/TeamNewPipe/NewPipe/issues/1051

atropo commented 4 years ago

Removing the mpsyt cache directory didn't worked for me.

But deleting the youtube-dl cache works fine, I do it with:

 youtube-dl --rm-cache-dir 

I'm using mpsyt on Ubuntu 18.04

DBX12 commented 4 years ago

@atropo I tried your approach but it was not successful. Are you sure you get the same error message / stack trace as the others in this issue?