Support subs for push local file
This commit is contained in:
parent
eefb8bb92d
commit
3cdbc57837
|
|
@ -3,6 +3,8 @@
|
||||||
package="com.github.catvod">
|
package="com.github.catvod">
|
||||||
|
|
||||||
<uses-permission android:name="android.permission.INTERNET" />
|
<uses-permission android:name="android.permission.INTERNET" />
|
||||||
|
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
|
||||||
|
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||||
|
|
||||||
<application
|
<application
|
||||||
android:icon="@mipmap/ic_launcher"
|
android:icon="@mipmap/ic_launcher"
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,16 @@ import android.content.Context;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.github.catvod.bean.Result;
|
import com.github.catvod.bean.Result;
|
||||||
|
import com.github.catvod.bean.Sub;
|
||||||
import com.github.catvod.bean.Vod;
|
import com.github.catvod.bean.Vod;
|
||||||
|
import com.github.catvod.utils.Utils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Push extends Ali {
|
public class Push extends Ali {
|
||||||
|
|
||||||
|
|
@ -26,12 +31,24 @@ public class Push extends Ali {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String playerContent(String flag, String id, List<String> vipFlags) {
|
public String playerContent(String flag, String id, List<String> vipFlags) {
|
||||||
if (flag.equals("直連")) return Result.get().url(id).string();
|
if (flag.equals("直連")) return Result.get().url(id).subs(getSubs(id)).string();
|
||||||
if (flag.equals("嗅探")) return Result.get().parse().url(id).string();
|
if (flag.equals("嗅探")) return Result.get().parse().url(id).string();
|
||||||
if (flag.equals("解析")) return Result.get().parse().jx().url(id).string();
|
if (flag.equals("解析")) return Result.get().parse().jx().url(id).string();
|
||||||
return super.playerContent(flag, id, vipFlags);
|
return super.playerContent(flag, id, vipFlags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<Sub> getSubs(String url) {
|
||||||
|
if (!url.startsWith("file://")) return Collections.emptyList();
|
||||||
|
File file = new File(url.replace("file://", ""));
|
||||||
|
if (file.getParentFile() == null) return Collections.emptyList();
|
||||||
|
List<Sub> subs = new ArrayList<>();
|
||||||
|
for (File temp : Objects.requireNonNull(file.getParentFile().listFiles())) {
|
||||||
|
String ext = Utils.getExt(temp.getName());
|
||||||
|
if (Utils.isSub(ext)) subs.add(Sub.create().name(Utils.removeExt(temp.getName())).ext(ext).url("file://" + temp.getAbsolutePath()));
|
||||||
|
}
|
||||||
|
return subs;
|
||||||
|
}
|
||||||
|
|
||||||
private Vod vod(String url) {
|
private Vod vod(String url) {
|
||||||
Vod vod = new Vod();
|
Vod vod = new Vod();
|
||||||
vod.setVodId(url);
|
vod.setVodId(url);
|
||||||
|
|
|
||||||
|
|
@ -45,6 +45,10 @@ public class Utils {
|
||||||
return ext.equals("srt") || ext.equals("ass") || ext.equals("ssa");
|
return ext.equals("srt") || ext.equals("ass") || ext.equals("ssa");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getExt(String name) {
|
||||||
|
return name.substring(name.lastIndexOf(".") + 1);
|
||||||
|
}
|
||||||
|
|
||||||
public static String getSize(double size) {
|
public static String getSize(double size) {
|
||||||
if (size <= 0) return "";
|
if (size <= 0) return "";
|
||||||
if (size > 1024 * 1024 * 1024 * 1024.0) {
|
if (size > 1024 * 1024 * 1024 * 1024.0) {
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
14916e05a5fabbc24aad217565c93f7b
|
0b5053aea39f2bdfa8196b8685daa086
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue