-
Notifications
You must be signed in to change notification settings - Fork 0
/
rss.html
81 lines (80 loc) · 3.32 KB
/
rss.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<html>
<head>
<link href="https://unpkg.com/[email protected]/dist/css/tabulator.min.css" rel="stylesheet">
<script type="text/javascript" src="https://unpkg.com/[email protected]/dist/js/tabulator.min.js"></script>
</head>
<body>
<div id="rss-agg-table"></div>
<script type='text/javascript'>
const DECORS = 'https://cors-anywhere.herokuapp.com/'
const NAME_RE = /(?<site>[A-Za-z0-9_-]+)\W(?<episode>[Ee]\d+|(?<year>\d{2,4})(?:\W(?<month>\d{2})\W(?<day>\d{2}))?)\W(?<title>.+)\WXXX/;
let sceneEvals = [
["1080p", "HEVC"],
["720p", "HEVC"],
["1080p"],
["720p"],
];
var table = new Tabulator("#rss-agg-table", {
index: "link",
columns: [
{title:"Site", field:"site", visible: false},
{title:"Episode", field:"episode", visible: false},
{title:"Title", field:"title", visible: false},
{title:"Published", field:"pubDate", visible: false},
{title:"Score", field:"score", visible: true},
{title:"Name", field:"name", formatter: "link", formatterParams: {labelField: "name", urlField:"link", download: true}},
],
initialFilter:[
{field:"score", type:">=", value:"0"},
{field:"title", type:"!=", value:"undefined"}
],
initialSort: [
{column:"score", dir:"asc"},
{column:"name", dir:"asc"},
{column:"pubDate", dir:"asc"},
],
headerVisible: false,
layout: "fitDataStretch",
layoutColumnsOnNewData: true,
groupBy: d => `${d.title} (${d.site} ${d.episode})`,
// groupStartOpen: false,
groupToggleElement: "header",
progressiveLoad: "load",
ajaxURL: window.localStorage.getItem("nzbUrl"),
ajaxParams: { 't': 'search', 'o': 'json', 'cat': 6040 },
ajaxURLGenerator: function(url, config, params) {
let pageUrl = new URL(url);
if (params.t) pageUrl.searchParams.set('t', params.t);
if (params.o) pageUrl.searchParams.set('o', params.o);
if (params.cat) pageUrl.searchParams.set('cat', params.cat);
if (params.apikey) pageUrl.searchParams.set('apikey', params.apikey);
if (!params.size) params.size = 100;
if (!params.page) params.page = 0;
pageUrl.searchParams.set('limit', params.size);
pageUrl.searchParams.set('offset', params.size * params.page);
return pageUrl;
},
ajaxResponse: function(url, params, response) {
return {"last_page": 1, "data": response.channel.item.map((jsonItem) => {
let item = {
"link": jsonItem.link.replaceAll('&','&'),
"name": jsonItem.title,
"pubDate": jsonItem.pubDate,
"score": Math.min(0, (100*sceneEvals.findIndex(e => e.every(t => jsonItem.title.includes(t))))/sceneEvals.length),
};
let match = NAME_RE.exec(jsonItem.title.replaceAll('.', ' '));
if (match) Object.assign(item, match.groups);
return item;
})};
},
});
table.on("tableBuilt", function(){
table.setSort([
{column:"score", dir:"asc"},
{column:"name", dir:"asc"},
{column:"pubDate", dir:"asc"},
]);
});
</script>
</body>
</html>