Compare commits

..

3 Commits

Author SHA1 Message Date
cb51483a00 Merge branch 'main' into dev-cache 2025-06-22 22:19:21 -05:00
2dc53c5270 feat: tags torrentio cache 2025-06-22 22:08:08 -05:00
9714cf1749 wip: adds clear cache button 2025-06-21 08:17:55 -05:00
3 changed files with 19 additions and 4 deletions

View File

@@ -10,8 +10,8 @@ use App\Torrentio\Exception\TorrentioRateLimitException;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Contracts\Cache\CacheInterface;
use Symfony\Contracts\Cache\ItemInterface; use Symfony\Contracts\Cache\ItemInterface;
use Symfony\Contracts\Cache\TagAwareCacheInterface;
class Torrentio class Torrentio
{ {
@@ -23,7 +23,7 @@ class Torrentio
public function __construct( public function __construct(
#[Autowire(env: 'REAL_DEBRID_KEY')] private string $realDebridKey, #[Autowire(env: 'REAL_DEBRID_KEY')] private string $realDebridKey,
private CacheInterface $cache, private TagAwareCacheInterface $cache,
private LoggerInterface $logger, private LoggerInterface $logger,
) { ) {
$this->searchUrl = str_replace('{realDebridKey}', $this->realDebridKey, $this->baseUrl); $this->searchUrl = str_replace('{realDebridKey}', $this->realDebridKey, $this->baseUrl);
@@ -36,8 +36,9 @@ class Torrentio
{ {
$cacheKey = "torrentio.{$imdbCode}"; $cacheKey = "torrentio.{$imdbCode}";
$results = $this->cache->get($cacheKey, function (ItemInterface $item) use ($imdbCode) { $results = $this->cache->get($cacheKey, function (ItemInterface $item) use ($imdbCode, $type) {
$item->expiresAt(Carbon::now()->addHour()->setMinute(0)->setSecond(0)); $item->expiresAt(Carbon::now()->addHour()->setMinute(0)->setSecond(0));
$item->tag(['torrentio', $type, $imdbCode]);
try { try {
$response = $this->client->get("$this->searchUrl/$imdbCode.json"); $response = $this->client->get("$this->searchUrl/$imdbCode.json");
return json_decode( return json_decode(
@@ -63,6 +64,7 @@ class Torrentio
$cacheKey = "torrentio.$imdbId.$season.$episode"; $cacheKey = "torrentio.$imdbId.$season.$episode";
$results = $this->cache->get($cacheKey, function (ItemInterface $item) use ($imdbId, $season, $episode) { $results = $this->cache->get($cacheKey, function (ItemInterface $item) use ($imdbId, $season, $episode) {
$item->expiresAt(Carbon::now()->addHour()->setMinute(0)->setSecond(0)); $item->expiresAt(Carbon::now()->addHour()->setMinute(0)->setSecond(0));
$item->tag(['torrentio', 'tvshows', 'torrentio.tvshows', $imdbId, "torrentio.$imdbId", "$imdbId.$season", "torrentio.$imdbId.$season", "$imdbId.$season.$episode", "torrentio.$imdbId.$season.$episode"]);
try { try {
$response = $this->client->get("$this->searchUrl/$imdbId:$season:$episode.json"); $response = $this->client->get("$this->searchUrl/$imdbId:$season:$episode.json");
return json_decode( return json_decode(

View File

@@ -19,7 +19,12 @@
</div> </div>
<div class="col-span-5 h-screen overflow-y-scroll"> <div class="col-span-5 h-screen overflow-y-scroll">
<twig:Header /> <twig:Header />
<h2 class="px-4 my-2 text-3xl font-bold text-gray-50">{% block h2 %}{% endblock %}</h2> <div class="px-4 mt-3 flex flex-row justify-between">
<h2 class="text-3xl font-bold text-gray-50">{% block h2 %}{% endblock %}</h2>
<div class="flex flex-row gap-1 align-end justify-end items-end">
{% block action_buttons %}{% endblock %}
</div>
</div>
{% block body %}{% endblock %} {% block body %}{% endblock %}
</div> </div>
</div> </div>

View File

@@ -2,6 +2,14 @@
{% block title %}Preferences{% endblock %} {% block title %}Preferences{% endblock %}
{% block h2 %}Preferences{% endblock %} {% block h2 %}Preferences{% endblock %}
{% block action_buttons %}
<button
class="px-1.5 py-1 my-2 text-white text-sm bg-blue-950 hover:bg-black/80 border-2 border-blue-500/90 rounded-md inline-block"
>
Clear Cache
</button>
{% endblock %}
{% block body %} {% block body %}
<div class="p-4 flex flex-row gap-2"> <div class="p-4 flex flex-row gap-2">
<twig:Card title="Media Preferences" class="w-full"> <twig:Card title="Media Preferences" class="w-full">