JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #1  
Old 20.08.2015, 00:02
panaho panaho is offline
Baby Loader
 
Join Date: Apr 2015
Posts: 7
Default Edytor Skryptów Zdarzeń

Witam.

Mam pewien problem.
W Edytorze Skryptów Zdarzeń po zdarzeniu "Pakiet zakończony" mam ustawione "Utwórz plik Info w katalogu pobierania ze szczegółowymi informacjami" z przykładowych skryptów."
Spoiler:
Code:
/*
    Event Script: writeInfoFile
 
                  Creates an Info-File into the DL-Folder with detailed information
                  
    Version: 0.21
 
 Requirements:
    Trigger "Package Finished"

 Tested:
     JD2 on Windows7-32bit Platform and jre8 (see path-creation code at the end of this script) 
 */


//---------- Global declarations -----------------
var bWriteFile = false; //pessimistic approach: no file-writing at start, if situation ok, then set it "true"
var sInfoFilePath = ""; //the target file, if already available, then APPENDING, else creation
var sText = ""; //will be filled with content (or not :-)
var sInfoFileType = ".info" //set path creation at the end of the script
var iContent = 0; //setting bit 1 if pwd is available, setting bit 2 if comments available //if not set, no info file
var myPackage = package;
var aParts = myPackage.getDownloadLinks();
var aArchives = package.getArchives();






//---------- ANALYZING SITUATION ----------
if (myPackage.isFinished() == true) {
    //no further analysis due to Trigger "Package Finished" :-)
    bWriteFile = true;
}




//---------- Building Info-Text -----------
if (bWriteFile == true) {
    sText += "**********************************" + "\r\n"
    sText += "*          P A C K A G E         *" + "\r\n"
    sText += "**********************************" + "\r\n"
    sText += "Package.Name              : " + myPackage.getName() + "\r\n" +
        "Package.DownloadFolder    : " + myPackage.getDownloadFolder() + "\r\n" +
        "Package.Total             : " + myPackage.getBytesTotal() + "\r\n" +
        "Package.Loaded            : " + myPackage.getBytesLoaded() + "\r\n" +
        "Package.Finished          : " + myPackage.isFinished() + "\r\n";
    if (myPackage.getComment() != undefined) {
        sText += "Package.Comment           : " + myPackage.getComment() + "\r\n";
        iContent |= 2;
    }

    sText += "\r\n"
    sText += "**********************************" + "\r\n"
    sText += "*            P A R T S           *" + "\r\n"
    sText += "**********************************" + "\r\n"
    for (var i = 0; i < aParts.length; i++) {
        sText += "Part.#                    : " + i + "\r\n" +
            "Part.Name                 : " + aParts[i].getName() + "\r\n" +
            "Part.Status               : " + aParts[i].getStatus() + "\r\n" +
            "Part.Enabled              : " + aParts[i].isEnabled() + "\r\n" +
            "Part.Finished             : " + aParts[i].isFinished() + "\r\n" +
            "Part.Skipped              : " + aParts[i].isSkipped() + "\r\n" +
            "Part.ExtractionStatus     : " + aParts[i].getExtractionStatus() + "\r\n" +
            "Part.Total                : " + aParts[i].getBytesTotal() + "\r\n" +
            "Part.Loaded               : " + aParts[i].getBytesLoaded() + "\r\n";
        if (aParts[i].getUrl() != undefined) {
            sText += "Part.URL                  : " + aParts[i].getUrl() + "\r\n";
        }
        if (aParts[i].getComment() != undefined) {
            sText += "Part.Comment              : " + aParts[i].getComment() + "\r\n";
            iContent |= 2;
        }
        var myArchive = aParts[i].getArchive();
        if (myArchive != undefined) {
            if (myArchive.getUsedPassword() != undefined) {
                sText += "Part.UsedPassword         : " + myArchive.getUsedPassword() + "\r\n";
                iContent |= 1;
            }
        }
        sText += "--------------------------:-" + "\r\n"
    }

    sText += "\r\n"
    sText += "**********************************" + "\r\n"
    sText += "*        A R C H I V E S         *" + "\r\n"
    sText += "**********************************" + "\r\n"
    for (var i = 0; i < aArchives.length; i++) {
        sText += "Archive.#                    : " + i + "\r\n" +
            "Archive.Name                 : " + aArchives[i].getName() + "\r\n" +
            "Archive.ArchiveTyp           : " + aArchives[i].getArchiveType() + "\r\n";

        if (aArchives[i].getInfo() != undefined) {
            sText += "Package.Archive.Info         : ";
            sText += JSON.stringify(aArchives[i].getInfo(), null, 2) + "\r\n";
        }
        sText += "--------------------------:-" + "\r\n"
    }
}




//---------- INFO.FILE naming and writing ----------- 
if (bWriteFile == true && iContent > 0) { //comment out or set "iContent >= 0" if info-file should be written always
    //- path creation
    sInfoFileType = "." + iContent + sInfoFileType //add content-type hint to filetype
    sInfoFilePath = myPackage.getDownloadFolder() + "/" + myPackage.getName() + sInfoFileType; //<packageFolder>/<packageName>.<iContent>.info
    if (sInfoFilePath.length > 255) { //path to long! -> shorten!!
        sInfoFilePath = myPackage.getDownloadFolder() + "/jd" + sInfoFileType; //<packageFolder>/jd.<iContent>.info
    }
    //- writing
    try {
        writeFile(sInfoFilePath, sText, true);
    } catch (e) {
        //no error handling implemented !    
    }
}


Po każdym pobraniu pliku zamiast zapisać plik info wyskakuje okienko z informacją:
Code:
"The Event Script 'Utwórz plik Info w katalogu pobierania ze szczegółowymi informacjami' requires permissions
for the trigger 'Pakiet zakończony'.
The script tries to
create a local file and write to it.
Do you want to allow this? If you are not sure, please check your script!"
Dopiero kiedy zatwierdzę akcję plik jest zapisywany.

Co zrobić abym nie musiał zatwierdzać każdego pliku info?

Pozdrawiam.
Reply With Quote
  #2  
Old 20.08.2015, 07:54
editestowy's Avatar
editestowy editestowy is offline
Polish Supporter
 
Join Date: May 2009
Location: PL
Posts: 3,026
Default

Spróbuj wejść do "Edycja skryptu", następnie z menu wybrać "Test Kompilacji" i "Test Uruchomienia"
Reply With Quote
  #3  
Old 20.08.2015, 14:04
panaho panaho is offline
Baby Loader
 
Join Date: Apr 2015
Posts: 7
Default

Hmmm....
Nie wiem czemu ale dzisiaj po kolejnej próbie ze skryptami wszystko działa prawidłowo

Nic wczoraj już nie robiłem.
Wyłączyłem komputer i włączyłem dzisiaj rano. I działa.

Ale...

Zauważyłem, że (przynajmniej u mnie) zawsze po pierwszym dodaniu jakiegoś skryptu i przy jego pierwszym działaniu wspomniane prze ze mnie wyżej okienko z zapytaniem ponownie wyskakuje.
Potem wszystko działa poprawnie.
Czemu? Nie wiem.

Dziękuję za zainteresowanie i pozdrawiam.
Reply With Quote
  #4  
Old 20.08.2015, 21:01
editestowy's Avatar
editestowy editestowy is offline
Polish Supporter
 
Join Date: May 2009
Location: PL
Posts: 3,026
Default

Dlatego zawsze po dodaniu/aktualizacji skryptu warto zrobić to co opisałem - wówczas prawa dostępu nadane są już na etapie "testu".
Reply With Quote
  #5  
Old 17.02.2016, 12:04
panaho panaho is offline
Baby Loader
 
Join Date: Apr 2015
Posts: 7
Default

Witam.

Od jakiegoś czasu Edytor Skryptów Zdarzeń, w folderze z ukończonym pakietem, tworzy mi plik o nazwie: "plik.2.info" zamiast "plik.info".
Między nazwę pliku i rozszerzenie wstawia dwójkę.
Nie wiem czemu i nie potrafię sobie z tym poradzić.
Ustawiałem jeszcze raz tworzenie pliku Info z Przykładowych skryptów i ciągle jest to samo.
Tekst w samym pliku Info jest już prawidłowo generowany.
Problem jest tylko z tą nazwą.
Czym to może być spowodowane? Jak temu zaradzić?

Mój obecny skrypt to:
Spoiler:
Code:
/*
    Event Script: writeInfoFile
 
                  Creates an Info-File into the DL-Folder with detailed information
                  
    Version: 0.21
 
 Requirements:
    Trigger "Package Finished"

 Tested:
     JD2 on Windows7-32bit Platform and jre8 (see path-creation code at the end of this script) 
 */


//---------- Global declarations -----------------
var bWriteFile = true; //pessimistic approach: no file-writing at start, if situation ok, then set it "true"
var sInfoFilePath = ""; //the target file, if already available, then APPENDING, else creation
var sText = ""; //will be filled with content (or not :-)
var sInfoFileType = ".info" //set path creation at the end of the script
var iContent = 0; //setting bit 1 if pwd is available, setting bit 2 if comments available //if not set, no info file
var myPackage = package;
var aParts = myPackage.getDownloadLinks();
var aArchives = package.getArchives();










//---------- Building Info-Text -----------
if (bWriteFile == true) {
    sText += "" + myPackage.getName() + "\r\n";
    sText += "-----------------------------------------" + "\r\n"
    if (myPackage.getComment() != undefined) {
        sText += "" + myPackage.getComment() + "\r\n";
        iContent |= 2;
        sText += "-----------------------------------------" + "\r\n"
        sText += "A.O." + "\r\n"
    }

}




//---------- INFO.FILE naming and writing ----------- 
if (bWriteFile == true && iContent > 0) { //comment out or set "iContent >= 0" if info-file should be written always
    //- path creation
    sInfoFileType = "." + iContent + sInfoFileType //add content-type hint to filetype
    sInfoFilePath = myPackage.getDownloadFolder() + "/" + myPackage.getName() + sInfoFileType; //<packageFolder>/<packageName>.<iContent>.info
    if (sInfoFilePath.length > 255) { //path to long! -> shorten!!
        sInfoFilePath = myPackage.getDownloadFolder() + "/jd" + sInfoFileType; //<packageFolder>/jd.<iContent>.info
    }
    //- writing
    try {
        writeFile(sInfoFilePath, sText, true);
    } catch (e) {
        //no error handling implemented !    
    }
}


Pozdrwiam.
Panaho
Reply With Quote
  #6  
Old 17.02.2016, 19:58
editestowy's Avatar
editestowy editestowy is offline
Polish Supporter
 
Join Date: May 2009
Location: PL
Posts: 3,026
Default

Nazwa pliku jest ustalana wg:
sInfoFileType = "." + iContent + sInfoFileType //add content-type hint to filetype


A iContent wcześniej:

if (myPackage.getComment() != undefined) {
sText += "" + myPackage.getComment() + "\r\n";
iContent |= 2;

czyli, jeśli pakiet ma komentarz, to zmienna iContent przyjmie wartość = 2,
a więc w nazwie pliku wynikowego będzie dodane:
.2.info
Reply With Quote
  #7  
Old 18.02.2016, 00:27
panaho panaho is offline
Baby Loader
 
Join Date: Apr 2015
Posts: 7
Default

Ufff..
Dziękuję za odpowiedź.
Nie wiem czy dobrze rozumuję bo słaby w tym temacie jestem.
Czyli żeby skrypt nie dodawał tej "dwójki" do nazwy pliku Info muszę z linijki:
Code:
sInfoFileType = "." + iContent + sInfoFileType //add content-type hint to filetype
wyrzucić
Code:
+ iContent
?

PS. Piszę z pracy i chwilowo nie mogę tego sprawdzić
Reply With Quote
  #8  
Old 18.02.2016, 18:07
editestowy's Avatar
editestowy editestowy is offline
Polish Supporter
 
Join Date: May 2009
Location: PL
Posts: 3,026
Default

Tak, ale pamiętaj, że
iContent musi być ustawione na wartość > 0 bo inaczej warunek:

(bWriteFile == true && iContent > 0)

spowoduje, że plik info nie zostanie zapisany (ewentualnie usunąć: && iContent > 0 z powyższego warunku
Reply With Quote
  #9  
Old 19.02.2016, 19:19
panaho panaho is offline
Baby Loader
 
Join Date: Apr 2015
Posts: 7
Default

OK. Wszystko już przetestowane w domu.

Zmieniłem linijkę:
Code:
sInfoFileType = "." + iContent + sInfoFileType //add content-type hint to filetype
na
Code:
sInfoFileType = "" + sInfoFileType //add content-type hint to filetype
i wszystko działa tak jak powinno.

Jeśli nie ma komentarza plik info nie jest tworzony i tak mi pasuje.

Raz jeszcze dziękuję Ci za pomoc.
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 17:38.
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.