#2921
|
|||
|
|||
Code:
/* disable dupes trigger : toolbar button pressed */ if (name == "disable dupes") { var original = []; getAllCrawledLinks().forEach(function(link) { var url = link.contentURL; if(url){ if(original.indexOf(url) == -1){ original.push(url); //link.comment = "original"; } else { link.enabled = false; //link.comment = "dupe" } } }) } Script also has an option to set comment which is disabled by default. If enabled, the comment on first link will be set as 'orginal' and subsequent links will be set to "dupes". This will be useful for creating view filters. |
#2922
|
||||
|
||||
Quote:
EDIT Problem: When I enable the Scripter-button in the toolbar, another script gets started. That way I can only enable or disable all my scripts. Finally got it working, disabling dupes that is. But I had to change the trigger to LinkGrabber Context Menu Button pressed. With 25,000 links in LinkGrabber, it takes about 12 seconds until the dupes are disabled. But that's ok. But I still don't know how to enable the comments, 'original' and 'dupes'. Can you please explain how I can enable comments? Thanks again and best regards, Stefan Last edited by StefanM; 26.04.2024 at 21:38. |
#2923
|
|||
|
|||
A toolbar button is more suitable since the objects used in the script are global. The name in the toolbar button should match the name used in the script. Change the toolbar button name from the default name to "disable dupes" (without quotes).
Since the script will overwite any custom comments set by the user, it is disabled by default (commented out). Uncomment the relevant code. For e.g, change: Code:
//link.comment = "original"; Code:
link.comment = "original"; |
#2924
|
||||
|
||||
Quote:
Quote:
Again, thank you so much for that macro! Whish I would be able to write such macros myself... |
#2925
|
||||
|
||||
No changes from those updates only plugin updates
__________________
JD-Dev & Server-Admin |
#2926
|
|||
|
|||
Delete empty folder (after files have been moved)?
Hello everyone,
I have written a script which moves downloaded files (which are not an archive) to another directory (the package name remains the same). The script also works. But after moving, the (now) empty folder remains in the original download directory. That's the script: Code:
/* Move finished non archive files Trigger: Download has stopped */ if (link.finished && !link.archive) { var downloadFolder = link.package.downloadFolder; var newFolder = downloadFolder.split("C:\\Users\\Tom\\Downloads\\JD 2\\").join("C:\\Users\\Tom\\Downloads\\JD 2\\F\\"); // Modify path if (newFolder != downloadFolder) { getPath(link.downloadPath).moveTo(newFolder); } } Maybe it is possible to combine both functions in one script, but unfortunately I am at a loss here. Can someone help me? That's my attempt (not working): Code:
/* Delete empty folder after files have been moved Trigger: Download has stopped */ if (link.finished) { var downloadFolder = getPath(link.downloadPath); // if (downloadFolder.exists() && downloadFolder.getChildren().length == 0) { downloadFolder.delete(); } } |
#2927
|
||||
|
||||
@SacredDB: link.downloadpath is the path to the file, not the folder, you need get the parent(folder) of the file like following
Quote:
__________________
JD-Dev & Server-Admin |
#2928
|
|||
|
|||
Quote:
Got it, now it's working. Thank you Jiaz! |
#2929
|
||||
|
||||
@SacredDB: you're welcome and thanks for the feedback. maybe wanna share your final scripts and short descriptions, in case other want to achieve similiar thing
__________________
JD-Dev & Server-Admin |
#2930
|
|||
|
|||
I don't understand java script programming at all, but I need a script that would put all the files from one post from kemono.su in one folder, no matter what file sharing site they are on. Please help me if it's not difficult.
|
#2931
|
||||
|
||||
Context for VanTuz post:
https://board.jdownloader.org/showth...577#post534577
__________________
JD Supporter, Plugin Dev. & Community Manager
Erste Schritte & Tutorials || JDownloader 2 Setup Download |
#2932
|
|||
|
|||
Hi. I wanted help making a script that is able to take postContentIndex, which returns an index for the order in which an image appears on a page, but zero pads it so the number is always 3 digits. e.g. 001, 002, ..., 011, etc. Instead of the current 1, 2, ..., 11, etc.
More context in this post. Jiaz mentions he's available to clarify details. https://board.jdownloader.org/showth...712#post534712 |
#2933
|
|||
|
|||
Quote:
Code:
if > source url contains : kemono.su/*/user/*/post/* then set > download directory : <jd:source:1> <jd:source:2> <jd:source:3> then set > package name : <jd:source:1> <jd:source:2> <jd:source:3> |
#2934
|
|||
|
|||
It didn't work. Or I did something wrong.
|
#2935
|
||||
|
||||
@mgpai
Context is missing here - he also wants to put all non-kemono results which are added originally via kemono to be put in one package e.g. also all mega.nz links. Reference: https://board.jdownloader.org/showth...577#post534577
__________________
JD Supporter, Plugin Dev. & Community Manager
Erste Schritte & Tutorials || JDownloader 2 Setup Download |
#2936
|
|||
|
|||
Quote:
|
#2937
|
|||
|
|||
So I'm doing something wrong and I don't understand how it should be.
|
#2938
|
|||
|
|||
Rule is applied only when adding links to JD. If it is still not working, post a screenshot of your packagizer rule.
|
#2939
|
|||
|
|||
|
#2941
|
|||
|
|||
Quote:
Code:
/* pad postContentIndex trigger : packagizer hook */ if (linkcheckDone && state == "BEFORE") { var current = link.getProperty("postContentIndex"); if (current != null) { var padded = ("000" + current).slice(-3); link.setProperty("postContentIndex", padded); } } |
#2942
|
|||
|
|||
I checked with a link to a specific post and it worked, but the fact is that I need the name of the post to be in the folder name. Of course, you can make sure that files from the post that are not on the file sharing site fall into a subfolder, but then if there are a lot of folders, then it will be difficult to sort the files by folders. And if there are a lot of pages with posts on the author's page, then even if you use third-party browser add-ons to copy several links at once, it will take a lot of time to copy all the links, and I would like to do something faster, if it is possible in principle.
|
#2943
|
|||
|
|||
is it possible to run an external (python?) script to resolve link? as many sites use cloudflare to block jd now
|
#2944
|
|||
|
|||
You can use callSync and callAsync methods (check built-in help for details) to call external programs from eventscripter.
|
#2945
|
|||
|
|||
yes but you can't change downloadlinks, can only add to linkgrabber and then the packages and filenames will be messed up.
|
#2946
|
|||
|
|||
Only directhttp links can be modified in GUI. Presently there are no eventscripter methods to do it. You can use addLinksQuery to insert new links in the same package preserving the file name, comment etc., depending on the output returned by your script. You can also use folderwatch MYJD API and add links directly from python script.
|
#2947
|
||||
|
||||
Script: Stop downloads during extraction
As the old script in this thread to stop downloads during extraction is not working anymore (producing a deadlock) here's a new one i put together on a user request:
Code:
/* Stop downloads during extraction Trigger Required: Any Extraction Event */ if (isDownloadControllerRunning() && event == "EXTRACTING") { // Extraction starting and download runnning stopDownloads(); } else if (!isDownloadControllerRunning() && event == "CLEANUP") { // Restart downloads startDownloads(); }
__________________
irc.libera.chat #jDownloader web.libera.chat/#jDownloader |
#2948
|
|||
|
|||
I wanted to share my script, that will automatically add YouTube thumbnails to the corresponding video File if they are downloaded in the same package. If the thumbnails don't show up in the link crawler, then you have to enable them in the plugin first.
Code:
// Adds Youtube thumbnail to video (requires you to download the video and thumbnail in the same package) // Should work with pretty much anything else in the package and you can also use as many youtube videos as you like. // Trigger Required: "Package Finished" // // This script uses ffmpeg (ffmpeg.org) // If not already done set the path to your ffmpeg file under advanced settings(ffmpegSetup: binary path) // // Aditional Info: // You can select which types you want the linkcrawler to grab under the youtube pluging. For example mp4 + jpg // // Detailed description: // Looks for all mp4 files in a package; compares the ContainerURL with all images in the package (img/png); // if the matching thumbnail is found copies the video and adds the thumbnail to the copy; // deletes the video without thumbnail and the thumbnail itself; renames the copied video to the original name // // Author @DamonDragon // // More event scripts can be found here: https://board.jdownloader.org/showpost.php?p=453474 // // For debugging you can use: // writeFile(JD_HOME + "/log_script_youtube_thumbnail_adder.txt", variable + "random text\n", true /*bool append*/ ); // var links = package.getDownloadLinks(); var ffmpeg = callAPI("config", "get", "org.jdownloader.controlling.ffmpeg.FFmpegSetup", null, "binarypath"); // delete file without recursion function deleteOriginalFile(filePath) { deleteFile(filePath, false); } // check all package links for youtube videos (MP4-Files) for (var i = 0; i < links.length; i++) { var videoLink = links[i]; var videoFile = videoLink.getDownloadPath(); // only looks for mp4 files from youtube.com // I only tried this script with mp4 files and I'm not sure if ffmpeg works for FLV or MKV, // but if it works or you want to try, you can repace "mp4" with "(mp4|flv|mkv)" for example. if (videoLink.getHost() == "youtube.com" && /\.mp4$/i.test(videoFile)) { var videoURL = videoLink.getContainerURL(); var imageFile = null; var thumbnail = false; // search for fitting thumbnail that has the same download url as the MP4-File for (var j = 0; j < links.length; j++) { var imageLink = links[j]; var tempImageFile = imageLink.getDownloadPath(); var imageURL = imageLink.getContainerURL(); // only looks for jpg and png files that are from youtube.com // compares the imageURL with the videoURL. If they match then this should be the thumbnail for the video. if (imageLink.getHost() == "youtube.com" && /\.(jpg|png)$/i.test(tempImageFile) && imageURL == videoURL) { thumbnail = true; imageFile = tempImageFile; // The additional if is needed in case you have multiple videos/images with // the same name and used "rename". This might execute the break on the first found thumbnail, // that had the same name instead of the renamed one. if (getPath(imageFile).exists() && getPath(videoFile).exists()) { break; } } } // copy video and add thumbnail if there is a matching thumbnail // checks if the image and the video are localy saved and not only in the package // (prevents the video file from getting deleted if the image isn't locally saved) if (thumbnail && getPath(videoFile).exists() && getPath(imageFile).exists()) { // Get original file extension var originalExtension = videoFile.substring(videoFile.lastIndexOf('.')); // temp name for the new video that has the thumbnail (will be renamed later) var finalVideo = videoFile + ".tmp." + originalExtension; // creates a new video (finalVideo) that contains the thumbnail callSync(ffmpeg, "-i", videoFile, "-i", imageFile, "-map", "0", "-map", "1", "-c", "copy", "-c:v:1", "png", "-disposition:v:1", "attached_pic", finalVideo); // save orginal filepath (name) var videoPath = getPath(videoFile); // delete thumbnail and unedited video (video without thumbnail) deleteOriginalFile(videoFile); deleteOriginalFile(imageFile); // rename to orginal filepath (name) getPath(finalVideo).renameTo(videoPath); } } } Last edited by DamonDragon; 06.06.2024 at 15:22. |
#2949
|
||||
|
||||
@DamonDragon: nice one! we will check if its easy doable to integrate this step with ffmpeg directly into plugin/download of video
__________________
JD-Dev & Server-Admin |
#2950
|
||||
|
||||
Script Request about file info in comments
@mpgai
New Script Request Change of Plan: Just one easy script-job (converting seconds.msec to hh:mm:ss.mesec) remaining which I will post in a new request. Here you can find my modified and simpler request. Please disregard below request/specifications @Jiaz wrote here, that it es possible to write additional file info, such as duration, resolution,… to the comment column in JD. So, I kindly ask you for your help: You can request the file info, I want to see as a comment, as follows: Working Example: (Replace XX with tt) Request: Code:
curl -X POST -H "Content-type: application/json" -d "{"id":"ea87de7828fed"}" hXXps://keep2share.cc/api/v2/getFileStatus Code:
{"status":"success","code":200,"name":"alla-2018-540p_full_mp4.mp4","is_available":true,"is_folder":false,"size":127429257,"access":"public","isAvailableForFree":true,"video_info":{"duration":718.12,"width":720,"height":540,"format":"MPEG-4"}} What I would like to see as comment is this: true TAB false TAB 127429257 TAB public TAB true TAB 718.12 TAB 720 TAB 540 TAB MPEG4 If TAB-separation is not possible, ";" could be used instaed. An even better output would be, if duration could be converted from 718.12 to 0:11:58,120 I would really appreciate your help here! Thanks for any efforts taken in advance!!! Last edited by StefanM; 18.06.2024 at 11:50. |
#2951
|
||||
|
||||
@StefanM
This should be possible via simple Packagizer rule though I'm not sure about the tab symbol but you should try that first, see: https://board.jdownloader.org/showth...437#post535437
__________________
JD Supporter, Plugin Dev. & Community Manager
Erste Schritte & Tutorials || JDownloader 2 Setup Download |
#2952
|
||||
|
||||
Quote:
In LinkgrabberContext.menu.json it loks like this: Code:
{"PATTERNLINKS":"{url}\t{type}\t{name}\t{filesize_raw}\t{path}... |
#2953
|
||||
|
||||
Well then I do not see any problems to do this.
Also you do not need to set that information as a comment (except if you want to see it in GUI). You could just make a custom copy command which includes all of those properties, separated by tabs. Adding the information for each item as a comment is, strictly saying, just using more RAM.
__________________
JD Supporter, Plugin Dev. & Community Manager
Erste Schritte & Tutorials || JDownloader 2 Setup Download |
#2954
|
|||
|
|||
has anyone got an eventscripter script that works with apprise yet?
Ive had a search but was surprised there wasnt anything. Basically need to recreate this when a download has finished: curl -X POST -d '{"urls": "mailto://user:pass@gmail.com", "body":"test message"}' \ -H "Content-Type: application/json" \ **External links are only visible to Support Staff****External links are only visible to Support Staff** Thanks |
#2955
|
||||
|
||||
@hulleyrob: what problem do you have/encounter or where are you stuck?
__________________
JD-Dev & Server-Admin |
#2956
|
|||
|
|||
Not really sure where to start as I dont know javascript.
The problem I want to solve is when a download is finished I want to make a call to apprise which will hand the notification for the finished download. I thought there maybe something already to do this or that can mimic the curl post call above that I can use. This call just needs the mailto part of the json replaced with whatever notification service you wish to use and have set up in apprise. The "test message" would be replaced with the name of the download. If you know of anything that can get me started which can make such a post call from the eventscripter that would be great. Last edited by hulleyrob; 17.06.2024 at 23:56. |
#2957
|
||||
|
||||
@hulleyrob, see for example in this thread https://board.jdownloader.org/showpo...6&postcount=22
you can write/edit script and hit the test/run button to see if it works I will prepare dummy/example by tomorrow
__________________
JD-Dev & Server-Admin Last edited by Jiaz; 18.06.2024 at 00:03. |
#2958
|
|||
|
|||
Thanks is that a standard JavaScript method?
As it’s not clear where to put headers and where body goes as per the curl example. I’m really surprised nobody has got one for apprise already as everything seems to use it for notifications nowadays. If you can do an example tomorrow that would be great. |
#2959
|
||||
|
||||
@hulleyrob: I will try to create simply curl compatibilty to make it easier for others to use. right now it's not possible to set custom headers. I will work on this as well.
__________________
JD-Dev & Server-Admin |
#2960
|
|||
|
|||
Actually I had overcomplicated it which wasnt helping I could have sent everything inline.
This example pass the test event and send a message successfully: postPage('**External links are only visible to Support Staff**, "urls=synology://192.168.0.4:5000/APPRISE_SYNOLOGY_TOKEN_REMOVED&body=" + package.getName() + " finished."); This works fine apprise (running in docker) is getting the message and passing it on to Synology chat. Thanks for your help. |
Thread Tools | |
Display Modes | |
|
|