Peertube: Trending videos depending on time frame

Created on 11 Mar 2018  路  5Comments  路  Source: Chocobozzz/PeerTube

I didn't see it in the API but it would be nice to be able to specify a time frame for the trending (view count) call.

For example you could then have trending in the last 24h, week, month, all time etc.

Status Type

Most helpful comment

All 5 comments

It isn't really blocked by #262 if you use publication date as a delimiter/weight.
Yes this will disable old videos to become trending, but is it really a common scenario?
You can just say that a "success" of each video is a number of views multiplied by some exp((-1)xKxdays passed from publication)+there can be a hard deadline like 3 years old max to optimize things.

Also need to notice that a situation calls for some swift (even if simplified) actions since "Trending" now really looks shameful and probably repells potential users by creating a stagnating image which does not really reflect the reality.

Now that the search filter allows to set a timeframe it would be interesting to at least only show videos that are less than 2 weeks old :)

You can kill me for that but...

here is a little bad ugly JS hack to make trending page only display videos that are less than a month old

doesn't work well if your starting page is the trending one

XMLHttpRequest.prototype.oldOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function(method, url, async, user, password) {
    if(url.indexOf("/api/v1/videos/")>=0&&url.indexOf("sort=-views")>=0){
        console.log(url);
        var urlP = new URL("http://example.bla"+url);
        var start = urlP.searchParams.get("start");
        var count = urlP.searchParams.get("count");
        var category = urlP.searchParams.get("categoryOneOf");
        var d = new Date();
        d.setMonth(d.getMonth()-1);
        var n = d.toISOString();
        url="/api/v1/search/videos?start="+start+"&count="+count+"&startDate="+n+"&sort=-views"+(category!==null?"&categoryOneOf="+category:"");
        console.log(url);
    }
    this.oldOpen(method, url);
};
Was this page helpful?
0 / 5 - 0 ratings

Related issues

XenonFiber picture XenonFiber  路  3Comments

roipoussiere picture roipoussiere  路  3Comments

milleniumbug picture milleniumbug  路  3Comments

ChameleonScales picture ChameleonScales  路  3Comments

Jorropo picture Jorropo  路  3Comments