JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #101  
Old 19.05.2017, 20:58
0r3n 0r3n is offline
Vacuum Cleaner
 
Join Date: Oct 2016
Posts: 16
Default

That's exactly, mgpai.
to a text file, or to csv file that have the file name and the comment.
anything that will help to save the comments will be helpful.
Reply With Quote
  #102  
Old 19.05.2017, 22:16
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 195
Default

Quote:
Originally Posted by 0r3n View Post
... save all comments from the comment column into a package to a txt file ...
Quote:
Originally Posted by 0r3n View Post
... or to csv file that have the file name and the comment ...
Code:
// Write link comments to 'csv' file.
// Trigger: "Package Finished".

var links = package.getDownloadLinks();
var data = [];

for (i = 0; i < links.length; i++) {
    var link = links[i];
    var comment = link.getComment();
    var fileName = link.getName();
    if (comment) data.push([fileName, comment].join(","));
}

if (data.length) {
    var destFolder = package.getDownloadFolder() + "/";
    var destFile = package.getName() + ".csv";
    writeFile(destFolder + destFile, data.join("\r\n"), true);
}

Last edited by mgpai; 19.05.2017 at 22:32. Reason: Optimized script
Reply With Quote
  #103  
Old 22.05.2017, 21:11
Fireman449 Fireman449 is offline
I will play nice!
 
Join Date: May 2017
Posts: 6
Question Script dont work if JDownloader starts it, but if I start it manually it works fine..

Quote:
Originally Posted by mgpai View Post
Can use either of the following, with trigger "Archive extraction Finished".

Synchronous:
Code:
callSync("cmd","/c","c:/myFolder/myBatch.bat");

Asynchronous:
Code:
callAsync(function(){},"cmd","/c","c:/myFolder/myBatch.bat");

At first, thank you for your really fast support
Now JD starts the script after unrar but the batch script doesnt find the sample or proof data. If i start the batch script manually the batch script is working fine.
I think the problem depends on the drive mapping cause the Log File is generated on "C:\temp" well but the script dont delete the files on drive Z:.

May you can help me out, here is my batch script:
Spoiler:
@echo off & setlocal


::Ordnername
set "name=sample"
set "name2=proof"


::Speicherpfad der Logdatei
set "path=C:\temp\deleted.txt"


::Suchpfad der Ordner
set "search=Z:\Downloads\Entpackt"



::Erstellen der .txt-Datei mit den Pfaden der gelöschten Ordner und Dateien
echo Folgende Ordner und Dateien mit dem Namen %name% und %name2% wurden unter %search% gefunden und entfernt: >> "%path%"
echo. >> "%path%"
cd "%search%"
dir /b /s "*%name%*" >> "%path%"
dir /b /s "*%name2%*" >> "%path%"
echo. >> "%path%"


::Löschen der Ordner
for /f "delims=" %%a in ('dir /ad /b /s "%name%"') do rd /s /q "%%a" 2>nul
for /f "delims=" %%a in ('dir /ad /b /s "%name2%"') do rd /s /q "%%a" 2>nul


::Löschen der Dateien die direkt im gleichen Ordner liegen
del /s "%search%\*%name%*.*"
del /s "%search%\*%name2%*.*"


::Öffnen der Log Datei (auskommentiert)
::%path%



EXIT
Reply With Quote
  #104  
Old 23.05.2017, 08:12
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 195
Default

Quote:
Originally Posted by Fireman449 View Post
I think the problem depends on the drive mapping cause the Log File is generated on "C:\temp" well but the script dont delete the files on drive Z:.
Troubleshoot the batch file using:

Code:
alert(callSync("cmd","/c","c:/myFolder/myBatch.bat"));// Log to screen (Dialog Box)
OR
Code:
log(callSync("cmd","/c","c:/myFolder/myBatch.bat"));// Log to file  "<JD>\logs\<sessionID>\ScriptEnvironment.log.0"

Alternatively, the folders can also be removed directly from event scripter
Code:
// Delete junk folders
// Trigger: "Archive Extraction Finished"

var archiveFolder = archive.getExtractToFolder(); // <- Will dynamically get the folder from 'archive info'. Can also set static folder.
var junkFolders = ["proof", "sample"]; // <- Specify folders to delete.

for (i = 0; i < junkFolders.length; i++) {
    var junkFolder = getPath(archiveFolder + "/" + junkFolders[i]);
    if (junkFolder.exists()) junkFolder.deleteRecursive();
}
Reply With Quote
  #105  
Old 28.05.2017, 15:47
PeTaKo PeTaKo is offline
Modem User
 
Join Date: May 2017
Posts: 4
Default

Quote:
Originally Posted by mgpai View Post
Code:
// Write link comments to 'csv' file.
// Trigger: "Package Finished".

var links = package.getDownloadLinks();
var data = [];

for (i = 0; i < links.length; i++) {
    var link = links[i];
    var comment = link.getComment();
    var fileName = link.getName();
    if (comment) data.push([fileName, comment].join(","));
}

if (data.length) {
    var destFolder = package.getDownloadFolder() + "/";
    var destFile = package.getName() + ".csv";
    writeFile(destFolder + destFile, data.join("\r\n"), true);
}
Hi mgpai, thanks a lot for all your support.

I was wondering if there is a way to automatically add the comments in the image metadata instead of creating a csv, just like the picture i attached to this post.
Attached Thumbnails
metadata.JPG  
Reply With Quote
  #106  
Old 29.05.2017, 08:41
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 195
Default Provided option set a different tag name to write the comments.

Quote:
Originally Posted by PeTaKo View Post
... automatically add the comments in the image metadata ...
Code:
// Add metadata to image file, using external program
// Trigger: "A Download Stopped"
// External program required: ExifTool by Phil Harvey (http://www.sno.phy.queensu.ca/~phil/exiftool/)
// IMPORTANT: Remove any command line parameters included in the executable. For e.g. in Windows OS, rename 'exiftool(-k).exe' to 'exiftool.exe'

if (link.isFinished()) {
    var filePath = link.getDownloadPath();
    var ext = getPath(filePath).getExtension();
    var supported = ["jpg", "tiff"]; // <- Specify supported file types.

    if (supported.indexOf(ext) > -1) {
        var comment = link.getComment();

        if (comment) {
            var exiftool = "c:/portable/exiftool/exiftool.exe"; // <- Set full path to "exiftool.exe"
            var tagName = "comment"; // <- For the comment to be visible in the OS file properties viewer, use OS compatible tag name.
            comment = comment.replace(/"/g, "'");
            callAsync(function() {}, exiftool, "-overwrite_original", "-" + tagName + "=" + comment, filePath);
        }
    }
}

Last edited by mgpai; 31.05.2017 at 14:34.
Reply With Quote
  #107  
Old 29.05.2017, 11:40
PeTaKo PeTaKo is offline
Modem User
 
Join Date: May 2017
Posts: 4
Default

Quote:
Originally Posted by mgpai View Post
Code:
// Add metadata to image file, using external program
// Trigger: "A Download Stopped"
// External program required: ExifTool by Phil Harvey (http://www.sno.phy.queensu.ca/~phil/exiftool/)
// IMPORTANT: Remove any command line parameters included in the executable. For e.g. in Windows OS, rename 'exiftool(-k).exe' to 'exiftool.exe'

if (link.isFinished()) {
    var filePath = link.getDownloadPath();
    var ext = getPath(filePath).getExtension();
    var supported = ["jpg", "tiff"]; // <- Specify supported file types.

    if (supported.indexOf(ext) > -1) {
        var comment = link.getComment();

        if (comment) {
            var exiftool = "c:/portable/exfitool/exiftool.exe"; // <- Set full path to "exiftool.exe".
            comment = comment.replace(/"/g, "'");
            callAsync(function() {}, exiftool, "-overwrite_original", "-comment=" + comment, filePath);
        }
    }
}
Hi mgpai, thank you so much, but i was unable to make it work :(

I used this code:

Code:
// Add metadata to image file, using external program
// Trigger: "A Download Stopped"
// External program required: ExifTool by Phil Harvey (**External links are only visible to Supporters****External links are only visible to Supporters**)
// IMPORTANT: Remove any command line parameters included in the executable. For e.g. in Windows OS, rename 'exiftool(-k).exe' to 'exiftool.exe'

if (link.isFinished()) {
    var filePath = link.getDownloadPath();
    var ext = getPath(filePath).getExtension();
    var supported = ["jpg", "tiff"]; // <- Specify supported file types.

    if (supported.indexOf(ext) > -1) {
        var comment = link.getComment();

        if (comment) {
            var exiftool = "c:/exiftool/exiftool.exe"; // <- Set full path to "exiftool.exe".
            comment = comment.replace(/"/g, "'");
            callAsync(function() {}, exiftool, "-overwrite_original", "-comment=" + comment, filePath);
        }
    }
}
I renamed the executable and I placed in the same path of the script. The trigger is also OK. I have windows 10 and don't know what i'm doing wrong since other scripts work well for me.

The first times I ran it i got a javascript error, but now I don't get any error, it just doesn't work.

Any suggestion?

Thanks in advance.

Last edited by raztoki; 29.05.2017 at 11:56.
Reply With Quote
  #108  
Old 29.05.2017, 13:49
Fireman449 Fireman449 is offline
I will play nice!
 
Join Date: May 2017
Posts: 6
Talking I need a little extension for your script...

Alternatively, the folders can also be removed directly from event scripter
Code:
// Delete junk folders
// Trigger: "Archive Extraction Finished"

var archiveFolder = archive.getExtractToFolder(); // <- Will dynamically get the folder from 'archive info'. Can also set static folder.
var junkFolders = ["proof", "sample"]; // <- Specify folders to delete.

for (i = 0; i < junkFolders.length; i++) {
    var junkFolder = getPath(archiveFolder + "/" + junkFolders[i]);
    if (junkFolder.exists()) junkFolder.deleteRecursive();
}
[/QUOTE]


Hi MPGAI,

thank you thats the easiest way to get it done and I think mostly this solution will work fine, but sometimes the sample or proof files are in the same folder as the movie with an name like "ljdbhawjhsamplelhbdla" or something else and then the script won`t work.

Unfortunately I am not good in Java Scripting, so if you have a little extension on the script that it will delete files who have the word "sample" or "proof" in the filename the script would be perfect for me.
Reply With Quote
  #109  
Old 31.05.2017, 14:56
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 195
Default

Quote:
Originally Posted by PeTaKo View Post
... i was unable to make it work ...
Solved via Chat. Script was working, but the comments were not visible in OS file properties viewer on account of the OS using a different tag for comments. Provided option in the script to set custom tag name. Updated script in Post #106 accordingly.

Quote:
Originally Posted by Fireman449 View Post
... sometimes the sample or proof files are in the same folder as the movie with an name like "ljdbhawjhsamplelhbdla" or something else ... if you have a little extension on the script that it will delete files who have the word "sample" or "proof" in the filename the script would be perfect for me. ...
Please note, the script will delete any file or folder which contains 'proof' or 'sample' in its name.

Code:
// Delete from extracted files, any file/folder which contains user specified keywords
// Trigger: "Archive Extraction Finished"

archive.getExtractedFilePaths().forEach(function(file) {
    var re = /.*(proof|sample).*/;
    var junkFile = re.test(file.getName());
    var junkFolder = re.test(file.getParent().getName());

    if (junkFile) file.delete();
    if (junkFolder) file.getParent().deleteRecursive();
});
Reply With Quote
  #110  
Old 31.05.2017, 17:07
PeTaKo PeTaKo is offline
Modem User
 
Join Date: May 2017
Posts: 4
Default

Quote:
Originally Posted by mgpai View Post
Code:
// Add metadata to image file, using external program
// Trigger: "A Download Stopped"
// External program required: ExifTool by Phil Harvey (http://www.sno.phy.queensu.ca/~phil/exiftool/)
// IMPORTANT: Remove any command line parameters included in the executable. For e.g. in Windows OS, rename 'exiftool(-k).exe' to 'exiftool.exe'

if (link.isFinished()) {
    var filePath = link.getDownloadPath();
    var ext = getPath(filePath).getExtension();
    var supported = ["jpg", "tiff"]; // <- Specify supported file types.

    if (supported.indexOf(ext) > -1) {
        var comment = link.getComment();

        if (comment) {
            var exiftool = "c:/portable/exiftool/exiftool.exe"; // <- Set full path to "exiftool.exe"
            var tagName = "comment"; // <- For the comment to be visible in the OS file properties viewer, use OS compatible tag name.
            comment = comment.replace(/"/g, "'");
            callAsync(function() {}, exiftool, "-overwrite_original", "-" + tagName + "=" + comment, filePath);
        }
    }
}
Hi mgpai! The script doesn't work when a jdownloader comment includes spanish characters like á é í ó ú ñ

Any idea to how make it work?

Thanks!
Reply With Quote
  #111  
Old 01.06.2017, 08:16
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 195
Default

Quote:
Originally Posted by PeTaKo View Post
... The script doesn't work when a jdownloader comment includes spanish characters like á é í ó ú ñ ...
The script just passes the parameters to the external program. Any further adjustments have to be made at the OS or external program level. In this case, you may need to use a different character set. Please check the 'exiftool' website/documentation for options/parameter to change it. If it works directly from command line, I can help you add it to the script.
Reply With Quote
  #112  
Old 01.06.2017, 09:33
PeTaKo PeTaKo is offline
Modem User
 
Join Date: May 2017
Posts: 4
Default

I did some research and when i write metadata using this coomand it works:

exiftool -L -XPcomment=áéíóúÑñ mypicture.jpg

Its as simple as adding -L in the writing command line

Thanks for your help mgpai!
Reply With Quote
  #113  
Old 02.06.2017, 04:04
Misho1702 Misho1702 is offline
Modem User
 
Join Date: Jun 2017
Posts: 1
Default

Great RSS script mgpai.
I managed to use it for playlists by changing user and users to playlist and playlists and changing the URL format. However, I'd like to decrease the time interval but I don't know if that would break something maybe with the rss2json or something.

Last edited by Jiaz; 02.06.2017 at 15:58.
Reply With Quote
  #114  
Old 03.06.2017, 21:59
0r3n 0r3n is offline
Vacuum Cleaner
 
Join Date: Oct 2016
Posts: 16
Smile

Quote:
Originally Posted by mgpai View Post
Code:
// Write link comments to 'csv' file.
// Trigger: "Package Finished".

var links = package.getDownloadLinks();
var data = [];

for (i = 0; i < links.length; i++) {
    var link = links[i];
    var comment = link.getComment();
    var fileName = link.getName();
    if (comment) data.push([fileName, comment].join(","));
}

if (data.length) {
    var destFolder = package.getDownloadFolder() + "/";
    var destFile = package.getName() + ".csv";
    writeFile(destFolder + destFile, data.join("\r\n"), true);
}
Thank you so much for this!
look so simple, and yet I had no idea how to implement it!
I just checked and it work like a charm
Thank you!!! much appreciated!!

== Edit ==
Is there a way to run it on the packages manually?
because some packages never finish.
for example:
If a package have 600 files, and I already have 580 of them and only 20 are downloaded (I configured JDownloader to skip the file if it's exist), so the package status at the end is: "An Error occured!" as in the attached picture.
Attached Images
File Type: png 2017-06-03_231421.png (1.5 KB, 0 views)

Last edited by 0r3n; 03.06.2017 at 22:16.
Reply With Quote
  #115  
Old 06.06.2017, 08:45
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 195
Default

Quote:
Originally Posted by Misho1702 View Post
... I'd like to decrease the time interval but I don't know if that would break something maybe with the rss2json or something.
Reducing the interval will not be of any help when fetching feeds using rss2json. They cache the results and from what I have observed, it is refreshed only every hour. So any query made within less than an hour of the initial query will return the same content.

Quote:
Originally Posted by 0r3n View Post
... Is there a way to run it on the packages manually? ...
Can create a custom button in context menu and use this script.

Code:
// Write link comments from a package to 'csv' file
// Trigger: "DownloadList Contextmenu Button Pressed"

var buttonName = "Comments to CSV"; // <- Button name used in context menu (case-sensitive)

if (name == buttonName && dlSelection.isPackageContext()) {
    var package = dlSelection.getContextPackage();
    var links = package.getDownloadLinks();
    var data = [];

    links.forEach(function(link) {
        var comment = link.getComment();
        var fileName = link.getName();
        if (comment) data.push([fileName, comment].join(","));
    });

    if (data.length) {
        var destFolder = package.getDownloadFolder() + "/";
        var destFile = package.getName() + ".csv";
        writeFile(destFolder + destFile, data.join("\r\n"), true);
    }
}
Reply With Quote
  #116  
Old 10.06.2017, 23:48
0r3n 0r3n is offline
Vacuum Cleaner
 
Join Date: Oct 2016
Posts: 16
Default

Man, You are awesome! Thank you! much appreciated!!!
Reply With Quote
  #117  
Old 13.06.2017, 22:01
maxie47 maxie47 is offline
Baby Loader
 
Join Date: Feb 2015
Posts: 8
Default Suche Beispiele für RegEx - Dateien nicht entpacken die....

Hallo,
ich bin auf der Suche nach der Möglichkeit, aus Archiven bestimmte Dateien nicht zu entpacken.
Dazu habe ich entweder im Paketverwalter den Punkt "Erweiterte Einstellungen f. Archive" oder den Ereignis-Scripter gefunden.

Einzelne Dateien scheint recht einfach
[1-9][a-zA-Z] oder einfach [remove_this]
(s. wiki)

Wie erstelle ich aber so eine RegEx für z.B. die Unterverzeichnisse, die den Namen "sample" haben und alle Dateien, die sich darin befinden?
Wohin gegen der Unterordner "subs" mit seinen Datein sehr wohl entpackt werden soll.
Negative Lookaheads und Lookbehinds schauen ja nur den String selbst an, wie verhält sich das mit Unterodnern?
(Sorry, ich bin da nicht fit im Thema RegEx...)
Oder nehme ich dafür eine Batch? Wie würde der Inhalt aussehen?

Danke schon mal.
Reply With Quote
  #118  
Old 14.06.2017, 07:27
Informativ Informativ is offline
JD Fan
 
Join Date: Nov 2016
Posts: 78
Default

hey
i have running crawljob and some files offline or captcha not work.
now i have folder with only txt or txt and image file. It is possible this folder delete over event script?

Spoiler:
Reply With Quote
  #119  
Old 14.06.2017, 09:30
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 49,950
Default

@maxie47:
Entweder via regex Ordner mit *Sample* im namen oder alle Dateien mit *Sample* im Namen.
Es wird immer der komplette Pfad gegen das Pattern geprüft, daher sollte .*sample.* reichen.
__________________
JD-Dev & Server-Admin
Reply With Quote
  #120  
Old 16.06.2017, 08:54
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 195
Default

Quote:
Originally Posted by Informativ View Post
i have running crawljob and some files offline or captcha not work.
now i have folder with only txt or txt and image file. It is possible this folder delete over event script?
Note: This script will delete packages from download list and files/folders from disk.

Code:
// Delete 'jpg' and 'txt' files and remove download folder if empty.
// Trigger required: "A Download Stopped"

var links = link.getPackage().getDownloadLinks();

var packageMatch = links.some(function(link) {
    var ext = getPath(link.getDownloadPath()).getExtension();
    return ext == "jpg" || ext == "txt";
});

if (packageMatch) {
    var packageTried = links.every(function(link) {
        var status = link.getStatus();
        return status == "Skipped - Captcha is required" || status !== null;
    });

    if (packageTried) {
        var otherLinks = links.filter(function(link) {
            var ext = getPath(link.getDownloadPath()).getExtension();
            return !(/jpg|txt/).test(ext);
        });

        if (otherLinks.length) {
            var packageFailed = otherLinks.every(function(link) {
                var status = link.getStatus();
                return status == "Skipped - Captcha is required" || status == "File not found";
            });

            if (packageFailed) {
                package.remove();
                getPath(package.getDownloadFolder()).getChildren().forEach(function(file) {
                    var ext = getPath(file).getExtension();
                    if (ext == "txt" || ext == "jpg") {
                        file.delete();
                        file.getParent().delete();
                    }
                });
            }
        }
    }
}
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 04:08.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.