kopia lustrzana https://github.com/TeamNewPipe/NewPipe
Merge remote-tracking branch 'origin/master'
commit
0908b9cd76
|
@ -1,4 +1,4 @@
|
||||||
package org.schabi.newpipe.services.youtube;
|
package org.schabi.newpipe.extractor.youtube;
|
||||||
|
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
|
|
||||||
|
@ -82,9 +82,16 @@ public class YoutubeSearchEngineTest extends AndroidTestCase {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testViewCount() {
|
public void testViewCount() {
|
||||||
|
/*
|
||||||
for(VideoPreviewInfo i : result.resultList) {
|
for(VideoPreviewInfo i : result.resultList) {
|
||||||
assertTrue(Long.toString(i.view_count), i.view_count != -1);
|
assertTrue(Long.toString(i.view_count), i.view_count != -1);
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
// that specific link used for this test, there are no videos with less
|
||||||
|
// than 10.000 views, so we can test against that.
|
||||||
|
for(VideoPreviewInfo i : result.resultList) {
|
||||||
|
assertTrue(Long.toString(i.view_count), i.view_count >= 10000);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testIfSuggestionsAreReplied() {
|
public void testIfSuggestionsAreReplied() {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.schabi.newpipe.services.youtube;
|
package org.schabi.newpipe.extractor.youtube;
|
||||||
|
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
|
|
||||||
|
@ -70,8 +70,9 @@ public class YoutubeStreamExtractorDefaultTest extends AndroidTestCase {
|
||||||
assertTrue(extractor.getLength() > 0);
|
assertTrue(extractor.getLength() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetViews() throws ParsingException {
|
public void testGetViewCount() throws ParsingException {
|
||||||
assertTrue(extractor.getLength() > 0);
|
assertTrue(Long.toString(extractor.getViewCount()),
|
||||||
|
extractor.getViewCount() > /* specific to that video */ 1224000074);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetUploadDate() throws ParsingException {
|
public void testGetUploadDate() throws ParsingException {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.schabi.newpipe.services.youtube;
|
package org.schabi.newpipe.extractor.youtube;
|
||||||
|
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
|
|
||||||
|
|
|
@ -59,7 +59,7 @@ public interface StreamExtractor {
|
||||||
public abstract String getDescription() throws ParsingException;
|
public abstract String getDescription() throws ParsingException;
|
||||||
public abstract String getUploader() throws ParsingException;
|
public abstract String getUploader() throws ParsingException;
|
||||||
public abstract int getLength() 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 getUploadDate() throws ParsingException;
|
||||||
public abstract String getThumbnailUrl() throws ParsingException;
|
public abstract String getThumbnailUrl() throws ParsingException;
|
||||||
public abstract String getUploaderThumbnailUrl() throws ParsingException;
|
public abstract String getUploaderThumbnailUrl() throws ParsingException;
|
||||||
|
|
|
@ -150,7 +150,7 @@ public class VideoInfo extends AbstractVideoInfo {
|
||||||
videoInfo.addException(e);
|
videoInfo.addException(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
videoInfo.view_count = extractor.getViews();
|
videoInfo.view_count = extractor.getViewCount();
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
videoInfo.addException(e);
|
videoInfo.addException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -241,7 +241,10 @@ public class YoutubeSearchEngine implements SearchEngine {
|
||||||
String input = item.select("div[class=\"yt-lockup-meta\"]").first()
|
String input = item.select("div[class=\"yt-lockup-meta\"]").first()
|
||||||
.select("li").get(1)
|
.select("li").get(1)
|
||||||
.text();
|
.text();
|
||||||
output = Parser.matchGroup1("([0-9,\\. ])", input).replace(" ", "");
|
output = Parser.matchGroup1("([0-9,\\. ]*)", input)
|
||||||
|
.replace(" ", "")
|
||||||
|
.replace(".", "")
|
||||||
|
.replace(",", "");
|
||||||
|
|
||||||
return Long.parseLong(output);
|
return Long.parseLong(output);
|
||||||
}
|
}
|
||||||
|
|
|
@ -360,12 +360,12 @@ public class YoutubeStreamExtractor implements StreamExtractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getViews() throws ParsingException {
|
public long getViewCount() throws ParsingException {
|
||||||
try {
|
try {
|
||||||
String viewCountString = doc.select("meta[itemprop=interactionCount]").attr("content");
|
String viewCountString = doc.select("meta[itemprop=interactionCount]").attr("content");
|
||||||
return Long.parseLong(viewCountString);
|
return Long.parseLong(viewCountString);
|
||||||
} catch (Exception e) {//todo: find fallback method
|
} 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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue