actors the i dont know xD

This commit is contained in:
Lars Behrends
2025-11-07 13:20:48 +01:00
parent 5d86fcfda9
commit 3f2f80de11
10 changed files with 602 additions and 135 deletions

View File

@@ -41,11 +41,23 @@ class TvShowController extends Controller
}
$years = array_filter($years);
// Get view mode
// Get view mode and sort
$viewMode = $queryParams['view'] ?? 'grid'; // grid, list, covers
$sort = $queryParams['sort'] ?? 'title_asc';
// Get TV shows with pagination and filters
$tvshows = TvShow::getAllWithPagination($this->pdo, $page, $perPage, $search, $genres, $years);
// Validate view mode
if (!in_array($viewMode, ['grid', 'list', 'covers'])) {
$viewMode = 'grid';
}
// Validate sort option
$validSorts = ['title_asc', 'title_desc', 'year_asc', 'year_desc', 'rating_asc', 'rating_desc'];
if (!in_array($sort, $validSorts)) {
$sort = 'title_asc';
}
// Get TV shows with pagination, filters, and sorting
$tvshows = TvShow::getAllWithPagination($this->pdo, $page, $perPage, $search, $genres, $years, $sort);
// Get total count for pagination
$totalCount = TvShow::getTotalCount($this->pdo, $search, $genres, $years);

View File

@@ -130,7 +130,7 @@ class TvShow extends Model
/**
* Get all TV shows with pagination and optional search
*/
public static function getAllWithPagination(\PDO $pdo, int $page, int $perPage, string $search = '', array $genres = [], array $years = []): array
public static function getAllWithPagination(\PDO $pdo, int $page, int $perPage, string $search = '', array $genres = [], array $years = [], string $sort = 'title_asc'): array
{
$offset = ($page - 1) * $perPage;
@@ -166,7 +166,20 @@ class TvShow extends Model
$sql .= $whereClause . " YEAR(first_air_date) IN (" . implode(',', $placeholders) . ")";
}
$sql .= " ORDER BY t.title ASC LIMIT :limit OFFSET :offset";
// Add sorting
$sortMap = [
'title_asc' => 't.title ASC',
'title_desc' => 't.title DESC',
'year_desc' => 't.first_air_date DESC NULLS LAST',
'year_asc' => 't.first_air_date ASC NULLS LAST',
'rating_desc' => 't.rating DESC NULLS LAST',
'rating_asc' => 't.rating ASC NULLS LAST',
'recent' => 't.created_at DESC',
'oldest' => 't.created_at ASC',
];
$sortClause = $sortMap[$sort] ?? 't.title ASC';
$sql .= " ORDER BY {$sortClause} LIMIT :limit OFFSET :offset";
$stmt = $pdo->prepare($sql);
$stmt->bindValue(':limit', $perPage, \PDO::PARAM_INT);

View File

@@ -656,13 +656,32 @@ class StashSyncService extends BaseSyncService
$name = $performer['name'] ?? '';
if (empty($name)) return null;
// Check if actor already exists
// Check if actor already exists by name or alias
// First check by exact name
$stmt = $this->pdo->prepare("
SELECT id, name, thumbnail_path, metadata FROM actors WHERE name = :name
SELECT id, name, thumbnail_path, metadata FROM actors
WHERE name = :name
");
$stmt->execute(['name' => $name]);
$existingActor = $stmt->fetch(PDO::FETCH_ASSOC);
// If not found by name, check aliases in PHP
if (!$existingActor) {
$stmt = $this->pdo->prepare("SELECT id, name, thumbnail_path, metadata FROM actors");
$stmt->execute();
$allActors = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($allActors as $actor) {
$metadata = json_decode($actor['metadata'] ?? '{}', true);
$aliases = $metadata['aliases'] ?? [];
if (is_array($aliases) && in_array($name, $aliases)) {
$existingActor = $actor;
$this->logProgress("Found existing actor '{$actor['name']}' by alias '{$name}'");
break;
}
}
}
// Prepare rich metadata from Stash performer data
$actorMetadata = [
'stash_id' => $performer['id'] ?? null,
@@ -908,8 +927,9 @@ class StashSyncService extends BaseSyncService
try {
$this->logProgress('Starting existing performers sync with Stash...');
echo "Starting existing performers sync with Stash..\n";
// Get all existing actors from database
$stmt = $this->pdo->prepare("SELECT id, name, metadata FROM actors ORDER BY name ASC");
$stmt = $this->pdo->prepare("SELECT id, name, metadata FROM actors WHERE id IN (SELECT actor_id FROM actor_adult_video) ORDER BY name ASC");
$stmt->execute();
$existingActors = $stmt->fetchAll(\PDO::FETCH_ASSOC);

View File

@@ -392,18 +392,65 @@ class XbvrSyncService extends BaseSyncService
if (empty($actorName)) continue;
// Try to get detailed actor information from XBVR
$detailedActorData = $this->getActorDetails($actorName, $actorData);
// Handle XBVR "aka:" format (e.g., "aka:Bella Luna,Bella Luna")
$actorNames = $this->parseXbvrActorNames($actorName);
$foundActor = null;
foreach ($actorNames as $name) {
$detailedActorData = $this->getActorDetails($name, $actorData);
$detailedActorData['name'] = $name; // Ensure the name is set correctly
$actor = $this->getOrCreateActor($detailedActorData);
if ($actor) {
$actors[] = $actor;
$foundActor = $actor;
break; // Use the first found actor
}
}
// If no actor found with any of the names, create one with the first name
if (!$foundActor && !empty($actorNames)) {
$firstName = $actorNames[0];
$detailedActorData = $this->getActorDetails($firstName, $actorData);
$detailedActorData['name'] = $firstName;
$foundActor = $this->getOrCreateActor($detailedActorData);
}
if ($foundActor) {
$actors[] = $foundActor;
}
}
return $actors;
}
/**
* Parse XBVR actor names that may contain "aka:" format
* Example: "aka:Bella Luna,Bella Luna" -> ["Bella Luna", "Bella Luna"]
*/
private function parseXbvrActorNames(string $actorName): array
{
// Check if the name starts with "aka:"
if (strpos($actorName, 'aka:') === 0) {
// Remove "aka:" prefix and split by comma
$namesPart = substr($actorName, 4); // Remove "aka:"
$names = array_map('trim', explode(',', $namesPart));
// Filter out empty names
$names = array_filter($names, function($name) {
return !empty(trim($name));
});
if (!empty($names)) {
$this->logProgress("Parsed XBVR aka format '{$actorName}' into names: " . implode(', ', $names));
return $names;
}
}
// Return the original name if not in aka format
return [$actorName];
}
private function getActorDetails(string $actorName, $actorData): array
{
// If we already have detailed actor data from the scene, use it
@@ -587,13 +634,20 @@ class XbvrSyncService extends BaseSyncService
$name = $actorData['name'] ?? '';
if (empty($name)) return null;
// Check if actor already exists
// Check if actor already exists by name or alias
$stmt = $this->pdo->prepare("
SELECT id, name, thumbnail_path, metadata FROM actors WHERE name = :name
SELECT id, name, thumbnail_path, metadata FROM actors
WHERE name = :name
OR JSON_CONTAINS(metadata->'$.aliases', :name)
");
$stmt->execute(['name' => $name]);
$existingActor = $stmt->fetch(\PDO::FETCH_ASSOC);
// If found by alias, log it for debugging
if ($existingActor && $existingActor['name'] !== $name) {
$this->logProgress("Found existing actor '{$existingActor['name']}' by alias '{$name}'");
}
// Prepare metadata from XBVR actor data
$actorMetadata = [
'xbvr_id' => $actorData['xbvr_id'] ?? $actorData['id'] ?? null,

View File

@@ -11,7 +11,6 @@
<div class="text-center text-white">
<h1 class="text-3xl md:text-5xl font-bold mb-2">Actors & Performers</h1>
<p class="text-lg md:text-xl opacity-90 mb-4">{{ pagination.total_items }} performer{{ pagination.total_items != 1 ? 's' : '' }}</p>
{{dump(pagination)}}
<!-- Pagination in Hero -->
{% if pagination.total_pages > 1 %}
<div class="flex items-center justify-center space-x-2">

View File

@@ -90,9 +90,78 @@
</div>
</div>
<!-- Right Section: Page-specific controls -->
<!-- Right Section: User Menu and Page-specific controls -->
<div class="flex items-center space-x-4">
{% block nav_controls %}{% endblock %}
<!-- User Menu -->
<div class="relative ml-4" x-data="{ open: false }">
<button
@click="open = !open"
class="flex items-center text-sm rounded-full focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-slate-800 focus:ring-white"
id="user-menu-button"
aria-expanded="false"
aria-haspopup="true"
>
<span class="sr-only">Open user menu</span>
<div class="h-8 w-8 rounded-full bg-slate-700 flex items-center justify-center text-white">
<svg class="h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
</svg>
</div>
<span class="ml-2 text-white hidden md:inline">{{ auth.user.username|default('User') }}</span>
<svg class="ml-1 h-4 w-4 text-gray-300" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7" />
</svg>
</button>
<!-- Dropdown menu -->
<div
x-show="open"
@click.away="open = false"
x-transition:enter="transition ease-out duration-100"
x-transition:enter-start="transform opacity-0 scale-95"
x-transition:enter-end="transform opacity-100 scale-100"
x-transition:leave="transition ease-in duration-75"
x-transition:leave-start="transform opacity-100 scale-100"
x-transition:leave-end="transform opacity-0 scale-95"
class="origin-top-right absolute right-0 mt-2 w-48 rounded-md shadow-lg py-1 bg-white ring-1 ring-black ring-opacity-5 focus:outline-none z-50"
role="menu"
aria-orientation="vertical"
aria-labelledby="user-menu-button"
tabindex="-1"
>
<a href="{{ path_for('profile') }}" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem" tabindex="-1" id="user-menu-item-0">
<div class="flex items-center">
<svg class="mr-2 h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z" />
</svg>
Your Profile
</div>
</a>
<a href="{{ path_for('settings') }}" class="block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem" tabindex="-1" id="user-menu-item-1">
<div class="flex items-center">
<svg class="mr-2 h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10.325 4.317c.426-1.756 2.924-1.756 3.35 0a1.724 1.724 0 002.573 1.066c1.543-.94 3.31.826 2.37 2.37a1.724 1.724 0 001.065 2.572c1.756.426 1.756 2.924 0 3.35a1.724 1.724 0 00-1.066 2.573c.94 1.543-.826 3.31-2.37 2.37a1.724 1.724 0 00-2.572 1.065c-.426 1.756-2.924 1.756-3.35 0a1.724 1.724 0 00-2.573-1.066c-1.543.94-3.31-.826-2.37-2.37a1.724 1.724 0 00-1.065-2.572c-1.756-.426-1.756-2.924 0-3.35a1.724 1.724 0 001.066-2.573c-.94-1.543.826-3.31 2.37-2.37.996.608 2.296.07 2.572-1.065z" />
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 12a3 3 0 11-6 0 3 3 0 016 0z" />
</svg>
Settings
</div>
</a>
<div class="border-t border-gray-100"></div>
<form method="POST" action="{{ path_for('auth.logout') }}" class="w-full">
<button type="submit" class="w-full text-left block px-4 py-2 text-sm text-gray-700 hover:bg-gray-100" role="menuitem" tabindex="-1" id="user-menu-item-2">
<div class="flex items-center">
<svg class="mr-2 h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 16l4-4m0 0l-4-4m4 4H7m6 4v1a3 3 0 01-3 3H6a3 3 0 01-3-3V7a3 3 0 013-3h4a3 3 0 013 3v1" />
</svg>
Sign out
</div>
</button>
{{ csrf_token() | raw }}
</form>
</div>
</div>
</div>
</div>
</div>

View File

@@ -105,15 +105,19 @@
{% for item in items %}
<div class="group relative bg-white rounded-lg shadow-sm hover:shadow-lg transition-shadow duration-200 overflow-hidden">
<!-- Media Poster/Image -->
<div class="aspect-[2/3] bg-gray-200 relative overflow-hidden">
{% if item.poster_url %}
<img src="/images/{{ item.poster_url }}" alt="{{ item.title or item.name }}" class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-200">
<img src="{% if '/images/' in item.poster_url %}{{ item.poster_url }}{% else %}/images/{{ item.poster_url }}{% endif %}" alt="{{ item.title or item.name }}" class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-200">
{% elseif item.cover_image %}
<img src="/images/playnite/{{ item.cover_image }}" alt="{{ item.title or item.name }}" class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-200">
<img src="{% if '/images/' in item.cover_image %}/playnite/{{ item.cover_image }}{% else %}/images/playnite/{{ item.cover_image }}{% endif %}" alt="{{ item.title or item.name }}" class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-200">
{% elseif item.image_url %}
<img src="/images/playnite/{{ item.image_url }}" alt="{{ item.title or item.name }}" class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-200">
<img src="{% if '/images/' in item.image_url %}/playnite/{{ item.image_url }}{% else %}/images/playnite/{{ item.image_url }}{% endif %}" alt="{{ item.title or item.name }}" class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-200">
{% elseif item.thumbnail %}
<img src="{{ item.thumbnail }}" alt="{{ item.title or item.name }}" class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-200">
<img src="{% if '/images/' in item.thumbnail %}{{ item.thumbnail }}{% else %}/images/{{ item.thumbnail }}{% endif %}" alt="{{ item.title or item.name }}" class="w-full h-full object-cover group-hover:scale-105 transition-transform duration-200">
{% else %}
<div class="w-full h-full bg-gradient-to-br from-gray-300 to-gray-400 flex items-center justify-center">
<svg class="h-12 w-12 text-gray-500" fill="none" viewBox="0 0 24 24" stroke="currentColor">

View File

@@ -1,8 +1,8 @@
{% extends "layouts/app.twig" %}
{% block nav_controls %}
<!-- Search form -->
<form method="GET" class="flex gap-2">
<!-- Enhanced Search form -->
<form method="GET" class="flex gap-3 items-center">
<input type="hidden" name="view" value="{{ view_mode }}">
<input type="hidden" name="per_page" value="{{ pagination.per_page }}">
{% for genre in filters.genres %}
@@ -11,29 +11,40 @@
{% for year in filters.years %}
<input type="hidden" name="years[]" value="{{ year }}">
{% endfor %}
<div class="relative">
<div class="relative flex-1 max-w-md">
<input
type="text"
name="search"
value="{{ search }}"
placeholder="Search TV shows..."
class="pl-10 pr-4 py-2 border border-gray-300 rounded-md focus:ring-blue-500 focus:border-blue-500 w-64 bg-gray-800 text-white placeholder-gray-400"
placeholder="Search TV shows... (Ctrl+/)"
class="w-full pl-10 pr-4 py-2.5 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-blue-500 bg-white text-gray-900 placeholder-gray-500 shadow-sm transition-colors"
autocomplete="off"
>
<svg class="absolute left-3 top-1/2 transform -translate-y-1/2 text-gray-400 h-5 w-5" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
</svg>
{% if search %}
<button type="button" onclick="clearSearch()" class="absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 hover:text-gray-600">
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
</svg>
</button>
{% endif %}
</div>
<button type="submit" class="bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2">
<button type="submit" class="inline-flex items-center px-4 py-2.5 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors shadow-sm">
<svg class="w-4 h-4 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
</svg>
Search
</button>
</form>
<!-- View mode switcher -->
<div class="flex gap-1" role="group">
<!-- Enhanced View mode switcher -->
<div class="flex gap-1 bg-gray-100 rounded-lg p-1" role="group">
{% for mode in view_modes %}
<a
href="?view={{ mode }}{% if search %}&search={{ search }}{% endif %}{% if pagination.per_page != 24 %}&per_page={{ pagination.per_page }}{% endif %}{% for genre in filters.genres %}&genres[]={{ genre }}{% endfor %}{% for year in filters.years %}&years[]={{ year }}{% endfor %}"
class="inline-flex items-center px-3 py-2 border border-gray-300 bg-gray-800 text-gray-300 hover:bg-gray-700 hover:text-white focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 {{ view_mode == mode ? 'bg-blue-600 border-blue-500 text-white' : '' }}"
class="inline-flex items-center px-3 py-2 text-sm font-medium rounded-md transition-all duration-200 {{ view_mode == mode ? 'bg-white text-blue-600 shadow-sm' : 'text-gray-600 hover:text-gray-900 hover:bg-gray-200' }}"
title="{{ mode|title }} View"
>
{% if mode == 'grid' %}
@@ -46,6 +57,11 @@
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 6h16M4 10h16M4 14h16M4 18h16"/>
</svg>
{% endif %}
{% if mode == 'covers' %}
<svg class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"/>
</svg>
{% endif %}
<span class="hidden sm:inline ml-1">{{ mode|title }}</span>
</a>
{% endfor %}
@@ -168,49 +184,71 @@
{% block content %}
<!-- Main content area -->
<div class="p-6">
<div class="min-h-screen bg-gradient-to-br from-gray-50 to-gray-100" data-content>
<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
<!-- Header -->
<div class="mb-6">
<h1 class="text-3xl font-bold text-gray-900">TV Shows</h1>
<div class="mb-8">
<div class="flex items-center justify-between">
<div>
<h1 class="text-4xl font-bold text-gray-900 mb-2">TV Shows</h1>
{% if pagination.total_items > 0 %}
<div class="text-gray-500 text-sm mt-1">
{{ pagination.total_items }} TV shows
<div class="flex items-center gap-3 text-gray-600">
<span class="text-lg">{{ pagination.total_items }} TV shows</span>
{% if search %}
matching "{{ search }}"
<span class="text-sm bg-blue-50 text-blue-700 px-3 py-1 rounded-full">matching "{{ search }}"</span>
{% endif %}
{% if filters.genres or filters.years %}
{% if filters.genres %}
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800 ml-2">{{ filters.genres|join(', ') }}</span>
<span class="text-sm bg-purple-50 text-purple-700 px-3 py-1 rounded-full">{{ filters.genres|join(', ') }}</span>
{% endif %}
{% if filters.years %}
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-gray-100 text-gray-800 ml-2">{{ filters.years|join(', ') }}</span>
{% endif %}
<span class="text-sm bg-green-50 text-green-700 px-3 py-1 rounded-full">{{ filters.years|join(', ') }}</span>
{% endif %}
</div>
{% endif %}
</div>
<!-- Sort dropdown -->
<div class="flex items-center gap-4">
<div class="flex items-center gap-2">
<label for="sort" class="text-sm font-medium text-gray-700">Sort by:</label>
<select id="sort" class="text-sm border border-gray-300 rounded-lg px-3 py-2 bg-white focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-colors">
<option value="title_asc" {{ sort == 'title_asc' ? 'selected' : '' }}>Title A-Z</option>
<option value="title_desc" {{ sort == 'title_desc' ? 'selected' : '' }}>Title Z-A</option>
<option value="year_desc" {{ sort == 'year_desc' ? 'selected' : '' }}>Newest First</option>
<option value="year_asc" {{ sort == 'year_asc' ? 'selected' : '' }}>Oldest First</option>
<option value="rating_desc" {{ sort == 'rating_desc' ? 'selected' : '' }}>Highest Rated</option>
<option value="rating_asc" {{ sort == 'rating_asc' ? 'selected' : '' }}>Lowest Rated</option>
</select>
</div>
</div>
</div>
</div>
{% if tvshows is empty %}
<div class="text-center py-5">
<svg class="mx-auto text-muted mb-3" width="48" height="48" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<div class="text-center py-16">
<div class="mx-auto w-24 h-24 bg-gradient-to-br from-gray-100 to-gray-200 rounded-full flex items-center justify-center mb-6">
<svg class="w-12 h-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 4V2a1 1 0 011-1h8a1 1 0 011 1v2h4a1 1 0 010 2h-1v14a2 2 0 01-2 2H6a2 2 0 01-2-2V6H3a1 1 0 010-2h4z"/>
</svg>
<h3 class="h5 fw-medium text-dark">
</div>
<h3 class="text-2xl font-semibold text-gray-900 mb-3">
{% if search or filters.genres or filters.years %}
No TV shows found matching your criteria
{% else %}
No TV shows found
{% endif %}
</h3>
<p class="text-muted">
<p class="text-gray-600 text-lg mb-6 max-w-md mx-auto">
{% if search or filters.genres or filters.years %}
Try adjusting your search terms or filters.
Try adjusting your search terms or filters to find what you're looking for.
{% else %}
Start syncing your TV show libraries to see your TV shows here.
Start syncing your TV show libraries to see your collection here.
{% endif %}
</p>
{% if search or filters.genres or filters.years %}
<a href="{{ path_for('tvshows.index') }}" class="btn btn-primary mt-3">
<a href="{{ path_for('tvshows.index') }}" class="inline-flex items-center px-6 py-3 bg-blue-600 text-white font-medium rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors">
<svg class="w-5 h-5 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15"/>
</svg>
Clear filters
</a>
{% endif %}
@@ -218,51 +256,116 @@
{% else %}
<!-- TV Shows content based on view mode -->
{% if view_mode == 'list' %}
<!-- List view -->
<div class="bg-white rounded-lg shadow-md border border-gray-200">
<ul class="divide-y divide-gray-200">
<!-- Enhanced List view -->
<div class="bg-white rounded-xl shadow-lg border border-gray-200 overflow-hidden">
<ul class="divide-y divide-gray-100">
{% for tvshow in tvshows %}
<li class="px-4 py-3">
<div class="flex justify-between items-center">
<div class="flex items-center">
<li class="group hover:bg-gray-50 transition-colors duration-200">
<div class="px-6 py-4">
<div class="flex items-center justify-between">
<div class="flex items-center space-x-4 flex-1">
<!-- Poster -->
<div class="flex-shrink-0">
{% if tvshow.poster_url %}
<img class="rounded mr-3" style="width: 64px; height: 96px; object-fit: cover;" src="/images/{{ tvshow.poster_url }}" alt="{{ tvshow.title }}">
<div class="relative overflow-hidden rounded-lg shadow-sm group-hover:shadow-md transition-shadow duration-200">
<img class="w-16 h-24 object-cover transform group-hover:scale-105 transition-transform duration-200" src="/images/{{ tvshow.poster_url }}" alt="{{ tvshow.title }}">
</div>
{% else %}
<div class="bg-gray-100 rounded mr-3 flex items-center justify-center" style="width: 64px; height: 96px;">
<svg class="text-gray-600" width="32" height="32" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<div class="w-16 h-24 bg-gradient-to-br from-gray-100 to-gray-200 rounded-lg flex items-center justify-center shadow-sm">
<svg class="w-8 h-8 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 4V2a1 1 0 011-1h8a1 1 0 011 1v2h4a1 1 0 010 2h-1v14a2 2 0 01-2 2H6a2 2 0 01-2-2V6H3a1 1 0 010-2h4z"/>
</svg>
</div>
{% endif %}
</div>
<!-- Content -->
<div class="flex-1 min-w-0">
<div class="flex items-start justify-between">
<div class="flex-1">
<h3 class="text-sm font-semibold mb-1">
<a href="{{ path_for('tvshows.show', {'id': tvshow.id}) }}" class="no-underline text-gray-900 hover:text-blue-600">
<h3 class="text-lg font-semibold text-gray-900 mb-1 group-hover:text-blue-600 transition-colors">
<a href="{{ path_for('tvshows.show', {'id': tvshow.id}) }}" class="block truncate">
{{ tvshow.title }}
</a>
</h3>
<div class="flex items-center gap-3 text-sm text-gray-600">
<!-- Metadata row -->
<div class="flex items-center gap-4 text-sm text-gray-600 mb-2">
{% if tvshow.first_air_date %}
<div class="flex items-center gap-1">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
</svg>
<span>{{ tvshow.first_air_date|date('Y') }}</span>
</div>
{% endif %}
{% if tvshow.rating %}
<span>⭐ {{ tvshow.rating }}/10</span>
<div class="flex items-center gap-1">
<svg class="w-4 h-4 text-yellow-500" fill="currentColor" viewBox="0 0 24 24">
<path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>
</svg>
<span>{{ tvshow.rating }}/10</span>
</div>
{% endif %}
{% if tvshow.number_of_seasons %}
<div class="flex items-center gap-1">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"/>
</svg>
<span>{{ tvshow.number_of_seasons }} season{{ tvshow.number_of_seasons > 1 ? 's' : '' }}</span>
</div>
{% endif %}
{% if tvshow.number_of_episodes %}
<div class="flex items-center gap-1">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"/>
</svg>
<span>{{ tvshow.number_of_episodes }} episode{{ tvshow.number_of_episodes > 1 ? 's' : '' }}</span>
</div>
{% endif %}
</div>
<!-- Overview preview -->
{% if tvshow.overview %}
<p class="text-sm text-gray-600 line-clamp-2 mb-2">
{{ tvshow.overview|slice(0, 120) }}{% if tvshow.overview|length > 120 %}...{% endif %}
</p>
{% endif %}
<!-- Source -->
<div class="flex items-center gap-1 text-xs text-gray-500">
<svg class="w-3 h-3" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"/>
</svg>
<span>{{ tvshow.source_name }}</span>
</div>
</div>
</div>
<div class="flex gap-2">
</div>
</div>
<!-- Actions -->
<div class="flex items-center gap-3">
{% if tvshow.is_favorite %}
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-800">
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-red-100 text-red-800 border border-red-200">
<svg class="w-3 h-3 mr-1" fill="currentColor" viewBox="0 0 24 24">
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/>
</svg>
Favorite
</span>
{% endif %}
<a href="{{ path_for('tvshows.show', {'id': tvshow.id}) }}"
class="inline-flex items-center px-4 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors opacity-0 group-hover:opacity-100 transform translate-x-2 group-hover:translate-x-0 transition-all duration-200">
View Details
<svg class="w-4 h-4 ml-2" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
</svg>
</a>
</div>
</div>
</div>
</li>
@@ -301,61 +404,116 @@
</div>
{% else %}
<!-- Default grid view -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-6 gap-4">
<!-- Enhanced Default grid view -->
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-6 gap-6">
{% for tvshow in tvshows %}
<div class="bg-white rounded-lg shadow-md border border-gray-200 h-full">
<div class="p-4">
<div class="flex items-center">
<div class="group bg-white rounded-xl shadow-lg border border-gray-200 hover:shadow-xl transition-all duration-300 transform hover:-translate-y-1 h-full overflow-hidden">
<div class="p-6">
<div class="flex items-start space-x-4">
<!-- Poster -->
<div class="flex-shrink-0">
{% if tvshow.poster_url %}
<img class="rounded" style="width: 64px; height: 96px; object-fit: cover;" src="/images/{{ tvshow.poster_url }}" alt="{{ tvshow.title }}">
<div class="relative overflow-hidden rounded-lg shadow-md group-hover:shadow-lg transition-shadow duration-300">
<img class="w-20 h-30 object-cover transform group-hover:scale-105 transition-transform duration-300" src="/images/{{ tvshow.poster_url }}" alt="{{ tvshow.title }}">
</div>
{% else %}
<div class="bg-gray-100 rounded flex items-center justify-center" style="width: 64px; height: 96px;">
<svg class="text-gray-600" width="32" height="32" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<div class="w-20 h-30 bg-gradient-to-br from-gray-100 to-gray-200 rounded-lg flex items-center justify-center shadow-sm">
<svg class="w-8 h-8 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 4V2a1 1 0 011-1h8a1 1 0 011 1v2h4a1 1 0 010 2h-1v14a2 2 0 01-2 2H6a2 2 0 01-2-2V6H3a1 1 0 010-2h4z"/>
</svg>
</div>
{% endif %}
</div>
<div class="ml-3 flex-1">
<h5 class="text-lg font-semibold mb-1">
<a href="{{ path_for('tvshows.show', {'id': tvshow.id}) }}" class="no-underline text-gray-900 hover:text-blue-600">
<!-- Content -->
<div class="flex-1 min-w-0">
<h5 class="text-xl font-bold text-gray-900 mb-2 group-hover:text-blue-600 transition-colors line-clamp-2">
<a href="{{ path_for('tvshows.show', {'id': tvshow.id}) }}" class="block">
{{ tvshow.title }}
</a>
</h5>
<div class="flex items-center gap-2 text-sm text-gray-600 mb-2">
<!-- Metadata -->
<div class="flex items-center gap-3 text-sm text-gray-600 mb-3">
{% if tvshow.first_air_date %}
<div class="flex items-center gap-1">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z"/>
</svg>
<span>{{ tvshow.first_air_date|date('Y') }}</span>
</div>
{% endif %}
{% if tvshow.rating %}
<span>⭐ {{ tvshow.rating }}/10</span>
<div class="flex items-center gap-1">
<svg class="w-4 h-4 text-yellow-500" fill="currentColor" viewBox="0 0 24 24">
<path d="M12 2l3.09 6.26L22 9.27l-5 4.87 1.18 6.88L12 17.77l-6.18 3.25L7 14.14 2 9.27l6.91-1.01L12 2z"/>
</svg>
<span class="font-medium">{{ tvshow.rating }}/10</span>
</div>
{% endif %}
</div>
<!-- Source -->
{% if tvshow.source_name %}
<p class="text-sm text-gray-600 mb-2">
{{ tvshow.source_name }}
</p>
<div class="flex items-center gap-1 text-sm text-gray-500 mb-3">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13.828 10.172a4 4 0 00-5.656 0l-4 4a4 4 0 105.656 5.656l1.102-1.101m-.758-4.899a4 4 0 005.656 0l4-4a4 4 0 00-5.656-5.656l-1.1 1.1"/>
</svg>
<span>{{ tvshow.source_name }}</span>
</div>
{% endif %}
</div>
</div>
<!-- Overview -->
{% if tvshow.overview %}
<div class="mt-3">
<p class="text-sm text-gray-600" style="display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden;">
{{ tvshow.overview|slice(0, 150) }}{% if tvshow.overview|length > 150 %}...{% endif %}
<div class="mb-4">
<p class="text-sm text-gray-600 line-clamp-3 leading-relaxed">
{{ tvshow.overview|slice(0, 180) }}{% if tvshow.overview|length > 180 %}...{% endif %}
</p>
</div>
{% endif %}
<div class="mt-3 flex justify-between items-center text-sm text-gray-600">
<!-- Footer -->
<div class="flex items-center justify-between">
<div class="flex items-center gap-3 text-sm text-gray-600">
{% if tvshow.number_of_seasons %}
<span>{{ tvshow.number_of_seasons }} season{{ tvshow.number_of_seasons > 1 ? 's' : '' }}</span>
<span class="flex items-center gap-1">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"/>
</svg>
{{ tvshow.number_of_seasons }} season{{ tvshow.number_of_seasons > 1 ? 's' : '' }}
</span>
{% endif %}
<div class="flex gap-1">
{% if tvshow.number_of_episodes %}
<span class="flex items-center gap-1">
<svg class="w-4 h-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"/>
</svg>
{{ tvshow.number_of_episodes }} episode{{ tvshow.number_of_episodes > 1 ? 's' : '' }}
</span>
{% endif %}
</div>
<div class="flex items-center gap-2">
{% if tvshow.is_favorite %}
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-800">
<span class="inline-flex items-center px-3 py-1 rounded-full text-xs font-medium bg-red-100 text-red-800 border border-red-200">
<svg class="w-3 h-3 mr-1" fill="currentColor" viewBox="0 0 24 24">
<path d="M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z"/>
</svg>
Favorite
</span>
{% endif %}
<a href="{{ path_for('tvshows.show', {'id': tvshow.id}) }}"
class="inline-flex items-center px-3 py-2 bg-blue-600 text-white text-sm font-medium rounded-lg hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors opacity-0 group-hover:opacity-100 transform translate-x-2 group-hover:translate-x-0 transition-all duration-200">
View
<svg class="w-4 h-4 ml-1" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
</svg>
</a>
</div>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,63 @@
<?php
require_once __DIR__ . '/vendor/autoload.php';
try {
echo "=== Sync Existing Performers with Stash ===\n";
$config = require __DIR__ . '/config/database.php';
\App\Database\Database::setConfig($config);
$pdo = \App\Database\Database::getInstance();
// Get Stash configuration from database
$stmt = $pdo->prepare('SELECT * FROM sources WHERE name = ?');
$stmt->execute(['stash']);
$stashSource = $stmt->fetch(\PDO::FETCH_ASSOC);
if (!$stashSource) {
echo "ERROR: Stash source not configured in database\n";
exit(1);
}
echo "Found Stash configuration: {$stashSource['display_name']}\n";
// Create Stash sync service
$stashSyncService = new \App\Services\StashSyncService($pdo, $stashSource);
// Run the existing performers sync
echo "Starting sync of existing performers...\n";
$results = $stashSyncService->syncExistingPerformers();
echo "\n=== Sync Results ===\n";
echo "Processed: {$results['processed']} performers\n";
echo "Updated: {$results['updated']} performers\n";
echo "Skipped: {$results['skipped']} performers\n";
echo "Not found in Stash: " . count($results['not_found_in_stash']) . " performers\n";
echo "Errors: " . count($results['errors']) . " performers\n";
if (!empty($results['not_found_in_stash'])) {
echo "\n=== Actors Not Found in Stash ===\n";
echo "These actors exist in your local database but were not found in Stash.\n";
echo "You can create them in Stash for future syncs.\n\n";
foreach ($results['not_found_in_stash'] as $missingActor) {
echo "- {$missingActor['name']} (ID: {$missingActor['id']})\n";
}
echo "\nA detailed report has been saved to storage/logs/\n";
}
if (!empty($results['errors'])) {
echo "\n=== Errors ===\n";
foreach ($results['errors'] as $error) {
echo "- {$error}\n";
}
}
echo "\nSync completed successfully!\n";
} catch (Exception $e) {
echo "ERROR: " . $e->getMessage() . "\n";
echo "Stack trace:\n" . $e->getTraceAsString() . "\n";
exit(1);
}

75
view_missing_actors.php Normal file
View File

@@ -0,0 +1,75 @@
<?php
require_once __DIR__ . '/vendor/autoload.php';
try {
echo "=== View Missing Stash Actors Reports ===\n";
$logDir = __DIR__ . '/storage/logs';
if (!is_dir($logDir)) {
echo "No logs directory found. Run the sync first to generate reports.\n";
exit(0);
}
$files = glob($logDir . '/missing_stash_actors_*.json');
if (empty($files)) {
echo "No missing actors reports found. Run the sync script first.\n";
exit(0);
}
echo "Found " . count($files) . " report(s):\n\n";
// Sort by date (newest first)
usort($files, function($a, $b) {
return filemtime($b) <=> filemtime($a);
});
foreach ($files as $index => $file) {
$filename = basename($file);
$fileData = json_decode(file_get_contents($file), true);
if (!$fileData) {
echo "ERROR: Could not read report file: {$filename}\n";
continue;
}
echo "Report #" . ($index + 1) . ": {$filename}\n";
echo "Generated: " . ($fileData['generated_at'] ?? 'Unknown') . "\n";
echo "Total Missing Actors: " . ($fileData['total_missing'] ?? 0) . "\n";
if (!empty($fileData['description'])) {
echo "Description: " . $fileData['description'] . "\n";
}
if (!empty($fileData['missing_actors'])) {
echo "\nMissing Actors:\n";
foreach ($fileData['missing_actors'] as $actor) {
echo " - {$actor['name']} (ID: {$actor['id']})\n";
// Show some local metadata if available
$localMeta = $actor['local_metadata'] ?? [];
if (!empty($localMeta['birth_date'])) {
echo " Birth Date: {$localMeta['birth_date']}\n";
}
if (!empty($localMeta['nationality'])) {
echo " Nationality: {$localMeta['nationality']}\n";
}
if (!empty($localMeta['gender'])) {
echo " Gender: {$localMeta['gender']}\n";
}
echo "\n";
}
}
echo str_repeat("-", 50) . "\n\n";
}
echo "To create these actors in Stash, use the data above to manually add them.\n";
echo "After creating them in Stash, run the sync again to match them up.\n";
} catch (Exception $e) {
echo "ERROR: " . $e->getMessage() . "\n";
exit(1);
}