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 org.schabi.newpipe.extractor.utils.ExtractorHelper;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
public class PlaylistInfo extends ListInfo<StreamInfoItem> { public class PlaylistInfo extends ListInfo<StreamInfoItem> {
@ -45,6 +47,9 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
extractor.getServiceId(), extractor.getServiceId(),
extractor.getLinkHandler(), extractor.getLinkHandler(),
extractor.getName()); 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 { try {
info.setOriginalUrl(extractor.getOriginalUrl()); info.setOriginalUrl(extractor.getOriginalUrl());
@ -64,23 +69,31 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
try { try {
info.setUploaderUrl(extractor.getUploaderUrl()); info.setUploaderUrl(extractor.getUploaderUrl());
} catch (Exception e) { } catch (Exception e) {
info.addError(e); info.setUploaderUrl("");
uploaderParsingErrors.add(e);
} }
try { try {
info.setUploaderName(extractor.getUploaderName()); info.setUploaderName(extractor.getUploaderName());
} catch (Exception e) { } catch (Exception e) {
info.addError(e); info.setUploaderName("");
uploaderParsingErrors.add(e);
} }
try { try {
info.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl()); info.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
} catch (Exception e) { } catch (Exception e) {
info.addError(e); info.setUploaderAvatarUrl("");
uploaderParsingErrors.add(e);
} }
try { try {
info.setBannerUrl(extractor.getBannerUrl()); info.setBannerUrl(extractor.getBannerUrl());
} catch (Exception e) { } catch (Exception e) {
info.addError(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); final InfoItemsPage<StreamInfoItem> itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor);
info.setRelatedItems(itemsPage.getItems()); info.setRelatedItems(itemsPage.getItems());