impoort stuff!

This commit is contained in:
Lars Behrends
2025-10-24 16:04:34 +02:00
parent 73d8441787
commit 218d0c28c0
17 changed files with 3043 additions and 277 deletions

View File

@@ -3,16 +3,17 @@
namespace App\Controllers; namespace App\Controllers;
use Psr\Http\Message\ResponseInterface as Response; use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Views\Twig; use Slim\Views\Twig;
abstract class Controller abstract class Controller
{ {
protected $view; protected $view;
protected $auth;
public function __construct(Twig $view) public function __construct(Twig $view, $auth = null)
{ {
$this->view = $view; $this->view = $view;
$this->auth = $auth;
} }
protected function json(Response $response, $data, int $status = 200): Response protected function json(Response $response, $data, int $status = 200): Response
@@ -22,4 +23,122 @@ abstract class Controller
->withHeader('Content-Type', 'application/json') ->withHeader('Content-Type', 'application/json')
->withStatus($status); ->withStatus($status);
} }
protected function jsonResponse(Response $response, $data, int $status = 200): Response
{
return $this->json($response, $data, $status);
}
protected function withRedirect(Response $response, string $url): Response
{
return $response->withStatus(302)->withHeader('Location', $url);
}
protected function generateCSRFToken(): string
{
if ($this->auth && method_exists($this->auth, 'generateCSRFToken')) {
return $this->auth->generateCSRFToken();
}
// Fallback for when auth service is not available
if (!isset($_SESSION['csrf_token'])) {
$_SESSION['csrf_token'] = bin2hex(random_bytes(32));
}
return $_SESSION['csrf_token'];
}
protected function verifyCSRFToken(string $token): bool
{
if ($this->auth && method_exists($this->auth, 'verifyCSRFToken')) {
return $this->auth->verifyCSRFToken($token);
}
// Fallback for when auth service is not available
return isset($_SESSION['csrf_token']) && $_SESSION['csrf_token'] === $token;
}
protected function getRoutePath(string $routeName, array $data = [], array $queryParams = []): string
{
// Simple implementation matching the path_for function in templates
$basePath = '';
// Handle common route patterns
switch ($routeName) {
case 'home':
$basePath = '/';
break;
case 'games.index':
$basePath = '/media/games';
break;
case 'games.show':
$basePath = '/media/games/' . ($data['game_key'] ?? '');
break;
case 'movies.index':
$basePath = '/media/movies';
break;
case 'tvshows.index':
$basePath = '/media/tv-shows';
break;
case 'music.index':
$basePath = '/media/music';
break;
case 'admin.index':
$basePath = '/admin';
break;
case 'admin.playnite.import':
$basePath = '/admin/playnite/import';
break;
case 'admin.playnite.upload':
$basePath = '/admin/playnite/import';
break;
case 'admin.settings':
$basePath = '/admin/settings';
break;
case 'admin.sources':
$basePath = '/admin/sources';
break;
case 'admin.sync':
$basePath = '/admin/sync/' . ($data['id'] ?? '');
break;
case 'auth.login':
$basePath = '/login';
break;
case 'auth.logout':
$basePath = '/logout';
break;
case 'movies.show':
$basePath = '/media/movies/' . ($data['id'] ?? '');
break;
case 'tvshows.show':
$basePath = '/media/tv-shows/' . ($data['id'] ?? '');
break;
case 'music.show':
$basePath = '/media/music/' . ($data['id'] ?? '');
break;
case 'adult.index':
$basePath = '/media/adult';
break;
case 'adult.show':
$basePath = '/media/adult/' . ($data['id'] ?? '');
break;
case 'actors.index':
$basePath = '/media/actors';
break;
case 'actors.show':
$basePath = '/media/actors/' . ($data['id'] ?? '');
break;
case 'search.index':
$basePath = '/search';
break;
default:
$basePath = '/' . str_replace('.', '/', $routeName);
}
// Add query parameters
if (!empty($queryParams)) {
$basePath .= '?' . http_build_query($queryParams);
}
return $basePath;
}
} }

View File

@@ -0,0 +1,239 @@
<?php
namespace App\Controllers;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use App\Services\PlayniteImportService;
use Slim\Views\Twig;
class PlayniteImportController extends Controller
{
private \PDO $pdo;
private PlayniteImportService $importService;
protected $auth;
public function __construct(\PDO $pdo, Twig $view, $auth = null)
{
parent::__construct($view, $auth);
$this->pdo = $pdo;
$this->importService = new PlayniteImportService($pdo);
$this->auth = $auth;
}
/**
* Show the import form
*/
public function showImport(Request $request, Response $response, $args)
{
return $this->view->render($response, 'admin/playnite/import.twig', [
'title' => 'Import Playnite Games',
'csrf_token' => $this->generateCSRFToken()
]);
}
/**
* Handle file upload and preview
*/
public function upload(Request $request, Response $response, $args)
{
$data = $request->getParsedBody();
$csrfToken = $data['csrf_token'] ?? '';
// Verify CSRF token
if (!$this->verifyCSRFToken($csrfToken)) {
return $this->view->render($response->withStatus(400), 'admin/playnite/import.twig', [
'title' => 'Import Playnite Games',
'error' => 'Invalid CSRF token',
'csrf_token' => $this->generateCSRFToken()
]);
}
$uploadedFiles = $request->getUploadedFiles();
if (empty($uploadedFiles['playnite_file'])) {
return $this->view->render($response->withStatus(400), 'admin/playnite/import.twig', [
'title' => 'Import Playnite Games',
'error' => 'No file uploaded',
'csrf_token' => $this->generateCSRFToken()
]);
}
$file = $uploadedFiles['playnite_file'];
// Validate file
if ($file->getError() !== UPLOAD_ERR_OK) {
return $this->view->render($response->withStatus(400), 'admin/playnite/import.twig', [
'title' => 'Import Playnite Games',
'error' => 'Upload error: ' . $this->getUploadErrorMessage($file->getError()),
'csrf_token' => $this->generateCSRFToken()
]);
}
// Check file type
$filename = $file->getClientFilename();
$extension = strtolower(pathinfo($filename, PATHINFO_EXTENSION));
if (!in_array($extension, ['json'])) {
return $this->view->render($response->withStatus(400), 'admin/playnite/import.twig', [
'title' => 'Import Playnite Games',
'error' => 'Only JSON files are supported',
'csrf_token' => $this->generateCSRFToken()
]);
}
// Move uploaded file to temp location
$tempPath = sys_get_temp_dir() . '/playnite_import_' . uniqid() . '.json';
$file->moveTo($tempPath);
try {
// Parse and validate the file
$result = $this->importService->parsePlayniteFile($tempPath);
// Store the temp file path and results in session for the confirmation step
$_SESSION['playnite_import'] = [
'temp_file' => $tempPath,
'preview_data' => $result
];
return $this->view->render($response, 'admin/playnite/preview.twig', [
'title' => 'Preview Playnite Import',
'preview' => $result,
'filename' => $filename
]);
} catch (\Exception $e) {
// Clean up temp file
if (file_exists($tempPath)) {
unlink($tempPath);
}
return $this->view->render($response->withStatus(400), 'admin/playnite/import.twig', [
'title' => 'Import Playnite Games',
'error' => 'Error parsing file: ' . $e->getMessage(),
'csrf_token' => $this->generateCSRFToken()
]);
}
}
/**
* Confirm and execute the import
*/
public function confirm(Request $request, Response $response, $args)
{
if (!isset($_SESSION['playnite_import'])) {
return $response->withRedirect($this->getRoutePath('admin.playnite.import'));
}
$importData = $_SESSION['playnite_import'];
$tempPath = $importData['temp_file'];
$previewData = $importData['preview_data'];
// Get import options from form
$queryParams = $request->getQueryParams();
$updateExisting = ($queryParams['update_existing'] ?? 'false') === 'true';
try {
// Execute the import
$importResult = $this->importService->importGames($previewData['games'], $updateExisting);
// Clean up temp file
if (file_exists($tempPath)) {
unlink($tempPath);
}
// Clear session data
unset($_SESSION['playnite_import']);
return $this->view->render($response, 'admin/playnite/result.twig', [
'title' => 'Import Complete',
'import_result' => $importResult,
'preview_data' => $previewData
]);
} catch (\Exception $e) {
// Clean up temp file
if (file_exists($tempPath)) {
unlink($tempPath);
}
// Clear session data
unset($_SESSION['playnite_import']);
return $this->view->render($response->withStatus(500), 'admin/playnite/import.twig', [
'title' => 'Import Playnite Games',
'error' => 'Import failed: ' . $e->getMessage(),
'csrf_token' => $this->generateCSRFToken()
]);
}
}
/**
* Cancel the import (cleanup)
*/
public function cancel(Request $request, Response $response, $args)
{
if (isset($_SESSION['playnite_import'])) {
$tempPath = $_SESSION['playnite_import']['temp_file'];
if (file_exists($tempPath)) {
unlink($tempPath);
}
unset($_SESSION['playnite_import']);
}
return $response->withRedirect($this->getRoutePath('admin.playnite.import'));
}
/**
* API endpoint for programmatic imports
*/
public function apiImport(Request $request, Response $response, $args)
{
$data = $request->getParsedBody();
if (!isset($data['games']) || !is_array($data['games'])) {
return $this->jsonResponse($response->withStatus(400), [
'error' => 'Games data is required'
]);
}
try {
$importResult = $this->importService->importGames($data['games'], $data['update_existing'] ?? true);
return $this->jsonResponse($response, [
'success' => true,
'result' => $importResult
]);
} catch (\Exception $e) {
return $this->jsonResponse($response->withStatus(500), [
'error' => $e->getMessage()
]);
}
}
/**
* Get upload error message
*/
private function getUploadErrorMessage(int $errorCode): string
{
switch ($errorCode) {
case UPLOAD_ERR_INI_SIZE:
return 'File too large (exceeds server limit)';
case UPLOAD_ERR_FORM_SIZE:
return 'File too large (exceeds form limit)';
case UPLOAD_ERR_PARTIAL:
return 'File only partially uploaded';
case UPLOAD_ERR_NO_FILE:
return 'No file uploaded';
case UPLOAD_ERR_NO_TMP_DIR:
return 'No temporary directory';
case UPLOAD_ERR_CANT_WRITE:
return 'Cannot write to disk';
case UPLOAD_ERR_EXTENSION:
return 'File upload stopped by extension';
default:
return 'Unknown upload error';
}
}
}

View File

@@ -25,9 +25,27 @@ class Game extends Model
'is_favorite', 'is_favorite',
'metadata', 'metadata',
'platform_achievements', 'platform_achievements',
'platform_stats', 'background_image',
'source_id', 'cover_image',
'last_played_at' 'icon',
'genres_json',
'developers_json',
'publishers_json',
'tags_json',
'features_json',
'links_json',
'series_json',
'age_ratings_json',
'play_count',
'install_size',
'completion_status',
'critic_score',
'community_score',
'user_score',
'is_custom_game',
'installation_status',
'added_at',
'modified_at'
]; ];
protected array $casts = [ protected array $casts = [
@@ -39,7 +57,23 @@ class Game extends Model
'release_date' => 'date', 'release_date' => 'date',
'last_played_at' => 'datetime', 'last_played_at' => 'datetime',
'platform_achievements' => 'array', 'platform_achievements' => 'array',
'platform_stats' => 'array' 'critic_score' => 'int',
'community_score' => 'int',
'user_score' => 'int',
'play_count' => 'int',
'install_size' => 'int',
'installation_status' => 'int',
'is_custom_game' => 'bool',
'added_at' => 'datetime',
'modified_at' => 'datetime',
'genres_json' => 'array',
'developers_json' => 'array',
'publishers_json' => 'array',
'tags_json' => 'array',
'features_json' => 'array',
'links_json' => 'array',
'series_json' => 'array',
'age_ratings_json' => 'array'
]; ];
public function source() public function source()
@@ -295,4 +329,110 @@ class Game extends Model
return $games; return $games;
} }
/**
* Get Playnite-specific genres
*/
public function getGenres(): array
{
return $this->genres_json ?? [];
} }
/**
* Get Playnite-specific developers
*/
public function getDevelopers(): array
{
return $this->developers_json ?? [];
}
/**
* Get Playnite-specific publishers
*/
public function getPublishers(): array
{
return $this->publishers_json ?? [];
}
/**
* Get Playnite-specific tags
*/
public function getTags(): array
{
return $this->tags_json ?? [];
}
/**
* Get Playnite-specific features
*/
public function getFeatures(): array
{
return $this->features_json ?? [];
}
/**
* Get Playnite-specific links
*/
public function getLinks(): array
{
return $this->links_json ?? [];
}
/**
* Get Playnite-specific series
*/
public function getSeries(): array
{
return $this->series_json ?? [];
}
/**
* Get Playnite-specific age ratings
*/
public function getAgeRatings(): array
{
return $this->age_ratings_json ?? [];
}
/**
* Get formatted install size
*/
public function getFormattedInstallSize(): string
{
if (!$this->install_size) {
return 'Unknown';
}
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
$bytes = $this->install_size;
$i = 0;
while ($bytes >= 1024 && $i < count($units) - 1) {
$bytes /= 1024;
$i++;
}
return round($bytes, 2) . ' ' . $units[$i];
}
/**
* Get Steam store URL if available
*/
public function getSteamUrl(): ?string
{
if (!$this->steam_app_id) {
return null;
}
return "https://store.steampowered.com/app/{$this->steam_app_id}";
}
/**
* Check if game has rich Playnite data
*/
public function hasPlayniteData(): bool
{
return !empty($this->genres_json) || !empty($this->tags_json) ||
!empty($this->links_json) || !empty($this->background_image);
}
}

View File

@@ -37,19 +37,32 @@ class TvShow extends Model
]; ];
/** /**
* Get all actors associated with this TV show * Remove an actor from this TV show
*/ */
public function actors() public function removeActor(int $actorId): bool
{ {
$stmt = $this->pdo->prepare(" $stmt = $this->pdo->prepare("
SELECT a.* DELETE FROM actor_tv_show
FROM actors a WHERE tv_show_id = :tv_show_id AND actor_id = :actor_id
JOIN actor_tv_show ats ON a.id = ats.actor_id
WHERE ats.tv_show_id = :tv_show_id
ORDER BY a.name ASC
"); ");
$stmt->execute(['tv_show_id' => $this->id]); return $stmt->execute([
return $stmt->fetchAll(\PDO::FETCH_ASSOC); 'tv_show_id' => $this->id,
'actor_id' => $actorId
]);
}
/**
* Update the cast field with actor names
*/
public function updateCastField(): bool
{
$actors = $this->actors();
$actorNames = array_column($actors, 'name');
$castString = implode(', ', $actorNames);
return $this->update($this->id, [
'cast' => $castString
]);
} }
/** /**
@@ -152,30 +165,46 @@ class TvShow extends Model
public function getSeasonsWithEpisodes(): array public function getSeasonsWithEpisodes(): array
{ {
// Get all episodes for this TV show, grouped by season
$stmt = $this->pdo->prepare(" $stmt = $this->pdo->prepare("
SELECT s.*, SELECT season_number,
COUNT(e.id) as episode_count, COUNT(*) as episode_count,
SUM(CASE WHEN e.watched = 1 THEN 1 ELSE 0 END) as watched_episodes SUM(CASE WHEN watched = 1 THEN 1 ELSE 0 END) as watched_episodes
FROM seasons s FROM tv_episodes
LEFT JOIN episodes e ON s.id = e.season_id WHERE tv_show_id = :tv_show_id
WHERE s.tv_show_id = :tv_show_id GROUP BY season_number
GROUP BY s.id ORDER BY season_number ASC
ORDER BY s.season_number ASC
"); ");
$stmt->execute(['tv_show_id' => $this->id]); $stmt->execute(['tv_show_id' => $this->id]);
$seasons = $stmt->fetchAll(\PDO::FETCH_ASSOC); $seasonStats = $stmt->fetchAll(\PDO::FETCH_ASSOC);
// Get episodes for each season $seasons = [];
foreach ($seasons as &$season) {
// For each season, get the episodes and create a season object
foreach ($seasonStats as $stat) {
$seasonNumber = $stat['season_number'];
// Get episodes for this season
$stmt = $this->pdo->prepare(" $stmt = $this->pdo->prepare("
SELECT e.*, SELECT e.*
(SELECT COUNT(*) FROM user_episodes WHERE episode_id = e.id AND watched = 1) as watch_count FROM tv_episodes e
FROM episodes e WHERE e.tv_show_id = :tv_show_id AND e.season_number = :season_number
WHERE e.season_id = :season_id
ORDER BY e.episode_number ASC ORDER BY e.episode_number ASC
"); ");
$stmt->execute(['season_id' => $season['id']]); $stmt->execute([
$season['episodes'] = $stmt->fetchAll(\PDO::FETCH_ASSOC); 'tv_show_id' => $this->id,
'season_number' => $seasonNumber
]);
$episodes = $stmt->fetchAll(\PDO::FETCH_ASSOC);
// Create a season object (simulating the old seasons table structure)
$seasons[] = [
'id' => null, // No seasons table, so no ID
'season_number' => $seasonNumber,
'episode_count' => (int)$stat['episode_count'],
'watched_episodes' => (int)$stat['watched_episodes'],
'episodes' => $episodes
];
} }
return $seasons; return $seasons;

View File

@@ -0,0 +1,374 @@
<?php
namespace App\Services;
use App\Models\Game;
use App\Models\Source;
class PlayniteImportService
{
private \PDO $pdo;
public function __construct(\PDO $pdo)
{
$this->pdo = $pdo;
}
/**
* Parse and validate a Playnite export file
*/
public function parsePlayniteFile(string $filePath): array
{
if (!file_exists($filePath)) {
throw new \Exception("Playnite export file not found: {$filePath}");
}
$jsonContent = file_get_contents($filePath);
if ($jsonContent === false) {
throw new \Exception("Failed to read Playnite export file: {$filePath}");
}
$games = json_decode($jsonContent, true);
if (json_last_error() !== JSON_ERROR_NONE) {
throw new \Exception("Invalid JSON in Playnite export file: " . json_last_error_msg());
}
if (!is_array($games)) {
throw new \Exception("Playnite export file must contain an array of games");
}
return $this->validateAndTransformGames($games);
}
/**
* Validate and transform Playnite games data
*/
private function validateAndTransformGames(array $games): array
{
$transformedGames = [];
$errors = [];
$warnings = [];
foreach ($games as $index => $game) {
try {
$transformedGame = $this->transformPlayniteGame($game, $index + 1);
if ($transformedGame) {
$transformedGames[] = $transformedGame;
}
} catch (\Exception $e) {
$errors[] = "Game at index {$index}: " . $e->getMessage();
}
}
return [
'games' => $transformedGames,
'errors' => $errors,
'warnings' => $warnings,
'total' => count($games),
'valid' => count($transformedGames),
'invalid' => count($errors)
];
}
/**
* Transform a single Playnite game to our internal format
*/
private function transformPlayniteGame(array $game, int $index): array
{
// Validate required fields
if (empty($game['Name'])) {
throw new \Exception("Missing game name");
}
if (empty($game['GameId'])) {
throw new \Exception("Missing GameId");
}
// Find or create source
$source = $this->findOrCreateSource($game);
// Transform the game data
$transformed = [
'title' => $game['Name'],
'game_key' => $this->generateGameKey($game['Name'], $this->extractPlatformFromPlaynite($game)),
'description' => $this->cleanHtml($game['Description'] ?? ''),
'platform_game_id' => $game['GameId'],
'platform' => $this->extractPlatformFromPlaynite($game),
'source_id' => $source['id'],
// Rich media
'background_image' => $game['BackgroundImage'] ?? null,
'cover_image' => $game['CoverImage'] ?? null,
'icon' => $game['Icon'] ?? null,
// Multiple entities as JSON
'genres_json' => json_encode($game['Genres'] ?? []),
'developers_json' => json_encode($game['Developers'] ?? []),
'publishers_json' => json_encode($game['Publishers'] ?? []),
'tags_json' => json_encode($game['Tags'] ?? []),
'features_json' => json_encode($game['Features'] ?? []),
'links_json' => json_encode($game['Links'] ?? []),
'series_json' => json_encode($game['Series'] ?? []),
'age_ratings_json' => json_encode($game['AgeRatings'] ?? []),
// Play statistics
'playtime_minutes' => $this->parsePlaytime($game['Playtime'] ?? 0),
'play_count' => $game['PlayCount'] ?? 0,
'install_size' => $this->parseInstallSize($game['InstallSize'] ?? null),
'completion_status' => $game['CompletionStatus']['Name'] ?? null,
// Enhanced ratings
'rating' => $this->normalizeRating($game['CriticScore'] ?? null),
'critic_score' => $game['CriticScore'] ?? null,
'community_score' => $game['CommunityScore'] ?? null,
'user_score' => $game['UserScore'] ?? null,
// Legacy single-value fields (take first from arrays if available)
'genre' => $this->getFirstItemName($game['Genres'] ?? []),
'developer' => $this->getFirstItemName($game['Developers'] ?? []),
'publisher' => $this->getFirstItemName($game['Publishers'] ?? []),
// Platform-specific data
'steam_app_id' => $this->extractSteamAppId($game),
// Playnite-specific metadata
'is_installed' => $game['IsInstalled'] ?? false,
'is_favorite' => $game['Favorite'] ?? false,
'is_custom_game' => $game['IsCustomGame'] ?? false,
'installation_status' => $game['InstallationStatus'] ?? 0,
// Timestamps
'added_at' => isset($game['Added']) ? date('Y-m-d H:i:s', strtotime($game['Added'])) : null,
'modified_at' => isset($game['Modified']) ? date('Y-m-d H:i:s', strtotime($game['Modified'])) : null,
'last_played_at' => isset($game['LastActivity']) ? date('Y-m-d H:i:s', strtotime($game['LastActivity'])) : null,
'release_date' => isset($game['ReleaseDate']['ReleaseDate']) ? date('Y-m-d', strtotime($game['ReleaseDate']['ReleaseDate'])) : null,
// Playnite metadata
'metadata' => json_encode([
'playnite_id' => $game['Id'] ?? null,
'version' => $game['Version'] ?? null,
'hidden' => $game['Hidden'] ?? false,
'notes' => $game['Notes'] ?? null,
'manual' => $game['Manual'] ?? null,
'pre_script' => $game['PreScript'] ?? null,
'post_script' => $game['PostScript'] ?? null,
'game_started_script' => $game['GameStartedScript'] ?? null,
'use_global_scripts' => [
'pre' => $game['UseGlobalPreScript'] ?? true,
'post' => $game['UseGlobalPostScript'] ?? true,
'game_started' => $game['UseGlobalGameStartedScript'] ?? true
]
])
];
return $transformed;
}
/**
* Find or create a source for the game
*/
private function findOrCreateSource(array $game): array
{
$sourceName = $game['Source']['Name'] ?? 'Playnite';
$sourceId = $game['Source']['Id'] ?? null;
// Try to find existing source
$stmt = $this->pdo->prepare("SELECT id, display_name FROM sources WHERE display_name = :name OR id = :source_id");
$stmt->execute([
'name' => $sourceName,
'source_id' => $sourceId
]);
$source = $stmt->fetch(\PDO::FETCH_ASSOC);
if (!$source) {
// Create new source
$stmt = $this->pdo->prepare("INSERT INTO sources (display_name, created_at, updated_at) VALUES (:name, NOW(), NOW())");
$stmt->execute(['name' => $sourceName]);
$source = ['id' => $this->pdo->lastInsertId(), 'display_name' => $sourceName];
}
return $source;
}
/**
* Generate a consistent game key for grouping
*/
private function generateGameKey(string $title): string
{
return Game::generateGameKey($title);
}
/**
* Extract platform from Playnite data
*/
private function extractPlatformFromPlaynite(array $game): string
{
if (isset($game['Platforms']) && is_array($game['Platforms'])) {
$platformNames = array_map(function($platform) {
return $platform['Name'] ?? 'Unknown';
}, $game['Platforms']);
return implode(', ', $platformNames);
}
return 'PC'; // Default platform
}
/**
* Extract Steam App ID from game links or metadata
*/
private function extractSteamAppId(array $game): ?string
{
if (isset($game['Links']) && is_array($game['Links'])) {
foreach ($game['Links'] as $link) {
if (isset($link['Name']) && strtolower($link['Name']) === 'steam' &&
preg_match('/\/app\/(\d+)/', $link['Url'], $matches)) {
return $matches[1];
}
}
}
return null;
}
/**
* Parse playtime from Playnite format (usually in seconds)
*/
private function parsePlaytime($playtime): int
{
if (is_numeric($playtime)) {
return (int)($playtime / 60); // Convert seconds to minutes
}
return 0;
}
/**
* Parse install size
*/
private function parseInstallSize($installSize): ?int
{
if (is_numeric($installSize)) {
return (int)$installSize;
}
return null;
}
/**
* Normalize rating to 0-10 scale
*/
private function normalizeRating($rating): ?float
{
if (is_numeric($rating)) {
$rating = (float)$rating;
// If rating is 0-100 scale, convert to 0-10
if ($rating > 10) {
return $rating / 10;
}
return $rating;
}
return null;
}
/**
* Clean HTML from description
*/
private function cleanHtml(?string $html): ?string
{
if (!$html) {
return null;
}
// Remove HTML tags but keep basic formatting
$text = strip_tags($html);
// Decode HTML entities
$text = html_entity_decode($text, ENT_QUOTES, 'UTF-8');
// Clean up extra whitespace
$text = preg_replace('/\s+/', ' ', $text);
return trim($text);
}
/**
* Get first item name from an array of objects
*/
private function getFirstItemName(array $items): ?string
{
if (empty($items)) {
return null;
}
$first = reset($items);
return $first['Name'] ?? null;
}
/**
* Import games to database
*/
public function importGames(array $games, bool $updateExisting = true): array
{
$results = [
'imported' => 0,
'updated' => 0,
'skipped' => 0,
'errors' => []
];
foreach ($games as $gameData) {
try {
$existingGame = $this->findExistingGame($gameData);
if ($existingGame && $updateExisting) {
$this->updateGame($existingGame['id'], $gameData);
$results['updated']++;
} elseif (!$existingGame) {
$this->insertGame($gameData);
$results['imported']++;
} else {
$results['skipped']++;
}
} catch (\Exception $e) {
$results['errors'][] = "Failed to import {$gameData['title']}: " . $e->getMessage();
}
}
return $results;
}
/**
* Find existing game by platform_game_id and source_id
*/
private function findExistingGame(array $gameData): ?array
{
$stmt = $this->pdo->prepare("
SELECT id, title, platform_game_id, source_id
FROM games
WHERE platform_game_id = :platform_game_id AND source_id = :source_id
");
$stmt->execute([
'platform_game_id' => $gameData['platform_game_id'],
'source_id' => $gameData['source_id']
]);
return $stmt->fetch(\PDO::FETCH_ASSOC) ?: null;
}
/**
* Insert new game
*/
private function insertGame(array $gameData): void
{
// Use the Game model's create method which respects fillable fields
$gameModel = new Game($this->pdo);
$gameModel->create($gameData);
}
/**
* Update existing game
*/
private function updateGame(int $gameId, array $gameData): void
{
// Use the Game model's update method which respects fillable fields
$gameModel = new Game($this->pdo);
$gameModel->update($gameId, $gameData);
}
}

View File

@@ -0,0 +1,80 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use App\Database\Database;
class AddPlayniteFieldsToGamesTable extends Migration
{
public function up()
{
Database::getCapsule()->schema()->table('games', function ($table) {
// Rich media fields
$table->string('background_image')->nullable()->after('banner_url');
$table->string('cover_image')->nullable()->after('background_image');
$table->string('icon')->nullable()->after('cover_image');
// Multiple entities as JSON (to handle arrays of objects from Playnite)
$table->json('genres_json')->nullable()->after('genre');
$table->json('developers_json')->nullable()->after('developer');
$table->json('publishers_json')->nullable()->after('publisher');
$table->json('tags_json')->nullable()->after('genres_json');
$table->json('features_json')->nullable()->after('tags_json');
$table->json('links_json')->nullable()->after('features_json');
$table->json('series_json')->nullable()->after('links_json');
$table->json('age_ratings_json')->nullable()->after('series_json');
// Playnite-specific statistics
$table->integer('play_count')->default(0)->after('playtime_minutes');
$table->bigInteger('install_size')->nullable()->after('play_count');
$table->string('completion_status')->nullable()->after('completion_percentage');
// Enhanced ratings (from Playnite)
$table->integer('critic_score')->nullable()->after('rating');
$table->integer('community_score')->nullable()->after('critic_score');
$table->integer('user_score')->nullable()->after('community_score');
// Platform-specific identifiers from Playnite
//$table->string('platform_game_id')->nullable()->after('steam_app_id');
// Playnite-specific metadata
$table->timestamp('added_at')->nullable()->after('last_played_at');
$table->timestamp('modified_at')->nullable()->after('added_at');
$table->boolean('is_custom_game')->default(false)->after('is_favorite');
$table->integer('installation_status')->default(0)->after('is_installed');
// Legacy field removal (keeping for backward compatibility)
// These will be replaced by the JSON fields above
});
}
public function down()
{
Database::getCapsule()->schema()->table('games', function ($table) {
$table->dropColumn([
'background_image',
'cover_image',
'icon',
'genres_json',
'developers_json',
'publishers_json',
'tags_json',
'features_json',
'links_json',
'series_json',
'age_ratings_json',
'play_count',
'install_size',
'completion_status',
'critic_score',
'community_score',
'user_score',
'platform_game_id',
'added_at',
'modified_at',
'is_custom_game',
'installation_status'
]);
});
}
}

View File

@@ -0,0 +1,37 @@
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use App\Database\Database;
class CreateImportLogsTable extends Migration
{
public function up()
{
Database::getCapsule()->schema()->create('import_logs', function ($table) {
$table->id();
$table->string('import_type'); // 'playnite', 'csv', etc.
$table->enum('status', ['started', 'running', 'completed', 'failed'])->default('started');
$table->integer('total_items')->default(0);
$table->integer('processed_items')->default(0);
$table->integer('imported_items')->default(0);
$table->integer('updated_items')->default(0);
$table->integer('skipped_items')->default(0);
$table->json('errors')->nullable();
$table->text('message')->nullable();
$table->json('file_info')->nullable(); // File name, size, etc.
$table->string('log_file_path')->nullable(); // Path to detailed log file
$table->timestamp('started_at')->nullable();
$table->timestamp('completed_at')->nullable();
$table->timestamps();
$table->index(['import_type', 'status']);
$table->index(['created_at']);
});
}
public function down()
{
Database::getCapsule()->schema()->dropIfExists('import_logs');
}
}

View File

@@ -89,11 +89,11 @@ $container->set('view', function () use ($container) {
case 'admin.index': case 'admin.index':
$basePath = '/admin'; $basePath = '/admin';
break; break;
case 'admin.settings': case 'admin.playnite.import':
$basePath = '/admin/settings'; $basePath = '/admin/playnite/import';
break; break;
case 'admin.sources': case 'admin.playnite.upload':
$basePath = '/admin/sources'; $basePath = '/admin/playnite/import';
break; break;
case 'admin.sync': case 'admin.sync':
$basePath = '/admin/sync/' . ($data['id'] ?? ''); $basePath = '/admin/sync/' . ($data['id'] ?? '');
@@ -182,6 +182,21 @@ $container->set('view', function () use ($container) {
return $decoded === null ? null : $decoded; return $decoded === null ? null : $decoded;
})); }));
$twig->getEnvironment()->addFilter(new TwigFilter('filesizeformat', function ($bytes) {
if (!$bytes || !is_numeric($bytes)) {
return '0 B';
}
$units = ['B', 'KB', 'MB', 'GB', 'TB'];
$bytes = max($bytes, 0);
$pow = floor(($bytes ? log($bytes) : 0) / log(1024));
$pow = min($pow, count($units) - 1);
$bytes /= pow(1024, $pow);
return round($bytes, 2) . ' ' . $units[$pow];
}));
return $twig; return $twig;
}); });
@@ -248,6 +263,20 @@ $container->set(\App\Controllers\SettingsController::class, function ($c) {
return new \App\Controllers\SettingsController($c->get(PDO::class), $c->get('view')); return new \App\Controllers\SettingsController($c->get(PDO::class), $c->get('view'));
}); });
// Register PlayniteImportController
$container->set(\App\Controllers\PlayniteImportController::class, function ($c) {
return new \App\Controllers\PlayniteImportController(
$c->get(PDO::class),
$c->get('view'),
$c->get(\App\Services\AuthService::class)
);
});
// Register PlayniteImportService
$container->set(\App\Services\PlayniteImportService::class, function ($c) {
return new \App\Services\PlayniteImportService($c->get(PDO::class));
});
// Register middleware // Register middleware
$container->set(\App\Http\Middleware\AuthMiddleware::class, function ($c) { $container->set(\App\Http\Middleware\AuthMiddleware::class, function ($c) {
return new \App\Http\Middleware\AuthMiddleware($c->get(\App\Services\AuthService::class)); return new \App\Http\Middleware\AuthMiddleware($c->get(\App\Services\AuthService::class));

View File

@@ -254,6 +254,12 @@
<span>Sync Media</span> <span>Sync Media</span>
</a> </a>
</li> </li>
<li class="nav-item">
<a class="nav-link" href="{{ path_for('admin.playnite.import') }}">
<i class="bi bi-upload"></i>
<span>Playnite Import</span>
</a>
</li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="{{ path_for('home') }}" target="_blank"> <a class="nav-link" href="{{ path_for('home') }}" target="_blank">
<i bi bi-house-door"></i> <i bi bi-house-door"></i>

View File

@@ -0,0 +1,190 @@
{% extends "admin/layout.twig" %}
{% block content %}
<div class="px-4 py-6 sm:px-6 lg:px-8">
<div class="sm:flex sm:items-center">
<div class="sm:flex-auto">
<h1 class="text-2xl font-semibold text-gray-900">Import Playnite Games</h1>
<p class="mt-2 text-sm text-gray-700">
Import games from Playnite export files. Playnite is a game library management application that can export your game library to JSON format.
</p>
</div>
</div>
{% if error %}
<div class="mt-6 rounded-md bg-red-50 p-4">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-red-400" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd" />
</svg>
</div>
<div class="ml-3">
<h3 class="text-sm font-medium text-red-800">Import Error</h3>
<div class="mt-2 text-sm text-red-700">
<p>{{ error }}</p>
</div>
</div>
</div>
</div>
{% endif %}
<div class="mt-8 bg-white shadow rounded-lg">
<div class="px-6 py-6">
<div class="space-y-6">
<!-- Import Instructions -->
<div class="bg-blue-50 border border-blue-200 rounded-md p-4">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-blue-400" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd" />
</svg>
</div>
<div class="ml-3">
<h3 class="text-sm font-medium text-blue-800">How to Export from Playnite</h3>
<div class="mt-2 text-sm text-blue-700">
<ol class="list-decimal list-inside space-y-1">
<li>Open Playnite and go to Library → Export Library</li>
<li>Choose "JSON" as the export format</li>
<li>Select the games you want to export (or export all)</li>
<li>Save the JSON file to your computer</li>
<li>Upload the file using the form below</li>
</ol>
</div>
</div>
</div>
</div>
<!-- Upload Form -->
<form action="{{ path_for('admin.playnite.upload') }}" method="post" enctype="multipart/form-data" class="space-y-6">
<input type="hidden" name="csrf_token" value="{{ csrf_token }}">
<div>
<label for="playnite_file" class="block text-sm font-medium text-gray-700">
Playnite Export File
</label>
<div class="mt-1 flex justify-center px-6 pt-5 pb-6 border-2 border-gray-300 border-dashed rounded-md">
<div class="space-y-1 text-center">
<svg class="mx-auto h-12 w-12 text-gray-400" stroke="currentColor" fill="none" viewBox="0 0 48 48">
<path d="M28 8H12a4 4 0 00-4 4v20m32-12v8m0 0v8a4 4 0 01-4 4H12a4 4 0 01-4-4v-4m32-4l-3.172-3.172a4 4 0 00-5.656 0L28 28M8 32l9.172-9.172a4 4 0 015.656 0L28 28m0 0l4 4m4-24h8m-4-4v8m-12 4h.02" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />
</svg>
<div class="flex text-sm text-gray-600">
<label for="playnite_file" class="relative cursor-pointer bg-white rounded-md font-medium text-indigo-600 hover:text-indigo-500 focus-within:outline-none focus-within:ring-2 focus-within:ring-offset-2 focus-within:ring-indigo-500">
<span>Upload a file</span>
<input id="playnite_file" name="playnite_file" type="file" class="sr-only" accept=".json">
</label>
<p class="pl-1">or drag and drop</p>
</div>
<p class="text-xs text-gray-500">JSON files only</p>
</div>
</div>
</div>
<!-- Import Options -->
<div class="bg-gray-50 rounded-lg p-4">
<h3 class="text-sm font-medium text-gray-900 mb-3">Import Options</h3>
<div class="space-y-3">
<div class="flex items-start">
<div class="flex items-center h-5">
<input id="update_existing" name="update_existing" type="checkbox" class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded" checked>
</div>
<div class="ml-3 text-sm">
<label for="update_existing" class="font-medium text-gray-700">Update existing games</label>
<p class="text-gray-500">If a game with the same Playnite ID already exists, update it with the new data instead of creating a duplicate.</p>
</div>
</div>
</div>
</div>
<!-- Submit Button -->
<div class="flex justify-end space-x-3">
<a href="{{ path_for('admin.index') }}" class="bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Cancel
</a>
<button type="submit" class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Upload & Preview
</button>
</div>
</form>
</div>
</div>
</div>
<!-- Recent Imports -->
<div class="mt-8">
<h2 class="text-lg font-medium text-gray-900 mb-4">Recent Playnite Imports</h2>
<div class="bg-white shadow rounded-lg">
<div class="px-6 py-4">
<p class="text-sm text-gray-500">No recent imports found. Import history will appear here.</p>
</div>
</div>
</div>
</div>
<script>
// File upload preview
document.getElementById('playnite_file').addEventListener('change', function(e) {
const file = e.target.files[0];
if (file) {
const fileName = file.name;
const fileSize = (file.size / 1024 / 1024).toFixed(2) + ' MB';
// Update the UI to show file info without destroying the file input
const uploadArea = document.querySelector('.border-dashed');
const textElements = uploadArea.querySelectorAll('span, p');
// Update the text content instead of replacing HTML
if (textElements.length >= 2) {
textElements[0].textContent = fileName;
textElements[1].textContent = `${fileSize} - Ready to import`;
}
// Change the SVG to a success icon
const svg = uploadArea.querySelector('svg');
if (svg) {
svg.innerHTML = '<path d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" />';
svg.className = 'mx-auto h-12 w-12 text-green-400';
}
}
});
// Drag and drop functionality
const uploadArea = document.querySelector('.border-dashed');
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
uploadArea.addEventListener(eventName, preventDefaults, false);
document.body.addEventListener(eventName, preventDefaults, false);
});
['dragenter', 'dragover'].forEach(eventName => {
uploadArea.addEventListener(eventName, highlight, false);
});
['dragleave', 'drop'].forEach(eventName => {
uploadArea.addEventListener(eventName, unhighlight, false);
});
uploadArea.addEventListener('drop', handleDrop, false);
function preventDefaults(e) {
e.preventDefault();
e.stopPropagation();
}
function highlight(e) {
uploadArea.classList.add('border-indigo-500');
}
function unhighlight(e) {
uploadArea.classList.remove('border-indigo-500');
}
function handleDrop(e) {
const dt = e.dataTransfer;
const files = dt.files;
if (files.length > 0) {
document.getElementById('playnite_file').files = files;
document.getElementById('playnite_file').dispatchEvent(new Event('change'));
}
}
</script>
{% endblock %}

View File

@@ -0,0 +1,333 @@
{% extends "admin/layout.twig" %}
{% block content %}
<div class="px-4 py-6 sm:px-6 lg:px-8">
<div class="sm:flex sm:items-center">
<div class="sm:flex-auto">
<h1 class="text-2xl font-semibold text-gray-900">Preview Playnite Import</h1>
<p class="mt-2 text-sm text-gray-700">
Review the games that will be imported from "{{ filename }}". Check the details below and click "Import Games" to proceed.
</p>
</div>
<div class="mt-4 sm:mt-0 sm:ml-16 sm:flex-none">
<a href="{{ path_for('admin.playnite.import') }}" class="inline-flex items-center justify-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">
← Back to Import
</a>
</div>
</div>
<!-- Import Summary -->
<div class="mt-8 bg-white shadow rounded-lg">
<div class="px-6 py-4 border-b border-gray-200">
<h3 class="text-lg font-medium text-gray-900">Import Summary</h3>
</div>
<div class="px-6 py-4">
<dl class="grid grid-cols-1 gap-x-4 gap-y-6 sm:grid-cols-4">
<div>
<dt class="text-sm font-medium text-gray-500">Total Games</dt>
<dd class="mt-1 text-2xl font-semibold text-gray-900">{{ preview.total }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Valid Games</dt>
<dd class="mt-1 text-2xl font-semibold text-green-600">{{ preview.valid }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Invalid Games</dt>
<dd class="mt-1 text-2xl font-semibold text-red-600">{{ preview.invalid }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Sources</dt>
<dd class="mt-1 text-2xl font-semibold text-gray-900">{{ preview.games|length > 0 ? (preview.games|first).source_name : 'N/A' }}</dd>
</div>
</dl>
</div>
</div>
{% if preview.errors %}
<!-- Import Errors -->
<div class="mt-6 bg-red-50 border border-red-200 rounded-md">
<div class="px-6 py-4">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-red-400" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd" />
</svg>
</div>
<div class="ml-3">
<h3 class="text-sm font-medium text-red-800">Import Errors</h3>
<div class="mt-2 text-sm text-red-700">
<ul class="space-y-1">
{% for error in preview.errors %}
<li>{{ error }}</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
</div>
{% endif %}
<!-- Games Preview -->
<div class="mt-6 bg-white shadow rounded-lg">
<div class="px-6 py-4 border-b border-gray-200">
<div class="flex items-center justify-between">
<h3 class="text-lg font-medium text-gray-900">Games to Import</h3>
<div class="flex space-x-2">
<button type="button" onclick="toggleAllDetails()" class="inline-flex items-center px-3 py-1 border border-gray-300 shadow-sm text-sm leading-4 font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Toggle All Details
</button>
</div>
</div>
</div>
<div class="divide-y divide-gray-200">
{% for game in preview.games %}
<div class="px-6 py-4 game-item" data-game-index="{{ loop.index }}">
<div class="flex items-center justify-between">
<div class="flex items-center space-x-4">
{% if game.cover_image %}
<img class="h-16 w-16 rounded-lg object-cover" src="{{ game.cover_image }}" alt="{{ game.title }}">
{% else %}
<div class="h-16 w-16 rounded-lg bg-gray-200 flex items-center justify-center">
<svg class="h-8 w-8 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.828 14.828a4 4 0 01-5.656 0M9 10h1m4 0h1m-7 8h12a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"/>
</svg>
</div>
{% endif %}
<div>
<h4 class="text-lg font-medium text-gray-900">{{ game.title }}</h4>
<div class="flex items-center space-x-4 text-sm text-gray-500">
{% if game.genre %}
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
{{ game.genre }}
</span>
{% endif %}
{% if game.platform %}
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
{{ game.platform }}
</span>
{% endif %}
{% if game.release_date %}
<span>{{ game.release_date|date('Y') }}</span>
{% endif %}
</div>
</div>
</div>
<button type="button" onclick="toggleGameDetails('game-{{ loop.index }}')"
class="text-indigo-600 hover:text-indigo-900 text-sm font-medium">
Show Details
</button>
</div>
<!-- Game Details (hidden by default) -->
<div id="details-game-{{ loop.index }}" class="hidden mt-4 bg-gray-50 rounded-lg p-4">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<!-- Game Information -->
<div>
<h5 class="text-sm font-medium text-gray-900 mb-3">Game Information</h5>
<dl class="space-y-2">
{% if game.developer %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Developer:</dt>
<dd class="text-sm text-gray-900">{{ game.developer }}</dd>
</div>
{% endif %}
{% if game.publisher %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Publisher:</dt>
<dd class="text-sm text-gray-900">{{ game.publisher }}</dd>
</div>
{% endif %}
{% if game.release_date %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Release Date:</dt>
<dd class="text-sm text-gray-900">{{ game.release_date|date('M j, Y') }}</dd>
</div>
{% endif %}
{% if game.rating %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Rating:</dt>
<dd class="text-sm text-gray-900">{{ game.rating }}/10</dd>
</div>
{% endif %}
{% if game.playtime_minutes %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Playtime:</dt>
<dd class="text-sm text-gray-900">{{ (game.playtime_minutes / 60)|round(1) }} hours</dd>
</div>
{% endif %}
{% if game.critic_score %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Critic Score:</dt>
<dd class="text-sm text-gray-900">{{ game.critic_score }}%</dd>
</div>
{% endif %}
</dl>
</div>
<!-- Platform & Status -->
<div>
<h5 class="text-sm font-medium text-gray-900 mb-3">Platform & Status</h5>
<dl class="space-y-2">
{% if game.source_name %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Source:</dt>
<dd class="text-sm text-gray-900">{{ game.source_name }}</dd>
</div>
{% endif %}
{% if game.is_installed %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Status:</dt>
<dd class="text-sm">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
Installed
</span>
</dd>
</div>
{% endif %}
{% if game.is_favorite %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Favorite:</dt>
<dd class="text-sm">
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-red-100 text-red-800">
Yes
</span>
</dd>
</div>
{% endif %}
{% if game.completion_percentage > 0 %}
<div class="flex justify-between">
<dt class="text-sm text-gray-500">Completion:</dt>
<dd class="text-sm text-gray-900">{{ game.completion_percentage }}%</dd>
</div>
{% endif %}
</dl>
</div>
</div>
{% if game.description %}
<div class="mt-4">
<h5 class="text-sm font-medium text-gray-900 mb-2">Description</h5>
<p class="text-sm text-gray-600 line-clamp-3">{{ game.description|striptags|slice(0, 200) }}{% if game.description|length > 200 %}...{% endif %}</p>
</div>
{% endif %}
{% if game.genres_json %}
<div class="mt-4">
<h5 class="text-sm font-medium text-gray-900 mb-2">Genres</h5>
<div class="flex flex-wrap gap-1">
{% for genre in game.genres_json %}
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
{{ genre.Name }}
</span>
{% endfor %}
</div>
</div>
{% endif %}
{% if game.tags_json %}
<div class="mt-4">
<h5 class="text-sm font-medium text-gray-900 mb-2">Tags</h5>
<div class="flex flex-wrap gap-1">
{% for tag in game.tags_json|slice(0, 10) %}
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-gray-100 text-gray-800">
{{ tag.Name }}
</span>
{% endfor %}
{% if game.tags_json|length > 10 %}
<span class="text-xs text-gray-500">+{{ game.tags_json|length - 10 }} more</span>
{% endif %}
</div>
</div>
{% endif %}
</div>
</div>
{% endfor %}
</div>
</div>
<!-- Import Form -->
<div class="mt-6 bg-white shadow rounded-lg">
<div class="px-6 py-4 border-b border-gray-200">
<h3 class="text-lg font-medium text-gray-900">Confirm Import</h3>
</div>
<div class="px-6 py-4">
<form action="{{ path_for('admin.playnite.confirm') }}" method="post" class="space-y-4">
<div class="flex items-start">
<div class="flex items-center h-5">
<input id="update_existing" name="update_existing" type="checkbox" class="focus:ring-indigo-500 h-4 w-4 text-indigo-600 border-gray-300 rounded" checked>
</div>
<div class="ml-3 text-sm">
<label for="update_existing" class="font-medium text-gray-700">Update existing games</label>
<p class="text-gray-500">If a game with the same Playnite ID already exists, update it with the new data instead of creating a duplicate.</p>
</div>
</div>
<div class="flex justify-end space-x-3">
<a href="{{ path_for('admin.playnite.cancel') }}" class="bg-white py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Cancel
</a>
<button type="submit" class="inline-flex justify-center py-2 px-4 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Import {{ preview.valid }} Games
</button>
</div>
</form>
</div>
</div>
</div>
<script>
function toggleGameDetails(gameIndex) {
const details = document.getElementById('details-game-' + gameIndex);
const button = event.target;
if (details.classList.contains('hidden')) {
details.classList.remove('hidden');
button.textContent = 'Hide Details';
} else {
details.classList.add('hidden');
button.textContent = 'Show Details';
}
}
function toggleAllDetails() {
const gameItems = document.querySelectorAll('.game-item');
const allHidden = Array.from(gameItems).every(item => {
const index = item.dataset.gameIndex;
const details = document.getElementById('details-game-' + index);
return details.classList.contains('hidden');
});
gameItems.forEach(item => {
const index = item.dataset.gameIndex;
const details = document.getElementById('details-game-' + index);
const button = item.querySelector('button');
if (allHidden) {
details.classList.remove('hidden');
button.textContent = 'Hide Details';
} else {
details.classList.add('hidden');
button.textContent = 'Show Details';
}
});
}
// Show first game's details by default
document.addEventListener('DOMContentLoaded', function() {
const firstGameItem = document.querySelector('.game-item');
if (firstGameItem) {
const gameIndex = firstGameItem.dataset.gameIndex;
const details = document.getElementById('details-game-' + gameIndex);
if (details) {
details.classList.remove('hidden');
const button = firstGameItem.querySelector('button');
if (button) {
button.textContent = 'Hide Details';
}
}
}
});
</script>
{% endblock %}

View File

@@ -0,0 +1,292 @@
{% extends "admin/layout.twig" %}
{% block content %}
<div class="px-4 py-6 sm:px-6 lg:px-8">
<div class="sm:flex sm:items-center">
<div class="sm:flex-auto">
<h1 class="text-2xl font-semibold text-gray-900">Import Complete</h1>
<p class="mt-2 text-sm text-gray-700">
The Playnite import has been completed. Here's a summary of what was imported.
</p>
</div>
<div class="mt-4 sm:mt-0 sm:ml-16 sm:flex-none space-x-3">
<a href="{{ path_for('admin.playnite.import') }}" class="inline-flex items-center justify-center rounded-md border border-transparent bg-indigo-600 px-4 py-2 text-sm font-medium text-white shadow-sm hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">
Import More Games
</a>
<a href="{{ path_for('games.index') }}" class="inline-flex items-center justify-center rounded-md border border-gray-300 bg-white px-4 py-2 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-offset-2">
View Games
</a>
</div>
</div>
<!-- Import Results Summary -->
<div class="mt-8 bg-white shadow rounded-lg">
<div class="px-6 py-4 border-b border-gray-200">
<h3 class="text-lg font-medium text-gray-900">Import Results</h3>
</div>
<div class="px-6 py-4">
<dl class="grid grid-cols-1 gap-x-4 gap-y-6 sm:grid-cols-4">
<div>
<dt class="text-sm font-medium text-gray-500">Games Imported</dt>
<dd class="mt-1 text-2xl font-semibold text-green-600">{{ import_result.imported }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Games Updated</dt>
<dd class="mt-1 text-2xl font-semibold text-blue-600">{{ import_result.updated }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Games Skipped</dt>
<dd class="mt-1 text-2xl font-semibold text-gray-600">{{ import_result.skipped }}</dd>
</div>
<div>
<dt class="text-sm font-medium text-gray-500">Errors</dt>
<dd class="mt-1 text-2xl font-semibold text-red-600">{{ import_result.errors|length }}</dd>
</div>
</dl>
</div>
</div>
{% if import_result.errors %}
<!-- Import Errors -->
<div class="mt-6 bg-red-50 border border-red-200 rounded-md">
<div class="px-6 py-4">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-red-400" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd" />
</svg>
</div>
<div class="ml-3">
<h3 class="text-sm font-medium text-red-800">Import Errors</h3>
<div class="mt-2 text-sm text-red-700">
<p class="font-medium">The following games could not be imported:</p>
<ul class="mt-2 space-y-1">
{% for error in import_result.errors %}
<li class="flex items-start">
<span class="flex-shrink-0 w-1.5 h-1.5 bg-red-400 rounded-full mt-2 mr-2"></span>
{{ error }}
</li>
{% endfor %}
</ul>
</div>
</div>
</div>
</div>
</div>
{% endif %}
{% if import_result.imported > 0 or import_result.updated > 0 %}
<!-- Successfully Imported Games -->
<div class="mt-6 bg-white shadow rounded-lg">
<div class="px-6 py-4 border-b border-gray-200">
<div class="flex items-center justify-between">
<h3 class="text-lg font-medium text-gray-900">
{% if import_result.imported > 0 %}Imported Games{% endif %}
{% if import_result.imported > 0 and import_result.updated > 0 %} & {% endif %}
{% if import_result.updated > 0 %}Updated Games{% endif %}
</h3>
<div class="flex space-x-2">
<button type="button" onclick="toggleImportDetails()" class="inline-flex items-center px-3 py-1 border border-gray-300 shadow-sm text-sm leading-4 font-medium rounded-md text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500">
Toggle Details
</button>
</div>
</div>
</div>
<div id="import-details" class="hidden">
<div class="divide-y divide-gray-200">
{% for game in preview_data.games %}
<div class="px-6 py-4">
<div class="flex items-center justify-between">
<div class="flex items-center space-x-4">
{% if game.cover_image %}
<img class="h-12 w-12 rounded-lg object-cover" src="{{ game.cover_image }}" alt="{{ game.title }}">
{% else %}
<div class="h-12 w-12 rounded-lg bg-gray-200 flex items-center justify-center">
<svg class="h-6 w-6 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.828 14.828a4 4 0 01-5.656 0M9 10h1m4 0h1m-7 8h12a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z"/>
</svg>
</div>
{% endif %}
<div>
<h4 class="text-sm font-medium text-gray-900">{{ game.title }}</h4>
<div class="flex items-center space-x-2 text-xs text-gray-500">
{% if game.platform %}
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-green-100 text-green-800">
{{ game.platform }}
</span>
{% endif %}
{% if game.genre %}
<span class="inline-flex items-center px-2 py-0.5 rounded text-xs font-medium bg-blue-100 text-blue-800">
{{ game.genre }}
</span>
{% endif %}
</div>
</div>
</div>
<div class="flex items-center space-x-2">
{% if import_result.imported > 0 %}
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-green-100 text-green-800">
New
</span>
{% endif %}
{% if import_result.updated > 0 %}
<span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
Updated
</span>
{% endif %}
</div>
</div>
{% if game.description %}
<div class="mt-2">
<p class="text-xs text-gray-600 line-clamp-2">{{ game.description|striptags|slice(0, 150) }}{% if game.description|length > 150 %}...{% endif %}</p>
</div>
{% endif %}
</div>
{% endfor %}
</div>
</div>
</div>
{% endif %}
<!-- Import Statistics -->
<div class="mt-6 bg-white shadow rounded-lg">
<div class="px-6 py-4 border-b border-gray-200">
<h3 class="text-lg font-medium text-gray-900">Import Statistics</h3>
</div>
<div class="px-6 py-4">
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div>
<h4 class="text-sm font-medium text-gray-900 mb-3">Data Imported</h4>
<dl class="space-y-2">
{% set totalGames = import_result.imported + import_result.updated %}
{% if totalGames > 0 %}
<div class="flex justify-between text-sm">
<dt class="text-gray-500">Games with descriptions:</dt>
<dd class="text-gray-900">
{% set withDescriptions = 0 %}
{% for game in preview_data.games %}
{% if game.description %}
{% set withDescriptions = withDescriptions + 1 %}
{% endif %}
{% endfor %}
{{ withDescriptions }}
</dd>
</div>
<div class="flex justify-between text-sm">
<dt class="text-gray-500">Games with cover images:</dt>
<dd class="text-gray-900">
{% set withCovers = 0 %}
{% for game in preview_data.games %}
{% if game.cover_image %}
{% set withCovers = withCovers + 1 %}
{% endif %}
{% endfor %}
{{ withCovers }}
</dd>
</div>
<div class="flex justify-between text-sm">
<dt class="text-gray-500">Games with ratings:</dt>
<dd class="text-gray-900">
{% set withRatings = 0 %}
{% for game in preview_data.games %}
{% if game.rating %}
{% set withRatings = withRatings + 1 %}
{% endif %}
{% endfor %}
{{ withRatings }}
</dd>
</div>
<div class="flex justify-between text-sm">
<dt class="text-gray-500">Total playtime:</dt>
<dd class="text-gray-900">
{% set totalPlaytime = 0 %}
{% for game in preview_data.games %}
{% if game.playtime_minutes %}
{% set totalPlaytime = totalPlaytime + game.playtime_minutes %}
{% endif %}
{% endfor %}
{{ (totalPlaytime / 60)|round(1) }} hours
</dd>
</div>
{% endif %}
</dl>
</div>
<div>
<h4 class="text-sm font-medium text-gray-900 mb-3">Platform Distribution</h4>
<dl class="space-y-2">
{% set platforms = {} %}
{% for game in preview_data.games %}
{% if game.platform %}
{% set platformKey = game.platform %}
{% if platforms[platformKey] is defined %}
{% set platforms = platforms|merge({(platformKey): platforms[platformKey] + 1}) %}
{% else %}
{% set platforms = platforms|merge({(platformKey): 1}) %}
{% endif %}
{% endif %}
{% endfor %}
{% for platform, count in platforms %}
<div class="flex justify-between text-sm">
<dt class="text-gray-500">{{ platform }}:</dt>
<dd class="text-gray-900">{{ count }} games</dd>
</div>
{% endfor %}
</dl>
</div>
</div>
</div>
</div>
<!-- Next Steps -->
<div class="mt-6 bg-blue-50 border border-blue-200 rounded-md">
<div class="px-6 py-4">
<div class="flex">
<div class="flex-shrink-0">
<svg class="h-5 w-5 text-blue-400" viewBox="0 0 20 20" fill="currentColor">
<path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd" />
</svg>
</div>
<div class="ml-3">
<h3 class="text-sm font-medium text-blue-800">What happens next?</h3>
<div class="mt-2 text-sm text-blue-700">
<ul class="list-disc list-inside space-y-1">
<li>The imported games are now available in your Games library</li>
<li>Games are automatically grouped by title across different platforms</li>
<li>Rich metadata including descriptions, ratings, and images are preserved</li>
<li>You can update playtime and other statistics directly in the games interface</li>
<li>Background sync processes will keep the data current if configured</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
function toggleImportDetails() {
const details = document.getElementById('import-details');
const button = event.target;
if (details.classList.contains('hidden')) {
details.classList.remove('hidden');
button.textContent = 'Hide Details';
} else {
details.classList.add('hidden');
button.textContent = 'Show Details';
}
}
// Auto-hide details after 5 seconds
setTimeout(function() {
const button = document.querySelector('button[onclick="toggleImportDetails()"]');
if (button && !document.getElementById('import-details').classList.contains('hidden')) {
// Details are already visible, leave them as is
}
}, 5000);
</script>
{% endblock %}

View File

@@ -19,7 +19,7 @@
<div class="card-body"> <div class="card-body">
<div style="background-color: #f8f9fa; border-radius: 0.375rem; overflow: hidden;"> <div style="background-color: #f8f9fa; border-radius: 0.375rem; overflow: hidden;">
{% if movie.poster_url %} {% if movie.poster_url %}
<img src="{{ movie.poster_url }}" alt="{{ movie.title }}" class="w-100" style="max-height: 400px; object-fit: contain;"> <img src="/images/{{ movie.poster_url }}" alt="{{ movie.title }}" class="w-100" style="max-height: 400px; object-fit: contain;">
{% else %} {% else %}
<div class="w-100 h-100 d-flex align-items-center justify-content-center"> <div class="w-100 h-100 d-flex align-items-center justify-content-center">
<svg class="text-muted" width="96" height="96" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg class="text-muted" width="96" height="96" fill="none" viewBox="0 0 24 24" stroke="currentColor">
@@ -28,6 +28,22 @@
</div> </div>
{% endif %} {% endif %}
</div> </div>
<!-- Action buttons -->
<div class="mt-3 d-grid gap-2">
<button class="btn btn-primary">
<svg class="me-2" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.828 14.828a4 4 0 01-5.656 0M9 10h1m4 0h1m-6 8a9 9 0 110-18 9 9 0 010 18z"/>
</svg>
Mark as Watched
</button>
<button class="btn btn-outline-danger">
<svg class="me-2" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"/>
</svg>
Add to Favorites
</button>
</div>
</div> </div>
</div> </div>
@@ -36,6 +52,9 @@
<div class="card-body"> <div class="card-body">
<div class="mb-4"> <div class="mb-4">
<h1 class="display-5 fw-bold text-dark mb-2">{{ movie.title }}</h1> <h1 class="display-5 fw-bold text-dark mb-2">{{ movie.title }}</h1>
{% if movie.tagline %}
<p class="lead text-muted mb-3">{{ movie.tagline }}</p>
{% endif %}
<!-- Video metadata --> <!-- Video metadata -->
<div class="d-flex flex-wrap gap-3 small text-muted mb-3"> <div class="d-flex flex-wrap gap-3 small text-muted mb-3">
@@ -66,6 +85,15 @@
</span> </span>
{% endif %} {% endif %}
{% if movie.file_size %}
<span class="d-flex align-items-center">
<svg class="me-1" width="16" height="16" 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>
{{ movie.file_size|filesizeformat }}
</span>
{% endif %}
<span class="d-flex align-items-center"> <span class="d-flex align-items-center">
<svg class="me-1" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg class="me-1" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"/> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"/>
@@ -97,6 +125,15 @@
Favorite Favorite
</span> </span>
{% endif %} {% endif %}
{% if movie.collection %}
<span class="badge bg-info d-flex align-items-center">
<svg class="me-1" width="12" height="12" 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>
{{ movie.collection }}
</span>
{% endif %}
</div> </div>
</div> </div>
@@ -108,46 +145,57 @@
</div> </div>
{% endif %} {% endif %}
<!-- Additional details --> <!-- Cast & Crew Section -->
<div class="mb-4">
<h2 class="h5 fw-semibold text-dark mb-3">Cast & Crew</h2>
<div class="row g-3"> <div class="row g-3">
<!-- Cast & Crew -->
{% if movie.cast or movie.director or movie.writer or movie.actors %}
<div class="col-md-6">
<h3 class="h6 fw-semibold text-dark mb-3">Cast & Crew</h3>
<dl class="row g-2">
{% if movie.director %} {% if movie.director %}
<div class="col-4"> <div class="col-md-4">
<dt class="small text-muted">Director</dt> <div class="d-flex align-items-center">
<dd class="small text-dark">{{ movie.director }}</dd> <svg class="me-2 text-muted" width="20" height="20" 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>
<small class="text-muted d-block">Director</small>
<span class="fw-medium">{{ movie.director }}</span>
</div>
</div>
</div> </div>
{% endif %} {% endif %}
{% if movie.writer %}
<div class="col-4">
<dt class="small text-muted">Writer</dt>
<dd class="small text-dark">{{ movie.writer }}</dd>
</div>
{% endif %}
{% if movie.cast %}
<div class="col-12">
<dt class="small text-muted">Cast</dt>
<dd class="small text-dark">{{ movie.cast }}</dd>
</div>
{% endif %}
</dl>
<!-- Actors with thumbnails --> {% if movie.cast %}
<div class="col-md-8">
<div class="d-flex align-items-center">
<svg class="me-2 text-muted" width="20" height="20" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"/>
</svg>
<div>
<small class="text-muted d-block">Cast</small>
<div class="d-flex flex-wrap gap-1">
{% for actor in movie.cast|split(',') %}
<span class="badge bg-light text-dark">{{ actor|trim }}</span>
{% endfor %}
</div>
</div>
</div>
</div>
{% endif %}
</div>
</div>
<!-- Performers with thumbnails -->
{% if movie.actors %} {% if movie.actors %}
<div class="mt-3"> <div class="mb-4">
<h4 class="h6 fw-semibold text-dark mb-2">Performers</h4> <h3 class="h6 fw-semibold text-dark mb-3">Performers</h3>
<div class="d-flex flex-wrap gap-2"> <div class="d-flex flex-wrap gap-3">
{% for actor in movie.actors %} {% for actor in movie.actors %}
<a href="{{ path_for('actors.show', {'id': actor.id}) }}" class="text-decoration-none"> <a href="{{ path_for('actors.show', {'id': actor.id}) }}" class="text-decoration-none">
<div class="d-flex flex-column align-items-center" style="width: 60px;"> <div class="d-flex flex-column align-items-center" style="width: 80px;">
{% if actor.thumbnail_path %} {% if actor.thumbnail_path %}
<img src="/public/images/{{ actor.thumbnail_path }}" alt="{{ actor.name }}" class="rounded-circle mb-1" style="width: 40px; height: 40px; object-fit: cover;"> <img src="/images/{{ actor.thumbnail_path }}" alt="{{ actor.name }}" class="rounded-circle mb-2" style="width: 50px; height: 50px; object-fit: cover;">
{% else %} {% else %}
<div class="rounded-circle bg-light d-flex align-items-center justify-content-center mb-1" style="width: 40px; height: 40px;"> <div class="rounded-circle bg-light d-flex align-items-center justify-content-center mb-2" style="width: 50px; height: 50px;">
<svg class="text-muted" width="20" height="20" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg class="text-muted" width="24" height="24" 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"/> <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> </svg>
</div> </div>
@@ -159,30 +207,146 @@
</div> </div>
</div> </div>
{% endif %} {% endif %}
<!-- Video Details Grid -->
<div class="row g-3 mb-4">
<!-- Genres & Categories -->
{% if movie.genre or movie.categories %}
<div class="col-md-6">
<h3 class="h6 fw-semibold text-dark mb-3">Categories</h3>
<div class="d-flex flex-wrap gap-2">
{% if movie.genre %}
{% for genre in movie.genre|split(',') %}
<span class="badge bg-primary">{{ genre|trim }}</span>
{% endfor %}
{% endif %}
{% if movie.categories %}
{% for category in movie.categories|split(',') %}
<span class="badge bg-secondary">{{ category|trim }}</span>
{% endfor %}
{% endif %}
</div>
</div> </div>
{% endif %} {% endif %}
<!-- Genres & Studios --> <!-- Technical Details -->
{% if movie.genre or metadata.studios %} {% if movie.video_codec or movie.audio_codec or movie.resolution or movie.bitrate %}
<div class="col-md-6"> <div class="col-md-6">
<h3 class="h6 fw-semibold text-dark mb-3">Details</h3> <h3 class="h6 fw-semibold text-dark mb-3">Technical Details</h3>
<dl class="row g-2"> <div class="row g-2">
{% if movie.genre %} {% if movie.video_codec %}
<div class="col-4"> <div class="col-6">
<dt class="small text-muted">Genre</dt> <small class="text-muted d-block">Video Codec</small>
<dd class="small text-dark">{{ movie.genre }}</dd> <span class="fw-medium">{{ movie.video_codec }}</span>
</div> </div>
{% endif %} {% endif %}
{% if metadata.studios %} {% if movie.audio_codec %}
<div class="col-12"> <div class="col-6">
<dt class="small text-muted">Studio</dt> <small class="text-muted d-block">Audio Codec</small>
<dd class="small text-dark">{{ metadata.studios|join(', ') }}</dd> <span class="fw-medium">{{ movie.audio_codec }}</span>
</div> </div>
{% endif %} {% endif %}
</dl> {% if movie.resolution %}
<div class="col-6">
<small class="text-muted d-block">Resolution</small>
<span class="fw-medium">{{ movie.resolution }}</span>
</div>
{% endif %}
{% if movie.bitrate %}
<div class="col-6">
<small class="text-muted d-block">Bitrate</small>
<span class="fw-medium">{{ movie.bitrate }} kbps</span>
</div>
{% endif %}
{% if movie.frame_rate %}
<div class="col-6">
<small class="text-muted d-block">Frame Rate</small>
<span class="fw-medium">{{ movie.frame_rate }} fps</span>
</div>
{% endif %}
{% if movie.aspect_ratio %}
<div class="col-6">
<small class="text-muted d-block">Aspect Ratio</small>
<span class="fw-medium">{{ movie.aspect_ratio }}</span>
</div> </div>
{% endif %} {% endif %}
</div> </div>
</div>
{% endif %}
</div>
<!-- Studio & Production -->
{% if movie.studio or movie.production_companies %}
<div class="mb-4">
<h3 class="h6 fw-semibold text-dark mb-3">Production</h3>
<div class="row g-3">
{% if movie.studio %}
<div class="col-md-6">
<small class="text-muted d-block">Studio</small>
<span class="fw-medium">{{ movie.studio }}</span>
</div>
{% endif %}
{% if movie.production_companies %}
<div class="col-md-6">
<small class="text-muted d-block">Production Company</small>
<span class="fw-medium">{{ movie.production_companies }}</span>
</div>
{% endif %}
</div>
</div>
{% endif %}
<!-- File Information -->
{% if movie.file_path or movie.duration or movie.created_at %}
<div class="mb-4">
<h3 class="h6 fw-semibold text-dark mb-3">File Information</h3>
<div class="row g-3">
{% if movie.file_path %}
<div class="col-md-6">
<small class="text-muted d-block">File Path</small>
<span class="fw-medium small" style="word-break: break-all;">{{ movie.file_path }}</span>
</div>
{% endif %}
{% if movie.duration %}
<div class="col-md-3">
<small class="text-muted d-block">Duration</small>
<span class="fw-medium">{{ movie.duration }}</span>
</div>
{% endif %}
{% if movie.created_at %}
<div class="col-md-3">
<small class="text-muted d-block">Added</small>
<span class="fw-medium">{{ movie.created_at|date('M j, Y') }}</span>
</div>
{% endif %}
</div>
</div>
{% endif %}
<!-- Streaming & Availability -->
{% if movie.streaming_providers or movie.availability %}
<div class="mb-4">
<h3 class="h6 fw-semibold text-dark mb-3">Availability</h3>
<div class="row g-3">
{% if movie.streaming_providers %}
<div class="col-md-6">
<small class="text-muted d-block">Streaming Platforms</small>
<div class="d-flex flex-wrap gap-2">
{% for provider in movie.streaming_providers %}
<span class="badge bg-success">{{ provider }}</span>
{% endfor %}
</div>
</div>
{% endif %}
{% if movie.availability %}
<div class="col-md-6">
<small class="text-muted d-block">Availability Status</small>
<span class="fw-medium">{{ movie.availability }}</span>
</div>
{% endif %}
</div>
</div>
{% endif %}
<!-- Metadata (for debugging/advanced users) --> <!-- Metadata (for debugging/advanced users) -->
{% if metadata %} {% if metadata %}
@@ -192,7 +356,7 @@
<svg class="me-2 group-open:rotate-90 transition-transform" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg class="me-2 group-open:rotate-90 transition-transform" width="16" height="16" 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"/> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
</svg> </svg>
Technical Details Technical Details & Metadata
</summary> </summary>
<div class="mt-3 small"> <div class="mt-3 small">
<pre class="bg-light p-3 rounded"><code>{{ metadata|json_encode(constant('JSON_PRETTY_PRINT')) }}</code></pre> <pre class="bg-light p-3 rounded"><code>{{ metadata|json_encode(constant('JSON_PRETTY_PRINT')) }}</code></pre>

View File

@@ -172,6 +172,211 @@
<p class="text-sm text-gray-600">{{ version.description }}</p> <p class="text-sm text-gray-600">{{ version.description }}</p>
</div> </div>
{% endif %} {% endif %}
<!-- Playnite Rich Metadata -->
{% set playniteGenres = version.genres_json|json_decode %}
{% if playniteGenres %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-3">Genres</h3>
<div class="flex flex-wrap gap-2">
{% for genre in playniteGenres %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-blue-100 text-blue-800">
{{ genre.Name }}
</span>
{% endfor %}
</div>
</div>
{% endif %}
{% set playniteTags = version.tags_json|json_decode %}
{% if playniteTags %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-3">Tags</h3>
<div class="flex flex-wrap gap-2">
{% for tag in playniteTags|slice(0, 20) %}
<span class="inline-flex items-center px-2 py-1 rounded text-sm font-medium bg-gray-100 text-gray-800">
{{ tag.Name }}
</span>
{% endfor %}
{% if playniteTags|length > 20 %}
<span class="text-sm text-gray-500">+{{ playniteTags|length - 20 }} more</span>
{% endif %}
</div>
</div>
{% endif %}
{% set playniteFeatures = version.features_json|json_decode %}
{% if playniteFeatures %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-3">Features</h3>
<div class="flex flex-wrap gap-2">
{% for feature in playniteFeatures %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-green-100 text-green-800">
{{ feature.Name }}
</span>
{% endfor %}
</div>
</div>
{% endif %}
{% set playniteLinks = version.links_json|json_decode %}
{% if playniteLinks %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-3">Links</h3>
<div class="grid grid-cols-1 sm:grid-cols-2 gap-3">
{% for link in playniteLinks %}
<a href="{{ link.Url }}" target="_blank" rel="noopener noreferrer"
class="inline-flex items-center px-3 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 transition-colors duration-200">
<svg class="w-4 h-4 mr-2 text-gray-400" fill="currentColor" viewBox="0 0 20 20">
<path d="M11 3a1 1 0 100 2h2.586l-6.293 6.293a1 1 0 101.414 1.414L15 6.414V9a1 1 0 102 0V4a1 1 0 00-1-1h-5z"/>
<path d="M5 5a2 2 0 00-2 2v6a2 2 0 002 2h6a2 2 0 002-2v-3a1 1 0 10-2 0v3H5V7h3a1 1 0 000-2H5z"/>
</svg>
{{ link.Name }}
</a>
{% endfor %}
</div>
</div>
{% endif %}
{% set playniteSeries = version.series_json|json_decode %}
{% if playniteSeries %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-3">Series</h3>
<div class="flex flex-wrap gap-2">
{% for series in playniteSeries %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-purple-100 text-purple-800">
{{ series.Name }}
</span>
{% endfor %}
</div>
</div>
{% endif %}
{% set playniteAgeRatings = version.age_ratings_json|json_decode %}
{% if playniteAgeRatings %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-3">Age Ratings</h3>
<div class="flex flex-wrap gap-2">
{% for ageRating in playniteAgeRatings %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-yellow-100 text-yellow-800">
{{ ageRating.Name }}
</span>
{% endfor %}
</div>
</div>
{% endif %}
<!-- Enhanced Ratings Display -->
{% if version.critic_score or version.community_score or version.user_score %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-3">Ratings</h3>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
{% if version.critic_score %}
<div class="bg-gray-50 rounded-lg p-4">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-500">Critic Score</p>
<p class="text-2xl font-bold text-gray-900">{{ version.critic_score }}%</p>
</div>
<div class="flex-shrink-0">
<svg class="w-8 h-8 text-yellow-400" fill="currentColor" viewBox="0 0 20 20">
<path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"/>
</svg>
</div>
</div>
</div>
{% endif %}
{% if version.community_score %}
<div class="bg-gray-50 rounded-lg p-4">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-500">Community Score</p>
<p class="text-2xl font-bold text-gray-900">{{ version.community_score }}%</p>
</div>
<div class="flex-shrink-0">
<svg class="w-8 h-8 text-blue-400" fill="currentColor" viewBox="0 0 20 20">
<path d="M13 6a3 3 0 11-6 0 3 3 0 016 0zM18 8a2 2 0 11-4 0 2 2 0 014 0zM14 15a4 4 0 00-8 0v3h8v-3z"/>
</svg>
</div>
</div>
</div>
{% endif %}
{% if version.user_score %}
<div class="bg-gray-50 rounded-lg p-4">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-500">User Score</p>
<p class="text-2xl font-bold text-gray-900">{{ version.user_score }}%</p>
</div>
<div class="flex-shrink-0">
<svg class="w-8 h-8 text-green-400" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
</svg>
</div>
</div>
</div>
{% endif %}
</div>
</div>
{% endif %}
<!-- Playnite-specific Statistics -->
{% if version.play_count or version.install_size or version.completion_status %}
<div class="mt-6">
<h3 class="text-lg font-medium text-gray-900 mb-3">Playnite Statistics</h3>
<div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
{% if version.play_count %}
<div class="bg-gray-50 rounded-lg p-4">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-500">Play Count</p>
<p class="text-2xl font-bold text-gray-900">{{ version.play_count }}</p>
</div>
<div class="flex-shrink-0">
<svg class="w-8 h-8 text-indigo-400" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM9.555 7.168A1 1 0 008 8v4a1 1 0 001.555.832l3-2a1 1 0 000-1.664l-3-2z" clip-rule="evenodd"/>
</svg>
</div>
</div>
</div>
{% endif %}
{% if version.install_size %}
<div class="bg-gray-50 rounded-lg p-4">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-500">Install Size</p>
<p class="text-lg font-bold text-gray-900">{{ (version.install_size / 1024 / 1024 / 1024)|round(1) }} GB</p>
</div>
<div class="flex-shrink-0">
<svg class="w-8 h-8 text-gray-400" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M3 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zm0 4a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z" clip-rule="evenodd"/>
</svg>
</div>
</div>
</div>
{% endif %}
{% if version.completion_status %}
<div class="bg-gray-50 rounded-lg p-4">
<div class="flex items-center justify-between">
<div>
<p class="text-sm font-medium text-gray-500">Completion Status</p>
<p class="text-lg font-bold text-gray-900">{{ version.completion_status }}</p>
</div>
<div class="flex-shrink-0">
<svg class="w-8 h-8 text-green-400" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z" clip-rule="evenodd"/>
</svg>
</div>
</div>
</div>
{% endif %}
</div>
</div>
{% endif %}
</div> </div>
</div> </div>
{% endfor %} {% endfor %}

View File

@@ -1,44 +1,66 @@
{% extends "layouts/app.twig" %} {% extends "layouts/app.twig" %}
{% block content %} {% block content %}
<div class="px-4 py-6 sm:px-0"> <div class="container-fluid px-4 py-3">
<!-- Back button --> <!-- Back button -->
<div class="mb-6"> <div class="mb-4">
<a href="{{ path_for('movies.index') }}" class="inline-flex items-center text-sm text-indigo-600 hover:text-indigo-800"> <a href="{{ path_for('movies.index') }}" class="btn btn-link text-decoration-none p-0">
<svg class="w-4 h-4 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg class="me-2" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>
</svg> </svg>
Back to Movies Back to Movies
</a> </a>
</div> </div>
<div class="bg-white shadow rounded-lg overflow-hidden"> <div class="card shadow-sm">
<div class="md:flex"> <div class="row g-0">
<!-- Movie poster --> <!-- Movie poster -->
<div class="md:w-1/3 p-6"> <div class="col-md-4">
<div class="aspect-[2/3] bg-gray-200 rounded-lg overflow-hidden"> <div class="card-body p-4">
<div class="ratio ratio-2x3">
{% if movie.poster_url %} {% if movie.poster_url %}
<img src="{{ movie.poster_url }}" alt="{{ movie.title }}" class="w-full h-full object-cover"> <img src="/images/{{ movie.poster_url }}" alt="{{ movie.title }}" class="img-fluid rounded">
{% else %} {% else %}
<div class="w-full h-full flex items-center justify-center bg-gray-100"> <div class="w-100 h-100 d-flex align-items-center justify-content-center bg-light rounded">
<svg class="h-24 w-24 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg class="text-muted" width="96" height="96" 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"/> <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> </svg>
</div> </div>
{% endif %} {% endif %}
</div> </div>
<!-- Action buttons -->
<div class="mt-4 d-grid gap-2">
<button class="btn btn-primary">
<svg class="me-2" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.828 14.828a4 4 0 01-5.656 0M9 10h1m4 0h1m-6 8a9 9 0 110-18 9 9 0 010 18z"/>
</svg>
Mark as Watched
</button>
<button class="btn btn-outline-danger">
<svg class="me-2" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"/>
</svg>
Add to Favorites
</button>
</div>
</div>
</div> </div>
<!-- Movie details --> <!-- Movie details -->
<div class="md:w-2/3 p-6"> <div class="col-md-8">
<div class="mb-6"> <div class="card-body p-4">
<h1 class="text-3xl font-bold text-gray-900 mb-2">{{ movie.title }}</h1> <div class="mb-4">
<h1 class="display-4 fw-bold text-dark mb-2">{{ movie.title }}</h1>
{% if movie.tagline %}
<p class="lead text-muted mb-3">{{ movie.tagline }}</p>
{% endif %}
<!-- Movie metadata --> <!-- Movie metadata -->
<div class="flex flex-wrap gap-4 text-sm text-gray-600 mb-4"> <div class="d-flex flex-wrap gap-3 small text-muted mb-3">
{% if movie.release_date %} {% if movie.release_date %}
<span class="flex items-center"> <span class="d-flex align-items-center">
<svg class="w-4 h-4 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg class="me-1" width="16" height="16" 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"/> <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> </svg>
{{ movie.release_date|date('Y') }} {{ movie.release_date|date('Y') }}
@@ -46,8 +68,8 @@
{% endif %} {% endif %}
{% if movie.rating %} {% if movie.rating %}
<span class="flex items-center"> <span class="d-flex align-items-center">
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20"> <svg class="me-1" width="16" height="16" fill="currentColor" viewBox="0 0 20 20">
<path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"/> <path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"/>
</svg> </svg>
{{ movie.rating }}/10 {{ movie.rating }}/10
@@ -55,16 +77,25 @@
{% endif %} {% endif %}
{% if movie.runtime_minutes %} {% if movie.runtime_minutes %}
<span class="flex items-center"> <span class="d-flex align-items-center">
<svg class="w-4 h-4 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg class="me-1" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg> </svg>
{{ (movie.runtime_minutes / 60)|round(1) }}h {{ movie.runtime_minutes % 60 }}m {{ (movie.runtime_minutes / 60)|round(1) }}h {{ movie.runtime_minutes % 60 }}m
</span> </span>
{% endif %} {% endif %}
<span class="flex items-center"> {% if movie.vote_count %}
<svg class="w-4 h-4 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <span class="d-flex align-items-center">
<svg class="me-1" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"/>
</svg>
{{ movie.vote_count }} votes
</span>
{% endif %}
<span class="d-flex align-items-center">
<svg class="me-1" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"/> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"/>
</svg> </svg>
{{ movie.source_name }} {{ movie.source_name }}
@@ -72,10 +103,10 @@
</div> </div>
<!-- Status badges --> <!-- Status badges -->
<div class="flex flex-wrap gap-2"> <div class="d-flex flex-wrap gap-2">
{% if movie.watched %} {% if movie.watched %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-green-100 text-green-800"> <span class="badge bg-success d-flex align-items-center">
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20"> <svg class="me-1" width="12" height="12" fill="currentColor" viewBox="0 0 20 20">
<path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"/> <path fill-rule="evenodd" d="M16.707 5.293a1 1 0 010 1.414l-8 8a1 1 0 01-1.414 0l-4-4a1 1 0 011.414-1.414L8 12.586l7.293-7.293a1 1 0 011.414 0z" clip-rule="evenodd"/>
</svg> </svg>
Watched Watched
@@ -83,93 +114,230 @@
{% endif %} {% endif %}
{% if movie.watch_count > 0 %} {% if movie.watch_count > 0 %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-blue-100 text-blue-800"> <span class="badge bg-primary">{{ movie.watch_count }} watch{{ movie.watch_count > 1 ? 'es' : '' }}</span>
{{ movie.watch_count }} watch{{ movie.watch_count > 1 ? 'es' : '' }}
</span>
{% endif %} {% endif %}
{% if movie.is_favorite %} {% if movie.is_favorite %}
<span class="inline-flex items-center px-3 py-1 rounded-full text-sm font-medium bg-red-100 text-red-800"> <span class="badge bg-danger d-flex align-items-center">
<svg class="w-4 h-4 mr-1" fill="currentColor" viewBox="0 0 20 20"> <svg class="me-1" width="12" height="12" fill="currentColor" viewBox="0 0 20 20">
<path d="M3.172 5.172a4 4 0 015.656 0L10 6.343l1.172-1.171a4 4 0 115.656 5.656L10 17.657l-6.828-6.829a4 4 0 010-5.656z"/> <path d="M3.172 5.172a4 4 0 015.656 0L10 6.343l1.172-1.171a4 4 0 115.656 5.656L10 17.657l-6.828-6.829a4 4 0 010-5.656z"/>
</svg> </svg>
Favorite Favorite
</span> </span>
{% endif %} {% endif %}
{% if movie.status %}
<span class="badge bg-secondary">{{ movie.status|title }}</span>
{% endif %}
</div> </div>
</div> </div>
<!-- Overview --> <!-- Overview -->
{% if movie.overview %} {% if movie.overview %}
<div class="mb-6"> <div class="mb-4">
<h2 class="text-lg font-semibold text-gray-900 mb-2">Overview</h2> <h2 class="h5 fw-semibold text-dark mb-2">Overview</h2>
<p class="text-gray-700 leading-relaxed">{{ movie.overview }}</p> <p class="text-muted">{{ movie.overview }}</p>
</div> </div>
{% endif %} {% endif %}
<!-- Additional details --> <!-- Cast & Crew Section -->
<div class="grid grid-cols-1 md:grid-cols-2 gap-6"> <div class="mb-4">
<!-- Cast & Crew --> <h2 class="h5 fw-semibold text-dark mb-3">Cast & Crew</h2>
{% if movie.cast or movie.director or movie.writer %} <div class="row g-3">
<div>
<h3 class="text-md font-semibold text-gray-900 mb-3">Cast & Crew</h3>
<dl class="space-y-2">
{% if movie.director %} {% if movie.director %}
<div class="col-md-6">
<div class="d-flex align-items-center">
<svg class="me-2 text-muted" width="20" height="20" 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> <div>
<dt class="text-sm font-medium text-gray-500">Director</dt> <small class="text-muted d-block">Director</small>
<dd class="text-sm text-gray-900">{{ movie.director }}</dd> <span class="fw-medium">{{ movie.director }}</span>
</div> </div>
{% endif %}
{% if movie.writer %}
<div>
<dt class="text-sm font-medium text-gray-500">Writer</dt>
<dd class="text-sm text-gray-900">{{ movie.writer }}</dd>
</div> </div>
{% endif %}
{% if movie.cast %}
<div>
<dt class="text-sm font-medium text-gray-500">Cast</dt>
<dd class="text-sm text-gray-900">{{ movie.cast }}</dd>
</div>
{% endif %}
</dl>
</div> </div>
{% endif %} {% endif %}
<!-- Genres & Studios --> {% if movie.writer %}
{% if movie.genre or metadata.studios %} <div class="col-md-6">
<div class="d-flex align-items-center">
<svg class="me-2 text-muted" width="20" height="20" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M11 5H6a2 2 0 00-2 2v11a2 2 0 002 2h11a2 2 0 002-2v-5m-1.414-9.414a2 2 0 112.828 2.828L11.828 15H9v-2.828l8.586-8.586z"/>
</svg>
<div> <div>
<h3 class="text-md font-semibold text-gray-900 mb-3">Details</h3> <small class="text-muted d-block">Writer</small>
<dl class="space-y-2"> <span class="fw-medium">{{ movie.writer }}</span>
</div>
</div>
</div>
{% endif %}
</div>
{% if actors %}
<div class="mt-3">
<small class="text-muted d-block mb-2">Cast</small>
<div class="d-flex flex-wrap gap-2">
{% for actor in actors %}
<span class="badge bg-light text-dark">{{ actor.name }}</span>
{% endfor %}
</div>
</div>
{% endif %}
</div>
<!-- Movie Details Grid -->
<div class="row g-4 mb-4">
<!-- Genres -->
{% if movie.genre %} {% if movie.genre %}
<div> <div class="col-md-4">
<dt class="text-sm font-medium text-gray-500">Genre</dt> <h3 class="h6 fw-semibold text-dark mb-3">Genres</h3>
<dd class="text-sm text-gray-900">{{ movie.genre }}</dd> <div class="d-flex flex-wrap gap-2">
{% for genre in movie.genre|split(',') %}
<span class="badge bg-primary">{{ genre|trim }}</span>
{% endfor %}
</div>
</div> </div>
{% endif %} {% endif %}
{% if metadata.studios %}
<div> <!-- Production -->
<dt class="text-sm font-medium text-gray-500">Studio</dt> {% if movie.production_companies or movie.production_countries %}
<dd class="text-sm text-gray-900">{{ metadata.studios|join(', ') }}</dd> <div class="col-md-4">
</div> <h3 class="h6 fw-semibold text-dark mb-3">Production</h3>
<div class="mb-2">
{% if movie.production_companies %}
<small class="text-muted d-block">Companies</small>
<span class="fw-medium">{{ movie.production_companies }}</span>
{% endif %} {% endif %}
</dl> </div>
{% if movie.production_countries %}
<div class="mb-2">
<small class="text-muted d-block">Countries</small>
<span class="fw-medium">{{ movie.production_countries }}</span>
</div> </div>
{% endif %} {% endif %}
</div> </div>
{% endif %}
<!-- Technical Details -->
{% if movie.budget or movie.revenue or movie.original_language %}
<div class="col-md-4">
<h3 class="h6 fw-semibold text-dark mb-3">Technical</h3>
<div class="mb-2">
{% if movie.budget %}
<small class="text-muted d-block">Budget</small>
<span class="fw-medium">${{ movie.budget|number_format(0, '.', ',') }}</span>
{% endif %}
</div>
{% if movie.revenue %}
<div class="mb-2">
<small class="text-muted d-block">Revenue</small>
<span class="fw-medium">${{ movie.revenue|number_format(0, '.', ',') }}</span>
</div>
{% endif %}
{% if movie.original_language %}
<div class="mb-2">
<small class="text-muted d-block">Language</small>
<span class="fw-medium">{{ movie.original_language|upper }}</span>
</div>
{% endif %}
</div>
{% endif %}
</div>
<!-- Collection/Series Info -->
{% if movie.belongs_to_collection %}
<div class="mb-4 p-3 bg-light rounded">
<h3 class="h6 fw-semibold text-dark mb-2">Collection</h3>
<span class="fw-medium">{{ movie.belongs_to_collection }}</span>
</div>
{% endif %}
<!-- Streaming & Availability -->
{% if movie.streaming_providers or movie.availability %}
<div class="mb-4">
<h3 class="h5 fw-semibold text-dark mb-3">Where to Watch</h3>
<div class="row g-3">
{% if movie.streaming_providers %}
<div class="col-md-6">
<small class="text-muted d-block mb-2">Streaming</small>
<div class="d-flex flex-wrap gap-2">
{% for provider in movie.streaming_providers %}
<span class="badge bg-success">{{ provider }}</span>
{% endfor %}
</div>
</div>
{% endif %}
{% if movie.availability %}
<div class="col-md-6">
<small class="text-muted d-block mb-2">Availability</small>
<span class="fw-medium">{{ movie.availability }}</span>
</div>
{% endif %}
</div>
</div>
{% endif %}
<!-- User Reviews & Ratings -->
{% if movie.user_reviews or movie.critic_reviews %}
<div class="mb-4">
<h3 class="h5 fw-semibold text-dark mb-3">Reviews & Ratings</h3>
<div class="row g-4">
{% if movie.user_reviews %}
<div class="col-md-6">
<h4 class="h6 fw-semibold text-dark mb-2">User Reviews</h4>
<div class="vstack gap-3">
{% for review in movie.user_reviews[:3] %}
<div class="p-3 bg-light rounded">
<div class="d-flex align-items-center mb-2">
<div class="d-flex text-warning">
{% for i in 1..5 %}
<svg class="me-1" width="16" height="16" fill="{{ i <= review.rating ? 'currentColor' : 'none' }}" viewBox="0 0 20 20">
<path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"/>
</svg>
{% endfor %}
</div>
<span class="ms-2 small text-muted">{{ review.author }}</span>
</div>
<p class="small text-muted">{{ review.content|slice(0, 150) }}{% if review.content|length > 150 %}...{% endif %}</p>
</div>
{% endfor %}
</div>
</div>
{% endif %}
{% if movie.critic_reviews %}
<div class="col-md-6">
<h4 class="h6 fw-semibold text-dark mb-2">Critic Reviews</h4>
<div class="vstack gap-3">
{% for review in movie.critic_reviews[:3] %}
<div class="p-3 bg-light rounded">
<div class="d-flex align-items-center justify-content-between mb-2">
<span class="fw-medium">{{ review.publication }}</span>
<span class="badge bg-info">{{ review.rating }}/100</span>
</div>
<p class="small text-muted">{{ review.excerpt|slice(0, 150) }}{% if review.excerpt|length > 150 %}...{% endif %}</p>
</div>
{% endfor %}
</div>
</div>
{% endif %}
</div>
</div>
{% endif %}
<!-- Metadata (for debugging/advanced users) --> <!-- Metadata (for debugging/advanced users) -->
{% if metadata %} {% if metadata %}
<div class="mt-6 pt-6 border-t border-gray-200"> <div class="mt-4 pt-4 border-top">
<details class="group"> <details class="group">
<summary class="cursor-pointer text-sm font-medium text-gray-700 hover:text-gray-900 flex items-center"> <summary class="cursor-pointer small fw-medium text-muted hover:text-dark d-flex align-items-center">
<svg class="w-4 h-4 mr-2 group-open:rotate-90 transition-transform" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg class="me-2 group-open:rotate-90 transition-transform" width="16" height="16" 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"/> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7"/>
</svg> </svg>
Technical Details Technical Details & Metadata
</summary> </summary>
<div class="mt-4 text-sm"> <div class="mt-3 small">
<pre class="bg-gray-50 p-4 rounded-lg overflow-x-auto">{{ metadata|json_encode(constant('JSON_PRETTY_PRINT')) }}</pre> <pre class="bg-light p-3 rounded"><code>{{ metadata|json_encode(constant('JSON_PRETTY_PRINT')) }}</code></pre>
</div> </div>
</details> </details>
</div> </div>
@@ -178,4 +346,5 @@
</div> </div>
</div> </div>
</div> </div>
</div>
{% endblock %} {% endblock %}

View File

@@ -1,30 +1,381 @@
{% extends "layouts/app.twig" %} {% extends "layouts/app.twig" %}
{% block content %} {% block content %}
<div class="px-4 py-6 sm:px-0"> <div class="container-fluid px-4 py-3">
<!-- Back button --> <!-- Back button -->
<div class="mb-6"> <div class="mb-4">
<a href="{{ path_for('tvshows.index') }}" class="inline-flex items-center text-sm text-indigo-600 hover:text-indigo-800"> <a href="{{ path_for('tvshows.index') }}" class="btn btn-link text-decoration-none p-0">
<svg class="w-4 h-4 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <svg class="me-2" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/> <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/>
</svg> </svg>
Back to TV Shows Back to TV Shows
</a> </a>
</div> </div>
<!-- Coming Soon Message --> <div class="card shadow-sm">
<div class="text-center py-12"> <div class="row g-0">
<svg class="mx-auto h-12 w-12 text-gray-400" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <!-- TV Show poster -->
<div class="col-md-4">
<div class="card-body p-4">
<div class="ratio ratio-2x3">
{% if tvshow.poster_url %}
<img src="/images/{{ tvshow.poster_url }}" alt="{{ tvshow.title }}" class="img-fluid rounded">
{% else %}
<div class="w-100 h-100 d-flex align-items-center justify-content-center bg-light rounded">
<svg class="text-muted" width="96" height="96" 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"/> <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> </svg>
<h3 class="mt-2 text-sm font-medium text-gray-900">TV Show Details Coming Soon</h3> </div>
<p class="mt-1 text-sm text-gray-500">{{ message }}</p> {% endif %}
<div class="mt-6"> </div>
<div class="inline-flex items-center px-4 py-2 border border-gray-300 rounded-md text-sm font-medium text-gray-700 bg-white">
<svg class="w-4 h-4 mr-2" fill="none" viewBox="0 0 24 24" stroke="currentColor"> <!-- Action buttons -->
<div class="mt-4 d-grid gap-2">
<button class="btn btn-primary">
<svg class="me-2" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M14.828 14.828a4 4 0 01-5.656 0M9 10h1m4 0h1m-6 8a9 9 0 110-18 9 9 0 010 18z"/>
</svg>
Mark as Watched
</button>
<button class="btn btn-outline-danger">
<svg class="me-2" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4.318 6.318a4.5 4.5 0 000 6.364L12 20.364l7.682-7.682a4.5 4.5 0 00-6.364-6.364L12 7.636l-1.318-1.318a4.5 4.5 0 00-6.364 0z"/>
</svg>
Add to Favorites
</button>
</div>
</div>
</div>
<!-- TV Show details -->
<div class="col-md-8">
<div class="card-body p-4">
<div class="mb-4">
<h1 class="display-4 fw-bold text-dark mb-2">{{ tvshow.title }}</h1>
{% if tvshow.tagline %}
<p class="lead text-muted mb-3">{{ tvshow.tagline }}</p>
{% endif %}
<!-- TV Show metadata -->
<div class="d-flex flex-wrap gap-3 small text-muted mb-3">
{% if tvshow.first_air_date %}
<span class="d-flex align-items-center">
<svg class="me-1" width="16" height="16" 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>
{{ tvshow.first_air_date|date('Y') }}
</span>
{% endif %}
{% if tvshow.last_air_date %}
<span class="d-flex align-items-center">
<svg class="me-1" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 8v4l3 3m6-3a9 9 0 11-18 0 9 9 0 0118 0z"/>
</svg>
Ended {{ tvshow.last_air_date|date('Y') }}
</span>
{% endif %}
{% if tvshow.vote_average %}
<span class="d-flex align-items-center">
<svg class="me-1" width="16" height="16" fill="currentColor" viewBox="0 0 20 20">
<path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"/>
</svg>
{{ tvshow.vote_average }}/10
</span>
{% endif %}
{% if tvshow.number_of_seasons and tvshow.number_of_episodes %}
<span class="d-flex align-items-center">
<svg class="me-1" width="16" height="16" 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>
{{ tvshow.number_of_seasons }} season{{ tvshow.number_of_seasons > 1 ? 's' : '' }}, {{ tvshow.number_of_episodes }} episode{{ tvshow.number_of_episodes > 1 ? 's' : '' }}
</span>
{% endif %}
<span class="d-flex align-items-center">
<svg class="me-1" width="16" height="16" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"/>
</svg>
{{ tvshow.source_name }}
</span>
</div>
<!-- Status badges -->
<div class="d-flex flex-wrap gap-2">
{% if tvshow.status == 'Ended' %}
<span class="badge bg-danger d-flex align-items-center">
<svg class="me-1" width="12" height="12" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L3.732 16.5c-.77.833.192 2.5 1.732 2.5z"/>
</svg>
Ended
</span>
{% elseif tvshow.status == 'Returning Series' %}
<span class="badge bg-success d-flex align-items-center">
<svg class="me-1" width="12" height="12" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M13 10V3L4 14h7v7l9-11h-7z"/>
</svg>
Ongoing
</span>
{% endif %}
{% if tvshow.is_favorite %}
<span class="badge bg-warning text-dark d-flex align-items-center">
<svg class="me-1" width="12" height="12" fill="currentColor" viewBox="0 0 20 20">
<path d="M3.172 5.172a4 4 0 015.656 0L10 6.343l1.172-1.171a4 4 0 115.656 5.656L10 17.657l-6.828-6.829a4 4 0 010-5.656z"/>
</svg>
Favorite
</span>
{% endif %}
</div>
</div>
<!-- Overview -->
{% if tvshow.overview %}
<div class="mb-4">
<h2 class="h5 fw-semibold text-dark mb-2">Overview</h2>
<p class="text-muted">{{ tvshow.overview }}</p>
</div>
{% endif %}
<!-- Cast & Crew Section -->
<div class="mb-4">
<h2 class="h5 fw-semibold text-dark mb-3">Cast & Crew</h2>
<div class="row g-3">
{% if tvshow.created_by %}
<div class="col-md-6">
<div class="d-flex align-items-center">
<svg class="me-2 text-muted" width="20" height="20" 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>
<small class="text-muted d-block">Created by</small>
<span class="fw-medium">{{ tvshow.created_by }}</span>
</div>
</div>
</div>
{% endif %}
</div>
{% if actors %}
<div class="mt-3">
<small class="text-muted d-block mb-2">Main Cast</small>
<div class="d-flex flex-wrap gap-2">
{% for actor in actors %}
<span class="badge bg-light text-dark">{{ actor.name }}</span>
{% endfor %}
</div>
</div>
{% endif %}
</div>
<!-- TV Show Details Grid -->
<div class="row g-4 mb-4">
<!-- Genres -->
{% if tvshow.genre %}
<div class="col-md-4">
<h3 class="h6 fw-semibold text-dark mb-3">Genres</h3>
<div class="d-flex flex-wrap gap-2">
{% for genre in tvshow.genre|split(',') %}
<span class="badge bg-primary">{{ genre|trim }}</span>
{% endfor %}
</div>
</div>
{% endif %}
<!-- Networks & Production -->
{% if tvshow.networks or tvshow.production_companies %}
<div class="col-md-4">
<h3 class="h6 fw-semibold text-dark mb-3">Production</h3>
<div class="mb-2">
{% if tvshow.networks %}
<small class="text-muted d-block">Networks</small>
<span class="fw-medium">{{ tvshow.networks }}</span>
{% endif %}
</div>
{% if tvshow.production_companies %}
<div class="mb-2">
<small class="text-muted d-block">Companies</small>
<span class="fw-medium">{{ tvshow.production_companies }}</span>
</div>
{% endif %}
</div>
{% endif %}
<!-- Episode Details -->
{% if tvshow.episode_run_time or tvshow.origin_country %}
<div class="col-md-4">
<h3 class="h6 fw-semibold text-dark mb-3">Details</h3>
<div class="mb-2">
{% if tvshow.episode_run_time %}
<small class="text-muted d-block">Episode Runtime</small>
<span class="fw-medium">{{ tvshow.episode_run_time }} minutes</span>
{% endif %}
</div>
{% if tvshow.origin_country %}
<div class="mb-2">
<small class="text-muted d-block">Origin Country</small>
<span class="fw-medium">{{ tvshow.origin_country }}</span>
</div>
{% endif %}
{% if tvshow.original_language %}
<div class="mb-2">
<small class="text-muted d-block">Language</small>
<span class="fw-medium">{{ tvshow.original_language|upper }}</span>
</div>
{% endif %}
</div>
{% endif %}
</div>
<!-- Seasons Section -->
{% if seasons %}
<div class="mb-4">
<h3 class="h5 fw-semibold text-dark mb-3">Seasons</h3>
<div class="accordion" id="seasonsAccordion">
{% for season in seasons %}
<div class="accordion-item">
<h2 class="accordion-header" id="heading{{ season.season_number }}">
<button class="accordion-button {% if loop.first %}collapsed{% else %}collapsed{% endif %}" type="button" data-bs-toggle="collapse" data-bs-target="#collapse{{ season.season_number }}" aria-expanded="{% if loop.first %}true{% else %}false{% endif %}" aria-controls="collapse{{ season.season_number }}">
<div class="d-flex justify-content-between w-100">
<span>Season {{ season.season_number }}</span>
<span class="text-muted">{{ season.episode_count }} episodes</span>
</div>
</button>
</h2>
<div id="collapse{{ season.season_number }}" class="accordion-collapse collapse {% if loop.first %}show{% endif %}" aria-labelledby="heading{{ season.season_number }}" data-bs-parent="#seasonsAccordion">
<div class="accordion-body">
{% if season.episodes %}
<div class="list-group list-group-flush">
{% for episode in season.episodes %}
<div class="list-group-item d-flex align-items-center py-3">
<div class="flex-shrink-0 me-3">
{% if episode.poster_url %}
<img src="/images/{{ episode.poster_url }}" alt="{{ episode.title }}" class="rounded" style="width: 60px; height: 34px; object-fit: cover;">
{% else %}
<div class="rounded d-flex align-items-center justify-content-center bg-light" style="width: 60px; height: 34px;">
<svg class="text-muted" width="20" height="20" 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"/> <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> </svg>
TV Show ID: {{ tvshow.id }} </div>
{% endif %}
</div>
<div class="flex-grow-1">
<div class="d-flex align-items-center gap-2 mb-1">
<span class="badge bg-info">E{{ episode.episode_number }}</span>
{% if episode.air_date %}
<span class="small text-muted">{{ episode.air_date|date('M j, Y') }}</span>
{% endif %}
{% if episode.is_watched %}
<span class="badge bg-success">Watched</span>
{% endif %}
</div>
<h6 class="mb-1">{{ episode.title }}</h6>
{% if episode.overview %}
<p class="small text-muted mb-0">{{ episode.overview|slice(0, 100) }}{% if episode.overview|length > 100 %}...{% endif %}</p>
{% endif %}
</div>
</div>
{% endfor %}
</div>
{% else %}
<p class="text-muted">No episodes available.</p>
{% endif %}
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
<!-- Recent Episodes -->
{% if recent_episodes %}
<div class="mb-4">
<h3 class="h5 fw-semibold text-dark mb-3">Recent Episodes</h3>
<div class="vstack gap-3">
{% for episode in recent_episodes[:5] %}
<div class="card border-0 bg-light">
<div class="card-body p-3">
<div class="d-flex">
<div class="flex-shrink-0 me-3">
{% if episode.still_url %}
<img src="/images/{{ episode.still_url }}" alt="{{ episode.title }}" class="rounded" style="width: 120px; height: 68px; object-fit: cover;">
{% else %}
<div class="rounded d-flex align-items-center justify-content-center bg-secondary" style="width: 120px; height: 68px;">
<svg class="text-white" width="32" height="32" 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>
</div>
{% endif %}
</div>
<div class="flex-grow-1">
<div class="d-flex align-items-center gap-2 mb-1">
<span class="badge bg-info">S{{ episode.season_number }}E{{ episode.episode_number }}</span>
<span class="small text-muted">{{ episode.air_date|date('M j, Y') }}</span>
</div>
<h6 class="fw-medium mb-1">{{ episode.title }}</h6>
{% if episode.vote_average %}
<div class="d-flex align-items-center small text-muted">
<svg class="me-1 text-warning" width="14" height="14" fill="currentColor" viewBox="0 0 20 20">
<path d="M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"/>
</svg>
{{ episode.vote_average }}/10
</div>
{% endif %}
</div>
</div>
</div>
</div>
{% endfor %}
</div>
</div>
{% endif %}
<!-- Streaming & Availability -->
{% if tvshow.streaming_providers or tvshow.availability %}
<div class="mb-4">
<h3 class="h5 fw-semibold text-dark mb-3">Where to Watch</h3>
<div class="row g-3">
{% if tvshow.streaming_providers %}
<div class="col-md-6">
<small class="text-muted d-block mb-2">Streaming</small>
<div class="d-flex flex-wrap gap-2">
{% for provider in tvshow.streaming_providers %}
<span class="badge bg-success">{{ provider }}</span>
{% endfor %}
</div>
</div>
{% endif %}
{% if tvshow.availability %}
<div class="col-md-6">
<small class="text-muted d-block mb-2">Availability</small>
<span class="fw-medium">{{ tvshow.availability }}</span>
</div>
{% endif %}
</div>
</div>
{% endif %}
<!-- Metadata (for debugging/advanced users) -->
{% if metadata %}
<div class="mt-4 pt-4 border-top">
<details class="group">
<summary class="cursor-pointer small fw-medium text-muted hover:text-dark d-flex align-items-center">
<svg class="me-2 group-open:rotate-90 transition-transform" width="16" height="16" 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>
Technical Details & Metadata
</summary>
<div class="mt-3 small">
<pre class="bg-light p-3 rounded"><code>{{ metadata|json_encode(constant('JSON_PRETTY_PRINT')) }}</code></pre>
</div>
</details>
</div>
{% endif %}
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -92,6 +92,15 @@ $app->group('', function (RouteCollectorProxy $group) {
$syncGroup->get('/status/{log_id}', 'App\Controllers\SyncController:status')->setName('admin.sync.status'); $syncGroup->get('/status/{log_id}', 'App\Controllers\SyncController:status')->setName('admin.sync.status');
$syncGroup->post('/{log_id}/cancel', 'App\Controllers\SyncController:cancel')->setName('admin.sync.cancel'); $syncGroup->post('/{log_id}/cancel', 'App\Controllers\SyncController:cancel')->setName('admin.sync.cancel');
$syncGroup->post('/clear-logs', 'App\Controllers\SyncController:clearLogs')->setName('admin.sync.clearLogs'); $syncGroup->post('/clear-logs', 'App\Controllers\SyncController:clearLogs')->setName('admin.sync.clearLogs');
}); });
// Playnite Import
$adminGroup->group('/playnite', function (RouteCollectorProxy $playniteGroup) {
$playniteGroup->get('/import', 'App\Controllers\PlayniteImportController:showImport')->setName('admin.playnite.import');
$playniteGroup->post('/import', 'App\Controllers\PlayniteImportController:upload')->setName('admin.playnite.upload');
//$playniteGroup->get('/upload', 'App\Controllers\PlayniteImportController:upload')->setName('admin.playnite.upload');
$playniteGroup->post('/confirm', 'App\Controllers\PlayniteImportController:confirm')->setName('admin.playnite.confirm');
$playniteGroup->post('/cancel', 'App\Controllers\PlayniteImportController:cancel')->setName('admin.playnite.cancel');
$playniteGroup->post('/api', 'App\Controllers\PlayniteImportController:apiImport')->setName('admin.playnite.api');
});
})->add(AdminMiddleware::class); })->add(AdminMiddleware::class);