YouTubeExtractor
YouTubeExtractor copied to clipboard
Error While getting Youtube Data:java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference
I confirmed that it is not downloading today(05.15.2020.)
Then I checked the exception that caused the error. The error stack is as follows.
Error While getting Youtube Data:java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.toLowerCase()' on a null object reference utils.Utils.isListContain YoutubeStreamExtractor.parsePlayerConfig YoutubeStreamExtractor.doInBackground
When isListContain() was called, i checked that the second argument was null.
In the code of this "YoutubeStreamExtractor.java - parsePlayerConfig()"
if (Utils.isListContain(reasonUnavialable, RegexUtils.matchGroup(regexFindReason, body))) {
throw new ExtractorException(RegexUtils.matchGroup(regexFindReason, body));
}
RegexUtils.matchGroup(regexFindReason, body)) Its return value will be null.
Perhaps the structure of the body has changed, or the regular expression to be parsed has changed.
I lack the ability to analyze this. So I just commented out the if statement in the code above, I confirmed that the download worked fine.
However, it seems that a side effect has occurred. Do you know what the problem is? I would appreciate it if you could tell me how to fix it correctly.
Until the developer finds a real solution to this issue. There is a workaround you can use to fix it.
In naveed > utils > Utils.java file on line 37 or 40 modify IsListContain
method as below.
public static boolean isListContain(List<String> arraylist, String statement) {
for (String str : arraylist) {
if (statement != null && statement.toLowerCase().contains(str)) {
return true;
}
}
return false;
}
Note this is just a workaround! Apparently, statement
was null so I just added a null check there. This should resolve the extraction again!
@KaustubhPatange Good job, thanks for quick workaround.
@KaustubhPatange
Since the null check doesn't return true anyway, The intended function will not work.
So I think it's almost the same as what I commented out.
@hhyeok1026 Null check is in the for loop not outside, if you say if a string is null it skips the value and process further string.
Notice arraylist is not null, its one of the item are null.
The work around works successfully I can guarantee you that!
Edit: I haven't tested player config this workaround will continue extraction that's it.
@KaustubhPatange
My point is that the isListContain () method will always return false. This is because the current second argument is always null. This means that the functionality intended by the library developer is not working, there may be side effects.
@hhyeok1026 Yes there are side effects for sure. All we can do is wait for official developer to come up with a fix!