fixed viewcount failure
This commit is contained in:
parent
5d8f75beb4
commit
3441aceba3
7 changed files with 21 additions and 10 deletions
|
|
@ -59,7 +59,7 @@ public interface StreamExtractor {
|
|||
public abstract String getDescription() throws ParsingException;
|
||||
public abstract String getUploader() throws ParsingException;
|
||||
public abstract int getLength() throws ParsingException;
|
||||
public abstract long getViews() throws ParsingException;
|
||||
public abstract long getViewCount() throws ParsingException;
|
||||
public abstract String getUploadDate() throws ParsingException;
|
||||
public abstract String getThumbnailUrl() throws ParsingException;
|
||||
public abstract String getUploaderThumbnailUrl() throws ParsingException;
|
||||
|
|
|
|||
|
|
@ -150,7 +150,7 @@ public class VideoInfo extends AbstractVideoInfo {
|
|||
videoInfo.addException(e);
|
||||
}
|
||||
try {
|
||||
videoInfo.view_count = extractor.getViews();
|
||||
videoInfo.view_count = extractor.getViewCount();
|
||||
} catch(Exception e) {
|
||||
videoInfo.addException(e);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -241,7 +241,10 @@ public class YoutubeSearchEngine implements SearchEngine {
|
|||
String input = item.select("div[class=\"yt-lockup-meta\"]").first()
|
||||
.select("li").get(1)
|
||||
.text();
|
||||
output = Parser.matchGroup1("([0-9,\\. ])", input).replace(" ", "");
|
||||
output = Parser.matchGroup1("([0-9,\\. ]*)", input)
|
||||
.replace(" ", "")
|
||||
.replace(".", "")
|
||||
.replace(",", "");
|
||||
|
||||
return Long.parseLong(output);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -360,12 +360,12 @@ public class YoutubeStreamExtractor implements StreamExtractor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public long getViews() throws ParsingException {
|
||||
public long getViewCount() throws ParsingException {
|
||||
try {
|
||||
String viewCountString = doc.select("meta[itemprop=interactionCount]").attr("content");
|
||||
return Long.parseLong(viewCountString);
|
||||
} catch (Exception e) {//todo: find fallback method
|
||||
throw new ParsingException("failed to number of views", e);
|
||||
throw new ParsingException("failed to get number of views", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue