mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-14 06:10:33 +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 class CommentsInfoItemsCollector extends InfoItemsCollector<CommentsInfoItem, CommentsInfoItemExtractor> {
|
||||||
|
|
||||||
public CommentsInfoItemsCollector(int serviceId) {
|
public CommentsInfoItemsCollector(int serviceId) {
|
||||||
super(serviceId);
|
super(serviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommentsInfoItem extract(CommentsInfoItemExtractor extractor) throws ParsingException {
|
public CommentsInfoItem extract(CommentsInfoItemExtractor extractor) throws ParsingException {
|
||||||
|
|
||||||
// important information
|
// important information
|
||||||
int serviceId = getServiceId();
|
int serviceId = getServiceId();
|
||||||
String url = extractor.getUrl();
|
String url = extractor.getUrl();
|
||||||
String name = extractor.getName();
|
String name = extractor.getName();
|
||||||
|
|
||||||
CommentsInfoItem resultItem = new CommentsInfoItem(serviceId, url, name);
|
CommentsInfoItem resultItem = new CommentsInfoItem(serviceId, url, name);
|
||||||
|
|
||||||
// optional information
|
// optional information
|
||||||
try {
|
try {
|
||||||
resultItem.setCommentId(extractor.getCommentId());
|
resultItem.setCommentId(extractor.getCommentId());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setCommentText(extractor.getCommentText());
|
resultItem.setCommentText(extractor.getCommentText());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setAuthorName(extractor.getAuthorName());
|
resultItem.setAuthorName(extractor.getAuthorName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setAuthorThumbnail(extractor.getAuthorThumbnail());
|
resultItem.setAuthorThumbnail(extractor.getAuthorThumbnail());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setAuthorEndpoint(extractor.getAuthorEndpoint());
|
resultItem.setAuthorEndpoint(extractor.getAuthorEndpoint());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setPublishedTime(extractor.getPublishedTime());
|
resultItem.setPublishedTime(extractor.getPublishedTime());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setLikeCount(extractor.getLikeCount());
|
resultItem.setLikeCount(extractor.getLikeCount());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
return resultItem;
|
try {
|
||||||
}
|
resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
|
||||||
|
} catch (Exception e) {
|
||||||
|
addError(e);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
return resultItem;
|
||||||
public void commit(CommentsInfoItemExtractor extractor) {
|
}
|
||||||
try {
|
|
||||||
addItem(extract(extractor));
|
|
||||||
} catch (Exception e) {
|
|
||||||
addError(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<CommentsInfoItem> getCommentsInfoItemList() {
|
@Override
|
||||||
List<CommentsInfoItem> siiList = new Vector<>();
|
public void commit(CommentsInfoItemExtractor extractor) {
|
||||||
for (InfoItem ii : super.getItems()) {
|
try {
|
||||||
if (ii instanceof CommentsInfoItem) {
|
addItem(extract(extractor));
|
||||||
siiList.add((CommentsInfoItem) ii);
|
} catch (Exception e) {
|
||||||
}
|
addError(e);
|
||||||
}
|
}
|
||||||
return siiList;
|
}
|
||||||
}
|
|
||||||
|
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
|
@Override
|
||||||
public String getThumbnailUrl() throws ParsingException {
|
public String getThumbnailUrl() throws ParsingException {
|
||||||
try {
|
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) {
|
} catch (Exception e) {
|
||||||
throw new ParsingException("Could not get thumbnail url", e);
|
throw new ParsingException("Could not get thumbnail url", e);
|
||||||
}
|
}
|
||||||
@ -114,7 +114,7 @@ public class YoutubeCommentsExtractor extends CommentsExtractor {
|
|||||||
try {
|
try {
|
||||||
return c.get("authorText").get("simpleText").asText();
|
return c.get("authorText").get("simpleText").asText();
|
||||||
} catch (Exception e) {
|
} 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 {
|
try {
|
||||||
return c.get("publishedTimeText").get("runs").get(0).get("text").asText();
|
return c.get("publishedTimeText").get("runs").get(0).get("text").asText();
|
||||||
} catch (Exception e) {
|
} 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 {
|
try {
|
||||||
return c.get("likeCount").intValue();
|
return c.get("likeCount").intValue();
|
||||||
} catch (Exception e) {
|
} 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();
|
return c.get("contentText").get("runs").get(0).get("text").asText();
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} 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 {
|
try {
|
||||||
return c.get("commentId").asText();
|
return c.get("commentId").asText();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ParsingException("Could not get thumbnail url", e);
|
throw new ParsingException("Could not get comment id", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAuthorThumbnail() throws ParsingException {
|
public String getAuthorThumbnail() throws ParsingException {
|
||||||
try {
|
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) {
|
} 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 {
|
try {
|
||||||
return c.get("authorText").get("simpleText").asText();
|
return c.get("authorText").get("simpleText").asText();
|
||||||
} catch (Exception e) {
|
} 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"
|
return "https://youtube.com"
|
||||||
+ c.get("authorEndpoint").get("browseEndpoint").get("canonicalBaseUrl").asText();
|
+ c.get("authorEndpoint").get("browseEndpoint").get("canonicalBaseUrl").asText();
|
||||||
} catch (Exception e) {
|
} 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;
|
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.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.CommentsExtractor;
|
||||||
import org.schabi.newpipe.extractor.comments.CommentsInfo;
|
|
||||||
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.utils.DashMpdParser;
|
import org.schabi.newpipe.extractor.utils.DashMpdParser;
|
||||||
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
|
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.
|
* Created by Christian Schabesberger on 26.08.15.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user