Merge pull request #219 from Redirion/patch-1

Allow PlayLists with missing uploader
This commit is contained in:
Tobias Groza 2019-12-12 17:58:57 +01:00 committed by GitHub
commit be79f20217
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 16 additions and 3 deletions

View File

@ -11,6 +11,8 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class PlaylistInfo extends ListInfo<StreamInfoItem> {
@ -45,6 +47,9 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
extractor.getServiceId(),
extractor.getLinkHandler(),
extractor.getName());
// collect uploader extraction failures until we are sure this is not
// just a playlist without an uploader
List<Throwable> uploaderParsingErrors = new ArrayList<Throwable>(3);
try {
info.setOriginalUrl(extractor.getOriginalUrl());
@ -64,23 +69,31 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
try {
info.setUploaderUrl(extractor.getUploaderUrl());
} catch (Exception e) {
info.addError(e);
info.setUploaderUrl("");
uploaderParsingErrors.add(e);
}
try {
info.setUploaderName(extractor.getUploaderName());
} catch (Exception e) {
info.addError(e);
info.setUploaderName("");
uploaderParsingErrors.add(e);
}
try {
info.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
} catch (Exception e) {
info.addError(e);
info.setUploaderAvatarUrl("");
uploaderParsingErrors.add(e);
}
try {
info.setBannerUrl(extractor.getBannerUrl());
} catch (Exception e) {
info.addError(e);
}
// do not fail if everything but the uploader infos could be collected
if (uploaderParsingErrors.size() > 0 &&
(!info.getErrors().isEmpty() || uploaderParsingErrors.size() < 3)) {
info.addAllErrors(uploaderParsingErrors);
}
final InfoItemsPage<StreamInfoItem> itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor);
info.setRelatedItems(itemsPage.getItems());