diff --git a/watchlist.js b/watchlist.js
index 911d6c2..0b6bafa 100644
--- a/watchlist.js
+++ b/watchlist.js
@@ -1,4 +1,4 @@
-// Jellyfin Watchlist Enhancement Script
+// Jellyfin Watchlist Script
// Adds watchlist functionality throughout Jellyfin interface
// Requires: cardBuilder.js module to be loaded before this script
@@ -14,182 +14,6 @@
/************ Helpers ************/
-function formatPremiereDate(dateStr) {
- if (!dateStr) return "";
- return new Date(dateStr).toLocaleDateString(undefined, { weekday: "long", month: "long", day: "numeric" });
-}
-
-function setCardData(items, options) {
- // Stub function for compatibility
-}
-
-function buildCard(index, item, apiClient, options) {
- // Check if cardBuilder is available
- if (typeof window.cardBuilder !== 'undefined' && window.cardBuilder.buildCard) {
- // Use cardBuilder to create a proper Jellyfin card
- const cardElement = window.cardBuilder.buildCard(item);
- cardElement.setAttribute('data-index', index);
- cardElement.classList.add('discover-card');
-
- // Convert DOM element to HTML string
- return cardElement.outerHTML;
- } else {
- // Fallback to simple card if cardBuilder is not available
- WARN("cardBuilder not available, using fallback card creation");
- return buildFallbackCard(index, item, apiClient, options);
- }
-}
-
-function buildFallbackCard(index, item, apiClient, options) {
- var serverUrl = apiClient.serverAddress();
- var imgUrl = serverUrl + "/Items/" + item.Id + "/Images/Primary?maxWidth=200&tag=" + item.PrimaryImageTag;
- var itemUrl = getItemDetailUrl(item);
-
- var html = '';
- html += '
';
- html += '
';
- html += '
';
- html += '
';
- html += '
';
- html += '
';
- html += '
';
- html += '
';
- html += ' ';
- html += '
';
- html += '
';
- html += '
';
- html += '
';
- html += '
';
- html += ' ' + item.Name + '';
- html += ' ';
- html += '
';
- html += '
';
- html += '
';
-
- var date = new Date(item.PremiereDate);
-
- html += ' ' + date.getFullYear() + '';
- html += ' ';
- html += '
';
- html += '
';
- html += '
';
-
- return html;
-}
-
-async function toggleFavorite(itemId, btn) {
- const apiClient = window.ApiClient;
- const userId = apiClient.getCurrentUserId();
- const serverUrl = apiClient.serverAddress();
- const token = apiClient.accessToken();
-
- const isFav = btn.textContent === "♡";
- try {
- await fetch(`${serverUrl}/Users/${userId}/FavoriteItems/${itemId}?IsFavorite=${isFav}`, {
- method: "POST",
- headers: { "Authorization": `MediaBrowser Token=\"${token}\"` }
- });
- btn.textContent = isFav ? "♥" : "♡";
- } catch (err) {
- ERR("Favorite toggle failed", err);
- }
-}
-
-function buildCardsHtmlInternal(items, options) {
- setCardData(items, options);
- let html = "";
- let itemsInRow = 0;
- let currentIndexValue;
- let hasOpenRow = false;
- let hasOpenSection = false;
- const sectionTitleTagName = options.sectionTitleTagName || "div";
- const apiClient = window.ApiClient;
- let lastServerId;
-
- for (const [i, item] of items.entries()) {
- const serverId = item.ServerId || options.serverId;
- if (serverId !== lastServerId) lastServerId = serverId;
-
- let newIndexValue = "";
- if (options.indexBy === "PremiereDate") {
- newIndexValue = formatPremiereDate(item.PremiereDate);
- } else if (options.indexBy === "ProductionYear") {
- newIndexValue = item.ProductionYear;
- } else if (options.indexBy === "CommunityRating") {
- const rounded = item.CommunityRating % 1 >= 0.5 ? 0.5 : 0;
- newIndexValue = item.CommunityRating ? (Math.floor(item.CommunityRating) + rounded) + "+" : "";
- }
-
- // Handle section changes
- if (newIndexValue !== currentIndexValue) {
-
- // Close previous row and section if open
- if (hasOpenRow) {
- html += "";
- hasOpenRow = false;
- itemsInRow = 0;
- }
- if (hasOpenSection) {
- html += "";
- hasOpenSection = false;
- }
-
- // Start new section (always horizontal)
- html += "";
- html += `<${sectionTitleTagName} class="sectionTitle">${newIndexValue}${sectionTitleTagName}>`;
-
- currentIndexValue = newIndexValue;
- hasOpenSection = true;
- }
-
- // Handle row creation for multi-row layouts
- if (options.rows && itemsInRow === 0) {
- html += "
";
- hasOpenRow = true;
- }
-
- // Build the card with direct linking
- html += buildCard(i, item, apiClient, options);
- itemsInRow++;
-
- // Close row if we've reached the row limit
- if (options.rows && itemsInRow >= options.rows) {
- html += "
";
- hasOpenRow = false;
- itemsInRow = 0;
- }
- }
-
- // Close any remaining open elements
- if (hasOpenRow) html += "
";
- if (hasOpenSection) html += "";
-
- return html;
-}
-
-function buildCardWithLink(index, item, apiClient, options) {
- // Generate the URL for the item detail page
- const itemUrl = getItemDetailUrl(item);
-
- // Build the original card content
- const cardContent = buildCard(index, item, apiClient, options);
-
- // Wrap the card in a clickable link
- return `${cardContent}`;
-}
-
-function getItemDetailUrl(item) {
- // Construct the URL to the item's detail page
- // Adjust this based on your Jellyfin setup and routing
- const baseUrl = window.location.origin;
- const serverId = item.ServerId;
-
- // Standard Jellyfin item detail URL format
- return `${baseUrl}/web/#/details?id=${item.Id}&serverId=${serverId}`;
-}
-
async function fetchLikedItems(type) {
const apiClient = window.ApiClient;
const userId = apiClient.getCurrentUserId();