Files
ManageTorrent/src/Main.java
T
2024-11-14 17:32:31 +01:00

74 lines
3.2 KiB
Java

import java.io.File;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.ArrayList;
public class Main {
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");
/* 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()+"\"");
});
/* 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;
}
}
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());
});
}
}