JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #2961  
Old 18.06.2024, 10:53
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,281
Default

@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
Reply With Quote
  #2962  
Old 18.06.2024, 11:46
StefanM's Avatar
StefanM StefanM is offline
JD Legend
 
Join Date: Oct 2020
Posts: 734
Default

@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:
  • video_duration
  • video_width
  • video_height
  • video_format
Now, you can have these properties being shown in 'comments' by creating a Packagizer Rule.

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!
Reply With Quote
  #2963  
Old 20.06.2024, 11:42
hulleyrob hulleyrob is offline
Super Loader
 
Join Date: Dec 2022
Posts: 27
Default

Quote:
Originally Posted by Jiaz View Post
@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
funny you should say that, I have intermittent problem when running the event script a massive popup box appears occasionally with an IOException 424 failed dependency as the most obvious part of the error.

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.
Reply With Quote
  #2964  
Old 20.06.2024, 13:48
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,281
Default

@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:
setAdvancedAlert(myBoolean);/*enable/disable alert with textbox and copy&paste*/
setDisableOnException(myBoolean);/*enable/disable script on exceptions*/
__________________
JD-Dev & Server-Admin
Reply With Quote
  #2965  
Old 20.06.2024, 16:42
hulleyrob hulleyrob is offline
Super Loader
 
Join Date: Dec 2022
Posts: 27
Default

Thank you will give it a go later when I get home.
Reply With Quote
  #2966  
Old 20.06.2024, 18:19
hulleyrob hulleyrob is offline
Super Loader
 
Join Date: Dec 2022
Posts: 27
Default

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?
Reply With Quote
  #2967  
Old 21.06.2024, 01:44
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,281
Default

@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
Reply With Quote
  #2968  
Old 21.06.2024, 18:31
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,622
Default

Quote:
Originally Posted by StefanM View Post
What I would like to see is format hh:mm:ss.xxx
If you find a suitable JS snippet on github[gist] or stackoverflow which can do it, I can help you add it to eventscripter.
Reply With Quote
  #2969  
Old 21.06.2024, 18:47
StefanM's Avatar
StefanM StefanM is offline
JD Legend
 
Join Date: Oct 2020
Posts: 734
Default

Quote:
Originally Posted by mgpai View Post
If you find a suitable JS snippet on github[gist] or stackoverflow which can do it, I can help you add it to eventscripter.
Thanks for taking a look at my request!

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!
Reply With Quote
  #2970  
Old 21.06.2024, 19:06
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,622
Default

Quote:
Originally Posted by StefanM View Post
... replace the "." (point) with a "," (comma).
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(".",","));
    }
}
Reply With Quote
  #2971  
Old 21.06.2024, 19:54
StefanM's Avatar
StefanM StefanM is offline
JD Legend
 
Join Date: Oct 2020
Posts: 734
Default

Quote:
Originally Posted by mgpai View Post
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(".",","));
    }
}
Not working for me.
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?
Reply With Quote
  #2972  
Old 21.06.2024, 20:08
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,622
Default

Quote:
Originally Posted by StefanM View Post
Not working for me.
Which placeholder have you used in packagier rule?
Reply With Quote
  #2973  
Old 21.06.2024, 20:47
StefanM's Avatar
StefanM StefanM is offline
JD Legend
 
Join Date: Oct 2020
Posts: 734
Default

Quote:
Originally Posted by mgpai View Post
Which placeholder have you used in packagier rule?
Code:
<jd:prop:video_duration>		<jd:prop:video_width>	<jd:prop:video_height>	<jd:prop:video_format>
all separated by tabs.

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 20:50.
Reply With Quote
  #2974  
Old 21.06.2024, 20:52
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,622
Default

Quote:
Originally Posted by StefanM View Post
...all separated by tabs.
Quote:
generate "video_duration_comma" property
Will leave the original unchanged and add a new property.
Reply With Quote
  #2975  
Old 21.06.2024, 20:54
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,622
Default

Quote:
Originally Posted by StefanM View Post
Thank you very much!
You're welcome.
Reply With Quote
  #2976  
Old 22.06.2024, 11:18
StefanM's Avatar
StefanM StefanM is offline
JD Legend
 
Join Date: Oct 2020
Posts: 734
Default

Quote:
Originally Posted by mgpai View Post
If you find a suitable JS snippet on github[gist] or stackoverflow which can do it, I can help you add it to eventscripter.
Hello again!
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"
Explanation:

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:
  • Hours are calculated by dividing the total seconds by 3600 (the number of seconds in an hour).
  • Remaining seconds are calculated using the modulo operator % and then converted to minutes and seconds similarly.

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
Reply With Quote
  #2977  
Old 22.06.2024, 11:50
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,622
Default

Quote:
Originally Posted by StefanM View Post
Here's a JS snippet which hopefully does the job. It should even take care of the replacement of "." with ","
...
Copyright: ChatGPT
Contains methods not supported in eventscripter.

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.
Reply With Quote
  #2978  
Old 22.06.2024, 12:11
StefanM's Avatar
StefanM StefanM is offline
JD Legend
 
Join Date: Oct 2020
Posts: 734
Default

Quote:
Originally Posted by mgpai View Post
Contains methods not supported in eventscripter.
Then it's going to be very complicated for me to find something, because I'm not familiar with Java Script at all.
Quote:
Originally Posted by mgpai View Post
ChatGPT is not a reliable source for scripts/snippets. It often mixes up languages and also picks methods/functions out of thin air.
You are right. In my experience some 20 to 50 percent of answers I get, are incorrect. But as - on the other hand - some 50 to 80 percent are correct, I use ChatGPT quite often. E.g. even very complicated Excel formulas are nearly always working as specified.
Quote:
Originally Posted by mgpai View Post
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.
Do the JS methods supported in JD depend on the Java version I use with JD?
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?
Reply With Quote
  #2979  
Old 22.06.2024, 15:06
hulleyrob hulleyrob is offline
Super Loader
 
Join Date: Dec 2022
Posts: 27
Default

Quote:
Originally Posted by Jiaz View Post
@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?
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)
Reply With Quote
  #2980  
Old 22.06.2024, 16:26
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,622
Default

Quote:
Originally Posted by hulleyrob View Post
... went through so many different code snippets
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);
    };
}
Reply With Quote
  #2981  
Old 22.06.2024, 17:50
hulleyrob hulleyrob is offline
Super Loader
 
Join Date: Dec 2022
Posts: 27
Default

Quote:
Originally Posted by mgpai View Post
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);
    };
}
would alert be the popover message with the error and ok button as im trying to avoid that?
Reply With Quote
  #2982  
Old 23.06.2024, 01:50
TGU TGU is offline
JD Fan
 
Join Date: Jun 2024
Location: International Waters where DRM/DMCA protections are ignored
Posts: 72
Default

@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 01:55.
Reply With Quote
  #2983  
Old 23.06.2024, 16:20
StefanM's Avatar
StefanM StefanM is offline
JD Legend
 
Join Date: Oct 2020
Posts: 734
Default Verwendete Java Version und EventScripter

Zu diesem Java-Snippet teilte mir mgpai mit:
Quote:
Contains methods not supported in eventscripter.
...
...newer JS methods are not supported in JD...
Fragen dazu:
  1. Konkret welche der im Snippet verwendeten Befehle werden vom EventScripter nicht unterstützt?
  2. Welchen "Ersatz" kann man für die nicht unterstützen Befehle verwenden, d.h .das Snippet entsprechend umschreiben?
  3. Oder sind die "supported methods" abhängig von der im JD verwendeten Java-Version?
Reply With Quote
  #2984  
Old 24.06.2024, 11:08
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 73,479
Default

EventScripter Threads zusammengeführt.
__________________
JD Supporter, Plugin Dev. & Community Manager

Erste Schritte & Tutorials || JDownloader 2 Setup Download
Spoiler:

A users' JD crashes and the first thing to ask is:
Quote:
Originally Posted by Jiaz View Post
Do you have Nero installed?
Reply With Quote
  #2985  
Old 24.06.2024, 20:56
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,281
Default

@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:
let
oder
Quote:
.map
. Die Lösung von https://board.jdownloader.org/showpo...postcount=2982 sollte perfekt klappen.


@TGU: Thanks for your help and great and simple script solution!
__________________
JD-Dev & Server-Admin
Reply With Quote
  #2986  
Old 24.06.2024, 22:42
StefanM's Avatar
StefanM StefanM is offline
JD Legend
 
Join Date: Oct 2020
Posts: 734
Default

Quote:
Originally Posted by mgpai View Post
Contains methods not supported in eventscripter.

ChatGPT is not a reliable source for scripts/snippets....
Now, this snippet comes from a source you will trust:
https://board.jdownloader.org/showpo...postcount=2982

So, could you use it to create the script I'm after?

Thanks in advance!
Reply With Quote
  #2987  
Old 24.06.2024, 22:44
StefanM's Avatar
StefanM StefanM is offline
JD Legend
 
Join Date: Oct 2020
Posts: 734
Default

Quote:
Originally Posted by TGU View Post
@StefanM this should support the JD javascript version.

Code:
function convertToTimeFormat(input)...
Thanks a lot.
Forwarded it to mgpai.
Reply With Quote
  #2988  
Old 25.06.2024, 07:13
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,622
Default

Quote:
Originally Posted by StefanM View Post
Now, this snippet comes from a source you will trust:
**External links are only visible to Support Staff**...

So, could you use it to create the script I'm after?

Thanks in advance!
No. Getting a working snippet is not about TRUST. It is simply means getting one which works out of the box, without having to spend time tinkering it.

Linked scriopt does not work in it its current form. Contains method not supported it in JD.
Reply With Quote
  #2989  
Old 25.06.2024, 09:00
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,622
Default

Quote:
Originally Posted by hulleyrob View Post
would alert be the popover message with the error and ok button as im trying to avoid that?
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.
Reply With Quote
  #2990  
Old 25.06.2024, 11:01
StefanM's Avatar
StefanM StefanM is offline
JD Legend
 
Join Date: Oct 2020
Posts: 734
Default

Quote:
Originally Posted by TGU View Post
@StefanM this should support the JD javascript version.

Code:
function convertToTimeFormat(input)
...
Well, this is mgpai's reply:
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.
Reply With Quote
  #2991  
Old 25.06.2024, 11:19
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,281
Default

Quote:
Originally Posted by mgpai View Post
Linked scriopt does not work in it its current form. Contains method not supported it in JD.
Can be added via polyfil, see stackoverflow.com/questions/51445306/what-alternative-for-padstart
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
Reply With Quote
  #2992  
Old 25.06.2024, 11:48
StefanM's Avatar
StefanM StefanM is offline
JD Legend
 
Join Date: Oct 2020
Posts: 734
Default

Quote:
Originally Posted by mgpai View Post
Linked scriopt does not work in it its current form. Contains method not supported it in JD.
So, if I understand Jiaz correctly, the script can be used in JD Event Scripter when added via polyfill.

Quote:
Originally Posted by Jiaz View Post
Can be added via polyfil, see stackoverflow.com/questions/51445306/what-alternative-for-padstart
Tested and working
Code:
if (!String.prototype.padStart) {
...
@ Jiaz: This means that mgpai could use the script as is?

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:
Reply With Quote
  #2993  
Old 25.06.2024, 12:09
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 81,281
Default

Quote:
Originally Posted by StefanM View Post
can confirm that it correctly converts seconds.milliseconds to hh:mm:ss,xxx?
see my response
Quote:
Originally Posted by Jiaz View Post
Tested and working
__________________
JD-Dev & Server-Admin
Reply With Quote
  #2994  
Old 25.06.2024, 12:25
StefanM's Avatar
StefanM StefanM is offline
JD Legend
 
Join Date: Oct 2020
Posts: 734
Default

Quote:
Originally Posted by Jiaz View Post
see my response
Sorry!
I only asked explicitly for the function described so that mgpai can be sure that he wouldn't have to "rework" anything and that he can use the snippet as is.
Reply With Quote
  #2995  
Old 30.06.2024, 06:08
DamonDragon DamonDragon is offline
DSL User
 
Join Date: Aug 2016
Posts: 38
Default

Quote:
Originally Posted by Jiaz View Post
@DamonDragon: nice one! we will check if its easy doable to integrate this step with ffmpeg directly into plugin/download of video
Thank you
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
Reply With Quote
  #2996  
Old 01.07.2024, 17:20
StefanM's Avatar
StefanM StefanM is offline
JD Legend
 
Join Date: Oct 2020
Posts: 734
Default

Quote:
Originally Posted by mgpai View Post
No. Getting a working snippet is not about TRUST. It is simply means getting one which works out of the box, without having to spend time tinkering it.

Linked scriopt does not work in it its current form. Contains method not supported it in JD.
May I resend this snippet once again:
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>)
  • from seconds.msec
  • to hh:mm:ss,msec
However, if it is too much work for you, just let me know, and I won't ask for this script anymore.

Thanks!
Reply With Quote
  #2997  
Old 01.07.2024, 17:46
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,622
Default

Quote:
Originally Posted by StefanM View Post
However, if it is too much work for you, just let me know, and I won't ask for this script anymore.
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.
Reply With Quote
  #2998  
Old 01.07.2024, 18:18
StefanM's Avatar
StefanM StefanM is offline
JD Legend
 
Join Date: Oct 2020
Posts: 734
Default

Quote:
Originally Posted by mgpai View Post
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.
Yes, @Jiaz created this snippet for me, so you would have a working and tested (by @Jiaz) snippet.

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 18:42.
Reply With Quote
  #2999  
Old 01.07.2024, 19:01
nathan1 nathan1 is offline
JD VIP
 
Join Date: Apr 2012
Posts: 397
Default 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");
    }
});
but nothing, it freeze jdownloader I see

Last edited by nathan1; 01.07.2024 at 19:04.
Reply With Quote
  #3000  
Old 06.07.2024, 22:39
dataDyne's Avatar
dataDyne dataDyne is offline
Baby Loader
 
Join Date: Mar 2024
Posts: 8
Question

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:
Originally Posted by dataDyne View Post
Yes! Works perfectly
This is the full script for converting all YouTube audio files (aac,m4a,ogg,opus) to MP3 320 Kbps bitrate.With the Trigger in Event Scripter activated "A Download stopped", and automatically delete all original files:
Code:
/*
    Convert aac/m4a/ogg/opus files to 320 kbps mp3.
    Trigger required: "A Download Stopped".
*/

if (link.finished) {
    var input = link.downloadPath;
    var output = link.downloadPath.replace(/(.+\.)(aac|m4a|ogg|opus)$/i, "$1mp3");

    if (input != output) {
        var interfaceName = "org.jdownloader.controlling.ffmpeg.FFmpegSetup";
        var ffmpeg = callAPI("config", "get", interfaceName, null, "binarypath");

        callSync(ffmpeg, "-n", "-i", input, "-b:a", "320k", output);
        getPath(output).size && getPath(input).delete();
    }
}
-------
Only works the normal script for convert in MP3 128Kbps, and this script don't erase the original files:
Quote:
Originally Posted by mgpai View Post
Code:
/*
    Convert audio files to mp3 format
    Trigger : A download stopped
*/

if (link.finished) {
    var input = link.downloadPath;
    var output = input.replace(/(aac|m4a|ogg|opus)$/, "mp3");

    if (input != output) {
        try {
            var ffmpeg = callAPI("config", "get", "org.jdownloader.controlling.ffmpeg.FFmpegSetup", null, "binarypath");
            var bitrate = callSync(ffmpeg, "-i", input).match(/bitrate: (\d+) kb/)[1];

            callAsync(function(error) {
                !error && getPath(input).delete();
            }, ffmpeg, "-y", "-i", input, "-b:a", bitrate + "k", output);
        } catch (e) {};
    }
}
EDIT: This script convert all to MP3 128Kbps, and delele automatically all original files:
Quote:
Originally Posted by mgpai View Post
Code:
// Convert aac/m4a/ogg/opus files to mp3.
// Trigger required: "A Download Stopped".
// Requires ffmpeg/ffprobe. Uses JD ffmpeg/ffprobe settings if available.
// Overwrites destination file (mp3) if it already exists.

if (link.isFinished()) {
    var fileName = link.name.replace(/(.+)(\..+$)/, "$1");
    var fileType = link.name.replace(/(.+)(\..+$)/, "$2");
    var sourceFile = link.getDownloadPath();
    var audioFile = /\.(aac|m4a|ogg|opus)$/.test(sourceFile);

    if (audioFile) {
        var downloadFolder = package.getDownloadFolder();
        var destFile = downloadFolder + "/" + fileName + ".mp3";
        var ffmpeg = callAPI("config", "get", "org.jdownloader.controlling.ffmpeg.FFmpegSetup", null, "binarypath");
        var ffprobe = callAPI("config", "get", "org.jdownloader.controlling.ffmpeg.FFmpegSetup", null, "binarypathprobe");
        var data = JSON.parse(callSync(ffprobe, "-v", "quiet", "-print_format", "json", "-show_streams", "-show_format", sourceFile));
        var streamsBitrate = data.streams[0].bit_rate ? data.streams[0].bit_rate : 0;
        var formatBitrate = data.format.bit_rate ? data.format.bit_rate : 0;
        var bitrate = Math.max(streamsBitrate, formatBitrate) / 1000;
        var deleteSourceFile = true

        if (bitrate > 0) {
            callSync(ffmpeg, "-y", "-i", sourceFile, "-b:a", bitrate + "k", destFile);
            if (deleteSourceFile && getPath(destFile).exists()) deleteFile(sourceFile, false);
        }
    }
}
-------
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 05:39.
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 00:13.
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.