Update
This commit is contained in:
parent
25ca602820
commit
f60ec6ef27
|
|
@ -16,6 +16,7 @@ import com.github.catvod.crawler.Spider;
|
||||||
import com.github.catvod.utils.Image;
|
import com.github.catvod.utils.Image;
|
||||||
import com.github.catvod.utils.Util;
|
import com.github.catvod.utils.Util;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
|
@ -25,6 +26,7 @@ import java.util.Collections;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class Local extends Spider {
|
public class Local extends Spider {
|
||||||
|
|
||||||
|
|
@ -103,18 +105,18 @@ public class Local extends Spider {
|
||||||
Vod vod = new Vod();
|
Vod vod = new Vod();
|
||||||
vod.setVodId(file.getAbsolutePath());
|
vod.setVodId(file.getAbsolutePath());
|
||||||
vod.setVodName(file.getName());
|
vod.setVodName(file.getName());
|
||||||
vod.setVodPic(file.isFile() ? getBase64(file) : Image.FOLDER);
|
vod.setVodPic(file.isFile() ? Proxy.getUrl() + "?do=local&path=" + Base64.encodeToString(file.getAbsolutePath().getBytes(), Base64.DEFAULT | Base64.URL_SAFE) : Image.FOLDER);
|
||||||
vod.setVodRemarks(format.format(file.lastModified()));
|
vod.setVodRemarks(format.format(file.lastModified()));
|
||||||
vod.setVodTag(file.isDirectory() ? "folder" : "file");
|
vod.setVodTag(file.isDirectory() ? "folder" : "file");
|
||||||
return vod;
|
return vod;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getBase64(File file) {
|
private static byte[] getBase64(String path) {
|
||||||
Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(file.getAbsolutePath(), MediaStore.Images.Thumbnails.MINI_KIND);
|
Bitmap bitmap = ThumbnailUtils.createVideoThumbnail(path, MediaStore.Images.Thumbnails.MINI_KIND);
|
||||||
if (bitmap == null) return Image.VIDEO;
|
if (bitmap == null) return Base64.decode(Image.VIDEO.split("base64,")[1], Base64.DEFAULT);
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
|
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
|
||||||
return "data:image/jpg;base64," + Base64.encodeToString(baos.toByteArray(), Base64.DEFAULT);
|
return baos.toByteArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<Sub> getSubs(String path) {
|
private List<Sub> getSubs(String path) {
|
||||||
|
|
@ -128,4 +130,13 @@ public class Local extends Spider {
|
||||||
}
|
}
|
||||||
return subs;
|
return subs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Object[] proxy(Map<String, String> params) {
|
||||||
|
String path = new String(Base64.decode(params.get("path"), Base64.DEFAULT | Base64.URL_SAFE));
|
||||||
|
Object[] result = new Object[3];
|
||||||
|
result[0] = 200;
|
||||||
|
result[1] = "application/octet-stream";
|
||||||
|
result[2] = new ByteArrayInputStream(getBase64(path));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -21,6 +21,8 @@ public class Proxy extends Spider {
|
||||||
return Bili.proxy(params);
|
return Bili.proxy(params);
|
||||||
case "webdav":
|
case "webdav":
|
||||||
return WebDAV.vod(params);
|
return WebDAV.vod(params);
|
||||||
|
case "local":
|
||||||
|
return Local.proxy(params);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
748fbc51b767528466bdbbaee22c8803
|
c9605097e68348ad1779fc6047529c96
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue