CogentRedTester / mpv-scripts

A collection of scripts for mpv player
MIT License
252 stars 19 forks source link

youtube-search: youtube API does not accept search #11

Closed kamack38 closed 2 years ago

kamack38 commented 3 years ago

youtube-search doesn't return any results

[youtube_search] Search did not return a results list

Windows 10 mpv 0.33.0-268-g416668d3c8

kamack38 commented 3 years ago

In Google Cloud it gives me 403 response code.

CogentRedTester commented 3 years ago

Have you created and entered the YouTube API key?

kamack38 commented 3 years ago

Yes, as I said earlier Google Cloud shows me 100% fail rate with exit code 403. I entered the key both in the script-opts and directly into the plugin file.

CogentRedTester commented 3 years ago

Can you post a full log file and the exact string you were trying to search

kamack38 commented 3 years ago

obraz

CogentRedTester commented 3 years ago

Please upload a full log in file form, as created by the log-file option

kamack38 commented 3 years ago
[  55.826][d][global] config path: 'fonts' -/-> 'C:\Users\kamac\AppData\Roaming/mpv/fonts'
[  55.826][d][global] config path: 'fonts' -/-> 'C:/Program Files (x86)/mpv/fonts'
[  55.826][d][global] config path: 'fonts' -/-> 'C:/Program Files (x86)/mpv/mpv/fonts'
[  55.826][d][osd/libass] ASS library version: 0x1501000 (runtime 0x1501000)
[  55.826][v][osd/libass] libass API version: 0x1501000
[  55.826][v][osd/libass] libass source: commit: 5733e1c28b92ebbf090bea8f25e252aa40e0b9c4
[  55.827][v][osd/libass] Shaper: FriBidi 1.0.10 (SIMPLE) HarfBuzz-ng 2.8.2 (COMPLEX)
[  55.827][d][global] config path: 'subfont.ttf' -/-> 'C:\Users\kamac\AppData\Roaming/mpv/subfont.ttf'
[  55.827][d][global] config path: 'subfont.ttf' -/-> 'C:/Program Files (x86)/mpv/subfont.ttf'
[  55.827][d][global] config path: 'subfont.ttf' -/-> 'C:/Program Files (x86)/mpv/mpv/subfont.ttf'
[  55.827][d][global] config path: 'fonts.conf' -/-> 'C:\Users\kamac\AppData\Roaming/mpv/fonts.conf'
[  55.827][d][global] config path: 'fonts.conf' -/-> 'C:/Program Files (x86)/mpv/fonts.conf'
[  55.827][d][global] config path: 'fonts.conf' -> 'C:/Program Files (x86)/mpv/mpv/fonts.conf'
[  55.827][v][osd/libass] Setting up fonts...
[  55.827][v][osd/libass] Using font provider directwrite (with GDI)
[  55.827][v][osd/libass] Done.
[  55.828][d][cplayer] Run command: script-message-to, flags=64, args=[target="user_input", args="request-user-input", args="youtube_search/__user_input_request/1", args="youtube_search/", args="[youtube_search] Enter Query:", args="", args="", args=""]
[  55.828][d][cplayer] Run command: define-section, flags=64, args=[name="input_youtube_search", contents="Ctrl+y script-binding youtube_search/yt\nY script-binding youtube_search/youtube-search\n", flags="default"]
[  55.828][d][cplayer] Run command: enable-section, flags=64, args=[name="input_youtube_search", flags="allow-hide-cursor+allow-vo-dragging"]
[  55.828][d][cplayer] Run command: define-section, flags=64, args=[name="input_forced_youtube_search", contents="DOWN script-binding youtube_search/dynamic/1/scroll_down\nUP script-binding youtube_search/dynamic/1/scroll_up\nESC script-binding youtube_search/dynamic/1/close_browser\nENTER script-binding youtube_search/dynamic/1/play\nShift+ENTER script-binding youtube_search/dynamic/1/play_append\nCtrl+ENTER script-binding youtube_search/dynamic/1/play_new_window\n", flags="force"]
[  55.828][d][cplayer] Run command: enable-section, flags=64, args=[name="input_forced_youtube_search", flags="allow-hide-cursor+allow-vo-dragging"]
[  55.828][d][cplayer] Run command: define-section, flags=64, args=[name="input_user_input", contents="Ctrl+i script-binding user_input/user-input\n", flags="default"]
[  55.828][d][cplayer] Run command: enable-section, flags=64, args=[name="input_user_input", flags="allow-hide-cursor+allow-vo-dragging"]
[  55.828][d][cplayer] Run command: define-section, flags=64, args=[name="input_forced_user_input", contents="esc script-binding user_input/_userinput_esc\nenter script-binding user_input/_userinput_enter\nkp_enter script-binding user_input/_userinput_kp_enter\nshift+enter script-binding user_input/_userinput_shift+enter\nbs script-binding user_input/_userinput_bs\nshift+bs script-binding user_input/_userinput_shift+bs\ndel script-binding user_input/_userinput_del\nshift+del script-binding user_input/_userinput_shift+del\nins script-binding user_input/_userinput_ins\nshift+ins script-binding user_input/_userinput_shift+ins\nmbtn_mid script-binding user_input/_userinput_mbtn_mid\nleft script-binding user_input/_userinput_left\nright script-binding user_input/_userinput_right\nup script-binding user_input/_userinput_up\nwheel_up script-binding user_input/_userinput_wheel_up\ndown script-binding user_input/_userinput_down\nwheel_down script-binding user_input/_userinput_wheel_down\nwheel_left script-binding user_input/_userinput_wheel_left\nwheel_right script-binding user_input/_userinput_wheel_right\nctrl+left script-binding user_input/_userinput_ctrl+left\nctrl+right script-binding user_input/_userinput_ctrl+right\nhome script-binding user_input/_userinput_home\nend script-binding user_input/_userinput_end\npgup script-binding user_input/_userinput_pgup\npgdwn script-binding user_input/_userinput_pgdwn\nctrl+c script-binding user_input/_userinput_ctrl+c\nctrl+d script-binding user_input/_userinput_ctrl+d\nctrl+k script-binding user_input/_userinput_ctrl+k\nctrl+u script-binding user_input/_userinput_ctrl+u\nctrl+v script-binding user_input/_userinput_ctrl+v\nmeta+v script-binding user_input/_userinput_meta+v\nctrl+w script-binding user_input/_userinput_ctrl+w\nkp_dec script-binding user_input/_userinput_kp_dec\nkp0 script-binding user_input/_userinput_kp0\nkp1 script-binding user_input/_userinput_kp1\nkp2 script-binding user_input/_userinput_kp2\nkp3 script-binding user_input/_userinput_kp3\nkp4 script-binding user_input/_userinput_kp4\nkp5 script-binding user_input/_userinput_kp5\nkp6 script-binding user_input/_userinput_kp6\nkp7 script-binding user_input/_userinput_kp7\nkp8 script-binding user_input/_userinput_kp8\nkp9 script-binding user_input/_userinput_kp9\nany_unicode script-binding user_input/_userinput_text\n", flags="force"]
[  55.828][d][cplayer] Run command: enable-section, flags=64, args=[name="input_forced_user_input", flags="allow-hide-cursor+allow-vo-dragging"]
[  55.830][v][osd/libass] fontselect: (sans-serif, 400, 0) -> ArialMT, 0, ArialMT
[  55.830][v][osd/libass] fontselect: (Consolas, 400, 0) -> Consolas, 0, Consolas
[  55.833][v][osd/libass] fontselect: (sans-serif, 400, 0) -> ArialMT, 0, ArialMT
[  55.895][d][cplayer] Run command: script-binding, flags=73, args=[name="youtube_search/youtube-search"]
[  57.706][d][cplayer] Run command: script-binding, flags=73, args=[name="user_input/_userinput_text"]
[  57.780][d][cplayer] Run command: script-binding, flags=73, args=[name="user_input/_userinput_text"]
[  57.879][d][cplayer] Run command: script-binding, flags=73, args=[name="user_input/_userinput_text"]
[  57.985][d][cplayer] Run command: script-binding, flags=73, args=[name="user_input/_userinput_text"]
[  58.115][d][cplayer] Run command: script-binding, flags=73, args=[name="user_input/_userinput_text"]
[  58.201][d][cplayer] Run command: script-binding, flags=73, args=[name="user_input/_userinput_text"]
[  60.416][d][cplayer] Run command: script-binding, flags=73, args=[name="user_input/_userinput_enter"]
[  60.416][d][cplayer] Run command: script-message, flags=64, args=[args="youtube_search/__user_input_request/1", args="idk", args=""]
[  60.416][v][youtube_search] 40 40 
[  60.417][v][youtube_search] idk idk 
[  60.417][v][youtube_search] id,snippet id%2Csnippet 
[  60.417][d][youtube_search] https://www.googleapis.com/youtube/v3/search?key=hereIsmyApikey&maxResults=40&q=idk&part=id%2Csnippet 
[  60.417][d][cplayer] Run command: subprocess, flags=64, args=[args="curl,https://www.googleapis.com/youtube/v3/search?key=AIzaSyDqX0AiwHLvrOwAAIR66b4kVhUAa2fZylo&maxResults=40&q=idk&part=id%2Csnippet", playback_only="no", capture_size="67108864", capture_stdout="yes", capture_stderr="yes", detach="no", env="", stdin_data="", passthrough_stdin="no"]
[  60.417][d][cplayer] Run command: define-section, flags=64, args=[name="input_user_input", contents="Ctrl+i script-binding user_input/user-input\n", flags="default"]
[  60.417][d][cplayer] Run command: enable-section, flags=64, args=[name="input_user_input", flags="allow-hide-cursor+allow-vo-dragging"]
[  60.417][d][cplayer] Run command: define-section, flags=64, args=[name="input_forced_user_input", contents="", flags="force"]
[  60.417][d][cplayer] Run command: enable-section, flags=64, args=[name="input_forced_user_input", flags="allow-hide-cursor+allow-vo-dragging"]
[  60.489][d][cplayer] Run command: script-binding, flags=73, args=[name="user_input/_userinput_enter"]
[  60.625][w][youtube_search] Search did not return a results list 
[  61.120][d][cplayer] Run command: enable-section, flags=64, args=[name="input", flags=""]
[  61.121][v][vo/gpu] Reallocating OSD texture to 2048x512.
[  62.223][d][cplayer] Run command: script-binding, flags=73, args=[name="mpv_thumbnail_script_client_osc/__keybinding2"]
[  62.451][d][cplayer] Run command: disable-section, flags=64, args=[name="input"]
CogentRedTester commented 3 years ago

I get this output in the terminal when I use your API key:

{
  "error": {
    "code": 403,
    "message": "YouTube Data API v3 has not been used in project 991283974941 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=991283974941 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
    "errors": [
      {
        "message": "YouTube Data API v3 has not been used in project 991283974941 before or it is disabled. Enable it by visiting https://console.developers.google.com/apis/api/youtube.googleapis.com/overview?project=991283974941 then retry. If you enabled this API recently, wait a few minutes for the action to propagate to our systems and retry.",
        "domain": "usageLimits",
        "reason": "accessNotConfigured",
        "extendedHelp": "https://console.developers.google.com"
      }
    ],
    "status": "PERMISSION_DENIED"
  }
}

Try doing what it suggests

kamack38 commented 3 years ago

I have configured my OAuth and now I get this error

[youtube_search] {
[youtube_search]   "error": {
[youtube_search]     "code": 403,
[youtube_search]     "message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e.",
[youtube_search]     "errors": [
[youtube_search]       {
[youtube_search]         "message": "The request cannot be completed because you have exceeded your \u003ca href=\"/youtube/v3/getting-started#quota\"\u003equota\u003c/a\u003e.",
[youtube_search]         "domain": "youtube.quota",
[youtube_search]         "reason": "quotaExceeded"
[youtube_search]       }
[youtube_search]     ]
[youtube_search]   }
[youtube_search] }
[youtube_search]

And I have smth like this in my OAuth screen obraz

CogentRedTester commented 3 years ago

I have no idea what you've done, and I don't know what OAuth has to do with this script, perhaps you haven't enabled the correct API?

You need to enable the youtube data API v3 with this button: image

Then you have to search and enable the Youtube Data API v3 image

Then you have to create an API key in the credentials page: image

Then the key should be available to copy here: image

kamack38 commented 3 years ago

I still get the same error message.

CogentRedTester commented 3 years ago

Well according to the output you've gone past your daily quota. Wait a day or two and try again.

https://developers.google.com/youtube/v3/getting-started#quota

CogentRedTester commented 2 years ago

Has this been fixed? If so I'll close the issue.

kamack38 commented 2 years ago

No, it still tells me I have exceeded my quota.

MintMain21 commented 2 years ago

Just wanted to add that if I use shift+y to make a YouTube search upon opening MPV I won't get any search results, but if I use ctl+y to just open the search bar and then type my search the search results will pop up. Then, once I have a video loaded, using Shift+y twice to open the search bar on top of the search results will actually load proper search results.

Was going to make this it's own bug, but it sounds relevant to this one.

TLDR: Try using ctl+y to make a search instead of shift+y. CogentRedTester, if this isn't intentional, then you probably have a bug you might want to look into.

CogentRedTester commented 2 years ago

@MintMain21 I'm afraid I don't know what you mean. I can't replicate the behaviour that you are describing. If you're talking about the fact that you can open the search bar without opening the page first, then yes that is intentional.

MintMain21 commented 2 years ago

Okay, sorry, time to give this a proper Github step-by-step.

There are two ways to start up the extension. I can either use crtl+y to open the Search Bar, or shift+y to open Search Results and the Search Bar. If I do shift+y, then of course there will be no search results until after I make a search, but once I make the first seach the results won't update to reflect that. I push escape to exit, and then (at best) the results will either autogenerate or they'll appear upon pushing shift+y again.

On the other hand, if I make my initial search through ctl+y then the results will appear shortly after making the search, and then I can shift+y to see the current search results and make a new search querry.

In other words, upon booting up MPV, I need to deliberately choose ctl+y and not shift+y, but after doing one search I can use either command interchangably.

CogentRedTester commented 2 years ago

That doesn't happen for me. When I boot mpv and do shift+y I get the empty search page and the input box. When I type in a query and press enter the search page updates after a short delay. Can you make sure you have the latest versions of youtube-search user-input and scroll-list? If it is still an issue then please make a separate dedicated issue request, this thread is not the place to discuss this.

tnira commented 2 years ago

Last night, while setting up a script, I had same problem"403 QuotaExceeded" . I created a new project and used the API key right after I reacquired it, but there was no change. I even tried re-setting the API request limit with the same value.

I don't know now if something worked or if there was a temporary problem with the API, but this morning a search results were returned as if nothing had happened.

CogentRedTester commented 2 years ago

Interesting. Until we find a way to reliably replicate this I don't see any way to fix the issue. For now I'm going to say it's a Youtube issue, but I'll leave the issue open in case there are any updates.

CogentRedTester commented 2 years ago

A possible solution for everyone here is to use the new experimental support for Invidious API searches. See #13.

kamack38 commented 2 years ago

I created a new API key and read the #13 and now everything works. But, when using old API key, I got this error:

curl: (3) URL using bad/illegal format or missing URL