Compare commits

...

9 Commits

Author SHA1 Message Date
Brock H Caldwell
a30a554e06 fix: mysql healthcheck
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after 13s
2026-03-01 22:54:06 -06:00
Brock H Caldwell
bd6918abd1 fix: injects TMDB API token in build
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after 13s
2026-03-01 21:57:02 -06:00
Brock H Caldwell
9a0b0443d4 chore: lists filename in error output
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after 13s
2026-03-01 14:03:04 -06:00
1726b21d1d fix: uses latest tag by default
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after 13s
2026-03-01 18:37:09 +00:00
Brock H Caldwell
207fd26f50 fix: prevents 'your torrent is being downloaded' downloads from download seasson handler
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after 13s
2026-02-11 16:27:49 -06:00
Brock H Caldwell
aa357725e8 fix: prevents 'your torrent is being downloaded' downloads
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after -1m13s
2026-02-11 16:21:17 -06:00
Brock H Caldwell
759f64ea22 fix(DownloadSeasonHandler): actually captures season/episode numbers 2026-02-08 21:51:02 -06:00
Brock H Caldwell
cc88660c07 fix(DownloadSeasonHandler): captures episode id
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after 13s
2026-02-08 15:11:14 -06:00
Brock H Caldwell
dbcc24c49f fix(DownloadOptionEvaluator): bad logic checking filters
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after -50s
2026-02-08 12:34:50 -06:00
10 changed files with 74 additions and 53 deletions

3
.gitignore vendored
View File

@@ -24,3 +24,6 @@ phpstan.neon
/phpunit.xml
/.phpunit.cache/
###< phpunit/phpunit ###
docs/examples/movies/
docs/examples/tvshows/

View File

@@ -3,6 +3,9 @@ FROM code.caldwell.digital/home/torsearch-base:php8.4
ARG APP_VERSION="0.0.0-dev"
ENV APP_VERSION="${APP_VERSION}"
ARG TMDB_API=""
ENV TMDB_API="${TMDB_API}"
COPY . /app
COPY --chmod=775 docker/app/entrypoint.sh /usr/local/bin/docker-entrypoint
COPY docker/app/Caddyfile /etc/frankenphp/Caddyfile

View File

@@ -17,6 +17,9 @@ FROM code.caldwell.digital/home/torsearch-base-worker-supervisord:latest
# Set the APP_VERSION in the image
ENV APP_VERSION=${APP_VERSION}
ARG TMDB_API=""
ENV TMDB_API="${TMDB_API}"
# Copy the actual application code from the previously built app
COPY --chown=1000:1000 --from=app_image /app /app

View File

@@ -17,6 +17,9 @@ FROM code.caldwell.digital/home/torsearch-base-worker-supervisord:latest
# Set the APP_VERSION in the image
ENV APP_VERSION=${APP_VERSION}
ARG TMDB_API=""
ENV TMDB_API="${TMDB_API}"
# Copy the actual application code from the previously built app
COPY --chown=1000:1000 --from=app_image /app /app

View File

@@ -2,7 +2,7 @@
# Torsearch #
###################
# The version of Torsearch to run. Docker will this tag.
TAG=0.38.0
TAG=latest
# The port for which the web server (app container) will
# serve the application on the host.
@@ -11,8 +11,8 @@ WEB_PORT=8004
# The host directories where your media is stored.
# If you would like to use a docker driver for a network
# share, update the compose.yml file to reflect that.
LOCAL_MOVIES_DIR="<enter movies dir>"
LOCAL_TVSHOWS_DIR="<enter tvshows dir>"
LOCAL_MOVIES_DIR="./movies"
LOCAL_TVSHOWS_DIR="./tvshows"
# Set the timezone you're in. This helps render monitored items correctly on the calendar
TZ=America/Chicago
@@ -34,6 +34,8 @@ APP_ENV=prod
# Mercure is a Caddy module built into the webserver
# that facilitates the usage of websockets to transmit
# real time data (download progress, etc.)
# TBH, I've only run into issues when changing these. If
# you have problems after changing them, just revert them.
MERCURE_JWT_SECRET="!ChangeThisMercureHubJWTSecretKey!"
MERCURE_PUBLISHER_JWT_KEY="!ChangeThisMercureHubJWTSecretKey!"
MERCURE_SUBSCRIBER_JWT_KEY="!ChangeThisMercureHubJWTSecretKey!"
@@ -45,11 +47,11 @@ MERCURE_SUBSCRIBER_JWT_KEY="!ChangeThisMercureHubJWTSecretKey!"
# Use the DATABASE_URL below to use the MariaDB container
# provided in the example.compose.yml file, or remove this
# line and fill in the details of your own MySQL/MariaDB server
MYSQL_RANDOM_ROOT_PASSWORD=true
MYSQL_DATABASE=app
MYSQL_USER=app
MYSQL_PASSWORD=password
MYSQL_PASSWORD="P@ssword123"
MYSQL_DATABASE=app
MYSQL_HOST=database
MYSQL_RANDOM_ROOT_PASSWORD=true
DATABASE_URL="mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@${MYSQL_HOST}:3306/${MYSQL_DATABASE}?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
@@ -60,15 +62,6 @@ DATABASE_URL="mysql://${MYSQL_USER}:${MYSQL_PASSWORD}@${MYSQL_HOST}:3306/${MYSQL
REAL_DEBRID_KEY="<enter real debrid api key>"
###################
# TMDB #
###################
# Enter your TMDB API key
# This is used to provide rich search results when searching
# for media and rendering the Popular Movies and TV Shows section.
TMDB_API="<enter tmdb api key>"
###################
# Redis #
###################

View File

@@ -6,7 +6,8 @@ services:
- "${WEB_PORT}:80"
env_file: .env
depends_on:
- database
database:
condition: service_healthy
volumes:
- ${LOCAL_MOVIES_DIR}:/var/download/movies
- ${LOCAL_TVSHOWS_DIR}:/var/download/tvshows
@@ -43,7 +44,7 @@ services:
- mysql:/var/lib/mysql
env_file: .env
healthcheck:
test: [ "CMD", "mysqladmin", "-u", "${MYSQL_USER}", "-p", "${MYSQL_PASSWORD}" ,"ping", "-h", "localhost" ]
test: ["CMD", "mysqladmin", "ping"]
interval: 5s
timeout: 5s
retries: 10

View File

@@ -99,6 +99,7 @@ readonly class DownloadMediaHandler implements HandlerInterface
$badFileLocations = [
'https://torrentio.strem.fun/videos/failed_infringement_v2.mp4' => 'Removed for Copyright Infringement.',
'https://torrentio.strem.fun/videos/downloading_v2.mp4' => 'Your torrent is downloading to your debrid provider.'
];
$headers = get_headers($downloadUrl, true);

View File

@@ -10,6 +10,8 @@ use App\Download\Action\Command\DownloadSeasonCommand;
use App\Download\Action\Result\DownloadMediaResult;
use App\Download\Action\Result\DownloadSeasonResult;
use App\Download\DownloadOptionEvaluator;
use App\Download\Framework\Entity\Download;
use App\Download\Framework\Repository\DownloadRepository;
use App\Tmdb\TmdbClient;
use App\Torrentio\Action\Command\GetTvShowOptionsCommand;
use App\Torrentio\Action\Handler\GetTvShowOptionsHandler;
@@ -26,13 +28,13 @@ use Symfony\Component\Messenger\MessageBusInterface;
readonly class DownloadSeasonHandler implements HandlerInterface
{
public function __construct(
private MediaFiles $mediaFiles,
private LoggerInterface $logger,
private TmdbClient $tmdb,
private MessageBusInterface $bus,
private MediaFiles $mediaFiles,
private LoggerInterface $logger,
private TmdbClient $tmdb,
private MessageBusInterface $bus,
private DownloadOptionEvaluator $downloadOptionEvaluator,
private GetTvShowOptionsHandler $getTvShowOptionsHandler,
private UserRepository $userRepository,
private UserRepository $userRepository, private DownloadRepository $downloadRepository,
) {}
public function handle(CommandInterface $command): ResultInterface
@@ -68,13 +70,16 @@ readonly class DownloadSeasonHandler implements HandlerInterface
if (null !== $result) {
$this->logger->info('> [DownloadTvSeasonHandler] ......Found 1 matching result');
$this->logger->info('> [DownloadTvSeasonHandler] ......Dispatching DownloadMediaCommand for "' . $series->title . '" season ' . $command->season . ' episode ' . $episode->episodeNumber);
$download = $this->createDownload($command, $result->url, $series->title, $result->filename, $episode->episodeNumber);
$this->logger->info('> [DownloadTvSeasonHandler] ......Created Download entity with id ' . $download->getId());
$downloadCommand = new DownloadMediaCommand(
$result->url,
$series->title,
$result->filename,
'tvshows',
$command->imdbId,
$command->userId,
$download->getUrl(),
$download->getTitle(),
$download->getFilename(),
$download->getMediaType(),
$download->getImdbId(),
$download->getUser()->getId(),
$download->getId()
);
$this->bus->dispatch($downloadCommand);
$downloadCommands[] = $downloadCommand;
@@ -90,19 +95,27 @@ readonly class DownloadSeasonHandler implements HandlerInterface
);
}
private function getDownloadedEpisodes(string $title)
private function createDownload(DownloadSeasonCommand $command, string $url, string $title, string $filename, int $episodeNumber): Download
{
// Check current episodes
$downloadedEpisodes = $this->mediaFiles
->getEpisodes($title)
->map(fn($episode) => (object) (new PTN())->parse($episode))
->filter(fn ($episode) =>
property_exists($episode, 'episode')
&& property_exists($episode, 'season')
&& null !== $episode->episodeNumber
&& null !== $episode->season
)
->rekey(fn($episode) => $episode->episodeNumber);
$this->logger->info('> [MonitorTvSeasonHandler] Found ' . count($downloadedEpisodes) . ' downloaded episodes for title: ' . $monitor->getTitle());
$download = new Download();
$download->setUrl($url);
$download->setTitle($title);
$download->setFilename($filename);
$download->setImdbId($command->imdbId);
$download->setMediaType(MediaType::TvShow->value);
$download->setEpisodeId($this->getEpisodeNumber($command->season, $episodeNumber));
$download->setUser($this->userRepository->find($command->userId));
$this->downloadRepository->getEntityManager()->persist($download);
$this->downloadRepository->getEntityManager()->flush();
return $download;
}
private function getEpisodeNumber(int $season, int $episode): string
{
return sprintf(
"S%sE%s",
str_pad($season, 2, "0", STR_PAD_LEFT),
str_pad($episode, 2, "0", STR_PAD_LEFT)
);
}
}

View File

@@ -21,9 +21,10 @@ class DownloadOptionEvaluator
return false;
}
if (false === $this->validateSize($result, $filter)) {
return false;
}
// todo: This is arbitrary- revisit in the future
//if (false === $this->validateSize($result, $filter)) {
// return false;
//}
if (false === $this->validateDownloadUrl($result->url)) {
return false;
@@ -51,15 +52,15 @@ class DownloadOptionEvaluator
$valid = false;
}
if (null !== $filter->codec && in_array($result->codec, $filter->codec)) {
if (null !== $filter->codec && !in_array($result->codec, $filter->codec)) {
$valid = false;
}
if (null !== $filter->quality && in_array($result->quality, $filter->quality)) {
if (null !== $filter->quality && !in_array($result->quality, $filter->quality)) {
$valid = false;
}
if (null !== $filter->provider && in_array($result->provider, $filter->provider)) {
if (null !== $filter->provider && !in_array($result->provider, $filter->provider)) {
$valid = false;
}
@@ -88,6 +89,7 @@ class DownloadOptionEvaluator
{
$badFileLocations = [
'https://torrentio.strem.fun/videos/failed_infringement_v2.mp4' => 'Removed for Copyright Infringement.',
'https://torrentio.strem.fun/videos/downloading_v2.mp4' => 'Your torrent is downloading to your debrid provider.'
];
$headers = get_headers($downloadUrl, true);

View File

@@ -2,15 +2,14 @@
{% block body %}
<h2 class="px-4 py-4 text-3xl font-extrabold text-orange-500">500</h2>
<div class="flex flex-col bg-orange-500/50 p-4 rounded-lg gap-4 w-full md:w-[420px] border-orange-500 border-2 text-gray-50 animate-fade">
<div class="flex flex-col bg-orange-500/50 p-4 rounded-lg gap-4 w-full md:w-[540px] border-orange-500 border-2 text-gray-50 animate-fade">
<div class="flex flex-col m-0 text-center">
<h3 class="text-2xl text-bold text-center text-gray-50">Oh crap!</h3>
</div>
<p class="mb-2">There are many things I'm capable of, but this ain't one of 'em!</p>
<pre class="bg-gray-800 text-white p-4 rounded-md overflow-x-auto">
<code class="language-plaintext">
{{ exception.message }}
</code>
</pre>
<p class="text-sm mb-1">
<code>{{ exception.file }}</code>
</p>
<pre class="bg-gray-800 text-white p-4 rounded-md overflow-x-auto"><code class="language-plaintext">{{ exception.message|trim }}</code></pre>
</div>
{% endblock %}