wip: displays file info for existing tv episodes

This commit is contained in:
2025-06-07 21:36:33 -05:00
parent 228d320edc
commit f9a284cb67
9 changed files with 133 additions and 7 deletions

3
assets/bootstrap.js vendored
View File

@@ -1,5 +1,6 @@
import { startStimulusApp } from '@symfony/stimulus-bundle';
import Popover from '@stimulus-components/popover'
const app = startStimulusApp();
// register any custom, 3rd party controllers here
// app.register('some_controller_name', SomeImportedController);
app.register('popover', Popover);

View File

@@ -9,6 +9,7 @@
"ext-iconv": "*",
"1tomany/rich-bundle": "^1.8",
"aimeos/map": "^3.12",
"chrisullyott/php-filesize": "^4.2",
"doctrine/dbal": "^3",
"doctrine/doctrine-bundle": "^2.14",
"doctrine/doctrine-fixtures-bundle": "^4.1",

51
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "63610a631352051ae8327669536efcef",
"content-hash": "c519733202d45f8fb3a4f5b8e7dfb95b",
"packages": [
{
"name": "1tomany/rich-bundle",
@@ -186,6 +186,55 @@
],
"time": "2023-12-11T17:09:12+00:00"
},
{
"name": "chrisullyott/php-filesize",
"version": "v4.2.1",
"source": {
"type": "git",
"url": "https://github.com/chrisullyott/php-filesize.git",
"reference": "967ea3365c00974b50b608ffc045a267ab92ef43"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/chrisullyott/php-filesize/zipball/967ea3365c00974b50b608ffc045a267ab92ef43",
"reference": "967ea3365c00974b50b608ffc045a267ab92ef43",
"shasum": ""
},
"require": {
"php": ">=7.1"
},
"require-dev": {
"phpunit/phpunit": "^7"
},
"type": "library",
"autoload": {
"psr-4": {
"ChrisUllyott\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Chris Ullyott",
"email": "contact@chrisullyott.com",
"homepage": "http://www.chrisullyott.com"
}
],
"description": "Easily calculate file sizes and convert between units.",
"homepage": "https://github.com/chrisullyott/php-filesize",
"keywords": [
"php",
"size-calculation"
],
"support": {
"issues": "https://github.com/chrisullyott/php-filesize/issues",
"source": "https://github.com/chrisullyott/php-filesize"
},
"time": "2021-10-17T22:52:23+00:00"
},
{
"name": "composer/semver",
"version": "3.4.3",

View File

@@ -5,6 +5,7 @@
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters:
# Media
media.base_path: '/var/download'
media.default_movies_dir: movies
media.default_tvshows_dir: tvshows
media.movies_path: '%env(default:media.default_movies_dir:MOVIES_PATH)%'

View File

@@ -28,4 +28,7 @@ return [
'@hotwired/turbo' => [
'version' => '7.3.0',
],
'@stimulus-components/popover' => [
'version' => '7.0.0',
],
];

View File

@@ -13,6 +13,8 @@ class MediaFiles
{
private Finder $finder;
private string $basePath;
private string $moviesPath;
private string $tvShowsPath;
@@ -20,6 +22,9 @@ class MediaFiles
private Filesystem $filesystem;
public function __construct(
#[Autowire(param: 'media.base_path')]
string $basePath,
#[Autowire(param: 'media.movies_path')]
string $moviesPath,
@@ -29,6 +34,7 @@ class MediaFiles
Filesystem $filesystem,
) {
$this->finder = new Finder();
$this->basePath = $basePath;
$this->moviesPath = $moviesPath;
$this->tvShowsPath = $tvShowsPath;
$this->filesystem = $filesystem;
@@ -45,6 +51,11 @@ class MediaFiles
throw new \Exception(sprintf('A path for media type %s does not exist.', $mediaType));
}
public function getBasePath(): string
{
return $this->basePath;
}
public function getMoviesPath(): string
{
return $this->moviesPath;

View File

@@ -0,0 +1,32 @@
<?php
namespace App\Twig\Extensions;
use App\Monitor\Framework\Entity\Monitor;
use App\Monitor\Service\MediaFiles;
use ChrisUllyott\FileSize;
use Twig\Attribute\AsTwigFilter;
class UtilExtension
{
public function __construct(
private readonly MediaFiles $mediaFiles,
) {}
#[AsTwigFilter('filesize')]
public function type(string|int $size)
{
return (new FileSize($size))->asAuto();
}
#[AsTwigFilter('strip_media_path')]
public function stripMediaPath(string $path)
{
return str_replace(
$this->mediaFiles->getBasePath() . DIRECTORY_SEPARATOR,
'',
$path
);
}
}

View File

@@ -12,10 +12,25 @@ module.exports = {
"bg-purple-400",
"bg-orange-400",
"bg-blue-600",
"bg-rose-600"
"bg-rose-600",
"transition-opacity",
"ease-in",
"duration-700",
"opacity-100"
],
theme: {
extend: {},
extend: {
animation: {
fade: 'fadeIn .3s ease-in-out',
},
keyframes: {
fadeIn: {
from: { opacity: 0 },
to: { opacity: 1 },
},
},
},
},
plugins: [],
}

View File

@@ -20,9 +20,22 @@
</small>
{% if results.file != false %}
<small class="py-1 px-1.5 mr-1 grow-0 font-bold bg-blue-600 rounded-lg text-center text-white" title="{{ results.file.filename }}">
exists
</small>
<span data-controller="popover">
<template data-popover-target="content">
<div data-popover-target="card" class="absolute z-40 p-1 bg-stone-400 p-1 text-black rounded-md m-1 animate-fade">
<p class="font-bold text-sm text-left">Existing file(s) for this episode:</p>
<ul class="list-disc ml-3">
<li class="font-normal">{{ results.file.realPath|strip_media_path }} &mdash; <strong>{{ results.file.size|filesize }}</strong></li>
</ul>
</div>
</template>
<small
class="py-1 px-1.5 mr-1 grow-0 font-bold bg-blue-600 rounded-lg text-center text-white"
data-action="mouseenter->popover#show mouseleave->popover#hide"
>
exists
</small>
</span>
{% endif %}
{% if results.file == false %}