coslyk / moonplayer-plugins

Plugins for MoonPlayer
36 stars 5 forks source link

Odysee plugin #9

Closed cybardev closed 2 years ago

cybardev commented 3 years ago

Hello there. I would like to have a plugin for the video streaming platform Odysee, but I have no practical experience with JavaScript and especially not with JS regular expressions. Could you please either help me understand what to do, or make a plugin for this? I think modifying the iqiyi plugin will be the best option as it is the simplest (though I think only 1 while loop is needed for Odysee).

Here's some info I have about Odysee: 1) Search URL: https://odysee.com/$/top?name=searchterm 2) Tag containing target URL and title: <a href="/@channel:5/searchterm:b"><div class="claim-preview__title"><span title="Title String"... 3) URL of example video (doesn't exist): https://odysee.com/@channel:5/searchterm:b

In the above snippet, /@channel:5/searchterm:b has the channel name and the search term, and both 5 and b (must be a single character each) has some significance that I'm not aware of but is important nonetheless.

I think I could figure out how to make the extension if I knew how to make the regexp to parse that tag.

Here's the code I have (practically a copy of the iqiyi.js file):

var website_name = 'Odysee';

function search(key, page) {
    var url = 'https://odysee.com/$/top?name=' + key;
    moonplayer.get_content(url, function(content) {
        var result = list_links(content, "https://odysee.com/");
        moonplayer.show_result(result);
    });
}

function list_links(content, prefix) {
    var rex = /<a\s.*?href="\/@.+?">.*?title="(.+?)"/g;
    var match;
    var result = [];
    var urls = []

    while ((match = rex.exec(content)) !== null) {
        if (match[1].startsWith(prefix) && !urls.includes(match[1])) {
            urls.push(match[1]);
            result.push({ title: match[2], url: match[1] });
        }
    }

    return result;
}
coslyk commented 3 years ago

The search result is not stored in the html page directly, so you can't simply use regexp to find out the URLs...

You can inspect the page with the browser's developer tool, then you will find out that the search result is fetched by the API: https://api.lbry.tv/api/v1/proxy?m=claim_search with the following POST content:

{
    "jsonrpc":"2.0",
    "method":"claim_search",
    "params":{
        "page_size":20,
        "page":1,
        "name":"@KEYWORD@",
        "claim_type":[
            "stream",
            "channel"
        ],
        "no_totals":true,
        "not_channel_ids":[

        ],
        "not_tags":[
            "porn",
            "porno",
            "nsfw",
            "mature",
            "xxx",
            "sex",
            "creampie",
            "blowjob",
            "handjob",
            "vagina",
            "boobs",
            "big boobs",
            "big dick",
            "pussy",
            "cumshot",
            "anal",
            "hard fucking",
            "ass",
            "fuck",
            "hentai"
        ],
        "order_by":[
            "effective_amount"
        ],
        "fee_amount":"<=0",
        "include_purchase_receipt":true
    },
    "id":1608384939642
}

Unfortunately MoonPlayer's API does not fully support POST yet.

cybardev commented 3 years ago
  1. wow... those not_tags... :|

Unfortunately MoonPlayer's API does not fully support POST yet.

  1. Oh, ok. I'll close the issue then. Meanwhile, is there any way to play Odysee/LBRY videos through moonplayer? I can play them fine in mpv via youtube-dl, but Moonplayer seems to be making a fuss about plugins...