JDownloader Community - Appwork GmbH
 

Notices

Reply
 
Thread Tools Display Modes
  #121  
Old 09.12.2020, 16:45
Dockel Dockel is offline
Storm
 
Join Date: Feb 2020
Posts: 221
Default

Quote:
When adding new links to linkgrabber?
Yes. And in the download window as well.

Quote:
New script will only process links which are ONLINE, unlike the old script, which did not check for availability, which would result in wrong type of links (e.g. filecrypt container) being added to the history file.
Ah great, and may be needing less CPU therefore.

Many thanks for the script!
__________________
Aktuelles Windows
Reply With Quote
  #122  
Old 09.12.2020, 17:26
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,093
Default

Quote:
Originally Posted by Dockel View Post
Yes. And in the download window as well.
From what I can see, the links are disabled only in linkgrabber tab. In downloads tab, they are skipped, not disabled.

Can you number the scripts in your post? I will then tell you which script I think is used to skip/enable the link. You can then test with only that script enabled and see if the issue can be reproduced.
Reply With Quote
  #123  
Old 09.12.2020, 20:25
Dockel Dockel is offline
Storm
 
Join Date: Feb 2020
Posts: 221
Default

Quote:
From what I can see, the links are disabled only in linkgrabber tab. In downloads tab, they are skipped, not disabled.
Yes, that might be like it, I do not remember anymore, I remove the disabled links in the linkgrabber window generally.

Quote:
Can you number the scripts in your post?
Yes, in which order, numbering according to what, to a property, features, etc.? And I have lost the overview a bit because the scripts belonging to each other have become disordered because of de/activating them and such.

Quote:
I will then tell you which script I think is used to skip/enable the link.
Isn't it this one(?):

Code:
/* 
    Disable duplicate link in Lingrabber
    Trigger required: A new link has been added
*/

var link = crawledLink;

if (link.availableState == "ONLINE") {
    var name = "history";
    var lock = getModifyLock(name);

    lock.writeLock();

    var urls = getProperty(name, true);

    if (urls == null) {
        try {
            var file = JD_HOME + "/cfg/history.txt";
            var urls = readFile(file);

            setProperty(name, urls, true);
        } catch (e) {}
    }

    lock.writeUnlock();

    if (urls) {
        var url = link.contentURL || link.pluginURL;

        if (link.host == "youtube.com") {
            url = link.containerURL;
        }

        if (urls.indexOf(url) > -1) {
            var text = "#duplicatelink";
            var comment = link.comment;

            if (comment) {
                text = text + " " + comment;
            }

            link.comment = text;
            link.enabled = false;
        }
    }
}
And this one?

Code:
// Skip link if it present in download history (has "#duplicatelink" in comment)
// To download the file (prevent skipping), remove "#duplicatelink" from comment
// Trigger required: A Download Started

var comment = link.getComment() || "";

if (comment.indexOf("#duplicatelink") > -1) {
    // var url = link.getContentURL() || link.getPluginURL(); // Nur tatsächlich runtergeladene Varianten von YouTube werden als Duplikate behandelt
    var url = link.getHost() == "youtube.com" ? link.getContainerURL() : link.getContentURL() || link.getPluginURL(); // alle Varianten auf YouTube werden als Duplikate behandelt
    link.setEnabled(false); //To disable the link instead of skipping it, replace link.setSkipped(true); with link.setEnabled(false); in both the scripts
    alert("Download Skipped: \"" + url + "\" is present in history file.");
}
__________________
Aktuelles Windows
Reply With Quote
  #124  
Old 10.12.2020, 03:50
Dockel Dockel is offline
Storm
 
Join Date: Feb 2020
Posts: 221
Default

At the moment there are no dups disabled / find anymore.
__________________
Aktuelles Windows
Reply With Quote
  #125  
Old 10.12.2020, 04:26
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,093
Default

@Dockel: Can you please contact me in JD Chat?
Reply With Quote
  #126  
Old 10.12.2020, 10:50
Dockel Dockel is offline
Storm
 
Join Date: Feb 2020
Posts: 221
Default

Yes, I just did.
__________________
Aktuelles Windows
Reply With Quote
  #127  
Old 10.12.2020, 10:59
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 69,349
Default

Quote:
Originally Posted by mgpai View Post
I will optimize these scripts, but, I do not want to use global properties in new scripts, if it needs additional code to handle collision. It doesn't really make sense having to repeat the same code every time we need to read/write them. I think that should be the default behavior for global properties, or at least there should be a flag/switch to make it so.
Contact me by mail and I will explain. You have to synchronize read/write when dealing with shared variables/information. You have to make sure that changes are visible to all other scripts/executions as well. Instead of slow read/write to disk which was synchronized as well, you now have to synchronize the access in the script.
Your modified script reads file from disk once and then continue to use highspeed in memory list. The other scripts however still read/write from disk and thus the changes are not visible to the in memory list.
__________________
JD-Dev & Server-Admin

Last edited by Jiaz; 10.12.2020 at 11:01.
Reply With Quote
  #128  
Old 10.12.2020, 11:19
Dockel Dockel is offline
Storm
 
Join Date: Feb 2020
Posts: 221
Default

Jiaz, can one get a sound alert with new messages in the JD chat in JD?
__________________
Aktuelles Windows
Reply With Quote
  #129  
Old 10.12.2020, 11:22
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 69,349
Default

@Docker: The chat extension is very minimalistic and to be honest, if you're using chat that much you better stick with a real IRC client instead.
__________________
JD-Dev & Server-Admin
Reply With Quote
  #130  
Old 10.12.2020, 11:32
Dockel Dockel is offline
Storm
 
Join Date: Feb 2020
Posts: 221
Default

OK, mache ich, danke.
__________________
Aktuelles Windows
Reply With Quote
  #131  
Old 10.12.2020, 11:34
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 69,349
Default

Danke fürs Verständnis!
__________________
JD-Dev & Server-Admin
Reply With Quote
  #132  
Old 10.12.2020, 12:21
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,093
Default

Quote:
Originally Posted by Jiaz View Post
Contact me by mail and I will explain. You have to synchronize read/write when dealing with shared variables/information. You have to make sure that changes are visible to all other scripts/executions as well. Instead of slow read/write to disk which was synchronized as well, you now have to synchronize the access in the script.
Your modified script reads file from disk once and then continue to use highspeed in memory list. The other scripts however still read/write from disk and thus the changes are not visible to the in memory list.
I am working on it.
Reply With Quote
  #133  
Old 10.12.2020, 13:28
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,093
Default

Replacement scripts

Script #1
Code:
/*
    Move selected links from linkgrabber list to history file
    Trigger required: Linkgrabber Contextmenu Button Pressed
    Customize linkgrabber context menu > Add new "Eventscripter Trigger" button > Rename it to "Move to history" (without quotes) > Change Icon (optional)
*/

if (name = "Move to history") {
    var file = getPath(JD_HOME + "/cfg/history.txt");

    var lock = getModifyLock(file.name);
    lock.writeLock();

    var urls = getProperty(file.name,true) || file.exists() && readFile(file) || "";
    var unique = "";

    lgSelection.getLinks().forEach(function(link) {
        if (link.availableState == "ONLINE") {
            var url = link.contentURL || link.pluginURL;

            if (urls.indexOf(url) == -1) {
                unique += url + "\r\n";
            }

            link.remove();
        }
    })

    if (unique) {
        writeFile(file, unique + "\r\n", true);
    }
    
    setProperty(file.name, urls += unique, true);
    lock.writeUnlock();
}

Script #2
Code:
/*
    Move selected links from download list to history file / Disable corresponding links in linkgrabber list
    Trigger required: Downloadlist Contextmenu Button Pressed
    Customize linkgrabber context menu > Add new "Eventscripter Trigger" button > Rename it to "Move to history" (without quotes) > Change Icon (optional)
*/

if (name = "Move to history") {
    var file = getPath(JD_HOME + "/cfg/history.txt");

    var lock = getModifyLock(file.name);
    lock.writeLock();

    var urls = getProperty(file.name, true) || file.exists() && readFile(file) || "";
    var unique = "";

    dlSelection.getLinks().forEach(function(link) {
        if (link.finished) {
            var url = link.contentURL || link.pluginURL;

            if (urls.indexOf(url) == -1) {
                unique += url + "\r\n";
            }

            link.remove();
        }
    })

    if (unique) {
        writeFile(file, unique + "\r\n", true);
    }

    setProperty(file.name, urls += unique, true);

    lock.writeUnlock();

    getAllCrawledLinks().forEach(function(link) {
        if (link.availableState == "ONLINE") {
            var url = link.contentURL || link.pluginURL;

            if (link.host == "youtube.com") {
                url = link.containerURL;
            }

            if (urls.indexOf(url) > -1) {
                var text = "#duplicatelink";
                var comment = link.comment;

                if (comment) {
                    text = text + " " + comment;
                }

                link.comment = text;
                link.enabled = false;
            }
        }
    });
}

Script #3
Code:
/* 
    Disable duplicate link in Lingrabber list
    Trigger required: A new link has been added
*/

var link = crawledLink;

if (link.availableState == "ONLINE") {
    var file = getPath(JD_HOME + "/cfg/history.txt");

    var lock = getModifyLock(file.name);
    lock.writeLock();

    var urls = getProperty(file.name, true);

    if (urls == null) {
        urls = file.exists() && readFile(file) || "";
        setProperty(file.name, urls, true);
    }

    lock.writeUnlock();

    if (urls) {
        var url = link.contentURL || link.pluginURL;

        if (link.host == "youtube.com") {
            url = link.containerURL;
        }

        if (urls.indexOf(url) > -1) {
            var text = "#duplicatelink";
            var comment = link.comment;

            if (comment) {
                text = text + " " + comment;
            }

            link.comment = text;
            link.enabled = false;
        }
    }
}

Last edited by mgpai; 10.12.2020 at 16:38. Reason: Modified all 3 scripts.
Reply With Quote
  #134  
Old 10.12.2020, 14:18
Dockel Dockel is offline
Storm
 
Join Date: Feb 2020
Posts: 221
Default

Are the scripts numerated like mine are? If not, I would have done a mistake, I guess.

And scripts 4 and 5 stay like they are, I assume.
__________________
Aktuelles Windows
Reply With Quote
  #135  
Old 10.12.2020, 14:23
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 69,349
Default

@Dockel: Wait for updated scripts
@mgpai: contact me in chat, your script modification doesn't make sense
You misunderstood me
__________________
JD-Dev & Server-Admin
Reply With Quote
  #136  
Old 10.12.2020, 14:29
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,093
Default

Quote:
Originally Posted by Dockel View Post
Are the scripts numerated like mine are? If not, I would have done a mistake, I guess.

And scripts 4 and 5 stay like they are, I assume.
From what I can gather, only 3 scripts need to be replaced. They are not in any particular order. I numbered them so that they can be easily replaced in other posts.

Quote:
Originally Posted by Jiaz View Post
... contact me in chat
I don't see you online in IRC.
Reply With Quote
  #137  
Old 10.12.2020, 14:41
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 69,349
Default

@mgpai

Quote:
var history=getHistory();
alert(history);
addToHistory("test2222");
alert(history);

function getHistory() {
var file = getPath(JD_HOME + "/cfg/history.txt");
var name = file.name;
var lock = getModifyLock(name);
lock.writeLock();
history = getProperty(name, true);
if (history == null) {
if (file.exists()) {
history = readFile(file);
} else {
history = "";
}
setProperty(name, history, true);
}
lock.writeUnlock();
return history;
}

function addToHistory(value) {
var file = getPath(JD_HOME + "/cfg/history.txt");
var name = file.name;
var lock = getModifyLock(name);
lock.writeLock();
history = getProperty(name, true);
if (history == null) {
history = getHistory();
}
if (history.indexOf(value) == -1) {
var add = value+"\r\n";
history += add;
setProperty(name, history, true);
writeFile(file, add, true);
}
lock.writeUnlock();
return history;
}
__________________
JD-Dev & Server-Admin
Reply With Quote
  #138  
Old 10.12.2020, 14:57
Dockel Dockel is offline
Storm
 
Join Date: Feb 2020
Posts: 221
Default

All done, seems to work fine, tried some links. Many thanks!

Is there a way to mark / disable all the different video versions when loading a special video version only from YouTube?

E.g. I download this one

and all of the other versions automatically are disabled / marked as dups as well:
__________________
Aktuelles Windows
Reply With Quote
  #139  
Old 10.12.2020, 15:05
Jiaz's Avatar
Jiaz Jiaz is offline
JD Manager
 
Join Date: Mar 2009
Location: Germany
Posts: 69,349
Default

@Dockel: Needs a script that looks for other variants of same videoID @mgpai
__________________
JD-Dev & Server-Admin
Reply With Quote
  #140  
Old 10.12.2020, 17:23
mgpai mgpai is offline
Script Master
 
Join Date: Sep 2013
Posts: 1,093
Default

@dockel: All 3 new scripts needed to be updated. Please replace your existing scripts with the latest version.

Quote:
Originally Posted by Dockel View Post
Is there a way to mark / disable all the different video versions when loading a special video version only from YouTube?
You mean if there are multiple variants in the list, select one you want and disable the other variants?
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 02:55.
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.