Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

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 #20

Open
hhyeok1026 opened this issue May 15, 2020 · 6 comments

Comments

@hhyeok1026
Copy link
Contributor

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.

@KaustubhPatange
Copy link
Contributor

KaustubhPatange commented May 15, 2020

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!

@JmyW
Copy link

JmyW commented May 15, 2020

@KaustubhPatange Good job, thanks for quick workaround.

@hhyeok1026
Copy link
Contributor Author

@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.

@KaustubhPatange
Copy link
Contributor

KaustubhPatange commented May 19, 2020

@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.

@hhyeok1026
Copy link
Contributor Author

@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.

@KaustubhPatange
Copy link
Contributor

@hhyeok1026 Yes there are side effects for sure. All we can do is wait for official developer to come up with a fix!

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

No branches or pull requests

3 participants