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

Playlist thumbnails are broken #296

Open
khaled-0 opened this issue Oct 14, 2024 · 2 comments
Open

Playlist thumbnails are broken #296

khaled-0 opened this issue Oct 14, 2024 · 2 comments

Comments

@khaled-0
Copy link
Contributor

For playlist : https://www.youtube.com/playlist?list=PLP_uM5nc6HCAu1X-VJznlTU-iWRbw0on4
https://img.youtube.com/vi/PLP_uM5nc6HCAu1X-VJznlTU-iWRbw0on4/maxresdefault.jpg (or any variant)
returns no image.
Solution is to probably get the first video url, as i couldn't find any alt

@khaled-0
Copy link
Contributor Author

khaled-0 commented Oct 14, 2024

@khaled-0
Copy link
Contributor Author

I implemented a custom solution that requires parsing the html page.

https://github.com/khaled-0/Syncara/blob/fdfa6de4e89e5633262ab1597edf1e3f47c68876/lib/provider/library_provider.dart#L74

  // Parse html page to retrieve custom thumbnails
  static Future<Playlist> _playlistWithThumbnail(
    Playlist playlist,
  ) async {
    try {
      final response = await yt.YoutubeHttpClient().getString(
        playlist.externalURL,
      );
      final img = parse(response).querySelectorAll("meta[property='og:image']");

      final max = img.last.attributes["content"]!;
      final std = (img.elementAtOrNull(1) ?? img.first).attributes["content"]!;

      return playlist.copyWith(thumbnailStd: std, thumbnailMax: max);
    } catch (_) {
      return playlist;
    }
  }

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