JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1461  
Old 16.07.2020, 00:00
tisurame tisurame is offline
Modem User
 
Join Date: Jul 2020
Posts: 2
Default

Quote:
Originally Posted by mgpai View Post
Try using the 'alert' method to debug. If it turns out to be an OS issue, devs/user in the forum familiar with Linux should be able to point you in the right direction. You can also find be in JD Chat (link in above post) if you think I can help you with the troubleshooting.

Example:
Code:
var result = callSync("/home/thiago/makemkv.sh");
alert(result);
Thanks! The problem, after all, was because I was using a version installed using the snap store. Using the regular version solved the problem.
Reply With Quote
  #1462  
Old 16.07.2020, 18:36
LongDongGold LongDongGold is offline
I will play nice!
 
Join Date: Apr 2020
Posts: 5
Default

Hi.

So I got Event Scripter installed now and I would like JD to do a few things after finished downloads but only to certain files.

I want to cut out the first 7 seconds of any video downloaded from saidwebsite

I have the ffmpeg command line in a .bat file now that I run inside the folder with the videos.

I also use the packagizer in JD for saidwebsite so files are grabbed and downloaded into specific folder - <jd:prop:username>

I would be very happy if I could automatize some of all this manual work.

After download what i specifically want to happen is 7 first seconds cut out of the video & the new file must overwrite the old file in the folder

Then I only have the renaming of files to do manually afterwards - but if possible I would like to have that automated too

I use bulk rename utility right now and I have a template that:
removing chars:
Code:
///#,_-¦¡/¿'.;()//
and removing words:
Code:
480p 4k 720p 1080p 1440p 2160p
It also capitalize the title.

I would also like to have the file prefix to be the performers name & I would like to have the performers username at the end of the title removed.

It sounds like a lot - I know - and it is a lot of manual work right now.

Any help getting this more automatic is really appreciated.

Last edited by raztoki; 17.07.2020 at 00:44.
Reply With Quote
  #1463  
Old 24.07.2020, 08:30
sherbee sherbee is offline
JD Fan
 
Join Date: Mar 2019
Posts: 76
Default

Quote:
Originally Posted by mgpai View Post
Code:
var filePaths = archive.getExtractionLog().match(/\(FileArchiveFile\)File:[^|]+/g).map(function(filePath) {
    return filePath.replace(/.+?:(.+)/, "$1");
});

alert(filePaths.join("\n"));
Have idea how make distinguish between manual and automatical extract?
i make so: var links = archive.getDownloadLinks() || [];

And then if links.length > 0 I take it for automatical extract otherwise I take it for manual extract.
Is safe? Or better idea?
Because your code must only run when manual extract.

Last edited by sherbee; 24.07.2020 at 10:36.
Reply With Quote
  #1464  
Old 24.07.2020, 12:56
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 991
Default

Quote:
Originally Posted by sherbee View Post
Have idea how make distinguish between manual and automatical extract?
You can modify the code to also get file paths of archives with links:
Code:
var getArchiveFiles = function() {
    return archive.getExtractionLog().match(/\((DownloadLink|File)ArchiveFile\)File:[^|]+/g).map(function(string) {
        return string.replace(/.+?:(.+)/, "$1");
    });
}

Or use it with existing archive methods:
Code:
var getArchiveFiles = function() {
    var archiveLinks = archive.getDownloadLinks();

    if (archiveLinks) {
        return archiveLinks.map(function(link) {
            return link.getDownloadPath();
        })
    } else {
        return archive.getExtractionLog().match(/\(FileArchiveFile\)File:[^|]+/g).map(function(string) {
            return string.replace(/.+?:(.+)/, "$1");
        });
    }
}

Common usage for both functions:
Code:
getArchiveFiles().forEach(function(file) {
    // Do something with each archive file
    // alert(file);
});
Reply With Quote
  #1465  
Old 25.07.2020, 10:07
sherbee sherbee is offline
JD Fan
 
Join Date: Mar 2019
Posts: 76
Default

Quote:
Originally Posted by mgpai View Post
You can modify the code to also get file paths of archives with links:
Code:
var getArchiveFiles = function() {
    return archive.getExtractionLog().match(/\((DownloadLink|File)ArchiveFile\)File:[^|]+/g).map(function(string) {
        return string.replace(/.+?:(.+)/, "$1");
    });
}
But when use with manual extract it gives: 'TypeError: Cannot call method "match" of null' for this line of code:

Code:
return archive.getExtractionLog().match(/\((DownloadLink|File)ArchiveFile\)File:[^|]+/g).map(function(string) {
What I do is open 1 single package for extract, not multi archive or something. Then it extract, but then show this error.

I don't know what is wrong for automatic extraction after download no such error.

Last edited by sherbee; 25.07.2020 at 10:09.
Reply With Quote
  #1466  
Old 25.07.2020, 10:42
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 991
Default

Quote:
Originally Posted by sherbee View Post
But when use with manual extract it gives: 'TypeError: Cannot call method "match" of null' for this line of code...
I am unable to reproduce the error. Open the extraction log to check if it matches the regex pattern used in the script (just in case if it is language dependent), and modify if necessary.
Reply With Quote
  #1467  
Old 25.07.2020, 12:51
sherbee sherbee is offline
JD Fan
 
Join Date: Mar 2019
Posts: 76
Default

Quote:
Originally Posted by mgpai View Post
I am unable to reproduce the error. Open the extraction log to check if it matches the regex pattern used in the script (just in case if it is language dependent), and modify if necessary.
I check. First error was 7zip binding made error. I put new 7zip binding in folder now no more 7zip error.

But still 'TypeError: Cannot call method "match" of null''

So I look in log folder. Interesting: 1s time manual extract => Error. When retry same file => No error.

Other error happen: Wrapped org.appwork.exceptions.WTFException: java.io.FileNotFoundException:

Now I see there is /open folder in log folder. When extracting log goes in open folder then moved in extracting folder.
So I think null-error happen when log is still in 'open' folder so it cannot find it? Maybe this is reason? Or it wants find it in 'open' folder and it already in 'extracting' folder?
Reply With Quote
  #1468  
Old 25.07.2020, 14:30
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 991
Default

Quote:
Originally Posted by sherbee View Post
... So I think null-error happen when log is still in 'open' folder so it cannot find it? ...
Quite possible. I guess you will have to wait for the developers to confirm, and fix it if necessary. In the meanwhile, you can try this workaround.

Code:
var getArchiveFiles = function() {
    var log = archive.getExtractionLog();
    var count = 60; // max. seconds to wait for log

    while (!log && count) {
        log = archive.getExtractionLog();
        count--;
        sleep(1000);
    }

    if (log) {
        return archive.getExtractionLog().match(/\((DownloadLink|File)ArchiveFile\)File:[^|]+/g).map(function(string) {
            return string.replace(/.+?:(.+)/, "$1");
        });
    } else {
        alert("Log file for archive \"" + archive.getName() + "\" not found.");
        return [];
    }
}

getArchiveFiles().forEach(function(archiveFile) {
    // Do something with each archive file
    // alert(archiveFile);
})
Reply With Quote
  #1469  
Old 25.07.2020, 16:28
sherbee sherbee is offline
JD Fan
 
Join Date: Mar 2019
Posts: 76
Default

Quote:
Originally Posted by mgpai View Post
Quite possible. I guess you will have to wait for the developers to confirm, and fix it if necessary. In the meanwhile, you can try this workaround.

Code:
var getArchiveFiles = function() {
    var log = archive.getExtractionLog();
    var count = 60; // max. seconds to wait for log

    while (!log && count) {
        log = archive.getExtractionLog();
        count--;
        sleep(1000);
    }

    if (log) {
        return archive.getExtractionLog().match(/\((DownloadLink|File)ArchiveFile\)File:[^|]+/g).map(function(string) {
            return string.replace(/.+?:(.+)/, "$1");
        });
    } else {
        alert("Log file for archive \"" + archive.getName() + "\" not found.");
        return [];
    }
}

getArchiveFiles().forEach(function(archiveFile) {
    // Do something with each archive file
    // alert(archiveFile);
})
No works yet.

Still geting error like: 'Wrapped org.appwork.exceptions.WTFException: java.io.FileNotFoundException: \jdownloader\logs\extracting\*.txt'

But it should report error message: 'Log file for archive "" + archive.getName() + "" not found.' Right?

So log check not works?
Reply With Quote
  #1470  
Old 25.07.2020, 17:07
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 991
Default

Quote:
Originally Posted by sherbee View Post
Still geting error like: 'Wrapped org.appwork.exceptions.WTFException: java.io.FileNotFoundException: \jdownloader\logs\extracting\*.txt'

But it should report error message: 'Log file for archive "" + archive.getName()
+ "" not found.' Right?
That message will be displayed only on 'method of null' error (if 'log' is 'null'). This seems to be a different error which is thrown right at the beginning when executing "archive.getExtractionLog()" method, which disables the script and prevents the rest of the code from being executed.

Alternatively, you can use while loop to check the folder contents of 'open', and execute the script only after it is empty. It might then even work even without 'log = null' check.

Unfortunately I cannot test it since I am unable to reproduce the error. Feel free to find me in JD Chat if need any help with the script/troubleshooting.

Code:
kiwiirc.com/nextclient/irc.freenode.net/#jdownloader
Reply With Quote
  #1471  
Old 26.07.2020, 07:52
sherbee sherbee is offline
JD Fan
 
Join Date: Mar 2019
Posts: 76
Default

Quote:
Originally Posted by mgpai View Post
That message will be displayed only on 'method of null' error (if 'log' is 'null'). This seems to be a different error which is thrown right at the beginning when executing "archive.getExtractionLog()" method, which disables the script and prevents the rest of the code from being executed.

Alternatively, you can use while loop to check the folder contents of 'open', and execute the script only after it is empty. It might then even work even without 'log = null' check.

Unfortunately I cannot test it since I am unable to reproduce the error. Feel free to find me in JD Chat if need any help with the script/troubleshooting.

Code:
kiwiirc.com/nextclient/irc.freenode.net/#jdownloader
I have new error now.
Code:
getArchiveFiles().forEach(function(archiveFile) {
    // Do something with each archive file
    alert(archiveFile);
})
gives wrong name.
In single cases for example I manual extract file xyz.7z. But 'alert(archiveFile)' gives filename: xyz_2.7z.
When check I see file package name xyz with file name xyz_2.7z alrready in download list from earlier time.
So function not gives name from actual extract, but from some extraction earlier.
I can see in log from actual extract, that correct file xyz.7z i have select.

That is not good.
I see 3 times now. Always same: Extract file filename.7z manual. but name shows filename_2.7z and after check I see file with filename_2.7z already in download list from time ago. Actual log but show filename.7z.

Maybe it same reasen that makes bug I have report: https://board.jdownloader.org/showpo...54&postcount=8

It's problem because I take 'archiveFile' for move file automaticall after extract. So when it gives wrong filename, file cannot find to move.

Last edited by sherbee; 26.07.2020 at 07:58.
Reply With Quote
  #1472  
Old 26.07.2020, 09:31
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 991
Default

Quote:
Originally Posted by sherbee View Post
... Maybe it same reasen that makes bug I have report ...
Looks like it is related to the issue you reported. If the API method returns the wrong log, nothing can be done in the script to verify/rectify it.

If you can run a local file server, you can load the archive files to JD and generate 'local' download links which can be automatically extracted. While it may not solve the wrong 'log' or 'status' problem, you should be able to move the links using a script, without any issues.
Reply With Quote
  #1473  
Old 26.07.2020, 10:22
sherbee sherbee is offline
JD Fan
 
Join Date: Mar 2019
Posts: 76
Default

Quote:
Originally Posted by mgpai View Post
Looks like it is related to the issue you reported. If the API method returns the wrong log, nothing can be done in the script to verify/rectify it.

If you can run a local file server, you can load the archive files to JD and generate 'local' download links which can be automatically extracted. While it may not solve the wrong 'log' or 'status' problem, you should be able to move the links using a script, without any issues.
I have other idea. Because extraction log is correct.
So must take correct extraction log and use instead.

So idea is to make manual: 1. Get extraction log
2. Open extraction log
3. And use 'Archive Path:'-value

Is there not API to extract values from log? I think would be useful if simply could make like: getLogValue(logfile).archivepath or getLogValue('Archive Path')

and result would be archive path like: 'c:\user\sherbee\downloads\xyz.7z'

So this could work? And how?
Reply With Quote
  #1474  
Old 26.07.2020, 14:44
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 991
Default

Quote:
Originally Posted by sherbee View Post
... Is there not API to extract values from log? I think would be useful if simply could make like: getLogValue(logfile).archivepath or getLogValue('Archive Path')

and result would be archive path like: 'c:\user\sherbee\downloads\xyz.7z'
...
You can use existing methods to extract matching strings from the log file.

Code:
var match = readFile(getPath(path_to_correct_log_file)).match(/Archive Path\: (.+)/);

if (match) {
    var archivePath = match[1];
    alert(archivePath);
}
Reply With Quote
  #1475  
Old 27.07.2020, 10:26
sherbee sherbee is offline
JD Fan
 
Join Date: Mar 2019
Posts: 76
Default

Quote:
Originally Posted by mgpai View Post
You can use existing methods to extract matching strings from the log file.

Code:
var match = readFile(getPath(path_to_correct_log_file)).match(/Archive Path\: (.+)/);

if (match) {
    var archivePath = match[1];
    alert(archivePath);
}
I try thanks. But you have idea how to get correct path to log file and name? I see no method for it. And not written in any logs to extract? Take last log by date i think not reliable.
Reply With Quote
  #1476  
Old 27.07.2020, 13:18
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 991
Default

Quote:
Originally Posted by sherbee View Post
But you have idea how to get correct path to log file and name? I see no method for it. And not written in any logs to extract? Take last log by date i think not reliable.
You don't need to get the correct log file, or even any other data from the 'extraction finished' trigger. You can use any trigger (For e.g. JD started, interval) and loop through the log files of last 'x' hours present in the 'extracting' folder. Parse the content of each file to check if the extraction was 'successful', and if so get a list of 'archive files' and move them. If the log has not already been processed before, the 'archive files' will still be present in the folder and can be moved by the script.
Reply With Quote
  #1477  
Old 27.07.2020, 23:25
Mydgard Mydgard is offline
JD Adviser
 
Join Date: Jan 2011
Location: Germany
Posts: 102
Default

Hello fellow programmiers I have no clue about programming nor do i understand all those scripts, but i am searching for a function to change linkgrabber a little bit:

I would like to sometimes shutdown the linkgrabber organisation: Like if i enter 1 link, it will be shown under "verschiedene dateien" (dunno the english name for it), if i than enter 2 more links with part 1 and part 2, they won't be inside the "verschiedene dateien", they get a new folder with the name of these files.

Anyone has an idea how to change that? That ALL Links/Files being in one folder no matter if there are lonely links or links with part 1-x? Ideally with a button for on/off ...

Thx

Mydgard

PS: If Possible must be a ready script as i don't understand this scripting sry :D
Reply With Quote
  #1478  
Old 28.07.2020, 04:55
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,226
Default

@Mydgard
verschiedene dateien = various files
in english the title is just various, you can disable various in advanced settings
settings > advanced settings > LinkgrabberSettings.variouspackageenabled
you can also edit a threshold which links are no longer in various LinkgrabberSettings.variouspackagelimit
__________________
raztoki @ jDownloader reporter/developer
http://svn.jdownloader.org/users/170

Don't fight the system, use it to your advantage. :]
Reply With Quote
  #1479  
Old 28.07.2020, 08:02
sherbee sherbee is offline
JD Fan
 
Join Date: Mar 2019
Posts: 76
Default

Quote:
Originally Posted by mgpai View Post
You don't need to get the correct log file, or even any other data from the 'extraction finished' trigger. You can use any trigger (For e.g. JD started, interval) and loop through the log files of last 'x' hours present in the 'extracting' folder. Parse the content of each file to check if the extraction was 'successful', and if so get a list of 'archive files' and move them. If the log has not already been processed before, the 'archive files' will still be present in the folder and can be moved by the script.
But that not what I need.
I need:
1. Open archive
2. Extract archive
3. Move archive
4. Open next archive

Must move archive after extraction immediately.
Reply With Quote
  #1480  
Old 28.07.2020, 09:46
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 991
Default

Quote:
Originally Posted by sherbee View Post
But that not what I need.
I need:
1. Open archive
2. Extract archive
3. Move archive
4. Open next archive

Must move archive after extraction immediately.
It effectively does the same thing. The files will be moved as soon as the log file is available in the 'extracting' folder and queried. How fast you want it to be processed will depend on the the trigger you use.
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 14:18.
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 - 2020, Jelsoft Enterprises Ltd.