#1
|
|||
|
|||
Event Scripter scripts doubs
I made two scripts.
Every time that links is added into a package: Code:
if (true) { //url.includes("www3.animeflv.net")) var filename = link.getName(); if (filename !== null && filename.includes(" Episodio ")) { var newFilename = filename.replace("Episodio ", ""); var regex = /(\d+)\./g; var match = newFilename.match(regex); if (match !== null && match.length > 0) { var number = match[match.length - 1]; if (number < 10) { newFilename = newFilename.replace(number, "0" + number); } } link.setName(newFilename); } } Ex: "Ookami to Koushinryou; Merchant Meets the Wise Wolf Episodio 5" => "Ookami to Koushinryou; Merchant Meets the Wise Wolf 05" When I press a button, the script ensures the best favorite link must be enabled, the rest should be disabled. If there is no one favorite these remain untouched: Code:
if (name = "EST") { function includes(array, valor) { for (var i = 0; i < array.length; i++) { if (array[i] == valor) { return i; } } return -1; } var favoritos = ['mega.nz', 'streamtape.com']; var links = getAllDownloadLinks(); var packages = {}; var favs = {}; for (var i = 0; i < links.length; i++) { var link = links[i]; var package = link.getPackage().getName(); if (!packages[package]) { packages[package] = []; } packages[package].push(link); var dominio = link.getContentURL().split('/')[2]; var ind = includes(favoritos, dominio, packages[package].length - 1); if (ind >= 0 && (!favs[package] || favs[package] > ind)) { favs[package] = ind; } } for (var package in packages) { if (favs[package] !== undefined) { var fav = favs[package]; for (var i = 0; i < packages[package].length; i++) { var link = packages[package][i]; var dominio = link.getContentURL().split('/')[2]; link.setEnabled(favoritos[fav] == dominio); //link.setPriority(-2);//Do nothing!!!??? } } } } I'd like to apply the first script for the videos I download from "www3.animeflv.net" only. And the second rule I would like to apply after the package is formed before sending it down. Where can I find more information on which functions are available for each script depending on the trigger that triggers it? Is it possible to change the priority of a download link? Is it possible to sort the links? Last edited by RydemStorm; 08.07.2024 at 22:17. Reason: Fix |
#2
|
||||
|
||||
You can find all available Objects/Methods... in the Scripteditor at top (Menu "Show/Hide Help"). The available Objects/Methods depend on current select event trigger.
Quote:
and then customize the comment to place some meta information, that you can later use your script. You can also change trigger to "Packagizer Hook" and there you can make use of PackagizerLinkSandbox.getSourceUrls which contains the source/animeflv reference. Yes, there are set/getPriority methods available You can use controller API endpoints and create new packages and then add the links in desired order. Quote:
I recommend to ask here for help/hints when it's about scripting/scripts
__________________
JD-Dev & Server-Admin Last edited by Jiaz; 08.07.2024 at 23:26. |
#3
|
|||
|
|||
I put a Comment in Packagizer.
Then changed the validation: if (link.getComment() === "animeflv") { ... link.setPriority("HIGHEST");//Fixed, require string. Sort, pending study. Packagizer Hook: I don't know when it fired, but for this particular example it shot 22 times, with 2 packets, the first with 7/7 links shot up 16 times, and the second one with 0/1 link shot up 6 times. https://board.jdownloader.org/attach...1&d=1720560519 |
#4
|
|||
|
|||
I'm going to leave the latest version of the previous scripts, optimized and corrected in case it's of interest to anyone else.
Trigger: A new link has been added Explain: Clean names files and set priority. Code:
//crawledLink if (link.getComment() === "animeflv") { var filename = link.getName(); if (filename !== null && filename.includes(" Episodio ")) { var regex = /Episodio (\d+)/; var match = filename.match(regex); if (match) { var number = match[1]; var num = number < 10 ? "0" + number : number; filename = filename.replace("Episodio " + number, num); link.setName(filename); } } } function getPriority(domain) { var favorites = ["mega.nz", "streamtape.com", "gofile.io"]; for (var i = 0; i < favorites.length; i++) { if (favorites[i] === domain) { switch (i) { case 0: return "HIGHEST"; case 1: return "HIGHER"; case 2: return "HIGH"; default: return "DEFAULT"; } } } return "DEFAULT"; } var domain = link.getURL().split('/')[2]; var priority = getPriority(domain); link.setPriority(priority); Explain: I enable only the best favorite, disable the rest. If there are no favorites, I keep them all enabled. Code:
if (name = "EST") { var favorites = ["mega.nz", "streamtape.com", "gofile.io"]; function getFavoriteIndex(domain) { for (var i = 0; i < favorites.length; i++) { if (favorites[i] === domain) { return i; } } return -1; } for (var i = 0; i < getAllCrawledPackages().length; i++) { var best = -1; var package = getAllCrawledPackages()[i]; for (var j = 0; j < package.getDownloadLinks().length; j++) { var link = package.getDownloadLinks()[j]; var domain = link.getContentURL().split('/')[2]; var favorite = getFavoriteIndex(domain); if (favorite >= 0 && (best == -1 || best > favorite)) { best = favorite; } } for (var j = 0; j < package.getDownloadLinks().length; j++) { var link = package.getDownloadLinks()[j]; var domain = link.getContentURL().split('/')[2]; link.setEnabled(favorites[best] == domain || best == -1); } } } https://board.jdownloader.org/attach...1&d=1720563493 https://board.jdownloader.org/attach...1&d=1720563493 Last edited by RydemStorm; 10.07.2024 at 01:18. |
#5
|
||||
|
||||
Quote:
Quote:
__________________
JD-Dev & Server-Admin |
#6
|
||||
|
||||
Priorities can also be set via Packagizer, see https://support.jdownloader.org/de/k...the-packagizer
__________________
JD-Dev & Server-Admin |
#7
|
||||
|
||||
Thanks for sharing your final nice/clean script, you should also link/reference it here https://board.jdownloader.org/showthread.php?t=70525
__________________
JD-Dev & Server-Admin |
#8
|
|||
|
|||
How should I do that, just by doing Post Reply?
|
#9
|
|||
|
|||
API?
I'd like to create a new package, starting from an existing one. I intend to sort the links during the creation of the same.
Can someone give me a basic example of how to use the API? I think this would capture the package links, queryPackagesParameter. I know that I should create the new package with the function movetoNewPackageParameter. But I haven't even been able to invoke queryPackagesParameter and get it to work properly. |
#10
|
||||
|
||||
@RydemStorm: Just out of interest, why you wanna sort them? You are aware that order of links in list doesn't mean that this will also be the download order of the files. why the order that important to you? what you use/need it for?
__________________
JD-Dev & Server-Admin |
#11
|
|||
|
|||
Quote:
But if I have to manually make adjustments to make the download satisfactorily, having the links sorted makes things easier for me. Sometimes some download links do not work in the best possible way due to payment issues, limitations of free services, or blocks for certain countries or servers. Under these conditions, having the links in order helps me choose better download alternatives. Also, I would be interested in knowing a little more about how to access the API, I am a programmer, I like to program, and I am making some tweaks to the JDownloader, to make it easier for me to use. I've relatively covered the topics related to Packagizer, Link Crawler, Scripts Events, but I'm at zero with respect to the API. |
#12
|
||||
|
||||
@RydemStorm: Understood. You can find the api docs here https://my.jdownloader.org/developers/
You can get the latest/live help via localhost:3128/help when enabling the deprecated api in Settings->Advanced Settings in JDownloader Please see for example this script as reference https://board.jdownloader.org/showpo...85&postcount=1 Quote:
__________________
JD-Dev & Server-Admin |
Thread Tools | |
Display Modes | |
|
|