feat: 初始化XMBOX项目

This commit is contained in:
Tosencen
2025-07-03 06:16:21 +08:00
commit 0a10f73143
914 changed files with 71817 additions and 0 deletions
@@ -0,0 +1,23 @@
package com.xunlei.downloadlib;
import java.text.DecimalFormat;
import java.util.Arrays;
import java.util.List;
public class Util {
private static final List<String> VIDEO = Arrays.asList("avi", "flv", "mkv", "mov", "mp4", "mpeg", "mpe", "mpg", "wmv");
private static final List<String> AUDIO = Arrays.asList("aac", "ape", "flac", "mp3", "m4a", "ogg");
private static final String[] UNITS = new String[]{"bytes", "KB", "MB", "GB", "TB"};
private static final long MINIMAL = 30 * 1024 * 1024;
public static boolean isMedia(String ext, long size) {
return (VIDEO.contains(ext) || AUDIO.contains(ext)) && size > MINIMAL;
}
public static String size(long size) {
if (size <= 0) return "";
int group = (int) (Math.log10(size) / Math.log10(1024));
return "[" + new DecimalFormat("###0.#").format(size / Math.pow(1024, group)) + " " + UNITS[group] + "] ";
}
}