#1761
|
|||
|
|||
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! |
#1762
|
||||
|
||||
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 |
#1763
|
|||
|
|||
@mgpai:
Quote:
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. |
#1764
|
|||
|
|||
Quote:
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(); } |
#1765
|
|||
|
|||
@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(); Quote:
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. |
#1766
|
|||
|
|||
Quote:
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(); } |
#1767
|
|||
|
|||
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 |
#1768
|
|||
|
|||
The linked post does not contain any additional information. Please provide example links. You can also PM them.
|
#1769
|
|||
|
|||
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); 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"); 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? |
#1770
|
||||
|
||||
Quote:
Quote:
Quote:
Quote:
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. |
#1771
|
|||
|
|||
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); I will also try these commands but I guess they only save the "simple" page. Quote:
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. |
#1772
|
|||
|
|||
Quote:
Quote:
To run from script, you will need a program which can generate mht directly, without using browser. |
#1773
|
|||
|
|||
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? |
#1774
|
|||
|
|||
Quote:
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"); |
#1775
|
|||
|
|||
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")); Code:
test replace ( or test split) (blabla,url1,url2,url3,url4) Last edited by BJN01; 16.07.2021 at 11:22. |
#1776
|
|||
|
|||
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) |
#1777
|
|||
|
|||
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(); [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?] |
#1778
|
|||
|
|||
Code:
var hostname = link.getContainerURL().match(/:\/\/([^/]+)/)[1]; Quote:
Code:
var myFile = Readfile("path/to/file"); var url = link.contentURL(); if (myFile.indexOf(url) > -1) { link.setEnabled(false); } |
#1779
|
||||
|
||||
@mgpai:
@BJN01: containerURL might be undefined/null, you should add some checks for it
__________________
JD-Dev & Server-Admin |
#1780
|
||||
|
||||
@mgpai: I think your duplicate scripts would be great template for this, don't you think?
__________________
JD-Dev & Server-Admin |
#1781
|
|||
|
|||
Quote:
Quote:
@BJN01: Related thread |
#1782
|
|||
|
|||
thank you guys !!! I found some interesting things that I will try to adapt to my approach / starting idea.
|
#1783
|
|||
|
|||
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); } 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); }} )} 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:
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? |
#1784
|
||||
|
||||
@BJN01:
Quote:
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 |
#1785
|
|||
|
|||
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:
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:
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:
|
#1786
|
|||
|
|||
on some sites I find files with names like this:
Quote:
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? |
#1787
|
|||
|
|||
Quote:
Code:
^(\d+)(-[a-z0-9]{64})(\.(?:jpg|png))$ |
#1788
|
|||
|
|||
Quote:
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? |
#1789
|
|||
|
|||
It seems to be working fine. Please note, completed archives will be extracted only if all packages in the download list are finished.
|
#1790
|
|||
|
|||
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] ) |
#1791
|
|||
|
|||
Works fine. Please post your script OR screenshot of your rename dialog.
|
#1792
|
|||
|
|||
Quote:
[ 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. |
#1793
|
|||
|
|||
Quote:
Code:
regex101.com/r/qbj3rm/1 |
#1794
|
|||
|
|||
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. |
#1795
|
|||
|
|||
Quote:
Code:
var replace = function(a, b) { i.name = i.name.replace(a, b); } replace(/(\d+)(-[a-z0-9]{64})(\.(?:jpg|png))$/, "$1$3"); |
#1796
|
|||
|
|||
Quote:
$1$32$1$3-31171572ee3982a2fb88bafee6bea0df33a55af07f6b95d442752a3dbb22147e$1$3.png$1$3 ??? why ?? |
#1797
|
|||
|
|||
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 |
#1798
|
|||
|
|||
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. } //..... ) } Last edited by BJN01; 03.08.2021 at 15:55. |
#1799
|
|||
|
|||
Change:
Code:
function(i) Code:
function(link) |
#1800
|
||||
|
||||
@BJN01: Just in case you are familiar with java coding language, you could also directly write extensions/code in java.
__________________
JD-Dev & Server-Admin |
Thread Tools | |
Display Modes | |
|
|