本文整理了Java中at.huber.youtubeExtractor.YtFile.getFormat()
方法的一些代码示例,展示了YtFile.getFormat()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YtFile.getFormat()
方法的具体详情如下:
包路径:at.huber.youtubeExtractor.YtFile
类名称:YtFile
方法名:getFormat
[英]Format data for the specific file.
[中]格式化特定文件的数据。
代码示例来源:origin: HaarigerHarald/android-youtubeExtractor
@Override
public void onClick(View v) {
String filename;
if (videoTitle.length() > 55) {
filename = videoTitle.substring(0, 55) + "." + ytfile.getFormat().getExt();
} else {
filename = videoTitle + "." + ytfile.getFormat().getExt();
}
filename = filename.replaceAll("[\\\\><\"|*?%:#/]", "");
downloadFromUrl(ytfile.getUrl(), videoTitle, filename);
finish();
}
});
代码示例来源:origin: HaarigerHarald/android-youtubeExtractor
private void addButtonToMainLayout(final String videoTitle, final YtFile ytfile) {
// Display some buttons and let the user choose the format
String btnText = (ytfile.getFormat().getHeight() == -1) ? "Audio " +
ytfile.getFormat().getAudioBitrate() + " kbit/s" :
ytfile.getFormat().getHeight() + "p";
btnText += (ytfile.getFormat().isDashContainer()) ? " dash" : "";
Button btn = new Button(this);
btn.setText(btnText);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
String filename;
if (videoTitle.length() > 55) {
filename = videoTitle.substring(0, 55) + "." + ytfile.getFormat().getExt();
} else {
filename = videoTitle + "." + ytfile.getFormat().getExt();
}
filename = filename.replaceAll("[\\\\><\"|*?%:#/]", "");
downloadFromUrl(ytfile.getUrl(), videoTitle, filename);
finish();
}
});
mainLayout.addView(btn);
}
代码示例来源:origin: HaarigerHarald/android-youtubeExtractor
private void addFormatToList(YtFile ytFile, SparseArray<YtFile> ytFiles) {
int height = ytFile.getFormat().getHeight();
if (height != -1) {
for (YtFragmentedVideo frVideo : formatsToShowList) {
if (frVideo.height == height && (frVideo.videoFile == null ||
frVideo.videoFile.getFormat().getFps() == ytFile.getFormat().getFps())) {
return;
}
}
}
YtFragmentedVideo frVideo = new YtFragmentedVideo();
frVideo.height = height;
if (ytFile.getFormat().isDashContainer()) {
if (height > 0) {
frVideo.videoFile = ytFile;
frVideo.audioFile = ytFiles.get(ITAG_FOR_AUDIO);
} else {
frVideo.audioFile = ytFile;
}
} else {
frVideo.videoFile = ytFile;
}
formatsToShowList.add(frVideo);
}
代码示例来源:origin: HaarigerHarald/android-youtubeExtractor
@Override
public void onExtractionComplete(SparseArray<YtFile> ytFiles, VideoMeta vMeta) {
mainProgressBar.setVisibility(View.GONE);
if (ytFiles == null) {
TextView tv = new TextView(DownloadActivity.this);
tv.setText(R.string.app_update);
tv.setMovementMethod(LinkMovementMethod.getInstance());
mainLayout.addView(tv);
return;
}
formatsToShowList = new ArrayList<>();
for (int i = 0, itag; i < ytFiles.size(); i++) {
itag = ytFiles.keyAt(i);
YtFile ytFile = ytFiles.get(itag);
if (ytFile.getFormat().getHeight() == -1 || ytFile.getFormat().getHeight() >= 360) {
addFormatToList(ytFile, ytFiles);
}
}
Collections.sort(formatsToShowList, new Comparator<YtFragmentedVideo>() {
@Override
public int compare(YtFragmentedVideo lhs, YtFragmentedVideo rhs) {
return lhs.height - rhs.height;
}
});
for (YtFragmentedVideo files : formatsToShowList) {
addButtonToMainLayout(vMeta.getTitle(), files);
}
}
}.extract(youtubeLink, true, false);
代码示例来源:origin: HaarigerHarald/android-youtubeExtractor
@Override
public void onExtractionComplete(SparseArray<YtFile> ytFiles, VideoMeta vMeta) {
mainProgressBar.setVisibility(View.GONE);
if (ytFiles == null) {
// Something went wrong we got no urls. Always check this.
finish();
return;
}
// Iterate over itags
for (int i = 0, itag; i < ytFiles.size(); i++) {
itag = ytFiles.keyAt(i);
// ytFile represents one file with its url and meta data
YtFile ytFile = ytFiles.get(itag);
// Just add videos in a decent format => height -1 = audio
if (ytFile.getFormat().getHeight() == -1 || ytFile.getFormat().getHeight() >= 360) {
addButtonToMainLayout(vMeta.getTitle(), ytFile);
}
}
}
}.extract(youtubeLink, true, false);
代码示例来源:origin: HaarigerHarald/android-youtubeExtractor
btnText = "Audio " + ytFrVideo.audioFile.getFormat().getAudioBitrate() + " kbit/s";
else
btnText = (ytFrVideo.videoFile.getFormat().getFps() == 60) ? ytFrVideo.height + "p60" :
ytFrVideo.height + "p";
Button btn = new Button(this);
代码示例来源:origin: HaarigerHarald/android-youtubeExtractor
@Override
public void onClick(View v) {
String filename;
if (videoTitle.length() > 55) {
filename = videoTitle.substring(0, 55);
} else {
filename = videoTitle;
}
filename = filename.replaceAll("[\\\\><\"|*?%:#/]", "");
filename += (ytFrVideo.height == -1) ? "" : "-" + ytFrVideo.height + "p";
String downloadIds = "";
boolean hideAudioDownloadNotification = false;
if (ytFrVideo.videoFile != null) {
downloadIds += downloadFromUrl(ytFrVideo.videoFile.getUrl(), videoTitle,
filename + "." + ytFrVideo.videoFile.getFormat().getExt(), false);
downloadIds += "-";
hideAudioDownloadNotification = true;
}
if (ytFrVideo.audioFile != null) {
downloadIds += downloadFromUrl(ytFrVideo.audioFile.getUrl(), videoTitle,
filename + "." + ytFrVideo.audioFile.getFormat().getExt(), hideAudioDownloadNotification);
}
if (ytFrVideo.audioFile != null)
cacheDownloadIds(downloadIds);
finish();
}
});
内容来源于网络,如有侵权,请联系作者删除!