Compare commits
18 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9e2c5410ba | ||
|
|
4087543e78 | ||
|
|
d358ef8de6 | ||
|
|
79d9d61592 | ||
|
|
4d0a198510 | ||
|
|
5da1dde24d | ||
|
|
6ed327f78e | ||
|
|
1827c1df71 | ||
|
|
0c5fd2544b | ||
|
|
a6d5e2b026 | ||
|
|
688ea98922 | ||
|
|
d55a9cfdd5 | ||
|
|
e9021c22fa | ||
|
|
939660a715 | ||
|
|
fb3e7b20ff | ||
|
|
699dbaabc3 | ||
|
|
484ac40d99 | ||
|
|
b8a22e63c9 |
2
.env
2
.env
@@ -31,6 +31,8 @@ DATABASE_URL=
|
||||
|
||||
###< doctrine/doctrine-bundle ###
|
||||
MERCURE_JWT_SECRET="!ChangeThisMercureHubJWTSecretKey!"
|
||||
MERCURE_PUBLISHER_JWT_KEY="!ChangeThisMercureHubJWTSecretKey!"
|
||||
MERCURE_SUBSCRIBER_JWT_KEY="!ChangeThisMercureHubJWTSecretKey!"
|
||||
###> symfony/messenger ###
|
||||
# Choose one of the transports below
|
||||
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
|
||||
|
||||
59
.gitea/workflows/build_base_images.yml
Normal file
59
.gitea/workflows/build_base_images.yml
Normal file
@@ -0,0 +1,59 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-base-app:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Login to registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: "${{ vars.REGISTRY_URL }}"
|
||||
username: "${{ vars.REGISTRY_USER }}"
|
||||
password: "${{ vars.REGISTRY_PASS }}"
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
env:
|
||||
APP_FRANKENPHP_TAG: php8.4
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
file: docker/Dockerfile.base.worker
|
||||
platforms: linux/amd64
|
||||
build-args: |
|
||||
APP_FRANKENPHP_TAG=${{ env.APP_FRANKENPHP_TAG }}
|
||||
tags: |
|
||||
code.caldwell.digital/home/torsearch-base:${APP_FRANKENPHP_TAG}
|
||||
code.caldwell.digital/home/torsearch-base:latest
|
||||
|
||||
build-base-worker-supervisord:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repo
|
||||
uses: actions/checkout@v5
|
||||
|
||||
- name: Login to registry
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: "${{ vars.REGISTRY_URL }}"
|
||||
username: "${{ vars.REGISTRY_USER }}"
|
||||
password: "${{ vars.REGISTRY_PASS }}"
|
||||
|
||||
- name: Build and push
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
file: docker/Dockerfile.base.worker
|
||||
platforms: linux/amd64
|
||||
build-args: |
|
||||
ALPINE_VERSION=3.22
|
||||
tags: |
|
||||
code.caldwell.digital/home/torsearch-base-worker-supervisord:latest
|
||||
@@ -2,6 +2,8 @@ name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- "main"
|
||||
tags:
|
||||
- "v*"
|
||||
|
||||
@@ -45,7 +47,7 @@ jobs:
|
||||
tag="${{ gitea.REF_NAME }}"
|
||||
tmdb_api="${{ vars.TMDB_API }}"
|
||||
version=${tag:1}
|
||||
docker build -f docker/Dockerfile.app \
|
||||
docker build --pull -f docker/Dockerfile.app \
|
||||
-t code.caldwell.digital/home/torsearch-app:${version} \
|
||||
-t code.caldwell.digital/home/torsearch-app:latest \
|
||||
--build-arg "APP_VERSION=${version}" \
|
||||
@@ -59,7 +61,7 @@ jobs:
|
||||
tag="${{ gitea.REF_NAME }}"
|
||||
tmdb_api="${{ vars.TMDB_API }}"
|
||||
version=${tag:1}
|
||||
docker build -f docker/Dockerfile.worker \
|
||||
docker build --pull -f docker/Dockerfile.worker \
|
||||
-t code.caldwell.digital/home/torsearch-worker:${version} \
|
||||
-t code.caldwell.digital/home/torsearch-worker:latest \
|
||||
--build-arg "APP_VERSION=${version}" \
|
||||
@@ -73,7 +75,7 @@ jobs:
|
||||
tag="${{ gitea.REF_NAME }}"
|
||||
tmdb_api="${{ vars.TMDB_API }}"
|
||||
version=${tag:1}
|
||||
docker build -f docker/Dockerfile.scheduler \
|
||||
docker build --pull -f docker/Dockerfile.scheduler \
|
||||
-t code.caldwell.digital/home/torsearch-scheduler:${version} \
|
||||
-t code.caldwell.digital/home/torsearch-scheduler:latest \
|
||||
--build-arg "APP_VERSION=${version}" \
|
||||
|
||||
@@ -1,22 +1,19 @@
|
||||
# torsearch-app is built from this base
|
||||
export APP_FRANKENPHP_TAG=php8.4
|
||||
|
||||
#docker buildx build --platform=linux/amd64,linux/arm64 -f docker/Dockerfile.base.app -t code.caldwell.digital/home/torsearch-base:${APP_FRANKENPHP_TAG} -t code.caldwell.digital/home/torsearch-base:latest --build-arg "FRANKENPHP_TAG=${APP_FRANKENPHP_TAG}" .
|
||||
docker build -f docker/Dockerfile.base.app -t code.caldwell.digital/home/torsearch-base:${APP_FRANKENPHP_TAG} -t code.caldwell.digital/home/torsearch-base:latest --build-arg "FRANKENPHP_TAG=${APP_FRANKENPHP_TAG}" .
|
||||
docker push code.caldwell.digital/home/torsearch-base:${APP_FRANKENPHP_TAG}
|
||||
docker push code.caldwell.digital/home/torsearch-base:latest
|
||||
docker buildx build --platform=linux/amd64 -f docker/Dockerfile.base.app -t code.caldwell.digital/home/torsearch-base:${APP_FRANKENPHP_TAG} -t code.caldwell.digital/home/torsearch-base:latest --build-arg "FRANKENPHP_TAG=${APP_FRANKENPHP_TAG}" .
|
||||
docker push --platform=linux/amd64 code.caldwell.digital/home/torsearch-base:${APP_FRANKENPHP_TAG}
|
||||
docker push --platform=linux/amd64 code.caldwell.digital/home/torsearch-base:latest
|
||||
|
||||
# torsearch-worker & torsearch-scheduler are built from this base
|
||||
export WORKER_FRANKENPHP_TAG=php8.4-alpine
|
||||
|
||||
#docker buildx build --platform=linux/amd64,linux/arm64 -f docker/Dockerfile.base.worker -t code.caldwell.digital/home/torsearch-base-worker:${WORKER_FRANKENPHP_TAG} -t code.caldwell.digital/home/torsearch-base-worker:latest --build-arg "FRANKENPHP_TAG=${WORKER_FRANKENPHP_TAG}" .
|
||||
docker build -f docker/Dockerfile.base.worker -t code.caldwell.digital/home/torsearch-base-worker:${WORKER_FRANKENPHP_TAG} -t code.caldwell.digital/home/torsearch-base-worker:latest --build-arg "FRANKENPHP_TAG=${WORKER_FRANKENPHP_TAG}" .
|
||||
docker push code.caldwell.digital/home/torsearch-base-worker:${WORKER_FRANKENPHP_TAG}
|
||||
docker push code.caldwell.digital/home/torsearch-base-worker:latest
|
||||
docker buildx build --platform=linux/amd64 -f docker/Dockerfile.base.worker -t code.caldwell.digital/home/torsearch-base-worker:${WORKER_FRANKENPHP_TAG} -t code.caldwell.digital/home/torsearch-base-worker:latest --build-arg "FRANKENPHP_TAG=${WORKER_FRANKENPHP_TAG}" .
|
||||
docker push --platform=linux/amd64 code.caldwell.digital/home/torsearch-base-worker:${WORKER_FRANKENPHP_TAG}
|
||||
docker push --platform=linux/amd64 code.caldwell.digital/home/torsearch-base-worker:latest
|
||||
|
||||
# torsearch-worker-supervisord
|
||||
export ALPINE_VERSION=3.22
|
||||
|
||||
#docker buildx build --platform=linux/amd64,linux/arm64 -f docker/Dockerfile.base.worker -t code.caldwell.digital/home/torsearch-base-worker-supervisord:latest --build-arg "ALPINE_VERSION=${ALPINE_VERSION}" .
|
||||
docker build -f docker/Dockerfile.base.worker -t code.caldwell.digital/home/torsearch-base-worker-supervisord:latest --build-arg "ALPINE_VERSION=${ALPINE_VERSION}" .
|
||||
docker push code.caldwell.digital/home/torsearch-base-worker-supervisord:latest
|
||||
docker buildx build --platform=linux/amd64 -f docker/Dockerfile.base.worker -t code.caldwell.digital/home/torsearch-base-worker-supervisord:latest --build-arg "ALPINE_VERSION=${ALPINE_VERSION}" .
|
||||
docker push --platform=linux/amd64 code.caldwell.digital/home/torsearch-base-worker-supervisord:latest
|
||||
|
||||
@@ -27,8 +27,8 @@ services:
|
||||
tty: true
|
||||
environment:
|
||||
TZ: America/Chicago
|
||||
MERCURE_PUBLISHER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
|
||||
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
|
||||
MERCURE_PUBLISHER_JWT_KEY: "${MERCURE_PUBLISHER_JWT_KEY}"
|
||||
MERCURE_SUBSCRIBER_JWT_KEY: "${MERCURE_SUBSCRIBER_JWT_KEY}"
|
||||
depends_on:
|
||||
database:
|
||||
condition: service_healthy
|
||||
|
||||
@@ -16,11 +16,13 @@ RUN apk add --no-cache \
|
||||
php84-fileinfo \
|
||||
php84-fpm \
|
||||
php84-gd \
|
||||
php84-intl \
|
||||
php84-mbstring \
|
||||
php84-mysqli \
|
||||
php84-opcache \
|
||||
php84-openssl \
|
||||
php84-pdo_mysql \
|
||||
php84-session \
|
||||
php84-tokenizer \
|
||||
php84-xml \
|
||||
supervisor
|
||||
|
||||
@@ -113,9 +113,14 @@ class MediaFiles
|
||||
return Map::from($results);
|
||||
}
|
||||
|
||||
public function createMovieDirectory(string $path): string
|
||||
public function createMovieDirectory(string $title, string|int $year): string
|
||||
{
|
||||
$path = $this->moviesPath . DIRECTORY_SEPARATOR . $path;
|
||||
$path = sprintf(
|
||||
'%s' . DIRECTORY_SEPARATOR . '%s (%s)',
|
||||
$this->moviesPath,
|
||||
$title,
|
||||
$year
|
||||
);
|
||||
|
||||
if (false === $this->filesystem->exists($path)) {
|
||||
$this->filesystem->mkdir($path);
|
||||
@@ -124,9 +129,14 @@ class MediaFiles
|
||||
return $path;
|
||||
}
|
||||
|
||||
public function createTvShowDirectory(string $path): string
|
||||
public function createTvShowDirectory(string $title, string|int $year): string
|
||||
{
|
||||
$path = $this->tvShowsPath . DIRECTORY_SEPARATOR . $path;
|
||||
$path = sprintf(
|
||||
'%s' . DIRECTORY_SEPARATOR . '%s (%s)',
|
||||
$this->tvShowsPath,
|
||||
$title,
|
||||
$year
|
||||
);
|
||||
|
||||
if (false === $this->filesystem->exists($path)) {
|
||||
$this->filesystem->mkdir($path);
|
||||
|
||||
@@ -7,6 +7,8 @@ use App\Base\Service\MediaFiles;
|
||||
use App\Download\DownloadEvents;
|
||||
use App\Download\Framework\Entity\Download;
|
||||
use App\EventLog\Action\Command\AddEventLogCommand;
|
||||
use App\Search\Action\Command\GetMediaInfoCommand;
|
||||
use App\Search\Action\Handler\GetMediaInfoHandler;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\Cache\Adapter\RedisAdapter;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
@@ -25,6 +27,7 @@ class ProcessDownloader implements DownloaderInterface
|
||||
private MediaFiles $mediaFiles,
|
||||
private CacheInterface $cache,
|
||||
private readonly Broadcaster $broadcaster,
|
||||
private readonly GetMediaInfoHandler $getMediaInfoHandler,
|
||||
) {}
|
||||
|
||||
/**
|
||||
@@ -37,7 +40,7 @@ class ProcessDownloader implements DownloaderInterface
|
||||
$this->entityManager->flush();
|
||||
|
||||
$downloadPreferences = $downloadEntity->getUser()->getDownloadPreferences();
|
||||
$path = $this->getDownloadPath($mediaType, $title, $downloadPreferences);
|
||||
$path = $this->getDownloadPath($mediaType, $title, $downloadEntity->getImdbId(), $downloadPreferences);
|
||||
|
||||
$processArgs = ['wget', '-O', $downloadEntity->getFilename(), $url];
|
||||
|
||||
@@ -103,17 +106,22 @@ class ProcessDownloader implements DownloaderInterface
|
||||
$this->entityManager->flush();
|
||||
}
|
||||
|
||||
public function getDownloadPath(string $mediaType, string $title, array $downloadPreferences): string
|
||||
public function getDownloadPath(string $mediaType, string $title, string $imdbId, array $downloadPreferences): string
|
||||
{
|
||||
$mediaInfo = $this->getMediaInfoHandler->handle(new GetMediaInfoCommand(
|
||||
$imdbId,
|
||||
$mediaType,
|
||||
));
|
||||
|
||||
if ($mediaType === 'movies') {
|
||||
if ((bool) $downloadPreferences['movie_folder']->getPreferenceValue() === true) {
|
||||
return $this->mediaFiles->createMovieDirectory($title);
|
||||
return $this->mediaFiles->createMovieDirectory($title, $mediaInfo->media->year);
|
||||
}
|
||||
return $this->mediaFiles->getMoviesPath();
|
||||
}
|
||||
|
||||
if ($mediaType === 'tvshows') {
|
||||
return $this->mediaFiles->createTvShowDirectory($title);
|
||||
return $this->mediaFiles->createTvShowDirectory($title, $mediaInfo->media->year);
|
||||
}
|
||||
|
||||
throw new \Exception("There is no download path for media type: $mediaType");
|
||||
|
||||
@@ -11,6 +11,7 @@ use App\Monitor\Framework\Entity\Monitor;
|
||||
use App\Monitor\Framework\Repository\MonitorRepository;
|
||||
use App\Tmdb\Dto\TmdbEpisodeDto;
|
||||
use App\Tmdb\TmdbClient;
|
||||
use App\Tmdb\TmdbResult;
|
||||
use Carbon\Carbon;
|
||||
use DateTimeImmutable;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
@@ -36,18 +37,14 @@ readonly class MonitorTvShowHandler implements HandlerInterface
|
||||
public function handle(CommandInterface $command): ResultInterface
|
||||
{
|
||||
$this->logger->info('> [MonitorTvShowHandler] Executing MonitorTvShowHandler');
|
||||
|
||||
$monitor = $this->monitorRepository->find($command->monitorId);
|
||||
$this->refreshData($monitor);
|
||||
$showTmdbData = $this->tmdb->tvshowDetails($monitor->getImdbId());
|
||||
|
||||
$this->refreshData($monitor, $showTmdbData);
|
||||
|
||||
// Check current episodes
|
||||
$downloadedEpisodes = $this->mediaFiles
|
||||
->getEpisodes($monitor->getTitle())
|
||||
->map(fn($episode) => (object)(new PTN())->parse($episode))
|
||||
->filter(fn($episode) => property_exists($episode, 'episode')
|
||||
&& property_exists($episode, 'season')
|
||||
&& null !== $episode->episode
|
||||
&& null !== $episode->season
|
||||
);
|
||||
$downloadedEpisodes = $this->getDownloadedEpisodes($monitor->getTitle(), $showTmdbData);
|
||||
|
||||
$this->logger->info('> [MonitorTvShowHandler] Found ' . count($downloadedEpisodes) . ' downloaded episodes for title: ' . $monitor->getTitle());
|
||||
|
||||
@@ -130,6 +127,33 @@ readonly class MonitorTvShowHandler implements HandlerInterface
|
||||
);
|
||||
}
|
||||
|
||||
private function getDownloadedEpisodes(string $title, TmdbResult $showTmdbData): Map
|
||||
{
|
||||
// Episodes in folder w/o the year
|
||||
$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->episode
|
||||
&& null !== $episode->season
|
||||
);
|
||||
|
||||
return $downloadedEpisodes->concat(
|
||||
// Episodes in folder w/ the year
|
||||
$this->mediaFiles
|
||||
->getEpisodes(sprintf("%s (%s)", $title, $showTmdbData->year))
|
||||
->map(fn($episode) => (object) new PTN()->parse($episode))
|
||||
->filter(fn($episode) =>
|
||||
property_exists($episode, 'episode')
|
||||
&& property_exists($episode, 'season')
|
||||
&& null !== $episode->episode
|
||||
&& null !== $episode->season
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
private function episodeReleasedAfterMonitorCreated(
|
||||
string|DateTimeImmutable $monitorStartDate,
|
||||
TmdbEpisodeDto $episodeInShow
|
||||
@@ -159,11 +183,11 @@ readonly class MonitorTvShowHandler implements HandlerInterface
|
||||
]) !== null;
|
||||
}
|
||||
|
||||
private function refreshData(Monitor $monitor)
|
||||
private function refreshData(Monitor $monitor, TmdbResult $showTmdbData)
|
||||
{
|
||||
if (null === $monitor->getPoster()) {
|
||||
$this->logger->info('> [MonitorTvShowHandler] Refreshing poster for "' . $monitor->getTitle() . '"');
|
||||
$poster = $this->tmdb->tvshowDetails($monitor->getImdbId())->poster;
|
||||
$poster = $showTmdbData->poster;
|
||||
if (null !== $poster && "" !== $poster) {
|
||||
$monitor->setPoster($poster);
|
||||
}
|
||||
|
||||
10
src/Monitor/MonitorTypes.php
Normal file
10
src/Monitor/MonitorTypes.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace App\Monitor;
|
||||
|
||||
enum MonitorTypes: string
|
||||
{
|
||||
case TV_EPISODE = "tvepisode";
|
||||
case TV_SEASON = "tvseason";
|
||||
case TV_SERIES = "tvseries";
|
||||
}
|
||||
Reference in New Issue
Block a user