Clean webdav code
This commit is contained in:
parent
14423e2f9b
commit
943e8b1451
|
|
@ -79,6 +79,7 @@ public class Drive {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Sardine getWebdav() {
|
public Sardine getWebdav() {
|
||||||
|
if (webdav == null) init();
|
||||||
return webdav;
|
return webdav;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -86,11 +87,10 @@ public class Drive {
|
||||||
return new Class(getName(), getName(), "1");
|
return new Class(getName(), getName(), "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
public Drive init() {
|
private void init() {
|
||||||
webdav = new OkHttpSardine();
|
webdav = new OkHttpSardine();
|
||||||
webdav.setCredentials(getUser(), getPass());
|
webdav.setCredentials(getUser(), getPass());
|
||||||
setPath(Uri.parse(getServer()).getPath());
|
setPath(Uri.parse(getServer()).getPath());
|
||||||
return this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vod vod(DavResource item, String vodPic) {
|
public Vod vod(DavResource item, String vodPic) {
|
||||||
|
|
|
||||||
|
|
@ -73,7 +73,7 @@ public class WebDAV extends Spider {
|
||||||
fetchRule();
|
fetchRule();
|
||||||
List<Class> classes = new ArrayList<>();
|
List<Class> classes = new ArrayList<>();
|
||||||
LinkedHashMap<String, List<Filter>> filters = new LinkedHashMap<>();
|
LinkedHashMap<String, List<Filter>> filters = new LinkedHashMap<>();
|
||||||
for (Drive drive : drives) classes.add(drive.init().toType());
|
for (Drive drive : drives) classes.add(drive.toType());
|
||||||
for (Class item : classes) filters.put(item.getTypeId(), getFilter());
|
for (Class item : classes) filters.put(item.getTypeId(), getFilter());
|
||||||
return Result.string(classes, filters);
|
return Result.string(classes, filters);
|
||||||
}
|
}
|
||||||
|
|
@ -130,8 +130,7 @@ public class WebDAV extends Spider {
|
||||||
@Override
|
@Override
|
||||||
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
public String playerContent(String flag, String id, List<String> vipFlags) throws Exception {
|
||||||
String[] ids = id.split("~~~");
|
String[] ids = id.split("~~~");
|
||||||
String key = ids[0].contains("/") ? ids[0].substring(0, ids[0].indexOf("/")) : ids[0];
|
return Result.get().url(getProxyUrl(ids[0])).subs(getSub(ids)).string();
|
||||||
return Result.get().url(getProxyUrl(key, ids[0])).subs(getSub(ids)).string();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<DavResource> getList(Drive drive, String path, List<String> ext) throws Exception {
|
private List<DavResource> getList(Drive drive, String path, List<String> ext) throws Exception {
|
||||||
|
|
@ -172,25 +171,25 @@ public class WebDAV extends Spider {
|
||||||
String[] split = text.split("@@@");
|
String[] split = text.split("@@@");
|
||||||
String name = split[0];
|
String name = split[0];
|
||||||
String ext = split[1];
|
String ext = split[1];
|
||||||
String key = split[2].contains("/") ? split[2].substring(0, split[2].indexOf("/")) : split[2];
|
String url = getProxyUrl(split[2]);
|
||||||
String url = getProxyUrl(key, split[2]);
|
|
||||||
sub.add(Sub.create().name(name).ext(ext).url(url));
|
sub.add(Sub.create().name(name).ext(ext).url(url));
|
||||||
}
|
}
|
||||||
return sub;
|
return sub;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getProxyUrl(String key, String path) {
|
private String getProxyUrl(String url) {
|
||||||
return Proxy.getUrl() + "?do=webdav" + "&key=" + key + "&url=" + getDrive(key).getHost() + path.replace(key, "");
|
return Proxy.getUrl() + "?do=webdav&url=" + url;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Object[] vod(Map<String, String> params) throws IOException {
|
public static Object[] vod(Map<String, String> params) throws IOException {
|
||||||
String key = params.get("key");
|
|
||||||
String url = params.get("url");
|
String url = params.get("url");
|
||||||
|
String key = url.contains("/") ? url.substring(0, url.indexOf("/")) : url;
|
||||||
|
url = url.substring(key.length());
|
||||||
Drive drive = getDrive(key);
|
Drive drive = getDrive(key);
|
||||||
Object[] result = new Object[3];
|
Object[] result = new Object[3];
|
||||||
result[0] = 200;
|
result[0] = 200;
|
||||||
result[1] = "application/octet-stream";
|
result[1] = "application/octet-stream";
|
||||||
result[2] = drive.getWebdav().get(url);
|
result[2] = drive.getWebdav().get(drive.getHost() + url);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -1 +1 @@
|
||||||
962a1af0469ede7b575046c69c1f52d3
|
be7bb5c4900ed56f8cc189aeabf0a989
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue