#1
|
|||
|
|||
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); } } } |
#2
|
||||
|
||||
@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 |
#3
|
|||
|
|||
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. |
#4
|
||||
|
||||
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. :] |
#5
|
||||
|
||||
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 |
#6
|
||||
|
||||
Quote:
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 |
#7
|
|||
|
|||
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. |
#8
|
||||
|
||||
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 |
#9
|
||||
|
||||
__________________
JD-Dev & Server-Admin |
#10
|
||||
|
||||
__________________
JD-Dev & Server-Admin |
#11
|
|||
|
|||
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 |
#12
|
||||
|
||||
getAllFilePackages will be available with next core update
FilePackage itself provides getDownloadLinks
__________________
JD-Dev & Server-Admin |
#13
|
||||
|
||||
also added getAllDownloadLinks with next core update
__________________
JD-Dev & Server-Admin |
Thread Tools | |
Display Modes | |
|
|