#1021
06.12.2019, 13:47
 mgpai Script Master Join Date: Sep 2013 Posts: 809

Quote:
 Originally Posted by SMS How can I rename files? I want to download domain.com/foo/bar.zip as bar_foo.zip rather than as bar.zip. The renaming should happen early. For example as a Packagizer Hook, or within the following call in a script I have: Code: myObject = callAPI("linkgrabberv2", "addLinks", { "links": theLink });
Code:
// Rename files by matching download url pattern
// Trigger: Packagizer Hook

if (state == "BEFORE") {
var patt = /.+\/domain\.com\/(foo)\/(bar)(\.zip)/i;
if (name) link.setName(name[2] + "_" + name[1] + name[3]);
}

Packagizer rules not suitable for this?
#1022
08.12.2019, 11:00
 SirJohnny Baby Loader Join Date: Oct 2019 Posts: 8

Hello, how can I see the output of my script ? In python, you would call print.
Is alert the only way ?

For example, I want to display the items that pass the if statement for debug purposes:

Code:
var allDownloadLinks = getAllDownloadLinks(); // Get all download links

}
})
#1023
08.12.2019, 12:18
 mgpai Script Master Join Date: Sep 2013 Posts: 809

Quote:
 Originally Posted by SirJohnny how can I see the output of my script ? In python, you would call print. Is alert the only way ?
You can also log the output to JD session logs using:
Code:
log(myObject[]);/*Log to stderr and to JDownloader Log Files*/

or, write to a file using:
Code:
writeFile(myString/*filepath*/, myString/*myText*/, myBoolean/*append*/);/*Write a text file*/
/* Example: */writeFile(JD_HOME+"/log.txt",JSON.stringify(this)+"\r\n",true);

You can append the debug string to a variable and view them in a single alert box after all the items in the array are processed.
#1024
08.12.2019, 19:10
 noone1 JD Beta Join Date: Oct 2013 Posts: 50

Quote:
 Originally Posted by SirJohnny Hello,
hello,

maybe this one could be more 'visual' while a bit time consuming if you try to display huge object!

Code:
function jdbox(){
/*call jdbox(arg1,arg2,...)

}
edt:oops, forgot the 2nd
Spoiler:
Code:
function print_r(arr, level) {
//stackoverflow.com/a/9613740
//format recursive Array/Hashes/Objects,Strings/Chars/Numbers etc...

var dumped_text = "";
if (!level) level = 0;

var level_padding = "";//The padding given at the beginning of the line.
for (var j = 0; j < level + 1; j++) level_padding += "    ";

if (typeof(arr) == 'object') {
for (var item in arr) {
var value = arr[item];

if (typeof(value) == 'object') {
dumped_text += level_padding + item + " ...\n";
dumped_text += print_r(value, level + 1);
} else {
dumped_text += level_padding + item + " => " + value + "\n";
}
}
} else {
dumped_text = "=> " + arr + " <=(" + typeof(arr) + ")";
}
return dumped_text;
}

edt2: logf will redirect to a file or simply combine it with alert. ex:alert("test1"+print_r(myobj)); not perfect but it run through any kind of type and display it...while we are hopping a debugger in JD

Otherwise I've just posted a question on the board with a script that contains 2 usefull functions I use (logf and print_r), may be it can help.
__________________
Spoiler:

>'msdos/js chimera' : we will rule the world!
>'py god' : calm down... you are era too early
>'vba Bellérophon': one day I will kill you both, I swear
>'wscript pegasus': me too, me too
>'php observer': haha, those kids are funny
epilogue
>'brainf*ck alien': +[>.+<] bzzzt
>'whitepace void':
...
>'java nut': I think, therefore I am, I know I'm not crazy! anybody in there??
:biggrin:

Last edited by noone1; 08.12.2019 at 19:34.
#1025
10.12.2019, 21:02
 askin2u Fibre Channel User Join Date: Mar 2015 Posts: 123

Hi, I have a question: I have differente debrid accounts.
I'd like to log the performance for comparison
I will try to explain in pseudocode
Code:
if isDownloadedUsingPremium(link)
then Log (host/accountUsed/successOrError/TimeStarted/TimeFinished/SizeorAverageSpeed)
else notLog
is it posssible to achieve?

thanks
#1026
10.12.2019, 22:28
 raztoki English Supporter Join Date: Apr 2010 Location: Australia Posts: 16,675

as is the log function jd core? or some more eventscripter function ?
if its jd core then logging function currently is core function.

raztoki
__________________

#1027
11.12.2019, 09:49
 askin2u Fibre Channel User Join Date: Mar 2015 Posts: 123

Quote:
 Originally Posted by raztoki @askin2u as is the log function jd core? or some more eventscripter function ? if its jd core then logging function currently is core function. raztoki
honestly don't know, I'd like to log every try to use a premium account in a file so that I can grep and get some stats.
#1028
11.12.2019, 10:17
 raztoki English Supporter Join Date: Apr 2010 Location: Australia Posts: 16,675

Not much useful stuff is within logs other than maybe start time and finish, probably easier just using event scripter and gather info and create/update db
or do it within the core create stats module/extension
__________________

#1029
11.12.2019, 18:25
 Rabelux Baby Loader Join Date: Oct 2018 Posts: 8
Exitcode of callsync()

Hi mgpai,
is there a way to retrieve the exit code of a callsync()-function?
Or to specify my question: how do I check whether the called function/script did not encounter any errors? If I got this correct a callsync() returns the first stdout that occours. In my case that doesn't leave a clue whether the call was succesfull.
To give you an idea what I'm trying to accomplish:
I have a headless setup of JDownloader on a remote server and after finishing a download I want that file to be copied to my local server via scp. If that was successfull the remote server should delete the file.
I got the copy-part working but cannot check whether it was successful.
My code:
Code:
//trigger: download stopped
disablePermissionChecks();
var result = callSync("scp", sourceFile, "user@hostname:/path");
if (result == 0) {
deleteFile(sourceFile, false);
log(sourceFile + " should be deleted")
} else {
log("Err: scp-result = " + result);
}
if (package.isFinished()) package.remove();
}
rabelux
#1030
12.12.2019, 06:01
 mgpai Script Master Join Date: Sep 2013 Posts: 809

Quote:
 Originally Posted by Rabelux is there a way to retrieve the exit code of a callsync()-function?
Exit code is captured by the "$?" operator. You should be able to get it by adding "echo$?" to your command. Cannot use callAsync() instead?
#1031
13.12.2019, 11:44
 Rabelux Baby Loader Join Date: Oct 2018 Posts: 8

Quote:
 You should be able to get it by adding "echo $?" to your command You mean something like Code: callSync("scp", sourceFile, "user@hostname:/path", "; echo$?")
or rather get the echo in a new call like callsync("echo $?")? The question is what does callSync() return? The first, the last, or the sum of all echos to stdout? What would be the benefit of using callAsync()? I thought using sync is better as i want to make sure the whole file has been copied. #1032 13.12.2019, 12:30  mgpai Script Master Join Date: Sep 2013 Posts: 809 Quote:  Originally Posted by Rabelux You mean something like Code: callSync("scp", sourceFile, "user@hostname:/path", "; echo$?") or rather get the echo in a new call like callsync("echo $?")? The question is what does callSync() return? The first, the last, or the sum of all echos to stdout? What would be the benefit of using callAsync()? I thought using sync is better as i want to make sure the whole file has been copied. callSync() will output stdOut or stdErr. You have to use the echo$? as the second command (using &), which will result in stdOut or stdErr + echo result. It is also possible to get just the exit code by redirecting redirect the stdOut & stdErr to null device.

callAsync() will be more suitable as the exitCode, stdOut or stdErr will be available to the callback function. This will be available after the external command has ended (in this case the file has been copied or failed). You then have to just query those properties before executing your code.

Feel free to find me in JD Chat if you need any help with this.
#1033
15.12.2019, 18:56
 HughJazz Baby Loader Join Date: Apr 2017 Posts: 5

Quote:
 Originally Posted by mgpai IG does not provide RSS feeds. You will have to use third-party services to generate custom RSS/XML feeds and add them at regular intervals to linkgrabber using a script. Alternatively, you can also use a script to add native IG urls to the linkgrabber at regular intervals. By default this will fetch all the content from the given url. There is a plugin option where you can specify the 'x' latest items to be fetched. This however does not seem to be currently working as expected. If you want to avoid adding duplicate urls to linkgrabber, you will have to leave the old urls in the download list or linkgrabber list. If the links are present in linkgrabber, JD will skip them. Links present in the download list will be added to the list and marked (BG color will be red) as duplicate. You can create a linkgrabber filter rule to also skip links which are present in the download list. Code: // Add urls to linkgrabber at user-defined intervals // Trigger: Interval (Recommended 3600000 ms or more) var urls = []; urls[urls.length] = "**External links are only visible to Support Staff**; urls[urls.length] = "**External links are only visible to Support Staff**; urls[urls.length] = "**External links are only visible to Support Staff**; urls[urls.length] = "**External links are only visible to Support Staff**; urls[urls.length] = "**External links are only visible to Support Staff**; callAPI("linkgrabberv2", "addLinks", { "links": urls.join(" ") });
I managed to add the script and it is working, but it keeps adding duplicate links, so can you please tell me how to create the filter rule to skip duplicate instagram links?
#1034
16.12.2019, 05:54
 mgpai Script Master Join Date: Sep 2013 Posts: 809

Quote:
 Originally Posted by HughJazz ... how to create the filter rule to skip duplicate instagram links?
Settings > Linkgrabber Filter > Filter :

Code:
Condition > is true > Link is already in downloadlist
Sourceurl(s) > contains > instagram.com
#1035
16.12.2019, 06:58
 raztoki English Supporter Join Date: Apr 2010 Location: Australia Posts: 16,675

creating a crontab like event in theory is good. but realistically when dupes are found decryption task should end.
__________________

#1036
16.12.2019, 19:27
 anonymous Baby Loader Join Date: Sep 2019 Posts: 8

Quote:
 Originally Posted by mgpai Code: // Rename files by matching download url pattern // Trigger: Packagizer Hook if (state == "BEFORE") { var patt = /.+\/domain\.com\/(foo)\/(bar)(\.zip)/i; var name = link.getURL().match(patt); if (name) link.setName(name[2] + "_" + name[1] + name[3]); } Packagizer rules not suitable for this?

Is this what I would need to use in the case of creating a directory and subdirectory based on the pinterest url?

**External links are only visible to Support Staff****External links are only visible to Support Staff**
**External links are only visible to Support Staff****External links are only visible to Support Staff**

mine was more like this with my basic javascript knowledge so, i didn't know exactly how to apply it to this situation
Code:
testVar = document.URL
testVar = https://www.pinterest.com/stewipanzon/english-bull-terrier/

const [first, second] = testVar.split("/").filter(n=>n).slice(-2);
if pinterestURL
if the url is in this format,
main folder is first string
subfolder is second string
...

first = stewipanzon
second = english-bull-terrier
Hoping someone can understand my intent
#1037
16.12.2019, 20:14
 mgpai Script Master Join Date: Sep 2013 Posts: 809

Quote:
 Originally Posted by anonymous Is this what I would need to use in the case of creating a directory and subdirectory based on the pinterest url?
Use the packagizer extension (unless for some reason you need to use a script).

Code:
if > Sourceurl(s) > contains : https://www.pinterest.com/*/*/
then set > Download Directory : <jd:source:1>\<jd:source:2>
#1038
16.12.2019, 20:49
 anonymous Baby Loader Join Date: Sep 2019 Posts: 8

Quote:
 Originally Posted by mgpai Use the packagizer extension (unless for some reason you need to use a script). Settings > Packagizier > Add: Code: if > Sourceurl(s) > contains : https://www.pinterest.com/*/*/ then set > Download Directory : \
Thanks. I thought i needed some kind of regexpr trick at first. I've been searching for those "jd:" parameters but haven't had any luck. I appreciate this a lot. Would it be possible to have it this apply to already downloaded items as well?

Code:
java.io.IOException: Could not create E:\Users\NewAdmin\pinterest\<jd:source:1>\<jd:source:2>
at jd.plugins.PluginForHost.renameOrMove(PluginForHost.java:2409)
at jd.plugins.PluginForHost.handle(PluginForHost.java:2400)
at jd.plugins.PluginForHost.move(PluginForHost.java:2358)
at jd.controlling.downloadcontroller.DownloadWatchDog$44.execute(DownloadWatchDog.java:4483) at jd.controlling.downloadcontroller.DownloadWatchDog$30.run(DownloadWatchDog.java:3008)

Last edited by anonymous; 17.12.2019 at 00:19.
#1039
17.12.2019, 06:24
 mgpai Script Master Join Date: Sep 2013 Posts: 809

Quote:
 Originally Posted by anonymous Thanks. I thought i needed some kind of regexpr trick at first. I've been searching for those "jd:" parameters but haven't had any luck.
You can also match/capture strings using regex by enabling the button at the end of the respective 'if' fields.

List of packagizer variables

Quote:
 Originally Posted by anonymous Would it be possible to have it this apply to already downloaded items as well?
Packagizer rules are processed before the links are added to the linkgrabber. You will have to remove and add them back again. Use the context menu to copy the links to clipboard before removing them from the list.
#1040
20.12.2019, 01:18
 DieKatzchen I will play nice! Join Date: Dec 2019 Posts: 1

Is there a way, using some combination of scripts and/or packagizer rules to convert the URL to a full path, e.g. **External links are only visible to Support Staff**... becomes C:\myfolder\foo\bar\file.zip? I almost had it with packagizer rules but it turned all the / into _ which is not what I want.

 Thread Tools Display Modes Linear Mode

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home International Support     JDownloader 2     Reconnect     Archive English Support     Problems & Bug Reports     Host Plugin Reports     Decrypter Plugin Reports     General Discussion     Suggestions & Requests Deutscher Support     Probleme & Bugreports     Hoster-Plugin Probleme     Decrypter-Plugin Probleme     Allgemeine Diskussion     Wünsche Pomoc w języku polskim     Zgłaszanie błędów programu     Ponowne po³±czenie (Reconnect)     Wtyczki hostingu     Wtyczki rozszyfrowujące     Dyskusja Ogólna     Sugestie i ¿yczenia Soporte en Español     Spanish     Reconexión Türkçe destek     Turkish     Tekrar bağlan Support français     French     Reconnexion

All times are GMT +2. The time now is 16:21.
 -- Deutsch (DE) -- English (US) -- Español (ES) -- Polski (PL) -- Türkçe (TR) JDownloader Community Board - Archive - Top 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 1Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.