JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1141  
Old 02.03.2020, 08:25
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,508
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,508
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,508
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,508
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,508
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,508
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,653
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,743
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: 640
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 10:42.
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.