lformella / xdcc-grabscher

XG is an IRC Downloadmanager written in C#.
http://www.larsformella.de/lang/en/portfolio/programme-software/xg
66 stars 50 forks source link

Greasemonkey Search Provider Script for XG 2 #48

Open Freedos opened 10 years ago

Freedos commented 10 years ago

I found this great Greasemonkey userscript fpr XG 2: http://userscripts.org/scripts/show/187324

I didn't modified it for XG 3 since 3 isn't working on my setup but maybe Lars wants to add it in his next version?

I also added ixIRC to it and fixed some bugs:

SearchProvider.Create("XDCC Finder", "http://www.xdccfinder.com/results.php?kw={0}&bt=&ch=&nw=&order=2&s={1}", function(self, responseDoc)
{
    var table = responseDoc.getElementById("tables");
    var results = [];
    for(var i = 1; i < table.rows.length; i += 2)
    {
        var tr = table.rows[i];
        results.push(new XGDownloadLink(
            tr.cells[5].children[0].href.substr(6, tr.cells[5].children[0].href.lastIndexOf("/")-5),
            tr.cells[1].children[0].textContent,
            tr.cells[2].children[0].textContent,
            tr.nextSibling.cells[0].children[2].children[1].textContent,
            tr.cells[5].children[0].textContent,
            tr.cells[0].children[0].title,
            tr.cells[3].textContent));  
    }
    return { items: results, pageCount: 10 }; responseDoc.getElementById("pagination").lastChild.previousSibling.textContent.trim()
}, function(page)
{
    return (page - 1) * 20;
});

SearchProvider.Create("ixIRC", "http://ixirc.com/?q={0}&pn={1}", function(self, responseDoc)
{
    var table = responseDoc.getElementById("results-table");
    var results = [];
    for(var i = 1; i < table.rows.length; i += 2)
    {
        var tr = table.rows[i];
        results.push(new XGDownloadLink(
            tr.cells[0].children[0].href.substr(6, tr.cells[0].children[0].href.lastIndexOf("/")-5),
            tr.cells[1].children[0].textContent,
            tr.cells[2].children[0].textContent,
            tr.cells[3].children[0].textContent,
            tr.cells[4].textContent,
            tr.cells[0].children[1].textContent,
            tr.cells[6].textContent));  
    }
    return { items: results, pageCount: 10}; //responseDoc.getElementsByClassName("page-numbers").lastChild.textContent -1
});
lformella commented 10 years ago

Is http://www.xdccfinder.com down / for sale?

lformella commented 10 years ago

It would be better to update the already embedded xg.bitpir.at service to use other search engines, too. If some engine goes down or there is a new one, you just have to add them in one place and all XG versions out there can use the updated engines.

You just have to patch the external function in the search controller (https://github.com/lformella/xg.bitpir.at/blob/master/XG/Classes/Controller/Search.php). Maybe there should be an extra function to get all engines and be able to select one when searching. Unfortunately some engines do not support sort by and to control the number of results. So there should be a possibility to disable this if it is not supported with your selected engine.

Do you know PHP? It would be great if somebody could develop the xg.bitpir.at part :)