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.
Agreed. Blocked by https://github.com/Chocobozzz/PeerTube/issues/262
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);
};
Most helpful comment
Implemented: https://github.com/Chocobozzz/PeerTube/commit/9a629c6efbe39dfac290347670ca41b0d7100f41