本文整理了Java中at.huber.youtubeExtractor.YouTubeExtractor.extract()
方法的一些代码示例,展示了YouTubeExtractor.extract()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YouTubeExtractor.extract()
方法的具体详情如下:
包路径:at.huber.youtubeExtractor.YouTubeExtractor
类名称:YouTubeExtractor
方法名:extract
[英]Start the extraction.
[中]开始提取。
代码示例来源:origin: Ashish-Bansal/OneTapVideoDownload
public static void startParsing(final Context context, String param, final Invokable<Video, Integer> invokable) {
YouTubeExtractor mYoutubeExtractor = new YouTubeExtractor(context) {
@Override
public void onExtractionComplete(SparseArray<YtFile> ytFiles, VideoMeta vMeta) {
if (ytFiles != null) {
YoutubeVideo video = new YoutubeVideo(vMeta.getTitle(), vMeta.getVideoId());
for(Pair p : YoutubeVideo.itagQualityMapping) {
YtFile videoFormat = ytFiles.get(Integer.parseInt(p.first.toString()));
if (videoFormat == null) {
continue;
}
video.addFormat(videoFormat.getUrl(), Integer.parseInt(p.first.toString()));
}
try {
invokable.invoke(video);
} catch (java.lang.Exception e) {
FirebaseCrash.report(e);
e.printStackTrace();
}
} else {
Log.e(TAG, "URLs are empty");
}
}
};
Log.v(TAG, YOUTUBE_URL_PREFIX + param);
mYoutubeExtractor.extract(YOUTUBE_URL_PREFIX + param, false, true);
}
}
代码示例来源:origin: HaarigerHarald/android-youtubeExtractor
@Override
public void run() {
final YouTubeExtractor ytEx = new YouTubeExtractor(getInstrumentation()
.getTargetContext()) {
@Override
public void onExtractionComplete(SparseArray<YtFile> ytFiles, VideoMeta videoMeta) {
assertEquals(expMeta.getVideoId(), videoMeta.getVideoId());
assertEquals(expMeta.getTitle(),videoMeta.getTitle());
assertEquals(expMeta.getAuthor(), videoMeta.getAuthor());
assertEquals(expMeta.getChannelId(), videoMeta.getChannelId());
assertEquals(expMeta.getVideoLength(), videoMeta.getVideoLength());
assertNotSame(0, videoMeta.getViewCount());
assertNotNull(ytFiles);
int itag = ytFiles.keyAt(new Random().nextInt(ytFiles.size()));
testUrl = ytFiles.get(itag).getUrl();
Log.d(EXTRACTOR_TEST_TAG, "Testing itag: " + itag +", url:" + testUrl);
signal.countDown();
}
};
ytEx.extract(youtubeLink, false, true);
}
});
代码示例来源:origin: HaarigerHarald/android-youtubeExtractor
@Override
public void run() {
final YouTubeExtractor ytEx = new YouTubeExtractor(getInstrumentation()
.getTargetContext()) {
@Override
public void onExtractionComplete(SparseArray<YtFile> ytFiles, VideoMeta videoMeta) {
assertNotNull(ytFiles);
int numNotDash = 0;
int itag;
for (int i = 0; i < ytFiles.size(); i++) {
itag = ytFiles.keyAt(i);
if (ytFiles.get(itag).getFormat().isDashContainer()) {
numNotDash = i;
break;
}
}
itag = ytFiles.keyAt(new Random().nextInt(ytFiles.size() - numNotDash) + numNotDash);
testUrl = ytFiles.get(itag).getUrl();
Log.d(EXTRACTOR_TEST_TAG, "Testing itag: " + itag +", url:" + testUrl);
signal.countDown();
}
};
ytEx.extract(youtubeLink, true, true);
}
});
内容来源于网络,如有侵权,请联系作者删除!