JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1761  
Old 05.07.2021, 14:28
Cyberavater Cyberavater is offline
JD Legend
 
Join Date: Feb 2019
Posts: 732
Default

If two file has same name, download the one with more size (i.e filter the small file link). You can read more details from here, https://board.jdownloader.org/showthread.php?t=87803

So, preferably adding a LinkGrabber rule would be much better but since the dev refused, I'd apprecite if anyone would write me a website independent EventScript, Thanks!
Reply With Quote
  #1762  
Old 05.07.2021, 15:05
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 71,510
Default

Quote:
Originally Posted by Cyberavater View Post
[...]but since the dev refused, [...]
You've requested an advanced feature which apart from you, probably only a hand full of users would use...

You are free to implement it on your own as we're open source or just create yourself an EventScripter script as explained before.

-psp-
__________________
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
  #1763  
Old 05.07.2021, 16:52
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

@mgpai:
Quote:
Are they direct links?
mmm ... " yes and no " :

the "files" that I would like to open are generally "php" that JD identifies on some sites when I try to select the link of a given file (but the speech also works for some "txt" files that I had found);
These files, if opened online (in the browser) have a sort of redirection function that avoids seeing the link to the real file that interests me ,
BUT
if I save these files (eg AAA.php) on hd and open it in notepad, inside it I can find the link to the real file I was looking for, and I can give it to jd x download.

[ p.s = x such sites have no plugins (they don't care about anyone but me), and I didn't ask for help on linkcrawler rules because I saw that the hosts on which files are loaded change from file to file.
For a while I solved by opening the saved php on hd to copy the "real" links. ... now I was looking for a process to speed things up]


If you need an example link you can use that of any video on youtube :

if I "copy" a link to a youtube video file (for example), between the verie captures there is also a "* .txt."
If you try to open the txt in the browser you are redirected to the video page without "reading" the content of the txt, but if you save the txt on hd and you can read it by viewing the content / text.

Last edited by BJN01; 05.07.2021 at 16:57.
Reply With Quote
  #1764  
Old 05.07.2021, 19:16
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,567
Default

Quote:
Originally Posted by BJN01 View Post
... If you try to open the txt in the browser you are redirected to the video page without "reading" the content of the txt, but if you save the txt on hd and you can read it by viewing the content / text.
In that case, you will have to use two scripts.

Code:
/*
    Preview files
    Trigger: Linkgrabber contextmenu button pressed
*/

if (name == "Preview files") {
    var types = ["php", "txt"];

    lgSelection.links.forEach(function(link) {
        var type = getPath(link.name).extension;

        if (types.indexOf(type) > -1) {
            link.setProperty("tmp", true);
            callAPI("linkgrabberv2", "moveToDownloadlist", [link.UUID], []);
        }

        if (!isDownloadControllerRunning()) {
            startDownloads();
        }
    })
}

Code:
/*
    Preview file
    Trigger: A download stopped
*/

if (
    link.finished &&
    link.getProperty("tmp")
) {
    var editor = "notepad.exe";
    var file = getPath(link.downloadPath);

    callSync(editor, file);

    callAPI("linkgrabberv2", "addLinks", {
        links: link.contentURL
    })

    file.delete();
    link.remove();
}
Reply With Quote
  #1765  
Old 06.07.2021, 02:18
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

@mgpai:
Many thanks ! , as always the scripts are great.
by copying a part of it and integrating it with packaging rules and an au3 to send commands to the notepad I was able to automate the capture of the right links.
(to many it may seem nonsense but for me it is already a great success ...)



if it could be useful to others I indicate what I did:

1)set of packaging rules with which:
- I uniquely identify the php file I need based on name and site
- I rename the php I am interested in with a specific name, [DwLinkphp.tmp]
(I also change the extension)
- set a particular directory for download ( ../tmp )
- validate : automatic confirmation, automatic start download , start automatic forced dl .

[1 rule for every site where I have php]

2)with the script I open the file just downloaded in notepad, through the au3 I send
the commands "Ctrl A + Ctrl C + Alt F + E" to notepad to copy everything and close it.
now JD finds the right "links" for me, and they appear in the linkgrabber window.
and finally, I delete the temporary file.

script
Code:
/*
   Auto Open file DwLinkphp.tmp in text editor
    Trigger : A download stopped

 DwLinkphp.tmp ----> ex file **.php  renamed via packaging rules 

*/

disablePermissionChecks(); /*disable permission checks*/


if (link.finished) {
    var file = getPath(link.downloadPath);

    if (file.name == "DwLinkphp.tmp") {
        var editor = "notepad.exe";
        callAsync(null, editor, file);
    }
}

sleep(250);

var autoitDir = 'C:\\####\\######\\AutoIt3' //''C:\\Program Files (x86)\\AutoIt3';
var autoitExe = 'AutoIt3.exe';
var autoitPath = getPath(autoitDir + "\\" + autoitExe);
var CtrlACtrlCAlltFExTxT = (JD_HOME + "/_bin/CtrlACtrlCAlltFExTxT.au3"); 

callAsync(null, autoitPath, CtrlACtrlCAlltFExTxT);

sleep(500);

var tmpFile = getPath(JD_HOME + "/tmp/DwLinkphp.tmp");
if (tmpFile.exists()) tmpFile.delete();
au3 code
Quote:
Global $titleJd = '[CLASS:Notepad; TITLE:DwLinkphp.tmp - Windows Notepad]'

WinActivate("[TITLE:DwLinkphp.tmp - Windows Notepad]")
WinActive("[CLASS:Notepad]")

If WinActive($titleJd) Then Send('{CTRLDOWN}a{CTRLUP}{CTRLDOWN}c{CTRLUP}{ALTDOWN}f{ALTUP}e')

Exit

there will certainly be parts that can be improved, in case suggestions are accepted
(but at least it works for what I need )

Last edited by BJN01; 06.07.2021 at 02:20.
Reply With Quote
  #1766  
Old 06.07.2021, 02:49
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,567
Default

Quote:
Originally Posted by BJN01 View Post
... with the script I open the file just downloaded in notepad, through the au3 I send
the commands "Ctrl A + Ctrl C + Alt F + E" to notepad to copy everything and close it.
now JD finds the right "links" for me, and they appear in the linkgrabber window.
and finally, I delete the temporary file.
You can also use eventscripter to add the content of a file.
Code:
/*
    Add file content
    Trigger : A download stopped
*/

if (
    link.finished &&
    link.name == "DwLinkphp.tmp"
) {
    var file = getPath(link.downloadPath);
    var content = readFile(file);

    callAPI("linkgrabberv2", "addLinks", {
        links: content
    });

    file.delete();
}
Reply With Quote
  #1767  
Old 06.07.2021, 10:19
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

Quote:
Originally Posted by mgpai View Post
You can also use eventscripter to add the content of a file.....
thanks for the tip, as always much appreciated.
it is undoubtedly a + simple solution of the <notepad + au3> that I used.
I'm going to put it to use right away.

Thanks
Reply With Quote
  #1768  
Old 09.07.2021, 16:02
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,567
Default

Quote:
Originally Posted by Cyberavater View Post
If two file has same name, download the one with more size (i.e filter the small file link). You can read more details from here ...
The linked post does not contain any additional information. Please provide example links. You can also PM them.
Reply With Quote
  #1769  
Old 13.07.2021, 21:00
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

good evening, I'm doing some "experiments" and I would like to ask:

a)
commands (in event scripts) that generate / recall the html code are:

<< var myString = getPage(myString/*URL*/);>>

Code:
var myUrl = "https://jdownloader.org/download/index"; //example
    var myHtml = br.getPage(myUrl);
alert (myHtml);
and postPage

Code:
var myString = postPage(myString/*URL*/, myString/*PostData*/);/*Loads a website (METHOD: POST) and returns the source code*/
/* Example: */var myhtmlSourceString=postPage("http://support.jdownloader.org/index.php","searchquery=captcha");
??? alternating with <"searchquery=captcha">, what should be indicated? , is there a list of "searchquery" to choose from, or the variable I indicate must I specify it first separately ??


b) is there a command (internal to JD) that, starting from the url, returns me the equivalent of the mhtml / mht?

c) there are many chrome apps on the net that save the page as mhtml (but I don't think there is anything like this in JD) ;
if it was not possible directly through internal commands, could you write a script that does this by relying on some external executable or similar?
[on the net there are programming codes and strings about the genre but I don't even know where to start reading them]
if I have to install some program or the like, I have no problems ... but I can't go by trial and error ...



the idea was:

- I copy a link in jd
- jd sees that it belongs to a given host
- jd "save" or "command something" and get a <Temp.mhtm> in a path set in the script (eg. <(JD_HOME + "/tmp/")>)

there's a way ? is there some code to use and how?
Reply With Quote
  #1770  
Old 13.07.2021, 23:52
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,567
Default

Quote:
Originally Posted by BJN01 View Post
..is there a list of "searchquery" to choose from, or the variable I indicate must I specify it first separately ??
In this case, "searchquery" is the parameter which is defined in the web page. "captcha" is the value which is to be provided by the user. You can only provide the value, not the parameter. For e.g., in this case if you want to search for "scripts" then you have to use "searchquery=scripts".

Quote:
b) is there a command (internal to JD) that, starting from the url, returns me the equivalent of the mhtml / mht?
You can always save webpage as plain html file either using script or directly in JD, but it will not save any assets like it does in mhtml.

Quote:
c) ... could you write a script that does this by relying on some external executable or similar?
I do not know of any programs which can save as mhtml. If you find one, I can help you run it from the script

Quote:
the idea was ... is there some code to use and how?
If you want to save just the html, you can use getPage to fetch the source code, and writeFile to save to disk.

Depending on what you want to save, you can use directhttp :// (remove the space before : when using in JD) at the beginning of the url or .jdeatme at the end of the url to force JD to save it to the disk, instead of parsing it. Can also use linkcrawler rule to do the same.
Reply With Quote
  #1771  
Old 14.07.2021, 02:13
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

the "<getPage + writeFile > to save to disk" , it's interesting, I made some attempts but it only saves the data as plain html, it doesn't "capture" what I want [unfortunately].

"directhttp :" ??
Code:
var myUrl = directhttp :"h#tps://jdownloader.org/download/index"; //example
    var myHtml = br.getPage(myUrl);
alert (myHtml);
".jdeatme" ?? --> << var myUrl = "ht#ps://linkat/link".jdeatme>> and (writeFile of myUrl)

I will also try these commands but I guess they only save the "simple" page.

Quote:
Quote:
c) ... could you write a script that does this by relying on some external executable or similar?
I do not know of any programs which can save as mhtml. If you find one, I can help you run it from the script
there are so many apps in chrome that save the webpage as a single mhtml / mht file, and I'm trying several of them.
at the moment, one of those that saves the mht file correctly is this:

"Save As MHT" in chrome web store : h##ps://chrome.google.com/webstore/detail/save-as-mht/hfmodljjaibbdndlikgagimhhodmobkc/related?hl=it

and , but above all on the creator page there are the various files with the codes / strings / commands - json , .js and the like. site h##ps://github.com/vsDizzy/SaveAsMHT

i am not capable but couldn't you modify something in the .js /.json to call them and use them with the script?
[it's possible to run an external .js /.json?]

Last edited by BJN01; 14.07.2021 at 02:18.
Reply With Quote
  #1772  
Old 14.07.2021, 07:07
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,567
Default

Quote:
Originally Posted by BJN01 View Post
I made some attempts but it only saves the data as plain html, it doesn't "capture" what I want [unfortunately].
Yes. I have already mentioned, using both script and GUI, JD can save only plain html code and not the assets which are used to render the page.

Quote:
there are so many apps in chrome that save the webpage as a single mhtml / mht file, and I'm trying several of them.
The extension which you have linked, can only save pages using context menu. Other js/json files in the repository are extension install related files. They cannot be used directly in any way to generate mht.

To run from script, you will need a program which can generate mht directly, without using browser.
Reply With Quote
  #1773  
Old 16.07.2021, 01:13
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

Thanks for the reply.

changing the argument, I have a variable which should be an array but behaves as a single value.

if I did not understand in the web page they process it with a command in a .js type << picArry = $("#arraydata").text().split(","), >> ...
I have made many attempts with split and replace but I cannot write the command correctly.

simplifying I think the command should say:

var AA1 = "(blabla,url1,url2,url3,url4)"
var AAA --> AA1 + consider as text + split at "," or , replace ("," , " ,")

alert (AAA + "\r\n")
---->
blabla ,
url1 ,
url2 ,
url3 ,
url4 ,

I can also write the variable to a txt and read the text from there, but I don't understand how it does the "replace ("," , ", ") "

must there be a way?
Reply With Quote
  #1774  
Old 16.07.2021, 01:42
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,567
Default

Quote:
Originally Posted by BJN01 View Post
... but I don't understand how it does the "replace ("," , ", ") "
The character which is used to split will be removed from the string and the resulting (split) values will be returned as an array of strings.

Example:
Code:
alert("ABABABA".split("B")); // [ "A", "A", "A", "A" ]

Code:
var AA1 = "(blabla,url1,url2,url3,url4)";
var AAA = AA1.split(","); // [ "(blabla", "url1", "url2", "url3", "url4)" ];
var AAA = AA1.replace(",", ","); // (blabla,url1,url2,url3,url4)

Just remove unwanted characters, split and join the array.
Code:
var AAA = AA1.replace(/[()]/g, "").split(",").join("\r\n");
Reply With Quote
  #1775  
Old 16.07.2021, 11:18
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

I really like this solution but, when I try to make it process the variable I want, I have an error message with both (split / replace)

<< cannot find funxtion split (or replace) in object ##follows all the contents of the string ##>>

should i add a split / replce function somewhere ??
or do I have to "say" somewhere that <this variable is an Array> ??

if I try something like:

Code:
var MArImg = "(blabla,url1,url2,url3,url4)"; // for test
var MArrayS = MArImg.split(",");
var MArrayR = MArImg.replace(",", " _ ");
alert("test split" + "\r\n" + (MArrayS + "\r\n"));
alert("test replace" + "\r\n" + (MArrayS + "\r\n"));
I have no error messages but the message in the alert is:

Code:
test replace ( or test split)
(blabla,url1,url2,url3,url4)
did i miss something?

Last edited by BJN01; 16.07.2021 at 11:22.
Reply With Quote
  #1776  
Old 16.07.2021, 12:02
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,567
Default

Quote:
Originally Posted by BJN01 View Post
... did i miss something?
You have used MArrayS in both alert messages. Same output can be achieved using replace, but you will have do a 'global' replace.

Code:
var MArrayS = MArImg.split(",").join("\r\n");
var MArrayR = MArImg.replace(/,/g, "\r\n");

Both will give the same output:
Code:
(blabla
url1
url2
url3
url4)
Reply With Quote
  #1777  
Old 19.07.2021, 10:07
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

Hi , some quick question (I think):

1) starting from the "link" is there a way to get the name of the site?

if link < ht#ps://siteA.blabla/page-oneOf300/nothingNew/Spoiler101.3 >

there is a expression / ReGex to get just: << siteA.blabla >> ??

the link I extract it from:
Code:
if (link.isFinished()) {
var StartLink = link.getContainerURL();
I have made many attempts but the maximum I arrive at is : < siteA.blabla/page-oneOf300 >

[or that operation must by be done by something external?]


2) is it possible to write a script that checks if a link is present in a txt (and if there is "disable" it)?
[or must the "comparison" be done by something external?]
Reply With Quote
  #1778  
Old 19.07.2021, 10:48
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,567
Default

Quote:
Originally Posted by BJN01 View Post
... get the name of the site..
Code:
var hostname = link.getContainerURL().match(/:\/\/([^/]+)/)[1];

Quote:
Originally Posted by BJN01 View Post
.... if a link is present in a txt (and if there is "disable" it) ...
Code:
var myFile = Readfile("path/to/file");
var url = link.contentURL();

if (myFile.indexOf(url) > -1) {
    link.setEnabled(false);
}
Reply With Quote
  #1779  
Old 19.07.2021, 17:58
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 80,056
Default

@mgpai:
@BJN01:
containerURL might be undefined/null, you should add some checks for it
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1780  
Old 19.07.2021, 17:59
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 80,056
Default

Quote:
Originally Posted by BJN01 View Post
2) is it possible to write a script that checks if a link is present in a txt (and if there is "disable" it)?
[or must the "comparison" be done by something external?]
@mgpai: I think your duplicate scripts would be great template for this, don't you think?
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1781  
Old 19.07.2021, 19:15
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,567
Default

Quote:
Originally Posted by Jiaz View Post
containerURL might be undefined/null, you should add some checks for it
Of course. The example was just to demonstrate how to extract the hostname from url.

Quote:
Originally Posted by Jiaz View Post
@mgpai: I think your duplicate scripts would be great template for this, don't you think?
Guess so.

@BJN01: Related thread
Reply With Quote
  #1782  
Old 19.07.2021, 21:48
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

thank you guys !!! I found some interesting things that I will try to adapt to my approach / starting idea.
Reply With Quote
  #1783  
Old 21.07.2021, 12:40
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

I tried to follow the scripts of the discussion linked above, but I do something wrong:

1)

--- Trigger required: A new link has been added -------------
test purpose = find the name of the site / host (x use it + forward).

wrong code
Code:
var link = crawledLink;
if (link.availableState == "ONLINE") {
var url = link.contentURL || link.pluginURL;
 var StartLink = link.getContainerURL();
 var Hostname = StartLink.match(/:\/\/([^/]+)/)[1];   // for Host name
     alert (Hostname);
}
error : <Cannot cal method "match" of null>

2) --- Trigger required: Linkgrabber Contextmenu button pressed ------------
test purpose = find the name of the site / host of the link Selected in LinkGRabber windows (x use it + forward).

wrong code
Code:
if (name == "Aggiungi Host Monitoring") {    
    
    getAllCrawledLinks().forEach(function(fileNameHost) {
        var links = lgSelection.getLinks()//getDownloadLinks();
    var urls = [];

    for (i = 0; i < links.length; i++) {
        var link = links[i];
                var downloadURL = link.getContentURL();
               var HostName = downloadURL.match(/:\/\/([^/]+)/)[1];
                alert(HostName);
       }}  )}
error = I selec 1 (one) link for test the script , and i get a "thousand" windows alerts...


what did I do wrong?
[I guess that I was wrong in indicating how to locate the links, but after many attempts I could not figure it out ]



3) with the command like :

<< writeFile(SaveLinkFile, daaata.join("\r\n") + "\r\n", true); >>

you add a "date" to the txt, but is there a way to delete that "date" (if it exists) from the txt?

ex :
txt -->
Quote:
A00
A01
A02
A03
...
AXX
var date0 = "A02"

read txt
If date0 find --> delete it from txt
else date0 notfind --> Do nothing.

opening the txt manually and editing it is + easy but I was wondering if there is a scripted way?
Reply With Quote
  #1784  
Old 21.07.2021, 13:17
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 80,056
Default

@BJN01:

Quote:
Originally Posted by BJN01 View Post
var StartLink = link.getContainerURL();
var Hostname = StartLink.match(/:\/\/([^/]+)/)[1]; // for Host name
error : <Cannot cal method "match" of null>
link.getContainerURL may return null, you have to check for it



You can use existing methods for this
link.getHost(), returns host name of the plugin
link.getDownloadHost(), returns actual host name of the internal download url
__________________
JD-Dev & Server-Admin
Reply With Quote
  #1785  
Old 21.07.2021, 13:45
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,567
Default

Quote:
Originally Posted by BJN01 View Post
error : <Cannot cal method "match" of null>
Add error handling for links which do not have container url.

Code:
var link = crawledLink;

if (link.availableState == "ONLINE") {
    var StartLink = link.getContainerURL();
    
    try {
        var Hostname = StartLink.match(/:\/\/([^/]+)/)[1]; // for Host name
        alert(Hostname);
    } catch (e) {};
}

Quote:
Originally Posted by BJN01 View Post
error = I selec 1 (one) link for test the script , and i get a "thousand" windows alerts...
Use only lgSelection links. Also, the alert should be placed outside the loop. Store/append the hostnames in a variable and use alert at the end to display them.

Code:
if (name == "Aggiungi Host Monitoring") {
    var HostNames = [];

    lgSelection.getLinks().forEach(function(link) {
        try {
            var HostName = link.contentURL.match(/:\/\/([^/]+)/)[1];
            HostNames.push(HostName);
        } catch (e) {};
    })

    alert(HostNames.join("\n"));
}

Quote:
Originally Posted by BJN01 View Post
.. opening the txt manually and editing it is + easy but I was wondering if there is a scripted way?
Code:
var file = getPath("path/to/file");
var text = readFile(file, true);
var update = false;
var str = "A02";

if (text.indexOf(str + "\r\n") > -1) {
    text.replace(str + "\r\n", "");
    update = true;
}

if (update) {
    file.delete();
    writeFile(file, text, true);
}

Quote:
Originally Posted by Jiaz View Post
@BJN01:
You can use existing methods for this
link.getHost(), returns host name of the plugin
link.getDownloadHost(), returns actual host name of the internal download url
Example in post #1777 was to get host name from container url.
Reply With Quote
  #1786  
Old 24.07.2021, 14:54
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

on some sites I find files with names like this:
Quote:
13-ba2646388a7dd350a8f252f79664f87f979bbe8182cc1576742f68af3cf307be.png

2-3578f8d84a541f5e536f56fefa2b6a0b4cd67d5ffe1e3322301e2f4c128a0aef.png

302-f8fc9e3f3fd7828767e87c55b0453e31d1780203e4d61041671acd00a6066144.jpg
I would like to make them things like:

13.png
02.png
302.jpg

but to use the < ..... replace ("old", "new") ..... >
I can't find a valid regex to use [ especially to eliminate the part between "-" and the file extension ] ,
how should the regex be?
Reply With Quote
  #1787  
Old 24.07.2021, 15:10
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,567
Default

Quote:
Originally Posted by BJN01 View Post
I can't find a valid regex to use [ especially to eliminate the part between "-" and the file extension ] , how should the regex be?
Code:
^(\d+)(-[a-z0-9]{64})(\.(?:jpg|png))$
Reply With Quote
  #1788  
Old 24.07.2021, 15:32
radix radix is offline
JD Alpha
 
Join Date: Apr 2009
Posts: 21
Default

Quote:
Originally Posted by Taobaibai View Post
To extract archives only after all downloads have finished, use this new script:
Code:
github.com/mgpai/resources/blob/master/jdownloader/eventscripter/scripts/Taobaibai_2.js


Thank you, that was what I was looking for!!!!
bei mir tut es nichts.
ich habe beim "archiventpacker" plugin den haken bei "Archive nach dem Download entpacken" entfernt. Und Trigger ist "Pakt fertiggestellt"

muss ich noch etwas ein- und/oder ausschalten?
Reply With Quote
  #1789  
Old 24.07.2021, 15:57
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,567
Default

Quote:
Originally Posted by radix View Post
bei mir tut es nichts.
ich habe beim "archiventpacker" plugin den haken bei "Archive nach dem Download entpacken" entfernt. Und Trigger ist "Pakt fertiggestellt"

muss ich noch etwas ein- und/oder ausschalten?
It seems to be working fine. Please note, completed archives will be extracted only if all packages in the download list are finished.
Reply With Quote
  #1790  
Old 24.07.2021, 16:36
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

Quote:
Originally Posted by mgpai View Post
Code:
^(\d+)(-[a-z0-9]{64})(\.(?:jpg|png))$
sorry, but it doesn't work.
(I also checked through F2 on various files and inserting the string, but it does nothing [in the preview the name remains the same] )
Reply With Quote
  #1791  
Old 24.07.2021, 16:45
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,567
Default

Quote:
Originally Posted by BJN01 View Post
sorry, but it doesn't work.
(I also checked through F2 on various files and inserting the string, but it does nothing [in the preview the name remains the same] )
Works fine. Please post your script OR screenshot of your rename dialog.
Reply With Quote
  #1792  
Old 24.07.2021, 17:08
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

Quote:
Originally Posted by mgpai View Post
Works fine. Please post your script OR screenshot of your rename dialog.
screenshot of rename dialog here --> ht#ps://i.postimg.cc/D0sBCVxW/F2-And-Preview.jpg
[ maybe I was wrong to copy the string between one first and another, this time it does something (but does everything change?) ]


x the script
I did a test, and if I write the piece I want to remove in the script it works, that is:

ex file :
2-3578f8d84a541f5e536f56fefa2b6a0b4cd67d5ffe1e3322301e2f4c128a0aef.png

+ script with:

blabla ... replace ("-3578f8d84a541f5e536f56fefa2b6a0b4cd67d5ffe1e3322301e2f4c128a0aef",""); .....


the file it becomes ---> 2.png [ok]

Last edited by BJN01; 24.07.2021 at 17:12.
Reply With Quote
  #1793  
Old 24.07.2021, 17:16
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,567
Default

Quote:
Originally Posted by BJN01 View Post
("-3578f8d84a541f5e536f56fefa2b6a0b4cd67d5ffe1e3322301e2f4c128a0aef",""); .....
the file it becomes ---> 2.png [ok]
OK. But, how are you using the regex pattern? You need to use the correct capture groups to replace.

Code:
regex101.com/r/qbj3rm/1
Reply With Quote
  #1794  
Old 24.07.2021, 18:33
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

ok , with the F2 I did not put "$1$3" ... so , i'm an idi#t ...

but , the script doesn't want to do its job ... am I doing something wrong then?


Code:
//trigger = a new link has been added  

var link = crawledLink;
if (link.availableState == "ONLINE") {
    var StartLink = link.getContainerURL();
    
    try {
        var Hostname = StartLink.match(/:\/\/([^/]+)/)[1]; // for Host name
        //alert(Hostname);
    } catch (e) {};
    
     if (Hostname == "#Site#" ) {            
          getAllCrawledLinks().forEach(function(i) {
        var replace = function(a, b) {
            i.name = i.name.split(a).join(b);
        }
   
 replace("^(\d+)(-[a-z0-9]{64})(\.(?:jpg|png))$" , "$1$3"); // not work , do nothing , the file name dont change
 replace("-07145d3f75219e8fa82c4d2335addb98f2ec54d1de7478a3edea333ce5a22ac8",""); // ok , do is job 
    })
    }
}

Last edited by BJN01; 24.07.2021 at 18:35.
Reply With Quote
  #1795  
Old 24.07.2021, 18:44
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,567
Default

Quote:
Originally Posted by BJN01 View Post
but , the script doesn't want to do its job ... am I doing something wrong then?
Split/join can be used when find/replace parameters are both strings. Since you are using regex here, you will need to use it as find parameter and, str (static) or capture groups as replace parameter.

Code:
var replace = function(a, b) {
    i.name = i.name.replace(a, b);
}

replace(/(\d+)(-[a-z0-9]{64})(\.(?:jpg|png))$/, "$1$3");
Reply With Quote
  #1796  
Old 24.07.2021, 18:56
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

Quote:
replace(/(\d+)(-[a-z0-9]{64})(\.(?:jpg|png))$/, "$1$3");
now the files become something like this:

$1$32$1$3-31171572ee3982a2fb88bafee6bea0df33a55af07f6b95d442752a3dbb22147e$1$3.png$1$3

??? why ??
Reply With Quote
  #1797  
Old 24.07.2021, 19:12
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,567
Default

Quote:
Originally Posted by BJN01 View Post
now the files become something like this: ...
??? why ??
Should be working fine:
Code:
var i = {
    name: "3-31171572ee3982a2fb88bafee6bea0df33a55af07f6b95d442752a3dbb22147e.png"
}

var replace = function(a, b) {
    i.name = i.name.replace(a, b);
}

replace(/(\d+)(-[a-z0-9]{64})(\.(?:jpg|png))$/, "$1$3");

alert(i.name);

Find me in JD chat if you want me to take a look at your script.
Code:
kiwiirc.com/nextclient/irc.libera.chat/#jdownloader
Reply With Quote
  #1798  
Old 03.08.2021, 15:52
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

hello ,

starting from the script I use to rename files and packages, I am creating one in which I change the name of the package and / or files only if they come from a given host / starting link.

that is, if the initial link is:
-from : vvvvv.siteAAA.A ---> change package name
-from : vvvvv.siteAAB.A ---> DO NOT change package name, leave it like this.

.... the problem is that I don't get any results.

trigger : hook packager
simplified version but not working

Code:
if (name = CuoPHv2 = "Cleanup packagenamesfromHost") {
    getAllCrawledPackages().forEach(function(i) {
        var replace = function(a, b) {
              link.name = link.name.replace(a, b);
             }
if (link.downloadHost == "SiteA.AAA"){// 
  replace ("[English]","[Eng]");// for test 
  replace (/(\[English])/,"[Eng]");// for test
  //... list of replace for that host.
}          

if (link.downloadHost == "SiteB.BBB"){// 
  replace ("ONE","[1]");// for test 
    //... list of replace for that host.
}          
// etc.


            }
//.....
 )
}
where am i wrong? what - how should I correct?

Last edited by BJN01; 03.08.2021 at 15:55.
Reply With Quote
  #1799  
Old 03.08.2021, 16:03
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,567
Default

Quote:
Originally Posted by BJN01 View Post
where am i wrong? what - how should I correct?
Change:
Code:
function(i)
to:
Code:
function(link)
Reply With Quote
  #1800  
Old 03.08.2021, 16:20
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 80,056
Default

@BJN01: Just in case you are familiar with java coding language, you could also directly write extensions/code in java.
__________________
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 18:39.
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.