JDownloader Community - Appwork GmbH
 

Reply
 
Thread Tools Display Modes
  #1181  
Old 07.03.2020, 10:00
BJN01 BJN01 is offline
Mega Loader
 
Join Date: Jan 2020
Posts: 60
Default

Quote:
Originally Posted by zreenmkr View Post
Am assuming you've created 'EventScripter Trigger' button. You need to give that each button a unique name and it is case sensitive.

1st Button
Code:
if (name == "My Button1 Name") {
//if button you rename from 'EventScripter Trigger' to '"My Button1 Name'. When this button is pressed then only this 1st codes in this body will be executed
}
2nd Button
Code:
if (name == "My Button2 Name") {
//if button you rename from 'EventScripter Trigger' to '"My Button2 Name'. When this button is pressed then only this 2nd codes in this body will be executed
}
thank you ,
I had changed the names even before but I noticed that I had not used what I indicated inside the script (I used the name of the script).
fixed names are now working properly
Reply With Quote
  #1182  
Old 07.03.2020, 10:17
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,142
Default

Quote:
Originally Posted by AlphaSlayer View Post
... am I doing the download location wrong? It doesn't seem to send it to that folder and i've tried with the slashes both wasy /, \. ... "destinationFolder": "C:\Users\Admin\Desktop\New folder\<jd:packagename>"
You have to use either "\\" or "/" as path separators.

Try:

Code:
"C:\\Users\\Admin\\Desktop\\New folder\\<jd:packagename>"

OR

"C:/Users/Admin/Desktop/New folder/<jd:packagename>"
Reply With Quote
  #1183  
Old 07.03.2020, 10:20
BJN01 BJN01 is offline
Mega Loader
 
Join Date: Jan 2020
Posts: 60
Default

in the topic I found this script that saves the list of files written in a txt:

Code:
/// Simple history
// Trigger Required : A Download Stopped
//
// Default folder: "<jdownloader>\auto\history" (e.g "c:\jdownloader\auto\history")
// Default file name: "<current date>.txt" (e.g. "Oct 07 2016.txt")

if (link.isFinished()) {
    var a /*date*/ = new Date().toString().substring(4, 16);
    var b /*history folder*/ = JD_HOME + "/auto/history/";
    var c /*history file Name */ = a + ".txt";
    var d /*download url*/ = link.getContentURL();
    var e /*download file name*/ = link.getName();

    if (!getPath(b).exists()) getPath(b).mkdirs();
    writeFile(b + c, [d, e].join(",") + "\r\n", true);
}
when the download is complete "add" the name of the file written to a txt (OK)


can you add a part where it creates a txt with the name of the packages written?
Reply With Quote
  #1184  
Old 07.03.2020, 10:52
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,142
Default

Quote:
Originally Posted by BJN01 View Post
can you add a part where it creates a txt with the name of the packages written?
Code:
// Simple history
// Trigger Required : A Download Stopped

if (link.isFinished()) {
    var folder = getPath(JD_HOME + "/auto/history/");
    var date = new Date().toString().substring(4, 16);
    var txtFile = getPath(folder + "/" + date + ".txt");

    var packageName = link.getPackage().getName();
    var fileName = link.getName();
    var url = link.getContentURL() || link.PluginURL();

    var data = [packageName, fileName, url];

    if (!folder.exists()) folder.mkdirs();
    writeFile(txtFile, data.join(", ") + "\r\n", true);
}
Reply With Quote
  #1185  
Old 07.03.2020, 13:11
BJN01 BJN01 is offline
Mega Loader
 
Join Date: Jan 2020
Posts: 60
Default

Thank you very much !!
I did some tests and managed to get what I wanted .

you have already written it somewhere, but what do you have to insert to change the type of date formatting?

that is, to switch from eg "Mar 07 2020.txt" to "2020 Mar 07.txt"
[mmm-dd-yyyy.txt] ------> [yyyy-mmm-dd.txt]?
Reply With Quote
  #1186  
Old 07.03.2020, 13:29
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,142
Default

Quote:
Originally Posted by BJN01 View Post
... what do you have to insert to ... switch from eg "Mar 07 2020.txt" to "2020 Mar 07.txt"
Code:
var date = Date().replace(/.{4}(.{6}).(.{4}).+/, "$2 $1");
Reply With Quote
  #1187  
Old 07.03.2020, 19:45
AlphaSlayer AlphaSlayer is offline
Wind Gust
 
Join Date: Sep 2019
Posts: 40
Default

Quote:
Originally Posted by mgpai View Post
You have to use either "\" or "/" as path separators.

Try:

Code:
"C:\\Users\\Admin\\Desktop\\New folder\\<jd:packagename>"

OR

"C:/Users/Admin/Desktop/New folder/<jd:packagename>"
Nope, neither one seemed to work it just saves it to the default download location witch is the downloads folder.
Reply With Quote
  #1188  
Old 08.03.2020, 00:53
AlphaSlayer AlphaSlayer is offline
Wind Gust
 
Join Date: Sep 2019
Posts: 40
Default

Quote:
Originally Posted by mgpai View Post
You have to use either "\" or "/" as path separators.

Try:

Code:
"C:\\Users\\Admin\\Desktop\\New folder\\<jd:packagename>"

OR

"C:/Users/Admin/Desktop/New folder/<jd:packagename>"
I figured out why it wouldn't change the download location. It was because I didn't have "overwritePackagizerRules": true. My next question is can I tell it to only download the video or audio file without changing the youtube plugin to only display the video or audio file? I ask because I have two links one where I only want the audio file and one where I only want the video file. I know I need to have two separate event scripts for each link.
Reply With Quote
  #1189  
Old 08.03.2020, 02:07
BJN01 BJN01 is offline
Mega Loader
 
Join Date: Jan 2020
Posts: 60
Default

@mgpai thanks, I modified what I had to and it works.



I don't know if it has already been asked but is it possible to insert a value through a warning window or similar?

the idea was:
- I press the button and a window appears where I can insert text
- Insert the test (word to delete)
- press "ok" (or enter after inserting text)
- and the script modifies the names of the packages (or files)


Code:
 
// Remove test/word from packagenames
// Trigger: Toolbar Button Pressed

if (name == "test") { 
    getAllCrawledPackages().forEach(function(package) {
            var curName = package.getName();
            var newName = curName;
            var replace = function(find, replace) {
                newName = newName.replace(find, replace);
            }
            
            wordremove = ("nada");  // <--- alert( [????] )  here the script should "ask me" to enter the variable it should use
            replace (wordremove, "");
         
            if (curName != newName) package.setName(newName);
        })
      }
Reply With Quote
  #1190  
Old 08.03.2020, 02:56
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Quote:
...I press the button and a window appears where I can insert text...
Currently there is no InputBox available. There is however a workaround just described here yesterday by using notepad.exe in Windows OS as an Input method.

See Post
Reply With Quote
  #1191  
Old 08.03.2020, 05:53
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,142
Default

Quote:
Originally Posted by AlphaSlayer View Post
can I tell it to only download the video or audio file without changing the youtube plugin to only display the video or audio file? I ask because I have two links one where I only want the audio file and one where I only want the video file.
Add an arbitrary string at the end of the url, for e.g #onlyAudio or #onlyVideo and create a linkgrabber filter rule to block other variants originating from that url.

Example Rule:
Code:
File Tye > is not > Audio File
Sourceurl(s) > contains > #onlyAudio

Quote:
I know I need to have two separate event scripts for each link.
You can use a single script. Just append different strings to the urls in the text file.
Reply With Quote
  #1192  
Old 08.03.2020, 06:16
AlphaSlayer AlphaSlayer is offline
Wind Gust
 
Join Date: Sep 2019
Posts: 40
Default

Quote:
Originally Posted by mgpai View Post
Add an arbitrary string at the end of the url, for e.g #onlyAudio or #onlyVideo and create a linkgrabber filter rule to block other variants originating from that url.

Example Rule:
Code:
File Tye > is not > Audio File
Sourceurl(s) > contains > #onlyAudio



You can use a single script. Just append different strings to the urls in the text file.
That rule is exactly what I needed! I think I might still have to use different scripts as I'm trying to save stuff from multiple channels and want a channel folder for each one currently right now it would just put everything into one folder. My folder layout is like this:
Youtube---Channel name---audio---audio files
---Channel name---videos---video files
etc.
I think I can create a package rule to set each one's download directory since each video package has the channel name included in it.
Reply With Quote
  #1193  
Old 08.03.2020, 08:31
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

Experimenting with api - have no clues what am doing. Assuming packagizer is switched off.

I have a bunch of links but only want to grab the favorite hosters. Unsuccessful start out code below, somehow it grabs all hosters with rar|zip plus more such as js|png|gif which I don't want. Would also like to set packageName and setName as Comment. doable? Thanks


Code:
// Selective Hosts Link Grabber
// Trigger: A new link has been added

String.prototype.prop = function() {
    return link.getProperty(this);
};

var downloadable = /(filefox.cc|rapidgator.net|uploaded.net)/.test(link.getHost()) && (/\.(rar|zip)$/).test(link.getName());

//alert('downloadable: ' + downloadable + ' - ' + link.getHost());

if (downloadable) {

    var name = link.getName();
    var url = link.getContentUrl();

    callAPI("linkgrabberv2", "addLinks", {
        "links": url,
        "autostart": false,
        "destinationFolder": "d:\\_downloads",
   ??  "packageName": "_fav_hosters",
   ??  "comment": name
    });
}

Last edited by zreenmkr; 08.03.2020 at 08:33.
Reply With Quote
  #1194  
Old 08.03.2020, 09:46
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,142
Default

Quote:
Originally Posted by BJN01 View Post
... is it possible to insert a value through a warning window or similar?
User the search and replace feature in GUI. (can also use 'regex'):
Code:
Select Links > Right-click > Properties > Rename
Reply With Quote
  #1195  
Old 08.03.2020, 09:54
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,142
Default

Quote:
Originally Posted by zreenmkr View Post
Experimenting with api ... I have a bunch of links but only want to grab the favorite hosters. ... somehow it grabs all hosters with rar|zip plus more such as js|png|gif which I don't want. Would also like to set packageName and setName as Comment
The 'addLink' API method is used only to add new links to JD, you can for example query a list of links from text tiles and add them using 'interval' trigger. Link object methods will not be available, since they will be created only after JD has processed the 'addLinkQuery'.

The 'A new link has been added' trigger returns the 'packagizer link' and is suitable to perform task similar to the packagizer extension (you will be able to set the 'download folder', 'package name', comment etc.) on the new link which has been added, but cannot filter/block any links at this stage. You will need to create linkgrabber filter rules to prevent the links from being added to JD.

While you can use 'addLink' API method with this trigger to add new links, it wil be treated as a entirely different task (which has no relation whatsoever with the 'new link' returned by that trigger).
Reply With Quote
  #1196  
Old 10.03.2020, 03:15
zreenmkr zreenmkr is offline
JD Addict
 
Join Date: Feb 2020
Posts: 174
Default

thanks.



Want to get some text from the site and append it to the fileName. Could you give an example of get html tag either via javascript getElementById() or parsing source code via regex or the best way.

I could think of two possibilities but don't know how to go about it.

Code:
//couldn't get it work reliablely

//with this full page about 140kb, it take a longtime to parse
//and it returns the surround tags as well or sometimes nothing at all
//htmlSource = getPage(url)

//with given short test segment then it works somewhat
    var htmlSource = '<p>start</p><div class="main"><p>p1</p><p>p2</p><p style=text-align:center><strong>My Text To Get</strong>item1<br />item2<br />item3<br /></p></div><p>End</p>'
    regex = /.*?<div class="main">.*?<p style=text-align:center><strong>(.*?)<\/strong>.*?<\/div>.*?/;
    var result = htmlSource.replace(regex, '$1');
    alert(result);


//have no ideas how this work, could it be used with getElementById() or what can you do with this? How about focus and click on a link?
var browserObject =  getBrowser();


Problem with script editor or is it just me: when you first open up the editor, it trying to auto format the script but it takes several seconds to do so. It'll take longer if script is long. The issue is because of that, any text i just typed before it finished up with auto format is lost. normal?
Reply With Quote
  #1197  
Old 10.03.2020, 04:48
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,142
Default

Quote:
Originally Posted by zreenmkr View Post
... example of get html tag either via javascript getElementById() or parsing source code via regex or the best way.
getPage() is a wrapper, so will be similar to getBrowser.getPage(myUrl). Cannot use browser object method (e.g. getElementById()), so have to parse html.

Code:
var br = getBrowser();
var myUrl = "https://jdownloader.org/download/index";
var myHtml = br.getPage(myUrl);
var re = /href=\"(http[^"]+)\"/g;
var result = myHtml.match(re);

alert(result);

Quote:
.. when you first open up the editor, it trying to auto format the script but it takes several seconds to do so. It'll take longer if script is long ...
I haven't noticed any delay of more than a couple of seconds. Could have to do with the content of the script.
Reply With Quote
  #1198  
Old 10.03.2020, 23:41
BJN01 BJN01 is offline
Mega Loader
 
Join Date: Jan 2020
Posts: 60
Default

hello , I recently started using the filter and packet function (and at the moment I was able to get them to do what I needed); but I have a question to ask you:


in the script you can set something like:

- if there is "this link" (es h**p:/siteA/dirb/img.jpg) in the linkgrabber links ---> delete it
- delete any links from the linkgrabber that comes from this path " xx" (es h**p:/siteB/2dir/shit/...)
- delete any links from the linkgrabber that comes from this path " xx" (es h**p:/siteB/2dir/shit/...) and have a specific name ( es uglWpg.*)




- delete all filtered links [there is a similar function in the menus "reset filtered connections"]
Reply With Quote
  #1199  
Old 11.03.2020, 07:01
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,142
Default

Quote:
Originally Posted by BJN01 View Post
... delete any links from the linkgrabber that ...
Code:
// Remove crawledlinks which match user-specified pattern

var patterns = [];
var addPattern = function(pattern) {
    patterns[patterns.length] = pattern;
}

addPattern(/microsoft.com\/.+/i);
addPattern(/apple.com\/robots.txt/i);
addPattern(/google.com/i);
addPattern(/robots.txt$/i);

getAllCrawledLinks().forEach(function(link) {
    patterns.forEach(function(pattern) {
        var url = link.getUrl();
        if (pattern.test(url)) link.remove();
    })
})
Quote:
delete all filtered links
Currently there aren't any methods available in Eventscripter or MYJD API which can be used to clear filtered links.
Reply With Quote
  #1200  
Old 11.03.2020, 10:24
BJN01 BJN01 is offline
Mega Loader
 
Join Date: Jan 2020
Posts: 60
Default

thank you ! I will try to work on it.

[just for peace of mind, with these commands I'm only going to delete the links of files "to be downloaded", I don't delete files already on HD or in download right?]


p.s= can all linkgrabber links be saved to a txt file?
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 06:09.
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 - 2021, Jelsoft Enterprises Ltd.