#2961
|
||||
|
||||
@hulleyrob: sometimes solution is easier than thought Thanks for sharing your solution!
I will still work on better/easier browser usage. In case you need further help/got questions, just ask
__________________
JD-Dev & Server-Admin |
#2962
|
||||
|
||||
@mpgai
New Script Request: A script which converts ssssss.ms (sec. and msec.) to hh:mm:ss.xxx Great thanks to Jiaz and especially pspzockerscene for implementing below properties in the PlugIns for keep2share and fileboom:
Important note: In order to get this working, in the PlugIn settings - e.g. for k2s (keep2share) - you need to set single linkcheck as File linkcheck mode. In Packagizer Rules, for Download-URLs which contain e.g k2s.cc set Comment as e.g. as <jd:prop:video_width>,<jd:prop:video_duration> For each new link added to LingGrabber, those properties will be shown in comments. The duration, however, is shown as raw value. For example: 4259.042 which is 4259 sec. and 42 msec. What I would like to see is format hh:mm:ss.xxx In this example 01:10:59.042 And for this conversion I would like to ask for a script. Thank you very much for any efforts taken! |
#2963
|
|||
|
|||
Quote:
Is it worth uploading the logs for you to take a look? 20.06.24 06.16.53 <--> 20.06.24 08.43.39 jdlog://3653411370661/ Also once it has failed it disables the script. just enabling it again makes it work fine for another x times. |
#2964
|
||||
|
||||
@hulleyrob: looks like some timeout issues with apprise, see
github.com/caronc/apprise-api/issues/29 github.com/caronc/apprise-api/issues/16 you should be able to try/catch the error to avoid the dialog/auto disable of the script alternative you can make use of the following commands Quote:
__________________
JD-Dev & Server-Admin |
#2965
|
|||
|
|||
Thank you will give it a go later when I get home.
|
#2966
|
|||
|
|||
try {
postPage('**External links are only visible to Support Staff**, "urls=synology://192.168.0.4:5000/TOKEN&body=" + package.getName() + " finished."); } catch (e) { if (!(e instanceof Error)) { e = new Error(e); } console.error(e.message); } A quick google of a JavaScript try catch and this appears to be working. Can you suggest any improvements? |
#2967
|
||||
|
||||
@hulleyrob: maybe URL encode package name to avoid issues if special/forbidden chars are part of it&final URL.
also maybe enqueue stuff that failed and retry sending them a few seconds later?
__________________
JD-Dev & Server-Admin |
#2968
|
|||
|
|||
If you find a suitable JS snippet on github[gist] or stackoverflow which can do it, I can help you add it to eventscripter.
|
#2969
|
||||
|
||||
Quote:
What I have is an Excel formula which can do the job. But I guess that cannot be used here. But in the meantime: Would it at least be possible to replace the "." (point) with a "," (comma). Example: 12345.678 should be replaced with 12345,678 Could you create a script, which can do this "replacement" job? That would also help me. Thanks in advance for any efforts taken! |
#2970
|
|||
|
|||
Code:
/* generate "video_duration_comma" property trigger : packagizer hook Enable "synchronous execution of script" checkbox in top panel */ if (linkcheckDone && state == "BEFORE") { var duration = link.getProperty("video_duration"); if (duration != null) { link.setProperty("video_duration_comma", duration.toString().replace(".",",")); } } |
#2971
|
||||
|
||||
Quote:
Probably my mistake? I selected "packagizer hook" I set the checkbox "synchronous execution of script" But still output in comment is something like this for duration: 4149.412 as it is without the script. Any ideas what I could have done wrong? |
#2972
|
|||
|
|||
Which placeholder have you used in packagier rule?
|
#2973
|
||||
|
||||
Code:
<jd:prop:video_duration> <jd:prop:video_width> <jd:prop:video_height> <jd:prop:video_format> But now I see my mistake: should haved used <jd:prop:video_duration_comma> Now it's working! Thank you very much! Last edited by StefanM; 21.06.2024 at 19:50. |
#2974
|
|||
|
|||
Quote:
|
#2975
|
|||
|
|||
|
#2976
|
||||
|
||||
Quote:
Here's a JS snippet which hopefully does the job. It should even take care of the replacement of "." with "," Code:
function convertToTimeFormat(input) { // Split the input string into seconds and milliseconds let [seconds, milliseconds] = input.split('.').map(Number); // Calculate hours, minutes, and remaining seconds let hours = Math.floor(seconds / 3600); seconds = seconds % 3600; let minutes = Math.floor(seconds / 60); seconds = seconds % 60; // Format hours, minutes, and seconds to always be two digits hours = hours.toString().padStart(2, '0'); minutes = minutes.toString().padStart(2, '0'); seconds = seconds.toString().padStart(2, '0'); // Format milliseconds to always be three digits milliseconds = milliseconds.toString().padStart(3, '0'); // Combine and return the formatted string return `${hours}:${minutes}:${seconds},${milliseconds}`; } // Example usage let input = "4259.042"; let formattedTime = convertToTimeFormat(input); console.log(formattedTime); // Output: "01:10:59,042" 1. Split the Input String: The input string is split into seconds and milliseconds using split('.'). 2. Convert to Numbers: Both parts of the split string are converted to numbers using map(Number). 3. Calculate Hours, Minutes, and Seconds:
4. Format with Padding: padStart(2, '0') ensures that hours, minutes, and seconds are always two digits. padStart(3, '0') ensures that milliseconds are always three digits. 5. Combine and Return: The formatted time parts are combined into the final string in the desired format. Copyright: ChatGPT |
#2977
|
|||
|
|||
Quote:
ChatGPT is not a reliable source for scripts/snippets. It often mixes up languages and also picks methods/functions out of thin air. That is the reason I suggested specific sources in my reply. While newer JS methods are not supported in JD, if you find a snippet which does, it should be possible to figure out to make it work in JD. |
#2978
|
||||
|
||||
Then it's going to be very complicated for me to find something, because I'm not familiar with Java Script at all.
Quote:
Quote:
As you probably know, JD is available with different Java versions. But... ...if I understand you correctly, even a snippet with newer JS methods would help, as long as it has not been created by ChatGPT? So, it would make sense if I continue searching for a snippet, created by a source one can trust? |
#2979
|
|||
|
|||
Quote:
Code:
//Add your script here. Feel free to use the available api properties and methods // Retry code var encoded = encodeURI(package.getName()); // appriseUrl in format: // discord://avatar@webhook_id/webhook_token // line://Token@User // ntfys://topic/ // pover://user@token/DEVICE // synology://hostname:port/token // tgram://bottoken/ChatID // mailtos://domain.com:465?user=userid&pass=password var appriseUrl = "synology://192.168.0.4:5000/TOKEN_REMOVED" // appriseAPI IP:Port/notify of the server running the apprise api var appriseAPI = '**External links are only visible to Support Staff** const fn = postPage( appriseAPI, "urls=" + appriseURL +"&body=" + encoded + " finished."); var maxRetries = 3 function retry(maxRetries, fn) { sleep(2000); return fn().catch(function(err) { if (maxRetries <= 0) { throw err; } return retry(maxRetries - 1, fn); }); } Well definitely took longer than I had hoped went through so many different code snippets from stack overflow but I couldnt get them working so ended up with this. @Jiaz can you see anything obviously wrong? (it seems to work but its hard to test the it might fail part) |
#2980
|
|||
|
|||
another one ...
Code:
var notified = false; var count = 0; var notify = function() { postPage("url", "data"); } while (!notified && count < 3) { try { notify(); notified = true; } catch (e) { alert(e.message); count++; sleep(2000); }; } |
#2981
|
|||
|
|||
would alert be the popover message with the error and ok button as im trying to avoid that?
|
#2982
|
|||
|
|||
@StefanM this should support the JD javascript version.
Code:
function convertToTimeFormat(input) { // Split the input string into seconds and milliseconds var split = input.split('.'); var seconds = split[0] var milliseconds = split[1] // Calculate hours, minutes, and remaining seconds var hours = Math.floor(seconds / 3600); seconds = seconds % 3600; var minutes = Math.floor(seconds / 60); seconds = seconds % 60; // Format hours, minutes, and seconds to always be two digits hours = String(hours).padStart(2, '0'); minutes = String(minutes).padStart(2, '0'); seconds = String(seconds).padStart(2, '0'); // Format milliseconds to always be three digits milliseconds = String(milliseconds).padStart(3, '0'); // Combine and return the formatted string return hours + ":" + minutes + ":" + seconds + "," + milliseconds; } Last edited by TGU; 23.06.2024 at 00:55. |
#2983
|
||||
|
||||
Verwendete Java Version und EventScripter
Zu diesem Java-Snippet teilte mir mgpai mit:
Quote:
|
#2984
|
||||
|
||||
EventScripter Threads zusammengeführt.
__________________
JD Supporter, Plugin Dev. & Community Manager
Erste Schritte & Tutorials || JDownloader 2 Setup Download |
#2985
|
||||
|
||||
@StefanM: Es geht um Javascript und nicht um Java. Unabhängig von der genutzten Java Version. Bei dem Testdurchlauf deines Skripts wird dir die Engine sagen welche Zeile/Befehle Probleme machen/unbekannt(nicht unterstützt) sind. Hier gilt, einfacheres Javascript zu nutzen. zb kann die genutzte Engine kein
Quote:
Quote:
@TGU: Thanks for your help and great and simple script solution!
__________________
JD-Dev & Server-Admin |
#2986
|
||||
|
||||
Quote:
https://board.jdownloader.org/showpo...postcount=2982 So, could you use it to create the script I'm after? Thanks in advance! |
#2987
|
||||
|
||||
Quote:
Forwarded it to mgpai. |
#2988
|
|||
|
|||
Quote:
Linked scriopt does not work in it its current form. Contains method not supported it in JD. |
#2989
|
|||
|
|||
Yes. That will be useful to find/fix the error. You can then remove or comment out that line. Once code is fixed, you may not even need the retry loop.
|
#2990
|
||||
|
||||
Quote:
https://board.jdownloader.org/showpo...postcount=2988 According to his expertise, it also uses methods, which are not supported by JD. Can you or maybe Jiaz help? Thanks for any efforts taken. |
#2991
|
||||
|
||||
Quote:
Tested and working Code:
if (!String.prototype.padStart) { String.prototype.padStart = function padStart(targetLength,padString) { targetLength = targetLength>>0; //truncate if number or convert non-number to 0; padString = String((typeof padString !== 'undefined' ? padString : ' ')); if (this.length > targetLength) { return String(this); } else { targetLength = targetLength-this.length; if (targetLength > padString.length) { padString += padString.repeat(targetLength/padString.length); //append to original to ensure we are longer than needed } return padString.slice(0,targetLength) + String(this); } }; }
__________________
JD-Dev & Server-Admin |
#2992
|
||||
|
||||
Quote:
Quote:
And you, Jiaz, can confirm that it correctly converts seconds.milliseconds to hh:mm:ss,xxx? So that there will be no additional workload for mgpai? Thanks again to everybody involved in my request for any efforts taken! :rolleyes: |
#2993
|
||||
|
||||
Quote:
__________________
JD-Dev & Server-Admin |
#2995
|
|||
|
|||
Quote:
That would be great. It would save a lot of overhead if it would be available directly within the plugin.You can let me know if there was any progress or if you need anything |
#2996
|
||||
|
||||
Quote:
https://board.jdownloader.org/showpo...postcount=2991 Not sure, whether or not you saw it. My script request was about converting the values of <jd:prop:video_duration_comma> (<jd:prop:video_duration>)
Thanks! |
#2997
|
|||
|
|||
It is a polyfill to be used in the original code provided by you and subsequently modified by @TGU. While I can look into it, I cannot provide an ETA.
|
#2998
|
||||
|
||||
Quote:
Thanks in advance for any efforts taken! No ETA is of course acceptable, as my request seems to be a more complicated one... Thanks again for willing to help me once more! Last edited by StefanM; 01.07.2024 at 17:42. |
#2999
|
|||
|
|||
trigger to rename package name when add specific url
Hi, I try to rename a package when I add this url
**External links are only visible to Support Staff****External links are only visible to Support Staff** it returns to me Moving for package name but I want to rename this package into a specific name, for example Dalpalan – Moving "New link added" trigger is selected and I tried to test with this javascript code Code:
var specificLink = "**External links are only visible to Support Staff**; functionName(function(link) { if (link.getDownloadURL() === specificLink) { var package = link.getPackage(); package.setName("Nuovo Nome del Pacchetto"); } }); Last edited by nathan1; 01.07.2024 at 18:04. |
#3000
|
||||
|
||||
This script for convert all audio files in MP3 320Kbps, don't work now, few weeks ago works perfectly: ...I check for updates regularly...someone put a actually 100% working script for convert all audio files to MP3 320Kbps and automatically delete original files?
------- EDIT: 100% working script for convert all audio files (YouTube, etc...) to MP3 320Kbps and automatically delete all original files: Quote:
Only works the normal script for convert in MP3 128Kbps, and this script don't erase the original files: Quote:
Quote:
I tried to reinstall JDownloader 2 but the same error occurs.I use W10 x64. ------- This is the error message box: Code:
An Error Occured:ID=1720285601855|Name=null|Trigger=ON_DOWNLOAD_CONTROLLER_STOPPED missing } in compound statement (#16) Ok Error details This Error is caused by: net.sourceforge.htmlunit.corejs.javascript.EvaluatorException: missing } in compound statement (#16) at net.sourceforge.htmlunit.corejs.javascript.DefaultErrorReporter.runtimeError(DefaultErrorReporter.java:71) at net.sourceforge.htmlunit.corejs.javascript.DefaultErrorReporter.error(DefaultErrorReporter.java:61) at net.sourceforge.htmlunit.corejs.javascript.Parser.addError(Parser.java:187) at net.sourceforge.htmlunit.corejs.javascript.Parser.addError(Parser.java:167) at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:254) at net.sourceforge.htmlunit.corejs.javascript.Parser.reportError(Parser.java:249) at net.sourceforge.htmlunit.corejs.javascript.Parser.mustMatchToken(Parser.java:401) at net.sourceforge.htmlunit.corejs.javascript.Parser.mustMatchToken(Parser.java:392) at net.sourceforge.htmlunit.corejs.javascript.Parser.block(Parser.java:1700) at net.sourceforge.htmlunit.corejs.javascript.Parser.statementHelper(Parser.java:1031) at net.sourceforge.htmlunit.corejs.javascript.Parser.statement(Parser.java:926) at net.sourceforge.htmlunit.corejs.javascript.Parser.ifStatement(Parser.java:1102) at net.sourceforge.htmlunit.corejs.javascript.Parser.statementHelper(Parser.java:970) at net.sourceforge.htmlunit.corejs.javascript.Parser.statement(Parser.java:926) at net.sourceforge.htmlunit.corejs.javascript.Parser.parse(Parser.java:570) at net.sourceforge.htmlunit.corejs.javascript.Parser.parse(Parser.java:491) at net.sourceforge.htmlunit.corejs.javascript.Context.compileImpl(Context.java:2661) at net.sourceforge.htmlunit.corejs.javascript.Context.compileString(Context.java:1624) at org.jdownloader.scripting.JSHtmlUnitPermissionRestricter$SandboxContextFactory$1.compileString(JSHtmlUnitPermissionRestricter.java:150) at net.sourceforge.htmlunit.corejs.javascript.Context.compileString(Context.java:1616) at net.sourceforge.htmlunit.corejs.javascript.Context.evaluateString(Context.java:1358) at org.jdownloader.extensions.eventscripter.ScriptThread.evalUNtrusted(ScriptThread.java:346) at org.jdownloader.extensions.eventscripter.ScriptThread.executeScipt(ScriptThread.java:194) at org.jdownloader.extensions.eventscripter.ScriptThread.run(ScriptThread.java:174) Last edited by dataDyne; 07.07.2024 at 04:39. |
Thread Tools | |
Display Modes | |
|
|