mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-13 05:40:34 +05:30
better quality thumbnails
This commit is contained in:
parent
f62f147ea0
commit
9fb0622a24
@ -9,75 +9,81 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
|
||||
public class CommentsInfoItemsCollector extends InfoItemsCollector<CommentsInfoItem, CommentsInfoItemExtractor> {
|
||||
|
||||
public CommentsInfoItemsCollector(int serviceId) {
|
||||
super(serviceId);
|
||||
}
|
||||
public CommentsInfoItemsCollector(int serviceId) {
|
||||
super(serviceId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommentsInfoItem extract(CommentsInfoItemExtractor extractor) throws ParsingException {
|
||||
@Override
|
||||
public CommentsInfoItem extract(CommentsInfoItemExtractor extractor) throws ParsingException {
|
||||
|
||||
// important information
|
||||
int serviceId = getServiceId();
|
||||
String url = extractor.getUrl();
|
||||
String name = extractor.getName();
|
||||
// important information
|
||||
int serviceId = getServiceId();
|
||||
String url = extractor.getUrl();
|
||||
String name = extractor.getName();
|
||||
|
||||
CommentsInfoItem resultItem = new CommentsInfoItem(serviceId, url, name);
|
||||
CommentsInfoItem resultItem = new CommentsInfoItem(serviceId, url, name);
|
||||
|
||||
// optional information
|
||||
try {
|
||||
resultItem.setCommentId(extractor.getCommentId());
|
||||
} catch (Exception e) {
|
||||
addError(e);
|
||||
}
|
||||
try {
|
||||
resultItem.setCommentText(extractor.getCommentText());
|
||||
} catch (Exception e) {
|
||||
addError(e);
|
||||
}
|
||||
try {
|
||||
resultItem.setAuthorName(extractor.getAuthorName());
|
||||
} catch (Exception e) {
|
||||
addError(e);
|
||||
}
|
||||
try {
|
||||
resultItem.setAuthorThumbnail(extractor.getAuthorThumbnail());
|
||||
} catch (Exception e) {
|
||||
addError(e);
|
||||
}
|
||||
try {
|
||||
resultItem.setAuthorEndpoint(extractor.getAuthorEndpoint());
|
||||
} catch (Exception e) {
|
||||
addError(e);
|
||||
}
|
||||
try {
|
||||
resultItem.setPublishedTime(extractor.getPublishedTime());
|
||||
} catch (Exception e) {
|
||||
addError(e);
|
||||
}
|
||||
try {
|
||||
resultItem.setLikeCount(extractor.getLikeCount());
|
||||
} catch (Exception e) {
|
||||
addError(e);
|
||||
}
|
||||
return resultItem;
|
||||
}
|
||||
// optional information
|
||||
try {
|
||||
resultItem.setCommentId(extractor.getCommentId());
|
||||
} catch (Exception e) {
|
||||
addError(e);
|
||||
}
|
||||
try {
|
||||
resultItem.setCommentText(extractor.getCommentText());
|
||||
} catch (Exception e) {
|
||||
addError(e);
|
||||
}
|
||||
try {
|
||||
resultItem.setAuthorName(extractor.getAuthorName());
|
||||
} catch (Exception e) {
|
||||
addError(e);
|
||||
}
|
||||
try {
|
||||
resultItem.setAuthorThumbnail(extractor.getAuthorThumbnail());
|
||||
} catch (Exception e) {
|
||||
addError(e);
|
||||
}
|
||||
try {
|
||||
resultItem.setAuthorEndpoint(extractor.getAuthorEndpoint());
|
||||
} catch (Exception e) {
|
||||
addError(e);
|
||||
}
|
||||
try {
|
||||
resultItem.setPublishedTime(extractor.getPublishedTime());
|
||||
} catch (Exception e) {
|
||||
addError(e);
|
||||
}
|
||||
try {
|
||||
resultItem.setLikeCount(extractor.getLikeCount());
|
||||
} catch (Exception e) {
|
||||
addError(e);
|
||||
}
|
||||
try {
|
||||
resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
|
||||
} catch (Exception e) {
|
||||
addError(e);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void commit(CommentsInfoItemExtractor extractor) {
|
||||
try {
|
||||
addItem(extract(extractor));
|
||||
} catch (Exception e) {
|
||||
addError(e);
|
||||
}
|
||||
}
|
||||
return resultItem;
|
||||
}
|
||||
|
||||
public List<CommentsInfoItem> getCommentsInfoItemList() {
|
||||
List<CommentsInfoItem> siiList = new Vector<>();
|
||||
for (InfoItem ii : super.getItems()) {
|
||||
if (ii instanceof CommentsInfoItem) {
|
||||
siiList.add((CommentsInfoItem) ii);
|
||||
}
|
||||
}
|
||||
return siiList;
|
||||
}
|
||||
@Override
|
||||
public void commit(CommentsInfoItemExtractor extractor) {
|
||||
try {
|
||||
addItem(extract(extractor));
|
||||
} catch (Exception e) {
|
||||
addError(e);
|
||||
}
|
||||
}
|
||||
|
||||
public List<CommentsInfoItem> getCommentsInfoItemList() {
|
||||
List<CommentsInfoItem> siiList = new Vector<>();
|
||||
for (InfoItem ii : super.getItems()) {
|
||||
if (ii instanceof CommentsInfoItem) {
|
||||
siiList.add((CommentsInfoItem) ii);
|
||||
}
|
||||
}
|
||||
return siiList;
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
|
||||
@Override
|
||||
public String getThumbnailUrl() throws ParsingException {
|
||||
try {
|
||||
return c.get("authorThumbnail").get("thumbnails").get(0).get("url").asText();
|
||||
return c.get("authorThumbnail").get("thumbnails").get(2).get("url").asText();
|
||||
} catch (Exception e) {
|
||||
throw new ParsingException("Could not get thumbnail url", e);
|
||||
}
|
||||
@ -114,7 +114,7 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
|
||||
try {
|
||||
return c.get("authorText").get("simpleText").asText();
|
||||
} catch (Exception e) {
|
||||
throw new ParsingException("Could not get thumbnail url", e);
|
||||
throw new ParsingException("Could not get author name", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
|
||||
try {
|
||||
return c.get("publishedTimeText").get("runs").get(0).get("text").asText();
|
||||
} catch (Exception e) {
|
||||
throw new ParsingException("Could not get thumbnail url", e);
|
||||
throw new ParsingException("Could not get publishedTimeText", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -132,7 +132,7 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
|
||||
try {
|
||||
return c.get("likeCount").intValue();
|
||||
} catch (Exception e) {
|
||||
throw new ParsingException("Could not get thumbnail url", e);
|
||||
throw new ParsingException("Could not get like count", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
|
||||
return c.get("contentText").get("runs").get(0).get("text").asText();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ParsingException("Could not get thumbnail url", e);
|
||||
throw new ParsingException("Could not get comment text", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,16 +154,16 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
|
||||
try {
|
||||
return c.get("commentId").asText();
|
||||
} catch (Exception e) {
|
||||
throw new ParsingException("Could not get thumbnail url", e);
|
||||
throw new ParsingException("Could not get comment id", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAuthorThumbnail() throws ParsingException {
|
||||
try {
|
||||
return c.get("authorThumbnail").get("thumbnails").get(0).get("url").asText();
|
||||
return c.get("authorThumbnail").get("thumbnails").get(2).get("url").asText();
|
||||
} catch (Exception e) {
|
||||
throw new ParsingException("Could not get thumbnail url", e);
|
||||
throw new ParsingException("Could not get author thumbnail", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
|
||||
try {
|
||||
return c.get("authorText").get("simpleText").asText();
|
||||
} catch (Exception e) {
|
||||
throw new ParsingException("Could not get thumbnail url", e);
|
||||
throw new ParsingException("Could not get author name", e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,7 +182,7 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
|
||||
return "https://youtube.com"
|
||||
+ c.get("authorEndpoint").get("browseEndpoint").get("canonicalBaseUrl").asText();
|
||||
} catch (Exception e) {
|
||||
throw new ParsingException("Could not get thumbnail url", e);
|
||||
throw new ParsingException("Could not get author endpoint", e);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,19 +1,22 @@
|
||||
package org.schabi.newpipe.extractor.stream;
|
||||
|
||||
import org.schabi.newpipe.extractor.*;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.schabi.newpipe.extractor.Info;
|
||||
import org.schabi.newpipe.extractor.InfoItem;
|
||||
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
import org.schabi.newpipe.extractor.Subtitles;
|
||||
import org.schabi.newpipe.extractor.comments.CommentsExtractor;
|
||||
import org.schabi.newpipe.extractor.comments.CommentsInfo;
|
||||
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
||||
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.utils.DashMpdParser;
|
||||
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 26.08.15.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user