sealedtx / java-youtube-downloader

Simple, almost zero-dependency java parser for retrieving youtube video metadata
Other
426 stars 116 forks source link

Playlist extraction error #67

Closed BrdEase closed 3 years ago

BrdEase commented 3 years ago

Trying the example code from the "usage" section, as follows:

import com.github.kiulian.downloader.YoutubeDownloader;
import com.github.kiulian.downloader.YoutubeException;
import com.github.kiulian.downloader.model.YoutubeVideo;
import com.github.kiulian.downloader.model.playlist.PlaylistDetails;
import com.github.kiulian.downloader.model.playlist.PlaylistVideoDetails;
import com.github.kiulian.downloader.model.playlist.YoutubePlaylist;

public class Youtube {

public static void main(String[] args) throws YoutubeException {

    YoutubeDownloader downloader = new YoutubeDownloader(); 
    // downloader configurations
    downloader.setParserRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36");
    downloader.setParserRetryOnFailure(1);

    String playlistId = "PLjhaAcnXuuftpJKWB21uRzqe-4_d4Uuoj"; // for url https://www.youtube.com/playlist?list=abc12345
    YoutubePlaylist playlist = downloader.getPlaylist(playlistId);

    // playlist details
    PlaylistDetails details = playlist.details();
    System.out.println(details.title());

    System.out.println(details.videoCount());

    // get video details
    PlaylistVideoDetails videoDetails = playlist.videos().get(0);
    System.out.println(videoDetails.title());

    System.out.println(videoDetails.index());

    // get video
    YoutubeVideo video = downloader.getVideo(videoDetails.videoId());
}

The playlist link is: https://www.youtube.com/playlist?list=PLjhaAcnXuuftpJKWB21uRzqe-4_d4Uuoj I'm using it's id: PLjhaAcnXuuftpJKWB21uRzqe-4_d4Uuoj

throws this:

Exception in thread "main" java.lang.NullPointerException at com.github.kiulian.downloader.model.AbstractVideoDetails.<init>(AbstractVideoDetails.java:28) 
at com.github.kiulian.downloader.model.playlist.PlaylistVideoDetails.<init>(PlaylistVideoDetails.java:19) 
at com.github.kiulian.downloader.parser.DefaultParser.populatePlaylist(DefaultParser.java:354) 
at com.github.kiulian.downloader.parser.DefaultParser.getPlaylistVideos(DefaultParser.java:271) 
at com.github.kiulian.downloader.YoutubeDownloader.getPlaylist(YoutubeDownloader.java:70) 
at spotify.youtube.Youtube.main(Youtube.java:20)

You should really consider making this library more usable, better docs, better examples and explanations, and of couse better Null Pointer Exception avoiding.

Dolanpls commented 3 years ago

Calm down @BrdEase 😒 this is a free library maked for an only person on his free time, its not perfect, but rememmber that its free and @sealedtx do a great job on his free time

BrdEase commented 3 years ago

unnecessary rudeness v2.0

Dolanpls commented 3 years ago

You are a Java developer, then why you don't fix the problem and create a new PR with the fix? This is an open community and all are welcome to improve the code

BrdEase commented 3 years ago

unnecessary rudeness v3.0

Shabinder commented 3 years ago

@BrdEase vey rude and demotivating , despite of all the free efforts by developer. :expressionless:

@sealedtx you are doing a great job ,keep up the good work.πŸ‘

BrdEase commented 3 years ago

Yeah i was rude af for no reason, I ended using youtube api.

Dolanpls commented 3 years ago

GL with api key limit

BrdEase commented 3 years ago

Enough for non-comercial use, according to this table (https://developers.google.com/youtube/v3/determine_quota_cost)

Dolanpls commented 3 years ago

Then you are very lucky πŸ˜‚ I had 15 keys and I would need 100 if I use his api because youtube reduced the api key limit one day 90% πŸ€¦πŸ»β€β™‚οΈ

BrdEase commented 3 years ago

If I have some free time I'll try to fix this library, and add a search video mechanism. Is there any way to get in touch with the dev?

sealedtx commented 3 years ago

@BrdEase Hi. Sorry for your bad experience. Please, notice that: 1) this library is web scrapper 2) youtube often changes web structure of its pages 3) I don't use this library every minute or even every day to find the errors

THIS DON'T WORK, DON'T LOOSE YOUR TIME TRYING TO MAKE THIS SHIT WORK

Thats why errors are fixed as soon as someone finds it and opens an issue. After reviewing I try to fix it when I have spare time or review PR. I will add something similar to your idea to README, to make people aware of this.

Is there any way to get in touch with the dev?

Sure, PRs are welcomed

BrdEase commented 3 years ago

What PR stands for?

sealedtx commented 3 years ago

What PR stands for?

PR - Pull Request

sealedtx commented 3 years ago

There was a problem with extraction of continuationItems (playlist pagination). Fixed in https://github.com/sealedtx/java-youtube-downloader/commit/f8cebea57114daf78529209245b892bbb41e5ea7 available in 2.4.5 release

BrdEase commented 3 years ago

Yeah you are fucking awesome dude