#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 18: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 19: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 16: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 | |
|
|