JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1  
Old 08.08.2015, 09:57
DerJens
Guest
 
Posts: n/a
Post EventScripter - Link Status

Hi,
ich habe die EventSctipter Extension entdeckt. Cool, dass ihr diese tolle Möglichkeit bereitstellt.
Ich habe nach einer API Doku gesucht, hatte aber keinen Erfolg. Gibt es eine Doku oder einen Code Editor mit Code Completion, der die JD Scripting API kennt?

Konkret möchte ich erstmal ein Script bauen, dass:
a) alle Downloads mit CRC Fehler resettet
b) alle übersprungenen Downloads fortsetzt
c) reset bei CRC Fehler aber nur X mal. Nach dem Xten reset() soll der nur der Status Text angepasst, aber kein Reset ausgeführt werden.

So etwa hatte ich mir das Script vorgestellt. Kann jemand helfen?

Code:
//check if downloads are running at all
if (isDownloadControllerRunning() && !isDownloadControllerStopping()) {
    var allLinks = getAllDownloadLinks();    // <--- Funktion???
    //loop through all Downloads
    for (var i = 0; i < links.length; i++) {
        var currentLink == allLinks[i];
        if (currentLink.getStatusText().contains("CRC Prüfung fehlgeschlagen"){
          var resetCount = currentLink.getTag();
          const maxResetCount == 5;
          if (resetCount == null) 
          {
              resetCount = 0;
          }
          if (resetCount <= maxResetCount)
          {
              currentLink.reset();
              resetCount ++;
              currentLink.setTag(resetCount);
          }
          else
          {
              currentLink.setStatusText("endgültig fehlgeschlagen (CRC)");
          }
        }
        else if (currentLink.getStatus() == "Skipped"){ // <-- enum Wert???? 
            currentLink.setSkipped(false);
        }
    }
}
Reply With Quote
  #2  
Old 08.08.2015, 10:36
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,614
Default

@DerJens
I would say using translation feedback isn't that great as it could change at any time a translator improves translation OR you switch language used in JD via user interface setting. But I guess that works for testing purposes. Ideally it would be better if getStatus was static, and not related to translations services.

There is no formal documentation other than what's in the HELP section of event scripter.

Quick look at the code (I'm not the best with js), I don't recommend this approach due to it been stored within memory, if you stop and restart download session or restart JDownloader all your count values are lost. Maybe best to store in some type of file? Also will if statement be suffice?, I know if statement in Java will only enter that statement once, are you running this in some type of managed loop?

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

Don't fight the system, use it to your advantage. :]

Last edited by raztoki; 08.08.2015 at 11:37. Reason: be = best
Reply With Quote
  #3  
Old 08.08.2015, 11:15
DerJens
Guest
 
Posts: n/a
Default

Hi,
thanks for your support.
The code above is still "pseudo code". It's not completed yet.
Storing the reset count in an external file is a good hint. I'll take care of it.

Within the EventScripter Help I haven't fond a function that returns an array with all download links (or all NOT running downloads).
I can't enumerate my "broken" downloads because "getRunningDownloadLinks()" returns just the running ones.

Than it would be very helpfully to have a list of all "download link properties" that I can get and set by "myDownloadLink.getProperty()" and "myDownloadLink.setProperty()". Could you provide a list of all properties or a "download link" class description?

Last edited by DerJens; 09.08.2015 at 12:27.
Reply With Quote
  #4  
Old 08.08.2015, 11:55
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,614
Default

Yes properties only available to EventScripter does make sense, then you wont need to store to disk like my recommendation earlier.

coalado is responsible for this addon, hopefully he can provide some feedback when he is next available.

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

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #5  
Old 10.08.2015, 11:49
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,532
Default

Warum nicht einfach auf das Event-Download fertig horchen?
Dannach prüfst du dann ob ein CRC Fehler passiert ist und kannst entsprechend handeln.
Macht ja wenig Sinn immer und immer wieder durch alle Links zu iterieren, wenn der gesuchte Fehler eh nur nach einem Download passieren kann.

Gibt es eine Doku oder einen Code Editor mit Code Completion, der die JD Scripting API kennt?
-> Nein, nur alle Funktionen /getter/setter die in der Hilfe überall des Editors angezeigt werden.

"myDownloadLink.getProperty()" and "myDownloadLink.setProperty()". Could you provide a list of all properties or a "download link" class description?
-> properies are plugin specific and not meant to be used outside plugins, so no
-> all important stuff are accessable via getter/setter. If you need more, just tell us
__________________
JD-Dev & Server-Admin
Reply With Quote
  #6  
Old 10.08.2015, 11:52
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,532
Default

Quote:
Originally Posted by DerJens View Post
Konkret möchte ich erstmal ein Script bauen, dass:
a) alle Downloads mit CRC Fehler resettet
b) alle übersprungenen Downloads fortsetzt
c) reset bei CRC Fehler aber nur X mal. Nach dem Xten reset() soll der nur der Status Text angepasst, aber kein Reset ausgeführt werden.
a.) hier am besten auf das Event nach dem Download beendet horchen.Und den Status prüfen
b.) Würde ich nicht pauschalisieren. Denn bei nem Skip mit Platte Voll/Ordner ungültig bist du schnell in einer Endlos-Schleife. Also auch hier eher merken wie oft du es *versucht* hast und dann nicht mehr erneut versuchen
c.) Status-Text kann man nicht anpassen, das ist ein Enum.

Sprich du brauchst noch ein Session-Abhängigen Speicher wo du solche Informationen ablegen kannst. Ich könnte dir ne Linkbasierende HashMap machen und eine Sessionbasierende HashMap, wäre das okay für dich?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #7  
Old 10.08.2015, 18:38
DerJens
Guest
 
Posts: n/a
Default

Hi Jiaz,
das hört sich alles sehr gut an.

Für den Reset nach einem CRC Fehler brauche ich dann eigentlich nur noch die String Werte sammeln, die "myDownloadLink.getStatus()" zurückgeben kann. Eine Funktion, die Enum Werte zurückgibt ist nicht zufällig "versteckt" dabei, oder? Den Rest kann ich mir aus den Info-File Beispiel herauslesen. Mit den HashMaps könnte man das Ganze absolut elegant lösen und die Anzahl der Neuversuche persistieren.

Den Skipped Status müsste ich doch eigentlich genauso leicht abfangen könnenEigentlich soll ein Script alle 1-2 Stunden über alle übersprungenen Downloads iterieren und diese neu anwerfen. Wenn ich dies auf den Status "Übersprungen - Kein Account" begrenzen kann...um so besser. Mit "getStatus()" sollte ich einen Loop bei voller Platte ausschließen können.
Hintergrund ist hier z.B. das Keep2Share Plugin. Immer wenn das Download Limit erreicht ist werden alle Download Links in den Status "Übersprungen - Kein Account" gesetzt. Wenn am Folgetag wieder Volumen da ist, dann springen die Downloads wegen des "Skipped Status" nicht wieder von selbst an. Ich muss also immer bewusst auf Fortsetzen klicken. Genau dies möchte ich mit dem Script "patchen". Dazu kann ich aber nicht das "Download hat gestoppt" Event benutzen. Für ein zeitgesteuertes Script fehlt eine Funktion, die alle Downloads bzw. alle "nicht-laufenden" Downloads zurückgibt.

Last edited by DerJens; 10.08.2015 at 21:12.
Reply With Quote
  #8  
Old 11.08.2015, 09:56
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,532
Default

Mal von dem CRC abgesehen, gehts dir primär darum das dein Account kein Traffic hat und die Links dann mit "Skipped,kein Account" übersprungen werden?
Und am nächsten Tag, sobald traffic wieder da ist, sollen diese automatisch wieder unskipped werden. Ich denke es macht in diesem Fall viel mehr Sinn das "richtig" zu lösen als sich mit nem Script zu behelfen

__________________
JD-Dev & Server-Admin
Reply With Quote
  #9  
Old 11.08.2015, 10:00
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,532
Default

__________________
JD-Dev & Server-Admin
Reply With Quote
  #10  
Old 11.08.2015, 10:02
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,532
Default

__________________
JD-Dev & Server-Admin
Reply With Quote
  #11  
Old 27.06.2016, 01:47
anikama anikama is offline
Mega Loader
 
Join Date: Feb 2012
Posts: 65
Default

Hi, I got this not working.
Is there any way to unskip (some or all) links by interval event??

var aLinks = getAllDownloadLinks(); /*function does not exist error */
var aLinks = archive.getDownloadLinks(); /*archive is not defined error */

var sHoster = "Hostername"

//loop through all Downloads to find hoster+skipped
for (var i = 0; i < aLinks.length; i++) {
//check if the download is hosted by hostername and skipped due to daily bandwidth limit reached
var sHost = aLinks[i].getHost();
var isSkip = aLinks[i].isSkipped();
//var sReason = aLinks[i].getSkippedReason();
//alert(sReason);
if (sHost == sHoster && isSkip) {
alert(i + ": unskip this " + sHoster);
aLinks[i].abort();
}
}

Greetz, ani
Reply With Quote
  #12  
Old 27.06.2016, 12:16
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,532
Default

getAllFilePackages will be available with next core update

FilePackage itself provides getDownloadLinks
__________________
JD-Dev & Server-Admin
Reply With Quote
  #13  
Old 27.06.2016, 12:19
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 79,532
Default

also added getAllDownloadLinks with next core update
__________________
JD-Dev & Server-Admin
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 02:35.
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.