Compare commits

...

24 Commits

Author SHA1 Message Date
Brock H Caldwell
2fc6d792bc chore: renames form field
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after -1m33s
2026-03-03 22:07:06 -06:00
Brock H Caldwell
c9f1a2d93a chore: updates readme
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after 13s
2026-03-03 22:04:22 -06:00
Brock H Caldwell
bbdd11d1b5 fix: rewords form question
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after -1m32s
2026-03-03 21:59:14 -06:00
Brock H Caldwell
1827908936 chore: updates readme
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after -1m32s
2026-03-03 20:16:49 -06:00
Brock H Caldwell
8b99a744e2 chore: updates readme
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after -1m32s
2026-03-03 20:12:00 -06:00
Brock H Caldwell
2d42b60e26 chore: cleanup
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after -1m32s
2026-03-03 19:50:16 -06:00
Brock H Caldwell
448dd12fa5 chore: adds note to compose.yml 2026-03-03 18:59:50 -06:00
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
Brock H Caldwell
939b059872 fix: adds download url check for monitors
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after -1m0s
2026-02-06 19:41:09 -06:00
Brock H Caldwell
f968e7e622 feat: allows configuring whether to cache torrentio results
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after 13s
2026-02-06 15:23:39 -06:00
Brock H Caldwell
7958f50ff7 fix: includes missing files from last commit 2026-02-06 15:23:18 -06:00
Brock H Caldwell
f4644d40ef feat: notifies user of bad RD download (failed for copyright, etc.)
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after 13s
2026-02-06 09:55:19 -06:00
Brock H Caldwell
37516c7f02 fix: closes modal when clicking dismiss button
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after -59s
2026-02-06 09:51:07 -06:00
Brock H Caldwell
c7956f5f0b fix: pushes alert dismiss button to end of div 2026-02-06 09:47:14 -06:00
Brock H Caldwell
fdf8714033 fix: supports random mysql root password 2026-02-05 18:51:06 -06:00
Brock H Caldwell
0e667fc7aa chore: updates example compose
Some checks failed
SonarQube Scan / SonarQube Trigger (push) Failing after 14s
2026-01-25 12:57:25 -06:00
28 changed files with 518 additions and 355 deletions

3
.env
View File

@@ -68,3 +68,6 @@ SENTRY_JS_URL=
# - only include media originally # - only include media originally
# produced in this language # produced in this language
TMDB_ORIGINAL_LANGUAGE=en TMDB_ORIGINAL_LANGUAGE=en
# Cache Torrentio Results
TORRENTIO_CACHE_RESULTS=true

3
.gitignore vendored
View File

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

224
README.md
View File

@@ -4,28 +4,6 @@ and download your favorite movies and tv shows. You can think of it like Stremio
comparison to Stremio? That's because Torsearch uses the same source for media files that Stremio uses: Torrentio comparison to Stremio? That's because Torsearch uses the same source for media files that Stremio uses: Torrentio
(hence the name: Torsearch). (hence the name: Torsearch).
After two failed attempts at running a media server, I decided to hang up my hat and give up my dream of a self-hosted
media server. I figured the days of torrenting were mostly over and everybody ranting & raving about their media collections
must be going to Walmart and buying up the bucket of old movies they have. That's until I stumbled across Stremio.
At first, it seemed too good to be true, but I was yearning for something just sketchy enough to try out. What could
go wrong with handing over my card information to an unknown organization across the pond? At the end of the day,
the cost benefit analysis landed in my favor, and about 30 minutes after purchasing my Real Debrid subscription and
setting up Stremio, I was in business.
My mind was blown. I might not have the most "cultured" taste in media, but it had everything I searched for and more! After
watching a few movies, I noticed the "Copy Download Link" button. "What's this lil guy do?" I asked myself. Duh, it
downloads the f*****g movie. And there's the 💡flashing over my head. There's gotta be a way to automate this, I told myself.
After a month of studying Stremio's code and lots of tinkering, I finally figured it out. Torrentio is the magic behind
the scenes. You feed it a Real Debrid API key and an IMDB ID, and it gives you a list of results to download that media.
Easy peasy.
In about an hour I had a proof of concept working. It wasn't pretty, but it wasn't supposed to be. That proof-of-concept
has blossomed into the beautiful Torsearch that I've been using nearly every day since then. The code in this repo
is a complete re-write of the proof-of-concept that started out ugly and ended up even uglier. Knowing the core functionality
required to make it work, I was able to re-write the app with some design patterns in place.
## Pics or didn't happen ## Pics or didn't happen
![Torsearch Homepage](https://code.caldwell.digital/home/torsearch/raw/branch/main/docs/img/torsearch_homepage.png) ![Torsearch Homepage](https://code.caldwell.digital/home/torsearch/raw/branch/main/docs/img/torsearch_homepage.png)
![TV Show Result](https://code.caldwell.digital/home/torsearch/raw/branch/main/docs/img/torsearch_severance.png) ![TV Show Result](https://code.caldwell.digital/home/torsearch/raw/branch/main/docs/img/torsearch_severance.png)
@@ -37,14 +15,202 @@ required to make it work, I was able to re-write the app with some design patter
- Search for Movies & TV Shows by their name - Search for Movies & TV Shows by their name
- Download directly to your NAS - Download directly to your NAS
- Monitor TV Shows for new episodes and automatically download them - Monitor TV Shows for new episodes and automatically download them
- Browse popular media and view its download options - Discover new media
- LDAP or local auth (OIDC coming soon) - OIDC
## Features on the roadmap
- Requests - allow users to request new media
- OIDC auth
- Prometheus logging
## Getting Started ## Getting Started
1. Clone the repo For all pieces to work, you will need to serve the application over HTTPS. Running behind an SSL terminating
reverse proxy is the recommended approach.
1. Create a `compose.yml` file
```yaml
services:
### The app contains the application and web server ###
app:
image: code.caldwell.digital/home/torsearch-app:${TAG}
ports:
- "${WEB_PORT}:80"
env_file: .env
depends_on:
database:
condition: service_healthy
volumes:
- ${LOCAL_MOVIES_DIR}:/var/download/movies
- ${LOCAL_TVSHOWS_DIR}:/var/download/tvshows
- mercure_data:/data
- mercure_config:/config
### The worker handles downloads and async jobs ###
worker:
image: code.caldwell.digital/home/torsearch-worker:${TAG}
volumes:
- ${LOCAL_MOVIES_DIR}:/var/download/movies
- ${LOCAL_TVSHOWS_DIR}:/var/download/tvshows
env_file: .env
depends_on:
- app
### The scheduler processes monitored media ###
scheduler:
image: code.caldwell.digital/home/torsearch-scheduler:${TAG}
volumes:
- ${LOCAL_MOVIES_DIR}:/var/download/movies
- ${LOCAL_TVSHOWS_DIR}:/var/download/tvshows
env_file: .env
depends_on:
- app
#!! If using your own database, this can be omitted !!#
database:
image: mariadb:10.11.2
volumes:
- mysql:/var/lib/mysql
env_file: .env
healthcheck:
test: ["CMD", "mysqladmin", "ping"]
interval: 5s
timeout: 5s
retries: 10
#!! If using your own redis, this can be omitted !!#
redis:
image: redis:latest
volumes:
- redis_data:/data
command: redis-server --maxmemory 512MB
restart: unless-stopped
volumes:
mysql:
mercure_config:
mercure_data:
redis_data:
```
2. Create a `.env` file
```dotenv
###################
# Torsearch #
###################
# The version of Torsearch to run. Docker will this tag.
TAG=latest
# The port for which the web server (app container) will
# serve the application on the host.
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.
# These are passed into the compose file as bind mounts.
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
###################
# Symfony #
###################
# The external URL of the application where it can be reached by a browser. Should start with https://
APP_URL="<enter url>"
# Requried by Symfony Framework. Feel free to change.
APP_SECRET="70169beadfbc8101c393cbfbba27a313"
# Change to 'dev' to show logs in the browser.
APP_ENV=prod
###################
# Mercure #
###################
# 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!"
###################
# Database #
###################
# 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_USER=app
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"
###################
# Real Debrid #
###################
# Enter your Real Debrid API key which is passed to Torrentio to retrieve download options
REAL_DEBRID_KEY="<enter real debrid api key>"
###################
# Redis #
###################
# Use your own Redis instance or use the below value to use the
# container included in the example compose.yml file.
REDIS_HOST="redis://redis"
###################
# Auth #
###################
# Options: form_login, oidc, or ldap (experimental)
# Fill the rest of the configuration based on your choice here
# No additional config is required for form_login
AUTH_METHOD=form_login
### OIDC ###
# To use OIDC, set the AUTH_METHOD to oidc and fill in the following properties
#OIDC_WELL_KNOWN_URL=
#OIDC_CLIENT_ID=
#OIDC_CLIENT_SECRET=
# Allows you to skip the login page and directly rely on your IdP for auth.
#OIDC_BYPASS_FORM_LOGIN=
```
3. Enter the `APP_URL` in the .env file
4. Enter the `REAL_DEBRID_KEY` in the .env file
5. Enter a new `WEB_PORT` if the default doesn't work for you
4. Run `docker compose up -d`
4. Visit the app in the browser
5. Create a user
6. Visit the Preferences page to set your filter. This filter is used whenever you don't choose a specific file to
download (e.g. downloading via Monitor or clicking the "Download Season", "Download Selected", or "Download Episode" buttons).
7. Start downloading media!
## Having issues?
Submit an issue in the repo, and I'll try to address it as soon as possible. I do have a full-time job and family, so my
time is limited, but I'll do my best!
## Notes
This is my first contribution to open-source, the community that's given me so much over the years!
This project has been my personal hobby project for the last 1.5 years. I've written and re-written it several times.
It's been my testing ground for trying new things, so if the code looks like shit, my bad. I'm a PHP developer by day and
tinkerer by night - this was my first go with Symfony/Twig components, tailwind, the Symfony RICH bundle, and a lot more.
At some point, I'll put together a contribution guide, so others can hack on it too.
No AI was used for development (only to generate a list of countries with their flag emojis). If the code is bad, it's my fault.
# Disclaimer
Torsearch does not host any media; it only combines API results from multiple sources to make browsing them easier.
Torsearch is not affiliated with Real Debrid, Torrentio, or TMDB.

View File

@@ -14,5 +14,6 @@ export default class extends Controller {
"3000" "3000"
)); ));
this.element.addEventListener('mouseover', () => clearTimeout(timer)); this.element.addEventListener('mouseover', () => clearTimeout(timer));
this.element.querySelector('.modal-close').addEventListener('click', () => this.element.remove());
} }
} }

View File

@@ -1,3 +1,5 @@
# This file is used for local development
# see the docs/examples directory for production examples
services: services:
caddy: caddy:
image: caddy:2.9.1 image: caddy:2.9.1
@@ -44,6 +46,7 @@ services:
environment: environment:
TZ: America/Chicago TZ: America/Chicago
scheduler: scheduler:
build: build:
dockerfile: docker/Dockerfile.scheduler dockerfile: docker/Dockerfile.scheduler
@@ -77,9 +80,9 @@ services:
environment: environment:
TZ: America/Chicago TZ: America/Chicago
MYSQL_DATABASE: app MYSQL_DATABASE: app
MYSQL_USERNAME: app MYSQL_USER: app
MYSQL_PASSWORD: password MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password MYSQL_RANDOM_ROOT_PASSWORD: true
healthcheck: healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ] test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
interval: 5s interval: 5s

View File

@@ -52,6 +52,9 @@ parameters:
sentry.dsn: '%env(SENTRY_DSN)%' sentry.dsn: '%env(SENTRY_DSN)%'
sentry.javascript_url: '%env(SENTRY_JS_URL)%' sentry.javascript_url: '%env(SENTRY_JS_URL)%'
# Torrentio
torrentio.cache_results: '%env(bool:TORRENTIO_CACHE_RESULTS)%'
services: services:
# default configuration for services in *this* file # default configuration for services in *this* file
_defaults: _defaults:

View File

@@ -1,40 +0,0 @@
services:
app:
image: registry.caldwell.digital/home/torsearch-app:${TAG}
ports:
- "${SWARM_PORT}:80"
environment:
MERCURE_PUBLISHER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
deploy:
replicas: 2
volumes:
- /mnt/media/downloads/movies:/var/download/movies
- /mnt/media/downloads/tvshows:/var/download/tvshows
- mercure_data:/data
- mercure_config:/config
worker:
image: registry.caldwell.digital/home/torsearch-worker:${TAG}
volumes:
- /mnt/media/downloads/movies:/var/download/movies
- /mnt/media/downloads/tvshows:/var/download/tvshows
deploy:
replicas: 2
depends_on:
- app
scheduler:
image: registry.caldwell.digital/home/torsearch-scheduler:${TAG}
volumes:
- /mnt/media/downloads/movies:/var/download/movies
- /mnt/media/downloads/tvshows:/var/download/tvshows
depends_on:
- app
volumes:
mercure_config:
mercure_data:

View File

@@ -3,6 +3,9 @@ FROM code.caldwell.digital/home/torsearch-base:php8.4
ARG APP_VERSION="0.0.0-dev" ARG APP_VERSION="0.0.0-dev"
ENV APP_VERSION="${APP_VERSION}" ENV APP_VERSION="${APP_VERSION}"
ARG TMDB_API=""
ENV TMDB_API="${TMDB_API}"
COPY . /app COPY . /app
COPY --chmod=775 docker/app/entrypoint.sh /usr/local/bin/docker-entrypoint COPY --chmod=775 docker/app/entrypoint.sh /usr/local/bin/docker-entrypoint
COPY docker/app/Caddyfile /etc/frankenphp/Caddyfile 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 # Set the APP_VERSION in the image
ENV APP_VERSION=${APP_VERSION} ENV APP_VERSION=${APP_VERSION}
ARG TMDB_API=""
ENV TMDB_API="${TMDB_API}"
# Copy the actual application code from the previously built app # Copy the actual application code from the previously built app
COPY --chown=1000:1000 --from=app_image /app /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 # Set the APP_VERSION in the image
ENV APP_VERSION=${APP_VERSION} ENV APP_VERSION=${APP_VERSION}
ARG TMDB_API=""
ENV TMDB_API="${TMDB_API}"
# Copy the actual application code from the previously built app # Copy the actual application code from the previously built app
COPY --chown=1000:1000 --from=app_image /app /app COPY --chown=1000:1000 --from=app_image /app /app

View File

@@ -1,58 +1,92 @@
# App must be served over HTTPS (requirement of Mercure) ###################
# Either serve behind an SSL terminating reverse proxy # Torsearch #
# or pass your certificates into the 'app' container. ###################
# Please omit any trailing slashes. The APP_URL is # The version of Torsearch to run. Docker will this tag.
# used to generate the Mercure URL behind the scenes. TAG=latest
APP_URL="https://dev.caldwell.digital"
# The port for which the web server (app container) will
# serve the application on the host.
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="./movies"
LOCAL_TVSHOWS_DIR="./tvshows"
# Set the timezone you're in. This helps render monitored items correctly on the calendar
TZ=America/Chicago
###################
# Symfony #
###################
# The external URL of the application where it can be reached by a browser.
APP_URL="<enter url>"
# Requried by Symfony Framework. Feel free to change.
APP_SECRET="70169beadfbc8101c393cbfbba27a313" APP_SECRET="70169beadfbc8101c393cbfbba27a313"
# Change to 'dev' to show logs in the browser.
APP_ENV=prod APP_ENV=prod
###################
# Mercure #
###################
# Mercure is a Caddy module built into the webserver # Mercure is a Caddy module built into the webserver
# that facilitates the usage of websockets to transmit # that facilitates the usage of websockets to transmit
# real time data (download progress, etc.) # 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_JWT_SECRET="!ChangeThisMercureHubJWTSecretKey!"
MERCURE_PUBLISHER_JWT_KEY="!ChangeThisMercureHubJWTSecretKey!"
MERCURE_SUBSCRIBER_JWT_KEY="!ChangeThisMercureHubJWTSecretKey!"
###################
# Database #
###################
# Use the DATABASE_URL below to use the MariaDB container # Use the DATABASE_URL below to use the MariaDB container
# provided in the example.compose.yml file, or remove this # provided in the example.compose.yml file, or remove this
# line and fill in the details of your own MySQL/MariaDB server # line and fill in the details of your own MySQL/MariaDB server
DATABASE_URL="mysql://root:password@database:3306/app?serverVersion=10.6.19.2-MariaDB&charset=utf8mb4" MYSQL_USER=app
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"
# Fill in your MySQL/MariaDB connection details
#DATABASE_URL="mysql://<mysql user>:<mysql pass>@<mysql host>:3306/<mysql db name>?serverVersion=10.6.19.2-MariaDB&charset=utf8mb4"
# Enter your Real Debrid API key ###################
# This key is never saved anywhere # Real Debrid #
# else and is passed to Torrentio ###################
# to retrieve download options # Enter your Real Debrid API key is passed to Torrentio to retrieve download options
REAL_DEBRID_KEY="" REAL_DEBRID_KEY="<enter real debrid api key>"
# 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=""
# Use your own Redis instance or use the ###################
# below value to use the container included # Redis #
# in the example compose.yml file. ###################
# Use your own Redis instance or use the below value to use the
# container included in the example compose.yml file.
REDIS_HOST="redis://redis" REDIS_HOST="redis://redis"
### Auth ###
# Change to "oidc" to and provide the required ###################
# environment variables below to use OIDC auth. # Auth #
###################
# Options: form_login, oidc, or ldap (experimental)
# Fill the rest of the configuration based on your choice here
# No additional config is required for form_login
AUTH_METHOD=form_login AUTH_METHOD=form_login
# OIDC ### OIDC ###
OIDC_WELL_KNOWN_URL= #OIDC_WELL_KNOWN_URL=
OIDC_CLIENT_ID= #OIDC_CLIENT_ID=
OIDC_CLIENT_SECRET= #OIDC_CLIENT_SECRET=
# Allows you to skip the login page and directly # Allows you to skip the login page and directly rely on your IdP for auth.
# rely on your IdP for auth. #OIDC_BYPASS_FORM_LOGIN=
OIDC_BYPASS_FORM_LOGIN=
### LDAP (*** Experimental! ***) ###
# LDAP Config: To use LDAP, enter the below fields # LDAP Config: To use LDAP, enter the below fields and run 'php bin/console config:set auth.method ldap'
# and run 'php bin/console config:set auth.method ldap'
# (LDAP is still in progress and not ready for use) # (LDAP is still in progress and not ready for use)
#LDAP_HOST= #LDAP_HOST=
#LDAP_PORT= #LDAP_PORT=

View File

@@ -1,78 +1,56 @@
services: services:
### The app contains the application and web server ###
app: app:
image: code.caldwell.digital/home/torsearch-app:latest image: code.caldwell.digital/home/torsearch-app:${TAG}
ports: ports:
- '8006:80' - "${WEB_PORT}:80"
env_file: env_file: .env
- .env
volumes:
- ./downloads/movies:/var/download/movies
- ./downloads/tvshows:/var/download/tvshows
environment:
TZ: America/Chicago
MERCURE_PUBLISHER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
depends_on: depends_on:
database: database:
condition: service_healthy condition: service_healthy
volumes:
- ${LOCAL_MOVIES_DIR}:/var/download/movies
- ${LOCAL_TVSHOWS_DIR}:/var/download/tvshows
- mercure_data:/data
- mercure_config:/config
# Downloads happen in this container. Replicate this
# container to run multiple downloads simultaneously. ### The worker handles downloads and async jobs ###
# Map your "movies" folder to /var/download/movies
# Map your "TV shows" folder to /var/download/tvshows
# If your folders are on another machine, use an NFS volume.
# This container runs a Symfony worker process.
# See: https://symfony.com/doc/current/messenger.html
worker: worker:
image: code.caldwell.digital/home/torsearch-worker:latest image: code.caldwell.digital/home/torsearch-worker:${TAG}
volumes: volumes:
- ./downloads/movies:/var/download/movies - ${LOCAL_MOVIES_DIR}:/var/download/movies
- ./downloads/tvshows:/var/download/tvshows - ${LOCAL_TVSHOWS_DIR}:/var/download/tvshows
environment: env_file: .env
TZ: America/Chicago
command: -vv --time-limit=3600 --limit=10
env_file:
- .env
restart: always
depends_on: depends_on:
app: - app
condition: service_healthy
# This container handles the monitoring for new media. When new
# monitors are added, jobs are periodically dispatched to this ### The scheduler processes monitored media ###
# container, and the desired media is searched for and downloaded.
# This container runs a Symfony worker process.
# See: https://symfony.com/doc/current/messenger.html
scheduler: scheduler:
image: code.caldwell.digital/home/torsearch-scheduler:latest image: code.caldwell.digital/home/torsearch-scheduler:${TAG}
volumes: volumes:
- ./downloads/movies:/var/download/movies - ${LOCAL_MOVIES_DIR}:/var/download/movies
- ./downloads/tvshows:/var/download/tvshows - ${LOCAL_TVSHOWS_DIR}:/var/download/tvshows
env_file: env_file: .env
- .env
command: -vv
environment:
TZ: America/Chicago
restart: always
depends_on: depends_on:
app: - app
condition: service_healthy
#!! If using your own database, this can be omitted !!#
database: database:
image: mariadb:10.11.2 image: mariadb:10.11.2
volumes: volumes:
- mysql:/var/lib/mysql - mysql:/var/lib/mysql
environment: env_file: .env
MYSQL_DATABASE: app
MYSQL_USERNAME: app
MYSQL_PASSWORD: password
MYSQL_ROOT_PASSWORD: password
healthcheck: healthcheck:
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ] test: ["CMD", "mysqladmin", "ping"]
interval: 5s interval: 5s
timeout: 5s timeout: 5s
retries: 10 retries: 10
#!! If using your own redis, this can be omitted !!#
redis: redis:
image: redis:latest image: redis:latest
volumes: volumes:
@@ -80,12 +58,6 @@ services:
command: redis-server --maxmemory 512MB command: redis-server --maxmemory 512MB
restart: unless-stopped restart: unless-stopped
# **Optional**
# Provides a simple method of viewing the database
adminer:
image: adminer
ports:
- "8081:8080"
volumes: volumes:
mysql: mysql:

View File

@@ -1,129 +0,0 @@
variable "image_tag" {
type = string
description = "Docker image tag to deploy."
default = "latest"
}
job "torsearch" {
datacenters = [ "home" ]
type = "service"
group "app" {
count = 2
update {
max_parallel = 4
min_healthy_time = "30s"
healthy_deadline = "3m"
auto_revert = true
}
network {
port "app" {
to = 80
}
}
task "app" {
driver = "docker"
config {
image = "registry.caldwell.digital/home/torsearch-app:${var.image_tag}"
ports = ["app"]
}
env {
MERCURE_PUBLISHER_JWT_KEY = "!ChangeThisMercureHubJWTSecretKey!"
MERCURE_SUBSCRIBER_JWT_KEY = "!ChangeThisMercureHubJWTSecretKey!"
}
service {
name = "torsearch-app"
provider = "nomad"
port = "app"
meta {
nomad_ingress_enabled = true
nomad_ingress_hostname = "torsearch-nomad.caldwell.digital"
}
}
}
}
group "worker" {
count = 2
update {
max_parallel = 4
min_healthy_time = "30s"
healthy_deadline = "3m"
auto_revert = true
}
volume "media" {
type = "host"
source = "media"
read_only = false
}
task "worker" {
driver = "docker"
volume_mount {
volume = "media"
destination = "/var/download"
read_only = false
}
config {
image = "registry.caldwell.digital/home/torsearch-worker:${var.image_tag}"
args = [
"-vv"
]
}
service {
name = "torsearch-worker"
provider = "nomad"
}
}
}
group "scheduler" {
count = 1
update {
max_parallel = 2
min_healthy_time = "30s"
healthy_deadline = "3m"
auto_revert = true
}
volume "media" {
type = "host"
source = "media"
read_only = false
}
task "scheduler" {
driver = "docker"
volume_mount {
volume = "media"
destination = "/var/download"
read_only = false
}
config {
image = "registry.caldwell.digital/home/torsearch-scheduler:${var.image_tag}"
args = [
"-vv"
]
}
service {
name = "torsearch-scheduler"
provider = "nomad"
}
}
}
}

View File

@@ -4,6 +4,7 @@ namespace App\Base;
use App\Base\Dto\AppVersionDto; use App\Base\Dto\AppVersionDto;
use Symfony\Component\DependencyInjection\Attribute\Autowire; use Symfony\Component\DependencyInjection\Attribute\Autowire;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
final class ConfigResolver final class ConfigResolver
@@ -14,6 +15,7 @@ final class ConfigResolver
public function __construct( public function __construct(
private readonly DenormalizerInterface $denormalizer, private readonly DenormalizerInterface $denormalizer,
private readonly RequestStack $requestStack,
#[Autowire(param: 'app.url')] #[Autowire(param: 'app.url')]
private readonly ?string $appUrl = null, private readonly ?string $appUrl = null,
@@ -62,6 +64,9 @@ final class ConfigResolver
#[Autowire(param: 'sentry.javascript_url')] #[Autowire(param: 'sentry.javascript_url')]
private ?string $sentryJavascriptUrl = null, private ?string $sentryJavascriptUrl = null,
#[Autowire(param: 'torrentio.cache_results')]
private ?bool $torrentioCacheResults = null,
) {} ) {}
public function validate(): bool public function validate(): bool
@@ -110,6 +115,11 @@ final class ConfigResolver
return $this->authOidcBypassFormLogin; return $this->authOidcBypassFormLogin;
} }
public function isTorrentioCacheEnabled(): bool
{
return $this->torrentioCacheResults;
}
public function getAppVersion(): AppVersionDto public function getAppVersion(): AppVersionDto
{ {
$matches = []; $matches = [];

View File

@@ -24,10 +24,10 @@ readonly class Broadcaster
private LoggerInterface $logger, private LoggerInterface $logger,
) {} ) {}
public function alert(string $title, string $message, string $type = "success", bool $sendPush = false): void public function alert(string $title, string $message, string $type = "success", bool $sendPush = false, ?string $mercureAlertTopic = null): void
{ {
try { try {
$userAlertTopic = $this->requestStack->getCurrentRequest()->getSession()->get('mercure_alert_topic'); $userAlertTopic = $mercureAlertTopic ?? $this->requestStack->getCurrentRequest()->getSession()->get('mercure_alert_topic');
$update = new Update( $update = new Update(
$userAlertTopic, $userAlertTopic,
$this->renderer->render('broadcast/Alert.stream.html.twig', [ $this->renderer->render('broadcast/Alert.stream.html.twig', [
@@ -39,7 +39,7 @@ readonly class Broadcaster
); );
$this->hub->publish($update); $this->hub->publish($update);
} catch (\Throwable $exception) { } catch (\Throwable $exception) {
// ToDo: look for better handling to get message to end user $this->logger->error('Unable to publish alert: ' . $exception->getMessage());
} }
if (true === $sendPush && in_array($this->notificationTransport, ['ntfy'])) { if (true === $sendPush && in_array($this->notificationTransport, ['ntfy'])) {

View File

@@ -17,5 +17,6 @@ class DownloadMediaCommand implements CommandInterface
public string $imdbId, public string $imdbId,
public int $userId, public int $userId,
public ?int $downloadId = null, public ?int $downloadId = null,
public ?string $mercureAlertTopic = null,
) {} ) {}
} }

View File

@@ -2,9 +2,12 @@
namespace App\Download\Action\Handler; namespace App\Download\Action\Handler;
use App\Base\Enum\MediaType;
use App\Base\Service\Broadcaster;
use App\Download\Action\Command\DownloadMediaCommand; use App\Download\Action\Command\DownloadMediaCommand;
use App\Download\Action\Result\DownloadMediaResult; use App\Download\Action\Result\DownloadMediaResult;
use App\Download\DownloadEvents; use App\Download\DownloadEvents;
use App\Download\Framework\Entity\Download;
use App\Download\Framework\Repository\DownloadRepository; use App\Download\Framework\Repository\DownloadRepository;
use App\Download\Downloader\DownloaderInterface; use App\Download\Downloader\DownloaderInterface;
use App\EventLog\Action\Command\AddEventLogCommand; use App\EventLog\Action\Command\AddEventLogCommand;
@@ -21,8 +24,8 @@ readonly class DownloadMediaHandler implements HandlerInterface
public function __construct( public function __construct(
private MessageBusInterface $bus, private MessageBusInterface $bus,
private DownloaderInterface $downloader, private DownloaderInterface $downloader,
private DownloadRepository $downloadRepository, private DownloadRepository $downloadRepository,
private UserRepository $userRepository, private UserRepository $userRepository, private Broadcaster $broadcaster,
) {} ) {}
public function handle(CommandInterface $command): ResultInterface public function handle(CommandInterface $command): ResultInterface
@@ -49,6 +52,16 @@ readonly class DownloadMediaHandler implements HandlerInterface
$download = $this->downloadRepository->find($command->downloadId); $download = $this->downloadRepository->find($command->downloadId);
} }
try {
$this->validateDownloadUrl($download->getUrl());
} catch (\Throwable $exception) {
$download->setProgress(100);
$download->setStatus('Failed');
$this->downloadRepository->getEntityManager()->flush();
$this->sendFailedDownloadAlert($download, $command->mercureAlertTopic, $exception->getMessage());
return new DownloadMediaResult(400, $exception->getMessage());
}
try { try {
if ($download->getStatus() !== 'Paused') { if ($download->getStatus() !== 'Paused') {
$this->downloadRepository->updateStatus($download->getId(), 'In Progress'); $this->downloadRepository->updateStatus($download->getId(), 'In Progress');
@@ -77,4 +90,31 @@ readonly class DownloadMediaHandler implements HandlerInterface
)); ));
return new DownloadMediaResult(200, "Success."); return new DownloadMediaResult(200, "Success.");
} }
public function validateDownloadUrl(string $downloadUrl)
{
$badFileSizes = [
2119075, // copyright infringement
];
$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);
if (array_key_exists($headers['Location'], $badFileLocations)) {
throw new \Exception($badFileLocations[$headers['Location']]);
}
}
private function sendFailedDownloadAlert(Download $download, string $mercureAlertTopic, ?string $message = null): void
{
$this->broadcaster->alert(
title: 'Download Failed',
message: $message ?? "{$download->getTitle()} failed to download.",
type: 'warning',
mercureAlertTopic: $mercureAlertTopic
);
}
} }

View File

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

@@ -10,6 +10,8 @@ use OneToMany\RichBundle\Contract\InputInterface;
/** @implements InputInterface<DownloadMediaInput> */ /** @implements InputInterface<DownloadMediaInput> */
class DownloadMediaInput implements InputInterface class DownloadMediaInput implements InputInterface
{ {
public ?string $mercureAlertTopic = null;
public function __construct( public function __construct(
#[SourceRequest('url')] #[SourceRequest('url')]
public string $url, public string $url,
@@ -44,6 +46,7 @@ class DownloadMediaInput implements InputInterface
$this->imdbId, $this->imdbId,
$this->userId, $this->userId,
$this->downloadId, $this->downloadId,
$this->mercureAlertTopic,
); );
} }
} }

View File

@@ -21,7 +21,12 @@ class DownloadOptionEvaluator
return false; return false;
} }
if (false === $this->validateSize($result, $filter)) { // todo: This is arbitrary- revisit in the future
//if (false === $this->validateSize($result, $filter)) {
// return false;
//}
if (false === $this->validateDownloadUrl($result->url)) {
return false; return false;
} }
@@ -47,15 +52,15 @@ class DownloadOptionEvaluator
$valid = false; $valid = false;
} }
if (null !== $filter->codec && in_array($result->codec, $filter->codec)) { if (null !== $filter->codec && !in_array($result->codec, $filter->codec)) {
$valid = false; $valid = false;
} }
if (null !== $filter->quality && in_array($result->quality, $filter->quality)) { if (null !== $filter->quality && !in_array($result->quality, $filter->quality)) {
$valid = false; $valid = false;
} }
if (null !== $filter->provider && in_array($result->provider, $filter->provider)) { if (null !== $filter->provider && !in_array($result->provider, $filter->provider)) {
$valid = false; $valid = false;
} }
@@ -79,4 +84,19 @@ class DownloadOptionEvaluator
return false; return false;
} }
public function validateDownloadUrl(string $downloadUrl)
{
$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);
if (array_key_exists($headers['Location'], $badFileLocations)) {
return false;
}
return true;
}
} }

View File

@@ -15,6 +15,7 @@ use App\Download\DownloadEvents;
use App\Download\Framework\Repository\DownloadRepository; use App\Download\Framework\Repository\DownloadRepository;
use App\EventLog\Action\Command\AddEventLogCommand; use App\EventLog\Action\Command\AddEventLogCommand;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Messenger\MessageBusInterface; use Symfony\Component\Messenger\MessageBusInterface;
use Symfony\Component\Routing\Attribute\Route; use Symfony\Component\Routing\Attribute\Route;
@@ -22,9 +23,9 @@ use Symfony\Component\Routing\Attribute\Route;
class ApiController extends AbstractController class ApiController extends AbstractController
{ {
public function __construct( public function __construct(
private DownloadRepository $downloadRepository, private DownloadRepository $downloadRepository,
private MessageBusInterface $bus, private MessageBusInterface $bus,
private readonly Broadcaster $broadcaster, private readonly Broadcaster $broadcaster, private readonly RequestStack $requestStack,
) {} ) {}
#[Route('/api/download', name: 'api_download', methods: ['POST'])] #[Route('/api/download', name: 'api_download', methods: ['POST'])]
@@ -42,6 +43,7 @@ class ApiController extends AbstractController
); );
$input->downloadId = $download->getId(); $input->downloadId = $download->getId();
$input->userId = $this->getUser()->getId(); $input->userId = $this->getUser()->getId();
$input->mercureAlertTopic = $this->requestStack->getSession()->get('mercure_alert_topic');
$this->bus->dispatch(new AddEventLogCommand( $this->bus->dispatch(new AddEventLogCommand(
$this->getUser(), $this->getUser(),

View File

@@ -98,6 +98,14 @@ class DownloadRepository extends ServiceEntityRepository
return $download; return $download;
} }
public function updateProgress(int $id, int $progress): Download
{
$download = $this->find($id);
$download->setProgress($progress);
$this->getEntityManager()->flush();
return $download;
}
public function delete(int $id) public function delete(int $id)
{ {
$entity = $this->find($id); $entity = $this->find($id);
@@ -115,4 +123,16 @@ class DownloadRepository extends ServiceEntityRepository
->getQuery() ->getQuery()
->getResult(); ->getResult();
} }
public function badDownloadUrls()
{
return $this->createQueryBuilder('d')
->select('d.url')
->andWhere('d.status = :status')
->andWhere('d.progress = 100')
->setParameter('status', 'Failed')
->distinct()
->getQuery()
->getResult();
}
} }

View File

@@ -2,14 +2,25 @@
namespace App\Torrentio\Client; namespace App\Torrentio\Client;
use Aimeos\Map;
use App\Download\Framework\Repository\DownloadRepository;
use App\Torrentio\Result\ResultFactory; use App\Torrentio\Result\ResultFactory;
use App\Torrentio\Exception\TorrentioRateLimitException; use App\Torrentio\Exception\TorrentioRateLimitException;
use Psr\Log\LoggerInterface;
class Torrentio class Torrentio
{ {
private array $badDownloadUrls = [];
public function __construct( public function __construct(
private readonly HttpClient $client, private readonly HttpClient $client,
) {} private readonly DownloadRepository $downloadRepository, private readonly LoggerInterface $logger,
) {
$badDownloadUrls = $this->downloadRepository->badDownloadUrls();
$this->badDownloadUrls = Map::from($badDownloadUrls)
->map(fn ($url) => $url['url'])
->toArray();
}
public function search(string $imdbCode, string $type, bool $parseResults = true): array public function search(string $imdbCode, string $type, bool $parseResults = true): array
{ {
@@ -47,6 +58,16 @@ class Torrentio
continue; continue;
} }
$url = explode('/', $stream['url']);
$filename = urldecode(end($url));
$url[count($url) - 1] = $filename;
$url = implode('/', $url);
if (in_array($stream['url'], $this->badDownloadUrls)) {
$this->logger->warning($stream['url'] . ' was skipped because it was identified as a bad download url.');
continue;
}
if ( if (
array_key_exists('behaviorHints', $stream) && array_key_exists('behaviorHints', $stream) &&
array_key_exists('bingeGroup', $stream['behaviorHints']) array_key_exists('bingeGroup', $stream['behaviorHints'])

View File

@@ -2,6 +2,7 @@
namespace App\Torrentio\Framework\Controller; namespace App\Torrentio\Framework\Controller;
use App\Base\ConfigResolver;
use App\Base\Service\Broadcaster; use App\Base\Service\Broadcaster;
use App\Torrentio\Action\Handler\GetMovieOptionsHandler; use App\Torrentio\Action\Handler\GetMovieOptionsHandler;
use App\Torrentio\Action\Handler\GetTvShowOptionsHandler; use App\Torrentio\Action\Handler\GetTvShowOptionsHandler;
@@ -27,6 +28,7 @@ final class WebController extends AbstractController
public function __construct( public function __construct(
private readonly GetMovieOptionsHandler $getMovieOptionsHandler, private readonly GetMovieOptionsHandler $getMovieOptionsHandler,
private readonly GetTvShowOptionsHandler $getTvShowOptionsHandler, private readonly GetTvShowOptionsHandler $getTvShowOptionsHandler,
private readonly ConfigResolver $configResolver,
private readonly Broadcaster $broadcaster, private readonly Broadcaster $broadcaster,
) {} ) {}
@@ -40,10 +42,14 @@ final class WebController extends AbstractController
$input->imdbId $input->imdbId
); );
$results = $cache->get($cacheId, function (ItemInterface $item) use ($input, $request) { if (true === $this->configResolver->isTorrentioCacheEnabled()) {
$item->expiresAt(Carbon::now()->addHour()->setMinute(0)->setSecond(0)); $results = $cache->get($cacheId, function (ItemInterface $item) use ($input, $request) {
return $this->getMovieOptionsHandler->handle($input->toCommand()); $item->expiresAt(Carbon::now()->addHour()->setMinute(0)->setSecond(0));
}); return $this->getMovieOptionsHandler->handle($input->toCommand());
});
} else {
$results = $this->getMovieOptionsHandler->handle($input->toCommand());
}
if ($request->headers->get('Turbo-Frame')) { if ($request->headers->get('Turbo-Frame')) {
return $this->sendFragmentResponse($results, $request); return $this->sendFragmentResponse($results, $request);
@@ -66,10 +72,14 @@ final class WebController extends AbstractController
); );
try { try {
$results = $cache->get($cacheId, function (ItemInterface $item) use ($input) { if (true === $this->configResolver->isTorrentioCacheEnabled()) {
$item->expiresAt(Carbon::now()->addHour()->setMinute(0)->setSecond(0)); $results = $cache->get($cacheId, function (ItemInterface $item) use ($input) {
return $this->getTvShowOptionsHandler->handle($input->toCommand()); $item->expiresAt(Carbon::now()->addHour()->setMinute(0)->setSecond(0));
}); return $this->getTvShowOptionsHandler->handle($input->toCommand());
});
} else {
$results = $this->getTvShowOptionsHandler->handle($input->toCommand());
}
if ($request->headers->get('Turbo-Frame')) { if ($request->headers->get('Turbo-Frame')) {
return $this->sendFragmentResponse($results, $request); return $this->sendFragmentResponse($results, $request);

View File

@@ -20,6 +20,7 @@ class RegistrationFormType extends AbstractType
->add('plainPassword', PasswordType::class, [ ->add('plainPassword', PasswordType::class, [
// instead of being set onto the object directly, // instead of being set onto the object directly,
// this is read and encoded in the controller // this is read and encoded in the controller
'label' => 'Password',
'mapped' => false, 'mapped' => false,
'attr' => ['autocomplete' => 'new-password'], 'attr' => ['autocomplete' => 'new-password'],
'constraints' => [ 'constraints' => [

View File

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

View File

@@ -2,16 +2,14 @@
class="alert alert-{{ type|default('success') }}" class="alert alert-{{ type|default('success') }}"
role="alert" role="alert"
> >
<div class="flex items-center"> <div class="flex justify-between items-center">
<svg class="shrink-0 w-4 h-4 me-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20"> <div class="flex items-center">
<path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/> <svg class="shrink-0 w-4 h-4 me-2" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="currentColor" viewBox="0 0 20 20">
</svg> <path d="M10 .5a9.5 9.5 0 1 0 9.5 9.5A9.51 9.51 0 0 0 10 .5ZM9.5 4a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3ZM12 15H8a1 1 0 0 1 0-2h1v-3H8a1 1 0 0 1 0-2h2a1 1 0 0 1 1 1v4h1a1 1 0 0 1 0 2Z"/>
</svg>
<h3 class="text-lg font-medium font-bold">{{ title|default('') }}</h3> <h3 class="text-lg font-medium font-bold">{{ title|default('') }}</h3>
</div>
<twig:ux:icon name="ic:twotone-cancel" style="text-align:right" width="16.75px" height="16.75px" class="modal-close rounded-full align-end text-red-600 hover:text-red-700" /> <twig:ux:icon name="ic:twotone-cancel" width="16.75px" height="16.75px" class="modal-close rounded-full align-end text-red-600 hover:text-red-700" />
<span class="sr-only">Info</span>
</div> </div>
<div class="mt-2 text-sm w-[300px] font-bold overflow-hidden text-wrap"> <div class="mt-2 text-sm w-[300px] font-bold overflow-hidden text-wrap">
{{ message }} {{ message }}

View File

@@ -30,7 +30,7 @@
<div class="flex flex-row gap-2 mb-2"> <div class="flex flex-row gap-2 mb-2">
<input type="hidden" name="movie_folder" id="movie_folder_hidden" value="0" /> <input type="hidden" name="movie_folder" id="movie_folder_hidden" value="0" />
<input type="checkbox" name="movie_folder" id="movie_folder" value="1" {{ downloadPreferences['movie_folder'].getPreferenceValue() == true ? 'checked' }} /> <input type="checkbox" name="movie_folder" id="movie_folder" value="1" {{ downloadPreferences['movie_folder'].getPreferenceValue() == true ? 'checked' }} />
<label class="text-gray-50" for="movie_folder">Store movies in a new directory?</label> <label class="text-gray-50" for="movie_folder">Create a new directory for each movie?</label>
</div> </div>
<button class="px-1.5 py-1 max-w-20 rounded-md bg-green-600 text-white" type="submit">Submit</button> <button class="px-1.5 py-1 max-w-20 rounded-md bg-green-600 text-white" type="submit">Submit</button>
</form> </form>