JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #1121  
Old 28.02.2020, 13:24
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by zreenmkr View Post
a) Is there a function to get filename or link on selected file in Downloads/LinkGrabber tab
Use context menu button triggers and their respective (dlSelection/lgSelection) methods

Quote:
b) and function that return all subfolders and a function return files in dir
Use 'filePath' methods.

Quote:
Originally Posted by zreenmkr View Post
Is it possible to check file exist via regex?
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.
Reply With Quote
  #1122  
Old 28.02.2020, 13:44
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

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')
Reply With Quote
  #1123  
Old 28.02.2020, 14:06
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

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 (:
Reply With Quote
  #1124  
Old 28.02.2020, 14:35
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by zreenmkr View Post
Is there a way to move selected file or package from Downloads back to LinkGrabber?
Cannot move as such. You can use a script to add them again to linkgrabber (will trigger crawling/linkchecking etc, just like when new links are added) and then delete them from download list using the same script. Can also break mirror detection and extraction, so you have to check the status of links before moving them.

Quote:
Also would like to move finished files from the selected package to (original packageName + 'DONE')
While possible, moving can break mirror detection, extraction etc. Also, mirrors which are marked as 'finished' do not trigger "download stopped" event, and hence will have to be moved manually.

It is better to rename the package after it is finished. Just use the rename method and append your custom string to it.

Quote:
Are all normal rules in Packagizer get executed first then finish up with this script?
Packagizer hook has a 'state' property, which will allow it run before or after packagizer rules are applied.

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.
Reply With Quote
  #1125  
Old 28.02.2020, 18:00
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

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.
Reply With Quote
  #1126  
Old 28.02.2020, 18:24
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by zreenmkr View Post
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.
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.
Reply With Quote
  #1127  
Old 29.02.2020, 00:27
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Talking

just learned I do have a blind spot!
Reply With Quote
  #1128  
Old 29.02.2020, 07:31
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
(dlSelection/lgSelection) methods
Can't get name of the Select File in LinkGrabber.

Code:
var getDlSel = lgSelection.getDownloadLink.getName();
alert(getDlSel);

//return error: ReferenceError: 'lgSelection' is not defined
Reply With Quote
  #1129  
Old 29.02.2020, 07:52
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by zreenmkr View Post
Can't get name of the Select File in LinkGrabber
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());
}
Reply With Quote
  #1130  
Old 29.02.2020, 08:27
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Code:
var myCrawledLink = myLinkgrabberSelection.getContextLink();
cool, how to send myCrawledLink.getName() to clipboard?

tried w/o luck: myCrawledLink.getName().execCommand("copy")

ref: hxxps://www.w3schools.com/howto/howto_js_copy_clipboard.asp
Reply With Quote
  #1131  
Old 29.02.2020, 08:41
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by zreenmkr View Post
how to send myCrawledLink.getName() to clipboard?

tried w/o luck: myCrawledLink.getName().execCommand("copy")
The 'execCommand' is a browser environment method. There are no eventscripter enviroment methods which can be used to copy content to the clipboard.

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.
Reply With Quote
  #1132  
Old 29.02.2020, 08:52
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

oh ok, that's too bad.

as far as debugging goes. alert() is the only other method other than writeFile()
Reply With Quote
  #1133  
Old 29.02.2020, 09:12
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by zreenmkr View Post
as far as debugging goes. alert() is the only other method other than writeFile()
You can also use the 'log' method. Unlike 'writeFile' you do not have to specify the output file. It will be logged to the default file in 'JD\logs' folder.
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.
Reply With Quote
  #1134  
Old 29.02.2020, 16:14
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

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 22:46.
Reply With Quote
  #1135  
Old 01.03.2020, 07:01
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by zreenmkr View Post
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.
Assigning a value to a variable which has not been declared will automatically make it 'global'. (Use "var i = 0" instead of "i = 0").

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.
Reply With Quote
  #1136  
Old 01.03.2020, 11:04
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
Assigning a value to a variable which has not been declared will automatically make it 'global'
That explained it. The only other thing i did try was declaring var in outer scope ONLY which also failed.
Reply With Quote
  #1137  
Old 01.03.2020, 11:07
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Is it a good common practice to use non-constant global var between functions instead of passing it?
Reply With Quote
  #1138  
Old 02.03.2020, 05:08
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
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.
I'm unable to find reference in help for dlSelection/lgSelection nor getContextLink() mentioned. name, link, package and among other are also documented.
Reply With Quote
  #1139  
Old 02.03.2020, 06:21
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by zreenmkr View Post
I'm unable to find reference in help for dlSelection/lgSelection nor getContextLink() mentioned
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.
Reply With Quote
  #1140  
Old 02.03.2020, 06:54
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

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.
Reply With Quote
  #1141  
Old 02.03.2020, 08:25
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by zreenmkr View Post
... can't seem to find a function that get package name on selected package.
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);
    }
}
Reply With Quote
  #1142  
Old 03.03.2020, 16:37
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

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.
Reply With Quote
  #1143  
Old 04.03.2020, 12:15
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by zreenmkr View Post
... Objective is to search for duplicate within jd ...
... How to set that File Name in search Inputbox? ...
There aren't any methods which can be used to set search terms in the toolbar.

Alternatively, you can detect duplicates and export them to a file or perform other actions, such as comment/disable/remove/skip those links.
Reply With Quote
  #1144  
Old 04.03.2020, 15:37
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
Alternatively, you can detect duplicates and export them to a file or perform other actions, such as comment/disable/remove/skip those links.
I've seen one of your scripts with function described but it's just too slow.

If there is a way to get classname of edit/input box would be nice.
Reply With Quote
  #1145  
Old 04.03.2020, 15:49
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

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);
Reply With Quote
  #1146  
Old 05.03.2020, 06:44
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by zreenmkr View Post
[CODE]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.
AFAIK Chrome does not permit opening internal urls from CLI. On the other hand FF does. Can use callSync/callAsync to open non-standard urls from script when the external program allows it.

Code:
var myBrowser = "D:\\Firefox\\Firefox.exe";
var myURL = "about:downloads";
callSync(myBrowser,myURL);
Reply With Quote
  #1147  
Old 05.03.2020, 11:05
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
AFAIK Chrome does not permit opening internal urls from CLI.
Thanks for the alternative. Too bad everything I do is in chrome.


Code:
getPage(url)
I'm planning on getting some properties from html source. Just the usual stuffs such as user/channel/date/views ect... I'm thinking of using regexp but I remember this youtube script on this thread. I don't understand any part of it.

Will this method work for any site or only on yt?

Code:
// Get link property
String.prototype.prop = function() {
    return link.getProperty(this);
};
How or what exactly getProperty(this) is looking for and how does it know what to look for? and what is 'this'?


Code:
Video: youtube + "watch?v=" + "YT_ID".prop() + "\">" + "YT_TITLE".prop()
I've looked into yt source page but didn't see 'YT_ID' or 'YT_TITLE' set as div id. Could you please elaborate?
Reply With Quote
  #1148  
Old 05.03.2020, 23:16
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

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:
-Shounin Yuusha wa Isekai wo Gyuujiru!-Vol 1-Ch 1
-Shounin Yuusha wa Isekai wo Gyuujiru!-Vol 1-Ch 2
-Shounin Yuusha wa Isekai wo Gyuujiru!-Vol 1-Ch 3
-Kenja no Mago-Ch 28 1
-Kenja no Mago-Ch 10 5
-Kenja no Mago-Vol 4-Ch 17 7
-[G-Wara] Under the Night Sky
-[Momoduki Suzu] Keeping My Junior All to Myself ❤ (Comic Kairakuten 2020-02)
-[mogg] Home Tutor ~Lesson 2 Siblings~ (Comic Kairakuten 2020-02)
each "package" / "folder" contains its files.

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:
-Shounin Yuusha wa Isekai wo Gyuujiru!-V01-Ch 1
-Shounin Yuusha wa Isekai wo Gyuujiru!-V01-Ch 2
-Shounin Yuusha wa Isekai wo Gyuujiru!-V01-Ch 3
-Kenja no Mago-Ch 28 1
-Kenja no Mago-Ch 10 5
-Kenja no Mago-V04-Ch 17 7
-[G-Wara] Under the Night Sky
-[Momoduki Suzu] Keeping My Junior All to Myself (Comic Kairakuten 2020-02)
-[mogg] Home Tutor -Lesson 2 Siblings- (Comic Kairakuten 2020-02)
note: the names of the individual files are as good as they are, what I have to change is just the name of the package
Reply With Quote
  #1149  
Old 06.03.2020, 00:47
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
...I would need a script that checks the package names and replaces or modifies some of them based on values ​​specified...
Generally a quick and easy way is use 'Packagizer' extension, add a few rules and you are set. It is as simple as Find and Replace with RegExp. Script is more flexible, I'll give it a try, brb.


Quote:
a) if you find "Vol " replace with "V0"

-Shounin Yuusha wa Isekai wo Gyuujiru!-V01-Ch 1
&
-Kenja no Mago-V04-Ch 17 7
If <Pacakage Name>(.*?)(-vol\s)(\d{1}-)(.*?)
Then <PackageName> $1$-V0$3$4
don't forget [x]regex checkbox on the far right
Reply With Quote
  #1150  
Old 06.03.2020, 01:34
BJN01 BJN01 is offline
JD Adviser
 
Join Date: Jan 2020
Posts: 113
Default

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:
Then <PackageName> $1$-V0$3$4
don't forget [x]regex checkbox on the far right
there is not [x]regex checkbox in the "then" options
, if I enter $1$-V0$3$4 and run the test the name of the package becomes: $1$-V0$3$4
Reply With Quote
  #1151  
Old 06.03.2020, 01:43
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
there is not [x]regex checkbox in the "then" options
regex check box is in the 'if' condition
Reply With Quote
  #1152  
Old 06.03.2020, 02:18
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
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>]
Need Input 2 Scripts below has Issues Explained HERE - Due to that can't get these scripts bellow to work.

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 02:24.
Reply With Quote
  #1153  
Old 06.03.2020, 07:40
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by zreenmkr View Post
How or what exactly getProperty(this) is looking for and how does it know what to look for? and what is 'this'?
If JD has stored strings from the source page as 'property' it can be accessed using the built-in methods or by using your own prototype/function. 'this' would the name of that 'property' in that context.

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:
I've looked into yt source page but didn't see 'YT_ID' or 'YT_TITLE' set as div id. Could you please elaborate?
It is not a part of the source page. It is a string containing the 'property' variables which is used to create a new html element for use in the file which will be generated/exported by the script.
Reply With Quote
  #1154  
Old 06.03.2020, 11:22
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by zreenmkr View Post
Need Input 2 Scripts below has Issues Explained HERE - Due to that can't get these scripts bellow to work.
What kind of limitations exactly? You can only use methods available for the specific object and use the correct method for the object type.

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.
Reply With Quote
  #1155  
Old 06.03.2020, 11:59
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,533
Default

Quote:
Originally Posted by BJN01 View Post
... 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 ...
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);
    })
}
Reply With Quote
  #1156  
Old 06.03.2020, 12:27
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
What kind of limitations exactly? You can only use methods available for the specific object and use the correct method for the object type
Now that you've explained, I kind of having an idea of what is going on. I don't have any background on objects nor object type.


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);
    }
}
Reply With Quote
  #1157  
Old 06.03.2020, 12:44
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
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.
Code:
var myChannelName = myDownloadLink.getProperty("YT_CHANNEL");
Where/what plugin to look into for all available properties for specific link? How do you know 'YT_CHANNEL' property is there?
Reply With Quote
  #1158  
Old 06.03.2020, 14:39
raztoki's Avatar
raztoki raztoki is offline
English Supporter
 
Join Date: Apr 2010
Location: Australia
Posts: 17,611
Default

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. :]
Reply With Quote
  #1159  
Old 06.03.2020, 14:41
pspzockerscene's Avatar
pspzockerscene pspzockerscene is offline
Community Manager
 
Join Date: Mar 2009
Location: Deutschland
Posts: 70,922
Default

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
Spoiler:

A users' JD crashes and the first thing to ask is:
Quote:
Originally Posted by Jiaz View Post
Do you have Nero installed?
Reply With Quote
  #1160  
Old 06.03.2020, 14:55
Dockel Dockel is offline
JD Legend
 
Join Date: Feb 2020
Posts: 664
Default Add a comment to all the downloads / links being marked / selected?

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
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT +2. The time now is 21:03.
Provided By AppWork GmbH | Privacy | Imprint
Parts of the Design are used from Kirsch designed by Andrew & Austin
Powered by vBulletin® Version 3.8.10 Beta 1
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.