Clean code
This commit is contained in:
parent
1c4ebf9aeb
commit
843cde8576
|
|
@ -110,10 +110,6 @@ public class Item {
|
|||
return getType() == 0 || getType() == 2 || getType() == 5;
|
||||
}
|
||||
|
||||
public String getExt() {
|
||||
return Util.getExt(getName());
|
||||
}
|
||||
|
||||
public String getVodId(String id) {
|
||||
return id + getPath() + "/" + getName();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -238,7 +238,10 @@ public class AList extends Spider {
|
|||
|
||||
private String findSubs(String path, List<Item> items) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (Item item : items) if (Util.isSub(item.getExt())) sb.append("~~~").append(item.getName()).append("@@@").append(item.getExt()).append("@@@").append(item.getVodId(path));
|
||||
for (Item item : items) {
|
||||
String ext = Util.getExt(item.getName());
|
||||
if (Util.isSub(ext)) sb.append("~~~").append(item.getName()).append("@@@").append(ext).append("@@@").append(item.getVodId(path));
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ public class Samba extends Spider {
|
|||
while (iterator.hasNext()) {
|
||||
FileIdBothDirectoryInformation item = iterator.next();
|
||||
if (isFolder(item) && item.getFileName().startsWith(".")) iterator.remove();
|
||||
if (isFile(item) && !Util.MEDIA.contains(Util.getExt(item.getFileName()))) iterator.remove();
|
||||
if (isFile(item) && !Util.isMedia(item.getFileName())) iterator.remove();
|
||||
}
|
||||
Collections.sort(items, (o1, o2) -> {
|
||||
if (isFolder(o1) && isFile(o2)) return -1;
|
||||
|
|
|
|||
|
|
@ -144,7 +144,7 @@ public class WebDAV extends Spider {
|
|||
|
||||
private List<DavResource> getSubs(List<DavResource> items) {
|
||||
List<DavResource> subs = new ArrayList<>();
|
||||
for (DavResource item : items) if (Util.isSub(getExt(item))) subs.add(item);
|
||||
for (DavResource item : items) if (Util.isSub(item.getName())) subs.add(item);
|
||||
return subs;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -45,8 +45,8 @@ public class Util {
|
|||
return RULE.matcher(url).find();
|
||||
}
|
||||
|
||||
public static boolean isSub(String ext) {
|
||||
return SUB.contains(ext);
|
||||
public static boolean isSub(String text) {
|
||||
return SUB.contains(getExt(text).toLowerCase());
|
||||
}
|
||||
|
||||
public static boolean isMedia(String text) {
|
||||
|
|
@ -54,7 +54,7 @@ public class Util {
|
|||
}
|
||||
|
||||
public static String getExt(String name) {
|
||||
return name.contains(".") ? name.substring(name.lastIndexOf(".") + 1) : name;
|
||||
return name.contains(".") ? name.substring(name.lastIndexOf(".") + 1).toLowerCase() : name.toLowerCase();
|
||||
}
|
||||
|
||||
public static String getSize(double size) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue