2018-08-20 00:52:19 +02:00
|
|
|
package org.schabi.newpipe.extractor.comments;
|
|
|
|
|
|
|
|
import org.schabi.newpipe.extractor.InfoItemsCollector;
|
|
|
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|
|
|
|
2021-03-14 01:05:58 +01:00
|
|
|
import java.util.ArrayList;
|
2019-04-28 22:03:16 +02:00
|
|
|
import java.util.List;
|
|
|
|
|
2022-03-17 14:47:08 +01:00
|
|
|
public final class CommentsInfoItemsCollector
|
|
|
|
extends InfoItemsCollector<CommentsInfoItem, CommentsInfoItemExtractor> {
|
2018-08-20 00:52:19 +02:00
|
|
|
|
2022-03-17 14:47:08 +01:00
|
|
|
public CommentsInfoItemsCollector(final int serviceId) {
|
2018-09-02 20:41:40 +02:00
|
|
|
super(serviceId);
|
|
|
|
}
|
2018-08-20 00:52:19 +02:00
|
|
|
|
2018-09-02 20:41:40 +02:00
|
|
|
@Override
|
2022-03-17 14:47:08 +01:00
|
|
|
public CommentsInfoItem extract(final CommentsInfoItemExtractor extractor)
|
|
|
|
throws ParsingException {
|
|
|
|
final CommentsInfoItem resultItem = new CommentsInfoItem(
|
|
|
|
getServiceId(), extractor.getUrl(), extractor.getName());
|
2018-08-20 00:52:19 +02:00
|
|
|
|
2018-09-02 20:41:40 +02:00
|
|
|
// optional information
|
|
|
|
try {
|
|
|
|
resultItem.setCommentId(extractor.getCommentId());
|
2022-03-17 14:47:08 +01:00
|
|
|
} catch (final Exception e) {
|
2018-09-02 20:41:40 +02:00
|
|
|
addError(e);
|
|
|
|
}
|
|
|
|
try {
|
|
|
|
resultItem.setCommentText(extractor.getCommentText());
|
2022-03-17 14:47:08 +01:00
|
|
|
} catch (final Exception e) {
|
2018-09-02 20:41:40 +02:00
|
|
|
addError(e);
|
|
|
|
}
|
|
|
|
try {
|
2020-04-21 19:49:17 +02:00
|
|
|
resultItem.setUploaderName(extractor.getUploaderName());
|
2022-03-17 14:47:08 +01:00
|
|
|
} catch (final Exception e) {
|
2018-09-02 20:41:40 +02:00
|
|
|
addError(e);
|
|
|
|
}
|
|
|
|
try {
|
2022-07-20 23:36:27 +02:00
|
|
|
resultItem.setUploaderAvatars(extractor.getUploaderAvatars());
|
2022-03-17 14:47:08 +01:00
|
|
|
} catch (final Exception e) {
|
2018-09-02 20:41:40 +02:00
|
|
|
addError(e);
|
|
|
|
}
|
|
|
|
try {
|
2020-04-21 19:49:17 +02:00
|
|
|
resultItem.setUploaderUrl(extractor.getUploaderUrl());
|
2022-03-17 14:47:08 +01:00
|
|
|
} catch (final Exception e) {
|
2018-09-02 20:41:40 +02:00
|
|
|
addError(e);
|
2019-04-28 22:03:16 +02:00
|
|
|
}
|
|
|
|
try {
|
2020-04-21 19:49:17 +02:00
|
|
|
resultItem.setTextualUploadDate(extractor.getTextualUploadDate());
|
2022-03-17 14:47:08 +01:00
|
|
|
} catch (final Exception e) {
|
2019-04-28 22:03:16 +02:00
|
|
|
addError(e);
|
2018-09-02 20:41:40 +02:00
|
|
|
}
|
|
|
|
try {
|
2020-04-21 19:49:17 +02:00
|
|
|
resultItem.setUploadDate(extractor.getUploadDate());
|
2022-03-17 14:47:08 +01:00
|
|
|
} catch (final Exception e) {
|
2018-09-02 20:41:40 +02:00
|
|
|
addError(e);
|
|
|
|
}
|
2021-05-21 19:40:51 +02:00
|
|
|
try {
|
|
|
|
resultItem.setLikeCount(extractor.getLikeCount());
|
2022-03-17 14:47:08 +01:00
|
|
|
} catch (final Exception e) {
|
2021-05-21 19:40:51 +02:00
|
|
|
addError(e);
|
|
|
|
}
|
2018-09-02 20:41:40 +02:00
|
|
|
try {
|
2021-05-27 19:48:31 +02:00
|
|
|
resultItem.setTextualLikeCount(extractor.getTextualLikeCount());
|
2022-03-17 14:47:08 +01:00
|
|
|
} catch (final Exception e) {
|
2018-09-02 20:41:40 +02:00
|
|
|
addError(e);
|
|
|
|
}
|
|
|
|
try {
|
2022-07-20 23:36:27 +02:00
|
|
|
resultItem.setThumbnails(extractor.getThumbnails());
|
2022-03-17 14:47:08 +01:00
|
|
|
} catch (final Exception e) {
|
2018-09-02 20:41:40 +02:00
|
|
|
addError(e);
|
|
|
|
}
|
2018-08-20 00:52:19 +02:00
|
|
|
|
2021-01-11 18:38:54 +01:00
|
|
|
try {
|
2021-01-23 13:06:07 +01:00
|
|
|
resultItem.setHeartedByUploader(extractor.isHeartedByUploader());
|
2022-03-17 14:47:08 +01:00
|
|
|
} catch (final Exception e) {
|
2021-01-11 18:38:54 +01:00
|
|
|
addError(e);
|
|
|
|
}
|
|
|
|
|
2021-01-22 23:59:22 +01:00
|
|
|
try {
|
2021-01-23 13:06:07 +01:00
|
|
|
resultItem.setPinned(extractor.isPinned());
|
2022-03-17 14:47:08 +01:00
|
|
|
} catch (final Exception e) {
|
2021-01-22 23:59:22 +01:00
|
|
|
addError(e);
|
|
|
|
}
|
|
|
|
|
2021-06-06 11:18:23 +02:00
|
|
|
try {
|
|
|
|
resultItem.setStreamPosition(extractor.getStreamPosition());
|
2022-03-17 14:47:08 +01:00
|
|
|
} catch (final Exception e) {
|
2021-06-06 11:18:23 +02:00
|
|
|
addError(e);
|
|
|
|
}
|
|
|
|
|
2022-10-15 12:40:06 +02:00
|
|
|
try {
|
|
|
|
resultItem.setReplyCount(extractor.getReplyCount());
|
|
|
|
} catch (final Exception e) {
|
|
|
|
addError(e);
|
|
|
|
}
|
|
|
|
|
2021-08-04 14:39:42 +02:00
|
|
|
try {
|
|
|
|
resultItem.setReplies(extractor.getReplies());
|
2022-03-17 14:47:08 +01:00
|
|
|
} catch (final Exception e) {
|
2021-08-04 14:39:42 +02:00
|
|
|
addError(e);
|
|
|
|
}
|
|
|
|
|
2018-09-02 20:41:40 +02:00
|
|
|
return resultItem;
|
|
|
|
}
|
2018-08-20 00:52:19 +02:00
|
|
|
|
2018-09-02 20:41:40 +02:00
|
|
|
@Override
|
2022-03-17 14:47:08 +01:00
|
|
|
public void commit(final CommentsInfoItemExtractor extractor) {
|
2018-09-02 20:41:40 +02:00
|
|
|
try {
|
|
|
|
addItem(extract(extractor));
|
2022-03-17 14:47:08 +01:00
|
|
|
} catch (final Exception e) {
|
2018-09-02 20:41:40 +02:00
|
|
|
addError(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<CommentsInfoItem> getCommentsInfoItemList() {
|
2021-08-04 18:44:04 +02:00
|
|
|
return new ArrayList<>(super.getItems());
|
2018-09-02 20:41:40 +02:00
|
|
|
}
|
2018-08-20 00:52:19 +02:00
|
|
|
}
|