This commit is contained in:
2024-11-14 17:32:31 +01:00
parent 8fca6d5a88
commit 6f2cf5a843
3 changed files with 74 additions and 40 deletions
+56 -27
View File
@@ -1,45 +1,74 @@
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Array;
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<>();
static ArrayList<File> orphanDownloadedTorrentList = new ArrayList<>();
static TorrentList transmission = new TorrentList();
static DownloadList drive = new DownloadList();
static ArrayList<File> downloadedTorrentFiles = new ArrayList<>();
static ArrayList<File> copiedTorrentFiles = new ArrayList<>();
static ArrayList<File> notCopiedTorrentFiles = new ArrayList<>();
static ArrayList<File> notCopiedPreferedTorrentFiles = new ArrayList<>();
static String[] preferedfiles = {"tushy","blacked","blackedraw","tushyraw","bangbus","woodmancasting","private"};
static boolean find;
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");
/* Vide la liste des torrent orphelins */
orphanDownloadedTorrentList.clear();
/* Construit la liste des torrents téléchargés */
System.out.println("Création de la liste des torrents téléchargés");
downloadedTorrentFiles = drive.RequestList("\\F:\\var\\lib\\transmission-daemon\\downloads");
/* Construit la liste des torrents copiés */
System.out.println("Création de la liste des torrents copiés");
copiedTorrentFiles = drive.RequestList("\\\\dartydisk6\\downloads");
/* Construit la liste des torrents actifs */
System.out.println("Création de la liste des torrents actifs");
ArrayList<Torrent> activeTorrentList = transmission.RequestList();
/* Etablit la liste des torrents téléchargés mais plus actifs */
System.out.println("Création de la liste des torrents orphelins");
for (File file: downloadedTorrentFiles) {
if (!transmission.FindTorrentByName(file.getName())) {
orphanDownloadedTorrentList.add(file);
}
}
orphanDownloadedTorrentList.forEach(file -> {
System.out.println("Orphean :" + file.getAbsolutePath());
System.out.println("sudo rm -R \""+file.getName()+"\"");
});
orphanList.forEach(file -> {
for (File file2 : copiedFiles) {
if (file.getName().equals(file2.getName())) {
break;
/* Etablit la liste des torrents téléchargés pas copiés */
System.out.println("Création de la liste des torrents à copier");
for (File file: downloadedTorrentFiles) {
find = false;
for (File copiedFile : copiedTorrentFiles) {
if (file.getName().equals(copiedFile.getName())) {
find = true;
}
}
System.out.println("Orphean :" + file.getName());
if (!find) {
notCopiedTorrentFiles.add(file);
for (String name : preferedfiles) {
if (file.getName().toLowerCase().contains(name)) {
notCopiedPreferedTorrentFiles.add(file);
}
}
}
}
notCopiedTorrentFiles.forEach(file -> {
System.out.println("Not Copied :" + file.getAbsolutePath());
});
notCopiedPreferedTorrentFiles.forEach(file -> {
System.out.println("Not Copied Prefered :" + file.getAbsolutePath());
});
}
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);
}
}
}