This commit is contained in:
TobiGr 2019-09-23 10:44:17 +02:00 committed by Tobias Groza
parent d1cd341592
commit 0710f31a39
1 changed files with 16 additions and 11 deletions

View File

@ -575,21 +575,26 @@ public class YoutubeStreamExtractor extends StreamExtractor {
*/ */
@Override @Override
public String getErrorMessage() { public String getErrorMessage() {
String errorMessage = doc.select("h1[id=\"unavailable-message\"]").first().text();
StringBuilder errorReason; StringBuilder errorReason;
Element errorElement = doc.select("h1[id=\"unavailable-message\"]").first();
if (errorMessage == null || errorMessage.isEmpty()) { if (errorElement == null) {
errorReason = null; errorReason = null;
} else if (errorMessage.contains("GEMA")) {
// Gema sometimes blocks youtube music content in germany:
// https://www.gema.de/en/
// Detailed description:
// https://en.wikipedia.org/wiki/GEMA_%28German_organization%29
errorReason = new StringBuilder("GEMA");
} else { } else {
errorReason = new StringBuilder(errorMessage); String errorMessage = errorElement.text();
errorReason.append(" "); if (errorMessage == null || errorMessage.isEmpty()) {
errorReason.append(doc.select("[id=\"unavailable-submessage\"]").first().text()); errorReason = null;
} else if (errorMessage.contains("GEMA")) {
// Gema sometimes blocks youtube music content in germany:
// https://www.gema.de/en/
// Detailed description:
// https://en.wikipedia.org/wiki/GEMA_%28German_organization%29
errorReason = new StringBuilder("GEMA");
} else {
errorReason = new StringBuilder(errorMessage);
errorReason.append(" ");
errorReason.append(doc.select("[id=\"unavailable-submessage\"]").first().text());
}
} }
return errorReason != null ? errorReason.toString() : null; return errorReason != null ? errorReason.toString() : null;