#2761
|
|||
|
|||
Ordner löschen nach Packetverwalter Regel
Ich könnte Unterstützung für ein script brauchen welches mir Ordner löscht nachdem die enthalten Videodatei(en) verschoben wurde.
Mein Ziel wäre: Video-Dateien (Filme/Serien) werden nach dem DL & entpacken in ein Verzeichnis meiner Wahl verschoben, und alles andere wird gelöscht Anmerkung: die heruntergeladenen Pakete werden natürlich ohnedies nach dem entpacken gelöscht auf Basis der Standardeinstellungen in JD. Bisher habe ich es zustande gebracht dass eine Paketverwalter Regel "wenn Video dann verschiebe" eine Teil der Aufgabe erledigt. Derzeitige Situation (möglicherweise zu "umständlich"?): Es wird auf HD1 heruntergeladen und nach HD2 entpackt. Auf HD2 befindet sich dann ein Ordner mit der/den Videodatei(en) die mit der aktuellen Regel auch korrekt auf HD3 verschoben werden. Aber der Ordner ist noch da, meist mit einer .nfo Datei und tw. auch mit einer .txt und/oder .url Datei, und der ganze Ordner soll eben in solch einem Fall (wenn Video) gelöscht werden. ABER, dies soll nur dann so wie beschrieben passieren, wenn es sich um "Video-downloads" handelt die vorher entpackt werden müssen, da ich hin und wieder zB auch Programm Pakete downloade soll dieser ganze Vorgang in solch einem Fall natürlich nicht passieren... An was ich bisher noch nicht gedacht habe ist ob ich evtl. anhand bestimmter Kriterien die Dateien auch gleich in spezielle Ordner verschieben lassen kann zB Ordner "Filme" oder "Serien"? ZB haben Serienfolgen im Dateinamen immer ein zB s01e03 enthalten, vielleicht gibt es auch sinnvollere Kriterien? Bin für jede Unterstützung dankbar! |
#2762
|
|||
|
|||
Hello Team,
Can you make a script that will check all files in the LinkGrabber, then compare (Name+Size) and delete the duplicate files from LinkGrabber? Thank you in advance. Last edited by mostafatefa2009; 21.02.2024 at 16:01. |
#2763
|
|||
|
|||
Quote:
Obviously no one has the time to help or maybe my request is ridiculous so I won't bother anymore. Thanks anyway. Bye bye. |
#2764
|
|||
|
|||
Quote:
I would instead suggest adding the links with the LinkGrabber and then extracting the JSON structure for the LinkGrabber table. Then, using a scripting language (Python, R, etc.), do a regex extraction for the PREFIX (video title?) and SUFFIX (resolution), and, grouping by PREFIX, determine what is the maximal SUFFIX, and pick the correspond URL. Then, remove the links from the LinkGrabber, and only add those picked URLs. |
#2765
|
|||
|
|||
Quote:
I asked for help because, despite the apparent simplicity of being able to use the EventScripter language to execute this operation directly in the LinkGrabber, I felt incapable of doing it alone. So, even if I managed to extract the linkgrabber result to try to create the same kind of script outside of Jdownloader, I won't be sure I'll succeed either. But by extracting the result from the linkgrabber, it would allow me to obtain the real links hidden behind a video with several different qualities so it would be a good start. (Hoping the Json file includes this kind of information of course). So..., all I have to do is figure out how to extract the linkgrabber result to a Json file or even a simple text file. Do you have an idea ? I can't find any information on the internet. Thanks in advance. |
#2766
|
|||
|
|||
Quote:
The LinkGrabber json can be found inside a zip at "cfg/linkcollector###.zip" below the JDownloader directory, where ### is a number. It might depend on your system/environment. Are you comfortable in any scripting languages? It may be easiest to work in whatever you are already comfortable with as long as it has JSON support. 1. Retrieve the linkcollector zip file and extract. 2. Take the extracted JSON file(s) and read into a data structure where you can do group-by and select operations (will depend on language). 3. For each extracted title, determine the PREFIX and SUFFIX by regex (e.g., "([^_]+)_([^_]+)p"). 4. Grouping by PREFIX, determine the maximal SUFFIX. Select the corresponding URL. 5. Take all of those selected URLs and put back into an empty LinkGrabber table. (If you need more help, it might be best to move this discussion to another thread to avoid polluting the thread with non-Event Scripter scripts.) |
#2767
|
|||
|
|||
Quote:
HTML Code:
// Define function to delete duplicate files
function deleteDuplicateFiles() {
var links = linkcollector.getDownloadLinks();
// Create an object to store file names and their occurrences
var fileOccurrences = {};
// Iterate through the links and count occurrences of each file name
for (var i = 0; i < links.length; i++) {
var fileName = links[i].getName();
if (fileOccurrences[fileName]) {
fileOccurrences[fileName]++;
} else {
fileOccurrences[fileName] = 1;
}
}
// Iterate through the links again and delete duplicates
for (var i = 0; i < links.length; i++) {
var fileName = links[i].getName();
// Delete duplicate files (keep only one copy)
if (fileOccurrences[fileName] > 1) {
fileOccurrences[fileName]--;
linkcollector.removePackage(links[i].getPackage());
i--; // Adjust index to account for removed link
}
}
}
// Register the function to be called on linkgrabber refresh
linkgrabber.onRefresh(function() {
// Delay the execution to ensure that the linkgrabber is fully refreshed
setTimeout(deleteDuplicateFiles, 1000);
});
|
#2768
|
|||
|
|||
Quote:
Code:
/* remove lower resolution trigger : linkgrabber context menu button pressed support : https://board.jdownloader.org/sendmessage.php?do=mailmember&u=73437 */ if (name == "cleanup") { var package = lgSelection.contextPackage; var add = function(name, res, str) { remove.push(name.replace(res, str)); } var remove = []; package.downloadLinks.forEach(function(link) { var name = link.name; var res = "1080p"; if (name.indexOf(res) > -1) { add(name, res, "720p"); add(name, res, "480p"); add(name, res, "360p"); add(name, res, "240p"); } res = "720p"; if (name.indexOf(res) > -1) { add(name, res, "480p"); add(name, res, "360p"); add(name, res, "240p"); } res = "480p" if (name.indexOf(res) > -1) { add(name, res, "360p"); add(name, res, "240p"); } res = "360p" if (name.indexOf(res) > -1) { add(name, res, "240p"); } }) package.downloadLinks.forEach(function(link) { if (remove.indexOf(link.name) > -1) { link.enabled = false; //link.remove(); } }) } Last edited by mgpai; 28.02.2024 at 14:35. Reason: Removed reduntant code |
#2769
|
|||
|
|||
mgpai Kindly help with my request
Quote:
|
#2770
|
|||
|
|||
Quote:
Code:
/* remove files with matching name and size trigger : click 'test run' button in the top panel suopport: https://board.jdownloader.org/sendmessage.php?do=mailmember&u=73437 */ var keys = []; getAllCrawledLinks().forEach(function(link) { var size = link.bytesTotal; if (size > 0) { var key = link.name + size; if (keys.indexOf(key) == -1) { keys.push(key); } else { link.enabled = false; //link.remove; } } }) |
#2771
|
|||
|
|||
Awesome! That really worked! Can you make it remove the duplicates instead?
Last edited by mostafatefa2009; 28.02.2024 at 16:28. |
#2772
|
|||
|
|||
Already in the script, but disabled by default. Google how to comment/uncomment code block in javascript.
|
#2773
|
||||
|
||||
@mostafatefa2009
The EventScripter feature is made to be used by users. It is super nice that mgpai is helping out here but ultimately you need to put time into this topic to use/understand existing scripts and create your own scripts.
__________________
JD Supporter, Plugin Dev. & Community Manager
Erste Schritte & Tutorials || JDownloader 2 Setup Download |
#2774
|
|||
|
|||
Update automatisch installieren mit Neustart, dann den Reconnect?
Gibt es eine Möglichkeit / ein Skript, das JD veranlasst bei einem erhältlichen Update das automatisch zu installieren, bevor er ein Reconnect ausführt, das er auch ohne Update ausführen würde, weil es die Downloads gerade sinnvoll machen?
Also: Reconnect steht bevor wegen der Downlaods / Einstellungen, voher installieren mit Neustart, dann den Reconnect, danach weiterladen.
__________________
Aktuelles Windows Last edited by Dockel; 28.02.2024 at 21:12. |
#2775
|
||||
|
||||
@Dockel: Mittels dem "Vor einem Reconnect" Trigger und dort dann auf Update prüfen und diese initiieren und neustarten. Bitte dazu im entsprechenden Thread um Rat/Hilfe fragen, siehe https://board.jdownloader.org/showthread.php?t=70525
__________________
JD-Dev & Server-Admin |
#2776
|
|||
|
|||
Install update automatically with restart, then reconnect?
Is there a way / a script that causes JD to automatically install an available update before executing a reconnect, which it would also do without an update because of the downloads progression?
So: Reconnect is imminent because of the downloads / settings, first install with restart, then reconnect, then continue downloading. https://board.jdownloader.org/showth...153#post531153
__________________
Aktuelles Windows |
#2777
|
|||
|
|||
Quote:
|
#2778
|
|||
|
|||
Quote:
I had a little trouble understanding that I had to give the package the name "cleanup" for it to work with this script specifically and the script is so simple that I ended up completely understanding it to the point that I feel ridiculous for not having made a little more effort to create it myself. It's so simple that I was able to create a version that also works in the download tab! (...because for some reason if I run the download with only the qualities I want, the downloads fail with "file not found" and resetting then checking the online status doesn't change anything. So I have to include all versions retrieved by the linkgrabber and download everything and once the downloads are complete, I use your script to sort, select and delete from the hard drive all unwanted versions.) Sooo.... Many many thanks for all the help you generously provide to all of us ! And also many thanks to all of the devs & CM behind JD. ^^ Have a nice day ! |
#2779
|
|||
|
|||
Package name can be anything. In the eventscripter panel you have to set the event trigger to "linkgrabber contextmenu button pressed" and then create a 'eventscripter trigger" button in the linkgrabber context menu and replace the default button name with "cleanup". You can then select any package and click the custom button to run the script.
|
#2780
|
|||
|
|||
Quote:
Code:
/* update before reconnect trigger : before a reconnect */ if (callAPI("update", "isUpdateAvailable")) { callAPI("update", "restartAndUpdate"); } |
#2781
|
|||
|
|||
Quote:
Thank you again mgpai |
#2782
|
|||
|
|||
Super! Thank you very much for the script!
__________________
Aktuelles Windows |
#2783
|
|||
|
|||
Something went wrong on the first reconnect:
Can't see the mistake I made.
__________________
Aktuelles Windows |
#2784
|
|||
|
|||
It seemed as if the script woked on the second reconnect (a message asking permission about the script appeared) And a little later this appears:
__________________
Aktuelles Windows Last edited by Dockel; 29.02.2024 at 17:05. |
#2785
|
|||
|
|||
My guess is internet connection get disconnected (by other script/setting/unknown reason) before the upddate can be downloaded. You can also use the "After a reconnect" trigger.
|
#2786
|
|||
|
|||
I believe, there is no other script doing this, only JD does it. Did I have to deactivate the reconnect option (but then there was no reconnection without an update anymore, I guess).
__________________
Aktuelles Windows |
#2787
|
|||
|
|||
Sounds great, glad you found a solution! Sorry I did not come up with an Event Scripter solution; I hadn't considered that videos normally only come in a few different vertical resolutions. The strategy I suggested mostly is to take into account any positive integer-valued vertical resolution.
|
#2788
|
|||
|
|||
Quote:
In the meanwhile, instead of 'before a rreconect' you can use 'after a reconnect. That should also solve the problem. |
#2789
|
|||
|
|||
Quote:
Quote:
__________________
Aktuelles Windows |
#2790
|
|||
|
|||
Before downloading or extracting a file whose path matches an existing file, JDownloader will generate a dialog prompt that gives the name of the file and the sizes of the existing and potential new file and then asks the user if they would like to overwrite, skip, or rename. Is it possible for a user-generated Event Scripter script to trigger this same dialog prompt at runtime?
|
#2791
|
|||
|
|||
Using comments for transfer status
I wanted to share some minor alterations of mgpai's script (https://board.jdownloader.org/showpo...8&postcount=20) for moving files as I thought it might be useful for others and addresses problems with data transfers that may otherwise go unnoticed.
One potential issue with moving files is that IO issues, reboots, crashes, etc. can interrupt a transfer. When the system recovers, the transfer will be incomplete, and one can be left with an incomplete copy in primary destination storage. For non-archives, it is more difficult to glean which files have not finished transferring when moving by a script (without looking at logs, examining files, etc.). Thus, it would be useful to "flag" when a file is moving and has successfuly transferred. Ideally, we would be able to set the status symbols (e.g., to a differently colored checkmark); however, since this does not seem possible, I instead take advantage of the comment column. This script checks if the file is intended for a "/mnt/scratch" temporary directory, sets a "Moving..." comment after the download is complete and before transfer, initiates a copy to a different final destination "/mnt/final", and then finally sets a "Successfully moved." comment, indicating the download was transferred successfully. If a transfer is later found to be incomplete ("Moving..."), the user can manually transfer externally or use a button-triggered script to complete the transfer. There is also some cleanup of the original file and package directory. Code:
// Move from scratch temp dir to final dir // Trigger: A Download stopped if (link.finished && !link.getArchive()) { // regex to check if folder in scratch directory const scratchRegex = new RegExp('^/mnt/scratch/'); var package = link.getPackage(); var downloadFolder = package.getDownloadFolder(); if (scratchRegex.test(downloadFolder)) { var destinationFolder = getPath("/mnt/final/" + link.package.name); link.setComment("Moving..."); var copied = getPath(link.downloadPath).copyTo(destinationFolder); if (copied) { getPath(link.downloadPath).delete(); // try to delete package dir if empty getPath(package.getDownloadFolder()).delete(); link.setComment("Successfully moved."); } } } For archives, this is already addressed by the extraction status symbols. However, for sake of completeness, I do the same for archive packages; again based on an mgpai script (https://board.jdownloader.org/showpo...84&postcount=7). Code:
// Set successful comment and delete empty dir for extracted archive // Trigger: "Archive Extraction Finished" var package = archive.getDownloadLinks()[0].getPackage(); var links = package.getDownloadLinks(); var runFilebot = true; for (var i = 0; i < links.length; i++) { var link = links[i]; if (link.getArchive() != null && link.getExtractionStatus() != "SUCCESSFUL" || !package.isFinished()) { runFilebot = false; break; } } if (runFilebot) { // try to delete package dir if empty getPath(package.getDownloadFolder()).delete(); for (var i = 0; i < links.length; i++) { var link = links[i]; link.setComment("Successfully extracted."); } } Last edited by blank; 12.06.2024 at 07:04. Reason: fixed package reference |
#2792
|
|||
|
|||
Quote:
Quote:
|
#2793
|
|||
|
|||
While it is not possible to display JD GUI, you can use external utils to display interactive dialog/prompt. For e.g. in windows, you can use vbs MsgBox/InputBox or nircmd qbox.
|
#2794
|
|||
|
|||
But even with "after a reconnect" something seems wrong there:
__________________
Aktuelles Windows Last edited by Dockel; 03.03.2024 at 09:51. |
#2795
|
|||
|
|||
Quote:
You will need to figure out yourself as to why internet is getting disconnected or, wait for @Jiaz to respond. In the meanwhile you can use the following script with either of the 'reconnect' triggers. It will restart and update only if connection is available, else it will play a sound. Code:
/* update before reconnect trigger : before a reconnect */ var connected = false; try { getPage("https://ipcheck0.jdownloader.org"); connected = true; } catch (e) {} if (connected) { if (callAPI("update", "isUpdateAvailable")) { callAPI("update", "restartAndUpdate"); } } else { playWavAudio(JD_HOME + "/themes/standard/org/jdownloader/sounds/captcha.wav"); } |
#2796
|
|||
|
|||
Thank you very much for the script!
When Reconnect is not activated the connection is kept like usual. Only when Reconnect is activated the connection will be interrupted. Yes, of course, let's wait for Jiaz. Thank you very much again!
__________________
Aktuelles Windows |
#2797
|
||||
|
||||
@Dockel: Typical issue caused by firewall/av blocking access to this url. Please check firewall/av and in doubt try to add it to exclude list or white/exclude list JDownloader.
This URL is part of the update cycle
__________________
JD-Dev & Server-Admin |
#2798
|
|||
|
|||
|
#2799
|
|||
|
|||
Thank you! I appreciate the confirmation. I was considering an external utility as well.
|
#2800
|
|||
|
|||
Maybe you got what I wrote in my reply, but just in case, I meant you can call external utils from the script and pass the input as parameter to eventscripter methods.
|
Thread Tools | |
Display Modes | |
|
|