#1121
|
|||
|
|||
![]() Quote:
Quote:
You can use the regex to only match file name string. To check if file exists, you have to use 'flilePath.exists()' method. Get the contents of the folder using 'filePath.getChildren()' method and filter them using your pattern. This will eliminate the need for file exists check, since it will return only the contents which exist on the disk. |
#1122
|
|||
|
|||
![]()
thanks master!
Is there a way to move selected file or package from Downloads back to LinkGrabber? Also would like to move finished files from the selected package to (original packageName + 'DONE') |
#1123
|
|||
|
|||
![]() Code:
//@mgpai //Packagizer Alt Filters // Trigger: Packagizer Hook var fn = link.getName(); var pn; if (!pn && /birds|elephant/.test(fn)) pn = "animals"; if (!pn && /bmw|honda|tesla/.test(fn)) pn = "cars"; if (!pn && /.*\.(pdf|epub|mobi)$/.test(fn)) pn = "ebooks"; if (pn) link.setPackageName(pn); When you brought up there is a possibility to exit out once a matched found. I thought a script that catches Packagizer rules return true then exit out. So, what is really happening behind the scene? Are all normal rules in Packagizer get executed first then finish up with this script? I'm not complaining, just trying to understand (: |
#1124
|
|||
|
|||
![]() Quote:
Quote:
It is better to rename the package after it is finished. Just use the rename method and append your custom string to it. Quote:
Code:
if(state == "BEFORE"){ //run this code before packagizer rules are applied } if(state = "AFTER"){ //run this code before packagizer rules are applied } Without the condition, the script will be executed twice. Once before packagizer rules are applied and once more after that. While the script can do a lot of things which the packagizer extension cannot, I use both. For simple tasks I use the extension and for features missing from the extension, I use a script. |
#1125
|
|||
|
|||
![]()
thanks again for the insight.
do you have the reference of all the jd functions glossary or is it documented? I looked up on wiki but couldn't find it. |
#1126
|
|||
|
|||
![]()
Click 'Show/Hide Help' in the script editor window main menu to list all the available methods. In some cases some context specific methods will be listed only after you have set/selected the event trigger for the script.
|
#1127
|
|||
|
|||
![]()
just learned I do have a blind spot!
|
#1128
|
|||
|
|||
![]() Quote:
Code:
var getDlSel = lgSelection.getDownloadLink.getName(); alert(getDlSel); //return error: ReferenceError: 'lgSelection' is not defined |
#1129
|
|||
|
|||
![]() Code:
// Linkgrabber context menu button pressed demo if (name == "LG context menu demo") { var myLinkgrabberSelection = lgSelection; var myCrawledLink = myLinkgrabberSelection.getContextLink(); if (myCrawledLink) alert(myCrawledLink.getName()); } |
#1130
|
|||
|
|||
![]() Code:
var myCrawledLink = myLinkgrabberSelection.getContextLink(); tried w/o luck: myCrawledLink.getName().execCommand("copy") ref: hxxps://www.w3schools.com/howto/howto_js_copy_clipboard.asp |
#1131
|
|||
|
|||
![]() Quote:
You can customize your context menu and add/configure "Copy Information" item and format the variables which you want to be copied to the clipboard when you click it. |
#1132
|
|||
|
|||
![]()
oh ok, that's too bad.
as far as debugging goes. alert() is the only other method other than writeFile() |
#1133
|
|||
|
|||
![]() Quote:
Code:
log(myObject[]);/*Log to stderr and to JDownloader Log Files*/ In lieu of console in eventscripter, you can load the log file or your custom file in notepad++ and enable its auto-update/scroll to end on update feature. |
#1134
|
|||
|
|||
![]()
thanks.
Why 'i' is global var in this scenario? Shouldn't 'i' is local in _getLists()? notice 'i' got overwrites each time it returns from func being called. Code:
//init var pkgs = getAllFilePackages(); var count = 0; for (i = 0; i < pkgs.length; i++) { var pkg = pkgs[i]; _getLists(pkg); count +=1; if (count > 5) break; } alert('pkg count:'+i+'/'+pkgs.length); //THIS i increment got reassigned to the i in _getLists() //function function _getLists(pkg) { var lists = pkg.getDownloadLinks(); var kount = 0; for (i = 0; i < lists.length; i++) { var list = lists[i]; kount +=1; if (kount > 2) break; } alert('list count:'+i+'/'+lists.length); } Last edited by zreenmkr; 29.02.2020 at 21:46. |
#1135
|
|||
|
|||
![]() Quote:
Nested functions have access to 'local' variables declared in their outer scope. So, in nested functions, it is better to use variable names which have not already been used in the outer scope. |
#1136
|
|||
|
|||
![]() Quote:
|
#1137
|
|||
|
|||
![]()
Is it a good common practice to use non-constant global var between functions instead of passing it?
|
#1138
|
|||
|
|||
![]() Quote:
|
#1139
|
|||
|
|||
![]()
Once you select a trigger, properties returned by that trigger will be listed at the bottom of the page and their corresponding methods will be listed separately further up on the same page.
|
#1140
|
|||
|
|||
![]()
got it.
Code:
// Get Selected packageName // Trigger : "DownloadList Contextmenu Button Pressed" if (name == "Get Selected packageName") { try { var selected = dlSelection.getContextLink(); var package = selected.getPackage(); if (selected) alert(selectedPackage + ': ' + package ); } catch (e) { alert('error: Right-Click on <fileName> & try again.'); } } Only able to get package name by right click on file name but can't seem to find a function that get package name on selected package. |
#1141
|
|||
|
|||
![]() Quote:
Code:
// Get Selected packageName // Trigger : "DownloadList Contextmenu Button Pressed" if (name == "Get Selected packageName") { try { var myDownloadlistSelection = dlSelection; var selectionIsPackage = myDownloadlistSelection.isPackageContext(); if (selectionIsPackage) { var myFilePackage = myDownloadlistSelection.getContextPackage(); var myFilePackageName = myFilePackage.getName(); alert("Selected Package: " + myFilePackageName); } else { alert('Select a package'); } } catch (e) { alert(e); } } |
#1142
|
|||
|
|||
![]()
Thanks,
// Objective is to search for duplicate within jd. Not the same as search for existed file on harddrive. // I think Trigger is: "DownloadList Buttombar Button Pressed" At the bottom left of both Downloads/LinkGrabber tabs, you able to search for (Package Name|File Name|Comment|Hoster) With all prior knowlege we know how to get file name via trigger 'DownloadList Contextmenu Button Pressed' How to set that File Name in search Inputbox? I found a few function that able to set text such as setText(), setName(), setComment() ect... but nothing similar to setSearch. |
#1143
|
|||
|
|||
![]() Quote:
Alternatively, you can detect duplicates and export them to a file or perform other actions, such as comment/disable/remove/skip those links. |
#1144
|
|||
|
|||
![]() Quote:
If there is a way to get classname of edit/input box would be nice. |
#1145
|
|||
|
|||
![]() Code:
//works as expected var url = 'https://board.jdownloader.org/'; openURL(url); Is there a work around to open browser history? I think there is a url check for 'http' start of string which is why it failed. Code:
//Not working var url = 'chrome://history/'; openURL(url); |
#1146
|
|||
|
|||
![]() Quote:
Code:
var myBrowser = "D:\\Firefox\\Firefox.exe"; var myURL = "about:downloads"; callSync(myBrowser,myURL); |
#1147
|
|||
|
|||
![]() Quote:
Code:
getPage(url) Will this method work for any site or only on yt? Code:
// Get link property String.prototype.prop = function() { return link.getProperty(this); }; Code:
Video: youtube + "watch?v=" + "YT_ID".prop() + "\">" + "YT_TITLE".prop() |
#1148
|
|||
|
|||
![]()
Hello , I read almost the whole topic (and it took me a lifetime);
I've already copied and tried some scripts , but I didn't find what I was looking for (there was something approaching but I have no idea how I could modify it). So I ask those who know the topic for help , is it possible to have a script that changes the name of the "packages" obtained with "linkcrawler" / plugin? I try to explain myself better: (es) I copy link of site "X" , "Y" ... etc. --> JD do is work , grab the file and pack them (ok) --> in the Linkgrabbe tab show something like: Quote:
now with [ Trigger: Toolbar Button Pressed] , I would need a script that checks the package names and replaces or modifies some of them based on values specified in the script, example: a) if you find "Vol " replace with "V0" b) if you find "~" replace with "-" c) if you find "Darkwing duck & co" replace with "nada" .... etc "clean up" replace strange characters like "❤,:,/,\,*,%,^,",°" with " " therefore after starting the script the titles of the example should become: Quote:
|
#1149
|
|||
|
|||
![]() Quote:
Quote:
Then <PackageName> $1$-V0$3$4 don't forget [x]regex checkbox on the far right |
#1150
|
|||
|
|||
![]()
thanks but I don't think Packagizer rules is helpful for what I want to do:
1)I don't always have to replace / modify the packagename [only when I need it, for this I would have started the script as <Toolbar Button Pressed>] 2) Quote:
, if I enter $1$-V0$3$4 and run the test the name of the package becomes: $1$-V0$3$4 |
#1151
|
|||
|
|||
![]() Quote:
|
#1152
|
|||
|
|||
![]() Quote:
![]() Issue1 : //replace() - Trigger selection limitation Issue2 : //setPackageName() - Trigger selection limitation see comments in the code OPTION 1 Code:
// Rename all Packages in LinkGrabber // Trigger : "Toolbar Button Pressed" if (name == "Rename All Packages in LinkGrabber") { try { var pkgs = getAllCrawledPackages(); for (var i = 0; i < pkgs.length; i++) { var packageName = pkgs[i]; var renamedPkg = _removeSpecialChars(packageName); //replace() limitation on trigger selection/Is there a workaround or other method available? alert('packageName RAW #' + i + ': ' + packageName); //alert('packageName RENAMED #' + i + ': '+renamedPkg); //need to resolve issue above about replace() //???.setPackageName(packageName) if (i > 5) break; //for testing purposes } } catch (e) { alert(e); } } OPTION 2 Code:
// Rename a single selected package - via Right Click // Trigger : "LinkGrabber Contextmenu Button Pressed" //if (name == "Rename Package Selection") { try { var selectionIsPackage = lgSelection.isPackageContext(); if (selectionIsPackage) { var filePackage = lgSelection.getContextPackage(); var packageName = filePackage.getName(); var packageName = _removeSpecialChars(packageName); alert("Selected Package: " + packageName); if (packageName) selectionIsPackage.setPackageName(packageName); //setPackageName() limitation on trigger selection/Is there a workaround or other method available? } } catch (e) { alert(e); } } Code:
//-------------------------------------------------------- //Find and Replace Package Name //-------------------------------------------------------- function _removeSpecialChars(packageName) { //var regex = /(\❤|\:|\/|\\|\*|\%|\^|\°|\!)/ig; //var packageName = packageName.replace(regex, ''); var regex = /(~)/ig; var packageName = packageName.replace(regex, '-'); var regex = /(-vol\s)(\d{1}-)/ig; //find '-Vol 1' var packageName = packageName.replace(regex, '-V0$2-'); var regex = /(-vol\s)(\d{2,3}-)/ig; //find '-Vol 00' to '-Vol 999' var packageName = packageName.replace(regex, '-V$2-'); return packageName; } Last edited by zreenmkr; 06.03.2020 at 01:24. |
#1153
|
|||
|
|||
![]() Quote:
Code:
//var myObject = myDownloadLink.getProperty(myString); var myChannelName = myDownloadLink.getProperty("YT_CHANNEL"); All properties available for a particular link can be accessed using this method. Some plugins will also store media tags like 'artist', 'album' etc. as 'property'. Check plugin source code for the list of properties stored by it. Quote:
|
#1154
|
|||
|
|||
![]() Quote:
Script 1: Code:
var packageName = pkgs[i]; // This is not an packagename string (mycCrawledpackage.getName()). It is a package object (myCrawledPackage = pkgs[i]). var renamedPkg = _removeSpecialChars(packageName); // You are trying to rename a package object (pkgs[i]) and not a a package name string (pgks[i].getName()). ???.setPackageName(packageName) // setPackageName(packageName) is a packagizer link method (myPackagizerLink.setPackageName(myPackageName)). To rename crawled package use myCrawledPackage.setName(packageName) method. Script 2: Code:
selectionIsPackage.setPackageName(packageName); // You are trying to use a packagizer link object method, on a selection object. Use crawled package object method, with crawled package object. (filePackage.setName(packageName)). Note: Variable name 'filePackage' usually means download list package. |
#1155
|
|||
|
|||
![]() Quote:
Code:
// Clean-up packagenames // Trigger: Toolbar Button Pressed if (name == "Clean-up packagenames") { getAllCrawledPackages().forEach(function(package) { var curName = package.getName(); var newName = curName; var replace = function(find, replace) { newName = newName.replace(find, replace); } replace("-Vol ", "-V0"); replace(/[~]/g, "-"); replace("Darkwing duck & co", "nada"); replace(/[❤:/\*%^°"]/g, " "); if (curName != newName) package.setName(newName); }) } |
#1156
|
|||
|
|||
![]() Quote:
Working scripts, thanks @mgpai Option 1 Code:
// ---===---===---===---===---===---===---===---===--- // Rename all Packages in LinkGrabber // Trigger : "Toolbar Button Pressed" // ---===---===---===---===---===---===---===---===--- if (name == "Rename All Packages") { try { var crawledPackages = getAllCrawledPackages(); for (var i = 0; i < crawledPackages.length; i++) { var crawledPackage = crawledPackages[i]; var packageName = crawledPackage.getName(); var renamedPackageName = _removeSpecialChars(packageName); alert('packageName RAW #' + i + ': ' + packageName + '\r\n' + 'packageName RENAMED #' + i + ': ' + renamedPackageName); if (packageName) crawledPackage.setName(renamedPackageName); //if (i > 5) break; //for testing purposes } } catch (e) { alert(e); } } Option 2 Code:
// ---===---===---===---===---===---===---===---===--- // Rename a single selected package - via Right Click // Trigger : "LinkGrabber Contextmenu Button Pressed" // ---===---===---===---===---===---===---===---===--- if (name == "Rename a Selected Package") { try { var selectionIsPackage = lgSelection.isPackageContext(); if (selectionIsPackage) { var selectionPackage = lgSelection.getContextPackage(); var packageName = selectionPackage.getName(); var renamedPackageName = _removeSpecialChars(packageName); alert('packageName RAW #' + i + ': ' + packageName + '\r\n' + 'packageName RENAMED #' + i + ': ' + renamedPackageName); if (packageName) selectionPackage.setName(renamedPackageName); } else { alert('select a crawledPackageName and try again.') } } catch (e) { alert(e); } } |
#1157
|
|||
|
|||
![]() Quote:
Code:
var myChannelName = myDownloadLink.getProperty("YT_CHANNEL"); |
#1158
|
||||
|
||||
![]()
most sites have dedicated plugins, so you need to find them. The easiest way is to download the source code (check the getting started guide). OR use logs to see which plugin then find the source for that specific plugin. Not all plugins have properties. Some plugins have properties, but not saved in that manner.
__________________
raztoki @ jDownloader reporter/developer http://svn.jdownloader.org/users/170 Don't fight the system, use it to your advantage. :] |
#1159
|
||||
|
||||
![]()
Here a link to the getting started guide which raztoki has mentioned in his post:
https://jdownloader.org/knowledge/wi...nt/get-started -psp-
__________________
JD Supporter, Plugin Dev. & Community Manager
Erste Schritte & Tutorials || JDownloader 2 Setup Download |
#1160
|
|||
|
|||
![]()
Is there a script which can add a comment to all the downloads / links being marked / selected (insead of having to do it for each single link separately?).
I asked here for such: https://board.jdownloader.org/showth...123#post459123 |
![]() |
Thread Tools | |
Display Modes | |
|
|