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

YouTube playlist error #682

Open
gaborszita opened this issue Jan 20, 2022 · 0 comments
Open

YouTube playlist error #682

gaborszita opened this issue Jan 20, 2022 · 0 comments

Comments

@gaborszita
Copy link

YouTube probably changed their API someway and now playing playlists doesn't work. I debugged the YouTube playlist loader function:

  public AudioPlaylist load(HttpInterface httpInterface, String playlistId, String selectedVideoId,
                            Function<AudioTrackInfo, AudioTrack> trackFactory) {

    HttpGet request = new HttpGet(getPlaylistUrl(playlistId) + PBJ_PARAMETER + "&hl=en");

    try (CloseableHttpResponse response = httpInterface.execute(request)) {
      HttpClientTools.assertSuccessWithContent(response, "playlist response");
      HttpClientTools.assertJsonContentType(response);

      JsonBrowser json = JsonBrowser.parse(response.getEntity().getContent());
      return buildPlaylist(httpInterface, json, selectedVideoId, trackFactory);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }

And I've seen that the buildPlaylist() method always throws an IOException. To see what's going on, I went further into what's really going on in the HTTP request. I executed the same HTTP query as this function and got this response:

)]}'
{"reload":"now"}

I immediately noticed this is a problem. It is not a valid response. I don't know what this PBJ parameter is to convert the response into json somehow, but it can be clearly seen that YouTube dropped support for it.
We have to change the way it gets the tracks in a playlist. It would be the best to YouTube's v3 API. They have a page describing how to do this: https://developers.google.com/youtube/v3/docs/playlistItems/list

However, this requires an API key. I tried using the API Key in the REQUEST_URL variable: AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8, but I got an error that YouTube API v3 isn't enabled for this key.

Here are the possible solutions to this problem:

  1. (easiest and the best in my opinion) Ask the person who maintains this API key (probably @Walkyst since he did the commit that included this API key) to enable YouTube API v3 for this API key. Then, we can go and fix the code to use the YouTube v3 API.
  2. Generate a new API key that can use the YouTube API v3 and use this key for the YouTube v3 API.
  3. (personally I don't recommend it because it would require a lot of method signature changes so therefore creating a new major) Ask the user (client) to provide a YouTube v3 API key.

If we discuss which option to use, I'd be happy to help and fix this issue. If a maintainer responds with which option we should use, I can fix this issue under one day and create a pull request ASAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant