Initial
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
public class Download {
|
||||
String name;
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import java.util.ArrayList;
|
||||
import java.io.File;
|
||||
|
||||
|
||||
public class DownloadList {
|
||||
private ArrayList<File> downloadList;
|
||||
|
||||
ArrayList<File> RequestList(String path)
|
||||
{
|
||||
File parentDirectory = new File(path);
|
||||
downloadList = new ArrayList<>();
|
||||
if (parentDirectory.exists() && parentDirectory.isDirectory())
|
||||
{
|
||||
for (File fileNiv1: parentDirectory.listFiles())
|
||||
{
|
||||
//files.add(file);
|
||||
if (fileNiv1.isDirectory())
|
||||
{
|
||||
downloadList.add(fileNiv1);
|
||||
if (fileNiv1.isDirectory()) {
|
||||
for (File directoryNiv1 : fileNiv1.listFiles()) {
|
||||
if (directoryNiv1.isDirectory() && !directoryNiv1.getName().equals("Screens")) {
|
||||
downloadList.add(directoryNiv1);
|
||||
if (directoryNiv1.isDirectory()) {
|
||||
for (File fileNiv2 : directoryNiv1.listFiles()) {
|
||||
if (!fileNiv2.getName().equals("Screens") && fileNiv2.isDirectory()) {
|
||||
downloadList.add(fileNiv2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}//System.out.println("Dir :"+file.getName());
|
||||
}
|
||||
}
|
||||
//for (File file:downloadList
|
||||
// ) {
|
||||
// System.out.println(file.getName());
|
||||
//}
|
||||
//System.out.println(files[0].getName());
|
||||
}
|
||||
return downloadList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class Main {
|
||||
|
||||
static ArrayList<File> orphanList = new ArrayList<>();
|
||||
static TorrentList torrentList = new TorrentList();
|
||||
static DownloadList downloadList = new DownloadList();
|
||||
static DownloadList copiedList = new DownloadList();
|
||||
static ArrayList<File> downloadedFiles = new ArrayList<>();
|
||||
|
||||
public static void main(String[] args) throws IOException, InterruptedException {
|
||||
System.out.println("ManageTorrent by SDA Corporation");
|
||||
orphanList.clear();
|
||||
downloadedFiles = downloadList.RequestList("\\F:\\var\\lib\\transmission-daemon\\downloads");
|
||||
ArrayList<File> copiedFiles = copiedList.RequestList("\\\\dartydisk6\\downloads");
|
||||
|
||||
|
||||
|
||||
orphanList.forEach(file -> {
|
||||
for (File file2 : copiedFiles) {
|
||||
if (file.getName().equals(file2.getName())) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
System.out.println("Orphean :" + file.getName());
|
||||
});
|
||||
}
|
||||
|
||||
public void ListTorrents() throws IOException, InterruptedException {
|
||||
ArrayList<Torrent> torrentDownloadedList = torrentList.RequestList();
|
||||
|
||||
for (File file:downloadedFiles
|
||||
) {
|
||||
for (Torrent torrent:torrentDownloadedList
|
||||
) {
|
||||
if (file.getName().equals(torrent.name)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
orphanList.add(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
public class Torrent {
|
||||
String name;
|
||||
String status;
|
||||
String ratio;
|
||||
|
||||
|
||||
public Torrent(String name, String status, String ratio) {
|
||||
this.name = name;
|
||||
this.status = status;
|
||||
this.ratio = ratio;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class TorrentList {
|
||||
ArrayList<Torrent> torrentArrayList = new ArrayList<>();
|
||||
|
||||
ArrayList RequestList() throws IOException, InterruptedException {
|
||||
final Process p = Runtime.getRuntime().exec("cmd /c C:\\PROGRA~1\\Transmission\\transmission-remote.exe seedbox.sda.zone:19091 -l");
|
||||
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
||||
String line = null;
|
||||
Integer i=0;
|
||||
try {
|
||||
while ((line = input.readLine()) != null)
|
||||
AddTorrentToList(line,i);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}).start();
|
||||
p.waitFor();
|
||||
return this.torrentArrayList;
|
||||
}
|
||||
void AddTorrentToList(String line, Integer i) {
|
||||
String name = null;
|
||||
String ratio = null;
|
||||
String status = null;
|
||||
try {
|
||||
ratio = line.substring(51,58);
|
||||
} catch (StringIndexOutOfBoundsException e) {
|
||||
//System.out.println(e);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
status = line.substring(59,65);
|
||||
} catch (StringIndexOutOfBoundsException e) {
|
||||
//System.out.println(e);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
name = line.substring(72);
|
||||
} catch (StringIndexOutOfBoundsException e) {
|
||||
//System.out.println(e);
|
||||
return;
|
||||
}
|
||||
Torrent e = new Torrent("name", "status", "ratio");
|
||||
this.torrentArrayList.add(e);
|
||||
//this.torrentArrayList.set(i, new Torrent("name", "status", "ratio"));
|
||||
//System.out.println(line);
|
||||
//System.out.println(name + " " + status + " " + ratio);
|
||||
//System.out.println(status);
|
||||
//System.out.println(ratio);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user