JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #81  
Old 24.04.2017, 17:51
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

You could directly query the 9kw api in your script
**External links are only visible to Support Staff**www.9kw.eu/api.html
and parse the server response for the queue size.
I suggest to ask mgpai for help how to make http request and parse answer
__________________
JD-Dev & Server-Admin
Reply With Quote
  #82  
Old 29.04.2017, 21:50
blacksun blacksun is offline
JD Legend
 
Join Date: Mar 2009
Location: Schwaben
Posts: 1,337
Default

@mgpai
I hope you can help me.
if a file is premium-only and you dont have an premium-account, the file is skipped, saying that there is no account.
at the bottom of JD, you get an icon:


if you click on that icon, the skipped status get removed and JD is trying these links again.

my Intension:
doing this automatically all 60 minutes --> remove skipped-status every 60 minutes

- only links with "skipped no account" should be affected, not other links with other status
- there is a difference between reseting a link and removing skipped-status (=click on the icon). is it possible to remove skipped-status only (i prefer) via script?

Thx
Reply With Quote
  #83  
Old 30.04.2017, 11:47
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,636
Default

Quote:
Originally Posted by blacksun View Post
... remove skipped-status every 60 minutes
- only links with "skipped no account" should be affected, ...
Code:
// Unskip 'account missing' links at user specified interval
// Trigger Required : "Interval"
// Set interval to 3600000 (60 minutes)

var links = getAllDownloadLinks();

for (i = 0; i < links.length; i++) {
    var link = links[i];
    if (link.isSkipped() && link.getSkippedReason() == "NO_ACCOUNT") {
        link.setSkipped(false);
    }
}
Reply With Quote
  #84  
Old 03.05.2017, 13:39
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,636
Default

Check RSS Feeds
Code:
// Check  RSS feeds
// Trigger Required: "Interval"
// Set interval to 3600000 (1 Hour) or more

var users = []; // <- Specify the youtube user IDs to check, e.g. ["cnn","bbc","nbc"]

if (interval >= 3600000) {
    var links = [];

    for (i = 0; i < users.length; i++) {
        var user = users[i];
        var content = JSON.parse(getPage("**External links are only visible to Support Staff** + user));
        var items = content.items ? content.items : [];

        for (j = 0; j < items.length; j++) {
            var item = items[j];
            links.push(item.link);
        }
    }

    callAPI("linkgrabberv2", "addLinks", {
        "links": links.join(" "),
        "autostart": null // <- Set to 'true' (without quotes) to autostart the downloads
    });
}

Last edited by Jiaz; 03.05.2017 at 15:23.
Reply With Quote
  #85  
Old 04.05.2017, 04:56
emilio530 emilio530 is offline
Storm
 
Join Date: Oct 2011
Location: In the paradise
Posts: 211
Default

Quote:
Originally Posted by Jiaz View Post
You could directly query the 9kw api in your script
**External links are only visible to Support Staff**...
and parse the server response for the queue size.
I suggest to ask mgpai for help how to make http request and parse answer
Quote:
Originally Posted by mgpai View Post
Check RSS Feeds
Excellent!! I'll try that and post here when have the script working.

Thanks! :D
Reply With Quote
  #86  
Old 04.05.2017, 07:50
IceRad12
Guest
 
Posts: n/a
Default

Hi, mgpai. I need a script that allows JDownloader to monitor a Youtube playlist or channel and automatically download new videos. In other words, if a new video is uploaded every day, JDownloader would detect that and download it without further intervention. Thank you for any help.
Reply With Quote
  #87  
Old 05.05.2017, 14:34
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,636
Default

@IceRad12,

You can use the script in Post #84 to monitor the RSS feeds to get recent videos from channels by specifying the usernames of those channels. Check your PM for link to a similar script which can be used for playlists. To automatically download the links after adding them to JD, you have to set 'autostart' to 'true' in the scripts.
Reply With Quote
  #88  
Old 05.05.2017, 16:13
IceRad12
Guest
 
Posts: n/a
Default

Quote:
Originally Posted by mgpai View Post
@IceRad12,

You can use the script in **External links are only visible to Support Staff**... to monitor the RSS feeds to get recent videos from channels by specifying the usernames of those channels. Check your PM for link to a similar script which can be used for playlists. To automatically download the links after adding them to JD, you have to set 'autostart' to 'true' in the scripts.
I think I need some assistance with this. I opened Event Scripter and copied the script exactly as presented. I set the Youtube ID inside the brackets. I set auto start to "true". However, I get a Reference Error when I click "test run". Did I forget to do something else?
Reply With Quote
  #89  
Old 08.05.2017, 11:58
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

Please provide a screenshot of the script and error message
__________________
JD-Dev & Server-Admin
Reply With Quote
  #90  
Old 09.05.2017, 06:23
emilio530 emilio530 is offline
Storm
 
Join Date: Oct 2011
Location: In the paradise
Posts: 211
Default

Hi, i got that working reading the stats file from 9kw. But i need to know how to set a stopmark in event scripter. I can't find the method. I checked how is this done via myJD and found a method setStopMark in DowndoadsV2.

How can i access this method from scripter?

Thanks
Reply With Quote
  #91  
Old 09.05.2017, 06:58
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,636
Default

Quote:
Originally Posted by IceRad12 View Post
I think I need some assistance with this...
Solved via Chat.

Quote:
Originally Posted by emilio530 View Post
... i need to know how to set a stopmark in event scripter ...
Set stop mark on link:
Code:
callAPI("downloadsV2", "setStopMark", linkUUID, -1);

Set stop mark on package:
Code:
callAPI("downloadsV2", "setStopMark", -1, packageUUID);

Remove stop mark:
Code:
callAPI("downloadsV2", "removeStopMark");
Reply With Quote
  #92  
Old 09.05.2017, 14:46
emilio530 emilio530 is offline
Storm
 
Join Date: Oct 2011
Location: In the paradise
Posts: 211
Default

Thanks mgpai!!
Reply With Quote
  #93  
Old 09.05.2017, 16:00
thecoder2012's Avatar
thecoder2012 thecoder2012 is offline
Verified Account
 
Join Date: Feb 2013
Location: Internet
Posts: 1,324
Default

Quote:
Originally Posted by emilio530 View Post
I would like to know if i can invoke some function that can help me get that info in a script so i can set a stopmark when the 9kw captcha queue is too high.
Quote:
Originally Posted by Jiaz View Post
You could directly query the 9kw api in your script and parse the server response for the queue size.
Simple example for high queue:
Code:
// Queue check for 9kw.eu
// Trigger Required: Interval

var newInterval = 10000;
if (interval == newInterval) {
    check9kw_queue();
} else {
    interval = newInterval;
}

function check9kw_queue() {
    var settings_9kw = "org.jdownloader.captcha.v2.solver.solver9kw.Captcha9kwSettings";
    var https = callAPI("config", "get", settings_9kw, null, "https");
    var servercheck_page = '://www.9kw.eu/grafik/servercheck.json';
    var servercheck;

    for (var i = 0; i < 3; i++) {
        if (https == 1) {
            servercheck = getPage("https" + servercheck_page);
        } else {
            servercheck = getPage("http" + servercheck_page);
        }

        if (IsValidJSONString(servercheck)) {
            var queue = JSON.parse(servercheck).queue;

            if (parseInt(queue) > 100) {
                //callAPI("downloadsV2", "setStopMark", linkUUID, -1);//Set stop mark on link
                //callAPI("downloadsV2", "setStopMark", -1, packageUUID);//Set stop mark on package
                setDownloadsPaused(true);
                //alert("High queue. " + "(" + queue + ")");
            } else {
                //callAPI("downloadsV2", "removeStopMark");//Remove stop mark
                setDownloadsPaused(false);
            }
            break;
        }
    }
}

function IsValidJSONString(str) {
    if (typeof str !== "string") {
        return false;
    }
    try {
        JSON.parse(str);
    } catch (e) {
        return false;
    }
    return true;
}

And one example for credits:
Code:
// Check for enough credits (captcha service 9kw.eu)
// Trigger Required: Interval

var newInterval = 30000;
if(interval == newInterval){
    check9kw_credits();
}else{
    interval = newInterval;
}

function check9kw_credits (){
	var settings_9kw = "org.jdownloader.captcha.v2.solver.solver9kw.Captcha9kwSettings";
	var apikey = callAPI("config", "get", settings_9kw, null, "ApiKey");
	var prio = callAPI("config", "get", settings_9kw, null, "prio");
	var confirm = callAPI("config", "get", settings_9kw, null, "confirm");
	var https = callAPI("config", "get", settings_9kw, null, "https");
	var credits_page = '://www.9kw.eu/index.cgi?action=usercaptchaguthaben&apikey=' + apikey;
	var credits;
	if (https == 1) {
	    credits = getPage("https" + credits_page);
	} else {
	    credits = getPage("http" + credits_page);
	}

	if (credits.match(/^\d+$/)) {
	    var min_credits = 30;
	    if (confirm) {
	        min_credits += 6;
	    }
	    if (prio) {
	        min_credits += parseInt(prio);
	    }
	    if (parseInt(credits) < min_credits) {
	        setDownloadsPaused(true);
	        //alert("Not enough credits. " + "(" + credits + ")");
	    }else{
	        setDownloadsPaused(false);
	    }
	}
}

Another example for 'account missing' and 'skipped - captcha input':
Code:
// Unskip 'account missing' and 'skipped - captcha input' links at user specified interval
// Trigger Required : "Interval"
// Set interval to 3600000 (60 minutes)

var newInterval = 3600000;
if (interval == newInterval) {
    check_skipped();
} else {
    interval = newInterval;
}

function check_skipped() {
    var links = getAllDownloadLinks();

    for (i = 0; i < links.length; i++) {
        var link = links[i];
        if (link.isSkipped()) {
            if (link.getSkippedReason() == "CAPTCHA" || link.getSkippedReason() == "NO_ACCOUNT") {
                link.setSkipped(false);
            }
        }
    }
}
__________________
Join 9kw.eu Captcha Service now and let your JD continue downloads while you sleep.

Last edited by thecoder2012; 27.05.2019 at 06:59.
Reply With Quote
  #94  
Old 09.05.2017, 16:37
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
Default

@thecoder2012: very NICE!
Just for your information, you could add your own remoteapi commands from your solver to api , for example callAPI("9kw", "getCredits"); contact us if you need help with this
__________________
JD-Dev & Server-Admin
Reply With Quote
  #95  
Old 10.05.2017, 01:26
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,674
Default

fyi, problem with using pause mode is sets download speed limit also. So stop marks are probably better if you don't want this to happen, on the assumption that it's the same function in GUI as API call.

raztoki
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #96  
Old 11.05.2017, 15:35
emilio530 emilio530 is offline
Storm
 
Join Date: Oct 2011
Location: In the paradise
Posts: 211
Default

Many thanks thecoder2012!! I'm testing the script i wrote for this problem and will share it as i have it working.

:thumbup:
Reply With Quote
  #97  
Old 18.05.2017, 17:37
Fireman449
Guest
 
Posts: n/a
Question Start a Batch Script if JD finish unrar

Hey MPGAI,

I have a little problem but nothing big for you

Backround:
I wrote a Batch script which automatically deletes "Proof" and "Sample" (Files and Folder) cause I dont need them. I also tried to set exclusions in the unrar extension of JD but nevertheless the files would be unpacked.

What I need:
The Batch Script is finish and works fine but I have no Idea how I could start the Batch Script after Unrar.
I allready tried to abuse the predefined "Play Sound after Unrar Script" from the Event Scripter but I dont get it right

So can you please help me to start my batch script after JD unrar the downloaded movie packages?
Reply With Quote
  #98  
Old 18.05.2017, 18:46
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,636
Default

Quote:
Originally Posted by Fireman449 View Post
... start my batch script after JD unrar ...
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");
Reply With Quote
  #99  
Old 19.05.2017, 13:03
0r3n
Guest
 
Posts: n/a
Default

Hi,

I'm looking for a way to save all comments from the comment column into a package to a txt file.

could you please kindly help with a script for this? :-)
Reply With Quote
  #100  
Old 19.05.2017, 16:07
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,636
Default

@0r3n,

There are two types of comments in JD. 'link' and 'package' comments.

Quote:
Originally Posted by 0r3n View Post
... save all comments from the comment column into a package ...
Do you mean save comments from all individual links of a package ...

Quote:
... to a txt file ...
... to a single txt file?
Reply With Quote
  #101  
Old 19.05.2017, 21:58
0r3n
Guest
 
Posts: n/a
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, 23:16
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,636
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 23:32. Reason: Optimized script
Reply With Quote
  #103  
Old 22.05.2017, 22:11
Fireman449
Guest
 
Posts: n/a
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, 09:12
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,636
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, 16:47
PeTaKo
Guest
 
Posts: n/a
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, 09:41
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,636
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 (**External links are only visible to Support Staff**
// 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 15:34.
Reply With Quote
  #107  
Old 29.05.2017, 12:40
PeTaKo
Guest
 
Posts: n/a
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 (**External links are only visible to Support Staff**// 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 Support Staff****External links are only visible to Support Staff**)
// 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 12:56.
Reply With Quote
  #108  
Old 29.05.2017, 14:49
Fireman449
Guest
 
Posts: n/a
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, 15:56
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,636
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, 18:07
PeTaKo
Guest
 
Posts: n/a
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 (**External links are only visible to Support Staff**
// 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, 09:16
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,636
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, 10:33
PeTaKo
Guest
 
Posts: n/a
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, 05:04
Misho1702
Guest
 
Posts: n/a
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 16:58.
Reply With Quote
  #114  
Old 03.06.2017, 22:59
0r3n
Guest
 
Posts: n/a
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 23:16.
Reply With Quote
  #115  
Old 06.06.2017, 09:45
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,636
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 11.06.2017, 00:48
0r3n
Guest
 
Posts: n/a
Default

Man, You are awesome! Thank you! much appreciated!!!
Reply With Quote
  #117  
Old 13.06.2017, 23:01
maxie47 maxie47 is offline
Registered / Inactive
 
Join Date: Feb 2015
Posts: 19
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, 08:27
Informativ Informativ is offline
Registered / Inactive
 
Join Date: Nov 2016
Posts: 106
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, 10:30
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,326
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, 09:54
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,636
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 03:52.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.