#2601
|
|||
|
|||
![]()
Hi there, I was hoping for some help in making a script.
I have a MEGA folder someone's shared with me that occasionally has new files added to it. I was hoping for a way to automatically add those new files to JD2 and have them downloaded to a specific folder. I figured the best way to do this is to have an Interval trigger EventScripter script that has LinkGrabber periodically re-analyse the MEGA folder URL, and if it finds new download links that have not previously been added to the download list then it should add them to the download list and start the download. Is there a way to do this with event scripter? EDIT: Here's my script in case it's useful for anyone else. Code:
// Paste this script into Jdownloader's EventScripter under a new Event named "LinkWatcher", with trigger set to "Interval", and interval set to 21600000 milliseconds (6hrs). // Make sure to "Test Run" once after making the event or editing the script, which will bring up a one-time pop-up box asking if you're okay that the script does API calls; click yes obviously and make sure "do not ask again" is checked. // If a particular link isn't working with this for some reason, remove all existing packages in the Linkgrabber that relate to that URL and try again. // Define each link to watch as a dict within the links array. // Leave unnecessary fields blank; e.g. password for download or extract (DPW and EPW respectively) may be unnecessary. // Name is just a field to make that particular link dict identifiable to you, it's not passed along to JD. // PackageName on the other hand defines the packge name in JD. // Ensure the backslashes in Path are doubled to escape them var links = [{ Name: "TV Show", PackageName: "AwesomePackage", URL: "**External links are only visible to Support Staff**, Path: "C:\\Downloads", DPW: "", EPW: "" }, { Name: "TV Show #2", PackageName: "LessAwesomePackage", URL: "**External links are only visible to Support Staff**, Path: "C:\\Downloads", DPW: "", EPW: "" }] // For info on the structure/options within the addlinks API call, see the following: https://my.jdownloader.org/developers/#tag_244 and https://my.jdownloader.org/developers/#tag_245 // Overwrite Packagizer Rules allows you to define the download path and Package Name, etc here in the script // Autostart automatically moves the files from linkgrabber -> download list and starts downloading them. // In order to make this operate entirely without human intervention, you need to set some keys in the Advanced Settings section of JD Settings // Set LinkgrabberSettings.defaultonaddeddupeslinksaction to "do NOT add, but remove them from linkgrabber". // Set LinkgrabberSettings.handledupesonconfirmlatestselection to "do NOT add, but remove them from linkgrabber". // The first is the most important one. This makes it so that by default, WITHOUT being asked, if you try to move an already-downloaded link from linkgrabber -> download list, it'll remove it from linkgrabber but it WON'T try to redownload it. To redownload it you'd need to delete the link from the download list, or just click Reset on it. for (i = 0; i < links.length; i++) { var link = links[i]; callAPI("linkgrabberv2", "addLinks", { "overwritePackagizerRules": true, "autostart": true, "links": link.URL, "packageName": link.PackageName, "downloadPassword": link.DPW, "extractPassword": link.EPW, "destinationFolder": link.Path }); }; Last edited by HeyItsJono; 14.04.2023 at 09:34. |
#2602
|
|||
|
|||
![]()
Hi everyone. I have a request.
I often have to check the same links several times to see if new videos have been uploaded (completed files stay in the download list so I remember the ones I already have). Is there a way to automate this via scripter? Basically I'm looking for a script that allows me to scan with linkchecker all the links I specify in a data structure (example array) var list=["www.link1.com" , "www.link2.com"....] Clicking on the trigger will start scanning all the links I have specified and then submit them to the linkgrabber, exactly as you would do with copy-paste, drag&drop. If it is not possible to implement the link list from the code one could alternatively use a link list saved in a text file. I have no idea how to do it. I thank you in advance |
#2603
|
|||
|
|||
![]()
Hey need a split package by Download from url. Thanks!
|
#2604
|
|||
|
|||
![]()
Hi!
Is it possible to write a script that will set an overall daily download size quota? Something along the lines of: A) When a download finishes it checks a date+time based CurrentDownloadPeriod VariableA, if it doesnt exist or is outside of the previous 24hrs it sets the current date/time B) sets a CurrentPeriodTotalDownloadSize VariableB (which also gets reset in A if A resets the date variable) that adds the completed downloads size incrementally as each download finishes, C) if CurrentPeriodTotalDownloadSize > 250GB, pause all downloads, wait 25hours, reset Variables A&B, and resumes all downloads If that's possible, which seems likely, if someone could write that for me without it being too much trouble, I'd appreciate it :D While my scripting knowledge is pretty limited, I'm also not opposed to trying to piece one together with all the previous examples/online help files, and then come back for more help when it doesn't work, lol. Actually, that's what i am going to do, but this will be a nice way to get the ball rolling for help when i come back frustrated that nothing i tried worked, and would be cool if some awesome person wrote a working option for when i can't figure it out, lol :D Thanks! |
#2605
|
|||
|
|||
![]() Quote:
|
#2606
|
|||
|
|||
![]() Quote:
Quote:
![]() Code:
var myBrowser = getBrowser(); myBrowser.headPage(link.getURL()); var responseHeader = myBrowser.getResponseHeader("Content-Disposition"); |
#2607
|
|||
|
|||
![]()
Can you please explain what you mean by that? that would result in one package for each download link?! or do you mean something different? or maybe I don't understand correct
![]() |
#2608
|
|||
|
|||
![]()
I could try to add such button at the bottom bar because the toolbar a top is shared between downloads and linkgrabber and would make it more complex. also the button would have to be enabled/disabled, depending on current view.
|
#2609
|
||||
|
||||
![]() Quote:
__________________
raztoki @ jDownloader reporter/developer http://svn.jdownloader.org/users/170 Don't fight the system, use it to your advantage. :] |
#2610
|
|||
|
|||
![]() Quote:
![]() |
#2611
|
|||
|
|||
![]()
Hey there,
I use the following script to rename video files of a certain size to lowercase ("ON_PACKAGIZER"): Code:
if (linkcheckDone && link.bytesTotal > 150 * 1024 * 1024 && link.bytesTotal < 2500 * 1024 * 1024) { var re = /(?:\.([^.]+))?$/; var ext = re.exec(link.name)[1].toLowerCase(); switch (ext) { case "mkv": case "mpeg": case "mp4": case "mpg": case "avi": link.name = link.name.toLowerCase(); } } I'd like to have a similar script to do the same for all video files, that are extracted from archives, but I'm not sure how to go about it ![]() Could someone please help me out? Thank you in advance! Last edited by aiimaim; 21.04.2023 at 10:43. |
#2612
|
||||
|
||||
![]()
@aiimaim: You could use trigger "Archive extraction finished" and then use
Quote:
Quote:
Quote:
Quote:
![]() |
#2613
|
|||
|
|||
![]()
Thank you for your input @notice.
So far I've come up with this reduced version of the script: Code:
var archiveFilePaths = archive.getExtractedFilePaths(); // Iterate through all extracted files in the archive for (var i = 0; i < archiveFilePaths.length; i++) { var archiveFilePath = archiveFilePaths[i]; var file = getPath(archiveFilePath); // Get a FilePath object if (file.getExtension()=="avi" || file.getExtension()=="mpeg" || file.getExtension()=="mpg" || file.getExtension()=="mp4" || file.getExtension()=="mkv") { if (file.isDirectory()) { // If it's a directory, traverse its contents recursively traverseDirectory(file, function(subFile) { subFile.renameName("test1 "+subFile.getName().toLowerCase()); // Rename the file to lowercase }); } else { // If it's a file, simply rename it to lowercase file.renameName("test2 "+file.getName().toLowerCase()); } } } // Helper function to recursively traverse a directory tree and apply a function to each file function traverseDirectory(directory, fn) { var files = directory.listFiles(); for (var i = 0; i < files.length; i++) { var file = files[i]; if (file.isDirectory()) { traverseDirectory(file, fn); } else { fn(file); } } } Code:
file.renameName(file.getName().toLowerCase()); Could this be a windows-related error, since Windows doesn't differentiate between lowercse and upprcase filenames? (Right now I'm testing under windows. The goal is to move it to my nas' headless installation, when it works.) EDIT: Suspicion confirmed, it works under linux. Last edited by aiimaim; 22.04.2023 at 18:15. |
#2614
|
|||
|
|||
![]()
@aiimaim: I will update rename methods with next core update. right now they checks for existing of new file and on windows this is true due to case insensitivity. After next core update it should work as expected. meanwhile you could do workaround like A->tA->a renaming. Thanks for bringing up this issue
Last edited by notice; 22.04.2023 at 16:50. |
#2615
|
|||
|
|||
![]()
@notice: Thanks for the quick feedback. Yea I thought of renaming twice, as you suggested. But since I'm using it on my linux based NAS, it's not an issue for me. It was just a slight inconvenience during testing on windows.
Last edited by aiimaim; 22.04.2023 at 19:26. |
#2616
|
|||
|
|||
![]() |
#2617
|
|||
|
|||
![]()
Hi, I understand that there is a script to randomize download order in links and/or folders but I can't find it. Any help would be appreciated. Tx!
|
#2618
|
|||
|
|||
![]()
Hi.
I try the first Convert "AAC/M4A/OGG/OPUS files to MP3" you have created and doesn't work it bring error. Is there any newest that really work? And after you add this script at "event scripter" is there anything else you must do to work? I try even create a new button like it shows here and still your script doesn't work. |
#2619
|
|||
|
|||
![]()
I'm trying to figure out a way of executing a bash-script at the end of either each extraction or at the end of the last extraction (not quite sure yet what would make more sense, probably after each extraction though).
Unfortunately, no coder here so I tried to find some available code here and also tried ChatGPT but don't get MyJDownloader to take the code. Found the following code in this thread (https://board.jdownloader.org/showpo...postcount=1421)... Quote:
JD is running headless on Ubuntu 22.04.2 LTS. Any hint is appreciated. |
#2620
|
|||
|
|||
![]()
Is there an event script code to switch tabs, specifically Downloads and LinkGrabber?
I read through the API document and found nothing relating to the action. No similar example script seems not to be listed here. All I want to do is switch focused tabs between Downloads and LinkGrabber in certain seconds like 5s. Can anyone show me how to do it? Thank you. |
![]() |
Thread Tools | |
Display Modes | |
|
|