Add existing.html

This commit is contained in:
Alex Thomassen 2022-09-09 22:08:34 +02:00
parent 13f140aa30
commit fef4b5bb83
4 changed files with 187 additions and 1 deletions

50
existing.html Normal file
View File

@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bootswatch/5.2.0/superhero/bootstrap.min.css" integrity="sha512-pCTSMcZZ+tTaq3FXSWGhMmO/OZ+52FqEdhlExLz8PTBQKMyqxAdav13kofJWiyI5zeieBo8tZ++SMZ2ZgueRBA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.9.1/font/bootstrap-icons.css" integrity="sha256-8M+b2Hj+vy/2J5tZ9pYDHeuPD59KsaEZn1XXj3xVhjg=" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/simple-datatables@3.2.2/dist/style.css" integrity="sha256-ZerMjX+PoTwR33srlBlYteG2MwTBUFimpp4wcT1w/lg=" crossorigin="anonymous">
<title>Cactflix [Main] &mdash; Plex &mdash; Existing Media</title>
<style type="text/css">
/**
* Override datatable styling to match dark background
*/
.dataTable-pagination a {
color: #dbdbdb;
}
.dataTable-pagination a:hover,
.dataTable-pagination .active a,
.dataTable-pagination .active a:focus,
.dataTable-pagination .active a:hover {
background-color: #1a242f;
}
.dataTable-sorter::before {
border-top: 4px solid #dbdbdb;
}
.dataTable-sorter::after {
border-bottom: 4px solid #dbdbdb;
}
</style>
</head>
<body>
<div class="container-fluid">
<h1 class="mt-4">Cactflix [Main] &mdash; Plex &mdash; Existing Media</h1>
<p>Existing media tracked in the different Sonarr &amp; Radarr instances.</p>
<p id="status-message">Loading... Please wait 🙂</p>
<table id="media-table" class="table table-striped table-hover mt-4">
</table>
</div>
</body>
<script src="https://cdn.jsdelivr.net/npm/simple-datatables@3.2.2/dist/umd/simple-datatables.js" integrity="sha256-Usm730G3l59Ux42era3GIRJOYXFLU7K9k7JFInXTeG0=" crossorigin="anonymous"></script>
<script src="existing.js"></script>
</html>

128
existing.js Normal file
View File

@ -0,0 +1,128 @@
const apiUrls = [
{
url: '/sonarr-hs-series',
name: 'hidden-sea',
domain: 'sonarr-hs',
},
{
url: '/sonarr-cb-series',
name: 'cold-badlands',
domain: 'sonarr-cb',
},
{
url: '/sonarr-fv-series',
name: 'fancy-valley',
domain: 'sonarr-fv',
},
{
url: '/radarr-hs-movies',
name: 'hidden-sea',
domain: 'radarr-hs',
},
{
url: '/radarr-cb-movies',
name: 'cold-badlands',
domain: 'radarr-cb',
},
{
url: '/radarr-fv-movies',
name: 'fancy-valley',
domain: 'radarr-fv',
},
];
let media = [];
function removeMessage()
{
const message = document.querySelector('#status-message');
if (message) {
message.remove();
}
}
async function initial()
{
for (const apiUrl of apiUrls) {
const response = await fetch(apiUrl.url);
let json = await response.json();
json.map((item) => {
item.server = `${apiUrl.name}|${apiUrl.domain}|${item.titleSlug}|${item.tmdbId || item.id}`;
item.mediaType = apiUrl.url.includes('sonarr') ? 'Series' : 'Movie';
return item;
});
media = [...media, ...json];
}
media = media.sort((a, b) => {
return a.sortTitle.localeCompare(b.sortTitle);
});
let rows = media.map((mediaItem) => {
const { title, mediaType, year, server } = mediaItem;
return [
title,
mediaType,
year,
server,
];
});
const tblData = {
headings: [
'Series/Movie name',
'Type',
'Year',
'Server',
],
data: rows,
};
const tbl = document.querySelector('#media-table');
const dataTblConfig = {
searchable: true,
fixedHeight: false,
perPage: 100,
perPageSelect: [25, 50, 100, 250, 500, 750, 1000],
data: tblData,
layout: {
top: '{search}{select}',
bottom: '{pager}{info}',
},
columns: [
{
select: [3],
render: function(data, cell, row) {
const [name, domain, slug, id] = data.split('|');
let url = `https://${domain}.decicus.com`;
if (domain.includes('sonarr')) {
url += `/series/${slug}`;
}
else {
url += `/movie/${id}`;
}
return `<a href="${url}" target="_blank">${name}</a>`;
},
}
],
};
removeMessage();
const dataTbl = new simpleDatatables.DataTable(tbl, dataTblConfig);
dataTbl.on('datatable.init', function() {
const search = document.querySelector('.dataTable-search input');
search.focus();
});
}
window.addEventListener('DOMContentLoaded', function() {
initial();
});

View File

@ -47,7 +47,7 @@
</tr>
<tr>
<td>🟠</td>
<td>Episode has aired, waiting for available download.</td>
<td>Episode has aired, waiting for available download. "Air time" accuracy may vary.</td>
</tr>
<tr>
<td></td>

View File

@ -4,6 +4,14 @@
location /sonarr-ics {
proxy_pass "https://sonarr.example.com/feed/calendar/Sonarr.ics?apikey=YOUR_API_KEY_HERE";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /sonarr-series {
proxy_pass "https://sonarr.example.com/api/v3/series?apikey=YOUR_API_KEY_HERE";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;