Compare commits
198 Commits
dev-prefer
...
dev-cache
| Author | SHA1 | Date | |
|---|---|---|---|
| 242dd6fe99 | |||
| a2b20b14ea | |||
| 7ed117d19b | |||
| d4077d036e | |||
| de88a36545 | |||
| cb51483a00 | |||
| 2dc53c5270 | |||
| 5938d33c89 | |||
| d95ab85415 | |||
| cc39e46bfd | |||
| ba092ab3c2 | |||
| 774d6f4999 | |||
| 0b56ee937d | |||
| 7b3d57b94a | |||
| 9714cf1749 | |||
| be7b610111 | |||
| 3e93a7c9c1 | |||
| bc78b83f8d | |||
| c5bcaeb1d4 | |||
| e39182ba91 | |||
| 965b747594 | |||
| 937e3c6270 | |||
| 2bb2845ead | |||
| fca189648b | |||
| 2121466322 | |||
| 1e130c3490 | |||
| 4b97faeadb | |||
| 3701e31ee0 | |||
| 210c674f25 | |||
| 175f4330f1 | |||
| 12aaf8e737 | |||
| 2e468dd9b0 | |||
| e070b95a36 | |||
| 20d397589a | |||
| 6c7a35005e | |||
| 0f16423f66 | |||
| 937313fe59 | |||
| 9b3506ab17 | |||
| 6e0eed8b4e | |||
| 38a5baa17e | |||
| 1d573c09e7 | |||
| 7989e2abd2 | |||
| df6c68aa46 | |||
| 6cd9a9b18e | |||
| b95e8f3794 | |||
| 8cc81fea19 | |||
| 15648e711b | |||
| f855aabd69 | |||
| 55a866170e | |||
| 9ab4f6cf57 | |||
| d40a4764eb | |||
| 0119830ea7 | |||
| 7ffa927d55 | |||
| 0b80779975 | |||
| 3c2092095f | |||
| a7bedae3db | |||
| 51c2a1c577 | |||
| f5ed464719 | |||
| aa31701ac8 | |||
| 781e4dcd23 | |||
| b5cd240fbd | |||
| ce5bc525dd | |||
| 63850e48fd | |||
| f9a284cb67 | |||
| 228d320edc | |||
| 6858d2d722 | |||
| 8cd004db4a | |||
| 6cc8985c4d | |||
| 9bfd92a011 | |||
| ac6276f444 | |||
| 6d4bbf2e72 | |||
| 8004de1dc8 | |||
| 2d9a2a1f14 | |||
| b6bc1645b4 | |||
| 16023f1a26 | |||
| 725034dd4e | |||
| 234aeab120 | |||
| 044df00982 | |||
| 92015feaac | |||
| 5b704d9b36 | |||
| 4f72481829 | |||
| 4ee338e397 | |||
| 08d28d9a4f | |||
| b17313c8fb | |||
| f2b50b4f60 | |||
| 393e3ef41f | |||
| b1ccf3bf00 | |||
| 785794790c | |||
| c0f67a32ff | |||
| 325e4e14a7 | |||
| f9017297f3 | |||
| 0c4def42a2 | |||
| 3100912927 | |||
| 07553a172f | |||
| a88da4f637 | |||
| a88f128ccb | |||
| b1ec344f42 | |||
| 1ee6db4668 | |||
| 76bad88190 | |||
| a4029725f9 | |||
| aed3d92462 | |||
| 76531f397f | |||
| c763d67fcb | |||
| e85ae5ac95 | |||
| 794189d70a | |||
| 34d9029b7c | |||
| 168bf04550 | |||
| 81eb2d1f62 | |||
| f5102b859f | |||
| a9c6abe06b | |||
| 764fef37e5 | |||
| 565481aa5a | |||
| 64b7d4c963 | |||
| 9eb7079ea6 | |||
| bd92480958 | |||
| 079a7e2cb5 | |||
| 295f68cb92 | |||
| a2a1154a22 | |||
| 3074b2d5f1 | |||
| 4638f3765a | |||
| 70189b95e1 | |||
| c47b1fc23f | |||
| f39e307bc4 | |||
| 3c965aa1ec | |||
| bd4ce76177 | |||
| fd0853d6f0 | |||
| 53ad80c90b | |||
| fb47cf9d6b | |||
| eac586d946 | |||
| ae0e416cdd | |||
| a64ac6b2cb | |||
| 1881247bf2 | |||
| 0337d7530a | |||
| 9b9240c35b | |||
| a568cb7c86 | |||
| daafeb79b7 | |||
| bc8c214c99 | |||
| d5f0098280 | |||
| 4cb9fd0810 | |||
| 7bc8720377 | |||
| cc4942a537 | |||
| c4f416af37 | |||
| 2c31485964 | |||
| 5d5d66bd79 | |||
| ce6fda257b | |||
| 7afc845343 | |||
| 546039aa43 | |||
| e6196ce078 | |||
| eecd5444a6 | |||
| 74506f6928 | |||
| 845a67bdd8 | |||
| 651697640c | |||
| dd48cc542f | |||
| 6c0e42d291 | |||
| e230913c89 | |||
| 8967d407cb | |||
| 217a667df2 | |||
| 4653feb123 | |||
| 6ad10a585d | |||
| eed2e70d21 | |||
| eded5a2fc8 | |||
| 8428fc6cf6 | |||
| 888a030680 | |||
| a628d85ef2 | |||
| afb62645f6 | |||
| 8aba35fee1 | |||
| 6817bd8c80 | |||
| 854177a121 | |||
| ddb71b3bb0 | |||
| 35a3e48ac9 | |||
| 6e55195e6f | |||
| e325687af5 | |||
| 4506306377 | |||
| 4287b52bd4 | |||
| 3724bcbb16 | |||
| 6c2cd7510f | |||
| 98bf8d2880 | |||
| 20ade478b1 | |||
| 4eed5fef78 | |||
| 5ff9842eaa | |||
| b93da3df1d | |||
| fe0ab2ef5a | |||
| 25ff3e726d | |||
| 527adb73c1 | |||
| 9166b4bbc8 | |||
| 5688b3a0df | |||
| babcb00440 | |||
| 993b34d668 | |||
| 73b3e5179a | |||
| d3176baff2 | |||
| cc77cccf0b | |||
| b0c10a028a | |||
| 12bf90a2b4 | |||
| 687b5ed873 | |||
| e5f0f358b7 | |||
| fd84648100 | |||
| f3285ba60c | |||
| 4f6f8f43f1 |
9
.env
@@ -15,7 +15,7 @@
|
|||||||
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
|
# https://symfony.com/doc/current/best_practices.html#use-environment-variables-for-infrastructure-configuration
|
||||||
|
|
||||||
###> symfony/framework-bundle ###
|
###> symfony/framework-bundle ###
|
||||||
APP_ENV=dev
|
APP_ENV=prod
|
||||||
APP_SECRET=
|
APP_SECRET=
|
||||||
###< symfony/framework-bundle ###
|
###< symfony/framework-bundle ###
|
||||||
|
|
||||||
@@ -26,12 +26,15 @@ APP_SECRET=
|
|||||||
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
|
# DATABASE_URL="sqlite:///%kernel.project_dir%/var/data.db"
|
||||||
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4"
|
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=8.0.32&charset=utf8mb4"
|
||||||
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
|
# DATABASE_URL="mysql://app:!ChangeMe!@127.0.0.1:3306/app?serverVersion=10.11.2-MariaDB&charset=utf8mb4"
|
||||||
DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8"
|
# DATABASE_URL="postgresql://app:!ChangeMe!@127.0.0.1:5432/app?serverVersion=16&charset=utf8"
|
||||||
###< doctrine/doctrine-bundle ###
|
|
||||||
|
|
||||||
|
###< doctrine/doctrine-bundle ###
|
||||||
|
MERCURE_JWT_SECRET="!ChangeThisMercureHubJWTSecretKey!"
|
||||||
###> symfony/messenger ###
|
###> symfony/messenger ###
|
||||||
# Choose one of the transports below
|
# Choose one of the transports below
|
||||||
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
|
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
|
||||||
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
|
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
|
||||||
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
|
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
|
||||||
###< symfony/messenger ###
|
###< symfony/messenger ###
|
||||||
|
|
||||||
|
REDIS_HOST=redis://redis
|
||||||
|
|||||||
7
.env.dev
@@ -1,7 +0,0 @@
|
|||||||
DATABASE_URL="mysql://root:password@database:3306/app?serverVersion=10.6.19.2-MariaDB&charset=utf8mb4"
|
|
||||||
APP_SECRET=70169beadfbc8101c393cbfbba27a313
|
|
||||||
|
|
||||||
DOWNLOAD_DIR=./movies
|
|
||||||
MERCURE_URL=http://mercure/.well-known/mercure
|
|
||||||
MERCURE_PUBLIC_URL=https://dev.caldwell.digital/hub/.well-known/mercure
|
|
||||||
MERCURE_JWT_SECRET="!ChangeThisMercureHubJWTSecretKey!"
|
|
||||||
10
.env.dist
@@ -1,10 +0,0 @@
|
|||||||
APP_SECRET="%%app_secret%%"
|
|
||||||
DATABASE_URL="%%db_url%%"
|
|
||||||
DOWNLOAD_DIR=%%download_dir%%
|
|
||||||
REAL_DEBRID_KEY="%%rd_key%%"
|
|
||||||
TMDB_API=%%tmdb_api%%
|
|
||||||
MERCURE_URL=%%mercure_url%%
|
|
||||||
MERCURE_PUBLIC_URL=%%mercure_public_url%%
|
|
||||||
MERCURE_JWT_SECRET="%%mercure_jwt_secret%%"
|
|
||||||
JELLYFIN_URL=%%jellyfin_url%%
|
|
||||||
JELLYFIN_TOKEN=%%jellyfin_token%%
|
|
||||||
5
.gitignore
vendored
@@ -1,4 +1,5 @@
|
|||||||
.idea
|
.idea
|
||||||
|
bolt.db
|
||||||
###> symfony/framework-bundle ###
|
###> symfony/framework-bundle ###
|
||||||
/.env.local
|
/.env.local
|
||||||
/.env.local.php
|
/.env.local.php
|
||||||
@@ -13,3 +14,7 @@
|
|||||||
/public/assets/
|
/public/assets/
|
||||||
/assets/vendor/
|
/assets/vendor/
|
||||||
###< symfony/asset-mapper ###
|
###< symfony/asset-mapper ###
|
||||||
|
|
||||||
|
###> phpstan/phpstan ###
|
||||||
|
phpstan.neon
|
||||||
|
###< phpstan/phpstan ###
|
||||||
|
|||||||
21
Dockerfile
@@ -1,4 +1,19 @@
|
|||||||
FROM registry.caldwell.digital/library/php:8.4-apache
|
FROM dunglas/frankenphp:php8.4
|
||||||
|
|
||||||
COPY ./bash/vhost.conf /etc/apache2/sites-enabled/vhost.conf
|
ENV SERVER_NAME=":80"
|
||||||
RUN rm /etc/apache2/sites-enabled/000-default.conf
|
ENV CADDY_GLOBAL_OPTIONS="auto_https off"
|
||||||
|
ENV APP_RUNTIME="Runtime\\FrankenPhpSymfony\\Runtime"
|
||||||
|
ENV APP_VERSION="0.0.1"
|
||||||
|
|
||||||
|
RUN install-php-extensions \
|
||||||
|
pdo_mysql \
|
||||||
|
gd \
|
||||||
|
intl \
|
||||||
|
zip \
|
||||||
|
opcache
|
||||||
|
|
||||||
|
RUN apt update && apt install -y wget
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=3s --timeout=3s --retries=10 CMD [ "php", "/app/bin/console", "startup:status" ]
|
||||||
|
|
||||||
|
COPY --chmod=0755 docker/app/Caddyfile /etc/frankenphp/Caddyfile
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
FROM registry.caldwell.digital/library/php:8.4-apache
|
|
||||||
|
|
||||||
COPY --chown=www-data:www-data . /var/www
|
|
||||||
COPY ./bash/vhost.conf /etc/apache2/sites-enabled/vhost.conf
|
|
||||||
RUN rm /etc/apache2/sites-enabled/000-default.conf
|
|
||||||
57
README.md
@@ -1,13 +1,50 @@
|
|||||||
# Caldwell Digital - Symfony Template
|
# Torsearch
|
||||||
Get up and running quickly with this Symfony framework template!
|
Torsearch is a "media acquisition tool" that works strictly with Real Debrid. Torsearch makes it easy to search for
|
||||||
|
and download your favorite movies and tv shows. You can think of it like Stremio, but without the streaming. Why the
|
||||||
|
comparison to Stremio? That's because Torsearch uses the same source for media files that Stremio uses: Torrentio
|
||||||
|
(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
|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|
## Features
|
||||||
|
- Search for Movies & TV Shows by their name
|
||||||
|
- Download directly to your NAS
|
||||||
|
- Monitor TV Shows for new episodes and automatically download them
|
||||||
|
- Browse popular media and view its download options
|
||||||
|
- LDAP or local auth (OIDC coming soon)
|
||||||
|
|
||||||
|
## Features on the roadmap
|
||||||
|
- Requests - allow users to request new media
|
||||||
|
- OIDC auth
|
||||||
|
- Prometheus logging
|
||||||
|
|
||||||
## Getting Started
|
## Getting Started
|
||||||
1. Run `source bash/get_certs.sh` to grab the wildcard certs
|
1. Clone the repo
|
||||||
2. Set the docker image tag in the `bash/build.sh` file
|
|
||||||
3. Set the docker image tag in the `deploy.compose.yml` file
|
|
||||||
4. run `composer install`
|
|
||||||
|
|
||||||
## Optional steps
|
|
||||||
1. Set phing vars
|
|
||||||
2. Update the project name in `build.xml`
|
|
||||||
3. Set a custom development hostname in `bash/vhost.conf`
|
|
||||||
|
|||||||
7
assets/bootstrap.js
vendored
@@ -1,5 +1,10 @@
|
|||||||
import { startStimulusApp } from '@symfony/stimulus-bundle';
|
import { startStimulusApp } from '@symfony/stimulus-bundle';
|
||||||
|
import Popover from '@stimulus-components/popover'
|
||||||
|
import Dialog from '@stimulus-components/dialog'
|
||||||
|
import Dropdown from '@stimulus-components/dropdown'
|
||||||
|
|
||||||
const app = startStimulusApp();
|
const app = startStimulusApp();
|
||||||
// register any custom, 3rd party controllers here
|
// register any custom, 3rd party controllers here
|
||||||
// app.register('some_controller_name', SomeImportedController);
|
app.register('popover', Popover);
|
||||||
|
app.register('dialog', Dialog);
|
||||||
|
app.register('dropdown', Dropdown);
|
||||||
|
|||||||
30
assets/controllers/clear_cache_controller.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { Controller } from '@hotwired/stimulus';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following line makes this controller "lazy": it won't be downloaded until needed
|
||||||
|
* See https://symfony.com/bundles/StimulusBundle/current/index.html#lazy-stimulus-controllers
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* stimulusFetch: 'lazy' */
|
||||||
|
export default class extends Controller {
|
||||||
|
initialize() {}
|
||||||
|
|
||||||
|
connect() {}
|
||||||
|
|
||||||
|
disconnect() {}
|
||||||
|
|
||||||
|
async clearAll() {
|
||||||
|
let response = await fetch('/api/torrentio/cache', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Accept': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
type: 'torrentio',
|
||||||
|
mediaType: 'tvshows',
|
||||||
|
})
|
||||||
|
});
|
||||||
|
response = await response.json()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,10 +12,11 @@ export default class extends Controller {
|
|||||||
filename: String,
|
filename: String,
|
||||||
mediaType: String,
|
mediaType: String,
|
||||||
imdbId: String,
|
imdbId: String,
|
||||||
|
episodeId: String
|
||||||
}
|
}
|
||||||
|
|
||||||
download() {
|
download() {
|
||||||
fetch('/download', {
|
fetch('/api/download', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
@@ -26,7 +27,8 @@ export default class extends Controller {
|
|||||||
title: this.element.dataset['title'],
|
title: this.element.dataset['title'],
|
||||||
filename: this.filenameValue,
|
filename: this.filenameValue,
|
||||||
mediaType: this.mediaTypeValue,
|
mediaType: this.mediaTypeValue,
|
||||||
imdbId: this.imdbIdValue
|
imdbId: this.imdbIdValue,
|
||||||
|
episodeId: this.episodeIdValue
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
.then(res => res.json())
|
.then(res => res.json())
|
||||||
|
|||||||
60
assets/controllers/download_list_controller.js
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import { Controller } from '@hotwired/stimulus';
|
||||||
|
import { getComponent } from '@symfony/ux-live-component';
|
||||||
|
/*
|
||||||
|
* The following line makes this controller "lazy": it won't be downloaded until needed
|
||||||
|
* See https://symfony.com/bundles/StimulusBundle/current/index.html#lazy-stimulus-controllers
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* stimulusFetch: 'lazy' */
|
||||||
|
export default class extends Controller {
|
||||||
|
static targets = ['download']
|
||||||
|
|
||||||
|
async initialize() {
|
||||||
|
this.component = await getComponent(this.element);
|
||||||
|
}
|
||||||
|
|
||||||
|
connect() {
|
||||||
|
// Called every time the controller is connected to the DOM
|
||||||
|
// (on page load, when it's added to the DOM, moved in the DOM, etc.)
|
||||||
|
|
||||||
|
// Here you can add event listeners on the element or target elements,
|
||||||
|
// add or remove classes, attributes, dispatch custom events, etc.
|
||||||
|
// this.fooTarget.addEventListener('click', this._fooBar)
|
||||||
|
}
|
||||||
|
|
||||||
|
downloadTargetConnected(target) {
|
||||||
|
let downloads = this.element.querySelectorAll('tbody tr');
|
||||||
|
if (downloads.length > 5) {
|
||||||
|
target.classList.add('hidden');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pauseDownload(data) {
|
||||||
|
fetch(`/api/download/${data.params.id}/pause`, {method: 'PATCH'})
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(json => console.debug(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
resumeDownload(data) {
|
||||||
|
fetch(`/api/download/${data.params.id}/resume`, {method: 'PATCH'})
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(json => console.debug(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
deleteDownload(data) {
|
||||||
|
fetch(`/api/download/${data.params.id}`, {method: 'DELETE'})
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(json => console.debug(json));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add custom controller actions here
|
||||||
|
// fooBar() { this.fooTarget.classList.toggle(this.bazClass) }
|
||||||
|
|
||||||
|
disconnect() {
|
||||||
|
// Called anytime its element is disconnected from the DOM
|
||||||
|
// (on page change, when it's removed from or moved in the DOM, etc.)
|
||||||
|
|
||||||
|
// Here you should remove all event listeners added in "connect()"
|
||||||
|
// this.fooTarget.removeEventListener('click', this._fooBar)
|
||||||
|
}
|
||||||
|
}
|
||||||
93
assets/controllers/monitor_button_controller.js
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
import { Controller } from '@hotwired/stimulus';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following line makes this controller "lazy": it won't be downloaded until needed
|
||||||
|
* See https://symfony.com/bundles/StimulusBundle/current/index.html#lazy-stimulus-controllers
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* stimulusFetch: 'lazy' */
|
||||||
|
export default class extends Controller {
|
||||||
|
static targets = ['button', 'options']
|
||||||
|
static outlets = ['result-filter']
|
||||||
|
static values = {
|
||||||
|
tmdbId: String,
|
||||||
|
imdbId: String,
|
||||||
|
title: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
initialize() {
|
||||||
|
// Called once when the controller is first instantiated (per element)
|
||||||
|
|
||||||
|
// Here you can initialize variables, create scoped callables for event
|
||||||
|
// listeners, instantiate external libraries, etc.
|
||||||
|
// this._fooBar = this.fooBar.bind(this)
|
||||||
|
}
|
||||||
|
|
||||||
|
connect() {
|
||||||
|
// Called every time the controller is connected to the DOM
|
||||||
|
// (on page load, when it's added to the DOM, moved in the DOM, etc.)
|
||||||
|
|
||||||
|
// Here you can add event listeners on the element or target elements,
|
||||||
|
// add or remove classes, attributes, dispatch custom events, etc.
|
||||||
|
// this.fooTarget.addEventListener('click', this._fooBar)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add custom controller actions here
|
||||||
|
// fooBar() { this.fooTarget.classList.toggle(this.bazClass) }
|
||||||
|
|
||||||
|
disconnect() {
|
||||||
|
// Called anytime its element is disconnected from the DOM
|
||||||
|
// (on page change, when it's removed from or moved in the DOM, etc.)
|
||||||
|
|
||||||
|
// Here you should remove all event listeners added in "connect()"
|
||||||
|
// this.fooTarget.removeEventListener('click', this._fooBar)
|
||||||
|
}
|
||||||
|
|
||||||
|
toggle() {
|
||||||
|
this.optionsTarget.classList.toggle('hidden');
|
||||||
|
}
|
||||||
|
|
||||||
|
async monitorSeries() {
|
||||||
|
await this.makeMonitor({
|
||||||
|
tmdbId: this.tmdbIdValue,
|
||||||
|
imdbId: this.imdbIdValue,
|
||||||
|
title: this.titleValue,
|
||||||
|
monitorType: 'tvshows',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async monitorSeason() {
|
||||||
|
await this.makeMonitor({
|
||||||
|
tmdbId: this.tmdbIdValue,
|
||||||
|
imdbId: this.imdbIdValue,
|
||||||
|
title: this.titleValue,
|
||||||
|
monitorType: 'tvseason',
|
||||||
|
season: this.resultFilterOutlet.activeFilter['season'],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async monitorEpisode() {
|
||||||
|
// ToDo: figure out how to set episode
|
||||||
|
await this.makeMonitor({
|
||||||
|
tmdbId: this.tmdbIdValue,
|
||||||
|
imdbId: this.imdbIdValue,
|
||||||
|
title: this.titleValue,
|
||||||
|
monitorType: 'tvepisode',
|
||||||
|
season: this.resultFilterOutlet.activeFilter['season'],
|
||||||
|
episode: '',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async makeMonitor(body) {
|
||||||
|
const response = await fetch('/api/monitor', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Accept': 'application/json',
|
||||||
|
},
|
||||||
|
body: JSON.stringify(body)
|
||||||
|
});
|
||||||
|
|
||||||
|
return await response.json();
|
||||||
|
}
|
||||||
|
}
|
||||||
14
assets/controllers/monitor_list_controller.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import { Controller } from '@hotwired/stimulus';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following line makes this controller "lazy": it won't be downloaded until needed
|
||||||
|
* See https://github.com/symfony/stimulus-bridge#lazy-controllers
|
||||||
|
*/
|
||||||
|
/* stimulusFetch: 'lazy' */
|
||||||
|
export default class extends Controller {
|
||||||
|
deleteMonitor(data) {
|
||||||
|
fetch(`/api/monitor/${data.params.id}`, {method: 'DELETE'})
|
||||||
|
.then(res => res.json())
|
||||||
|
.then(json => console.debug(json));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,13 +18,15 @@ export default class extends Controller {
|
|||||||
static targets = ['list']
|
static targets = ['list']
|
||||||
|
|
||||||
options = []
|
options = []
|
||||||
|
optionsLoaded = false
|
||||||
|
|
||||||
async connect() {
|
async connect() {
|
||||||
await this.setOptions();
|
await this.setOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
async setOptions() {
|
async setOptions() {
|
||||||
if (this.options.length === 0) {
|
if (false === this.optionsLoaded) {
|
||||||
|
this.optionsLoaded = true;
|
||||||
await fetch(`/torrentio/movies/${this.tmdbIdValue}/${this.imdbIdValue}`)
|
await fetch(`/torrentio/movies/${this.tmdbIdValue}/${this.imdbIdValue}`)
|
||||||
.then(res => res.text())
|
.then(res => res.text())
|
||||||
.then(response => {
|
.then(response => {
|
||||||
|
|||||||
25
assets/controllers/navbar_controller.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { Controller } from '@hotwired/stimulus';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following line makes this controller "lazy": it won't be downloaded until needed
|
||||||
|
* See https://github.com/symfony/stimulus-bridge#lazy-controllers
|
||||||
|
*/
|
||||||
|
/* stimulusFetch: 'lazy' */
|
||||||
|
export default class extends Controller {
|
||||||
|
inactiveStyles = "block rounded-lg px-4 py-2 text-sm font-medium text-gray-50 hover:bg-orange-500 hover:bg-opacity-80";
|
||||||
|
activeStyles = "block rounded-lg bg-orange-500 hover:bg-opacity-70 bg-clip-padding backdrop-filter backdrop-blur-md bg-opacity-80 px-4 py-2 text-sm font-medium text-gray-50";
|
||||||
|
|
||||||
|
connect() {
|
||||||
|
console.log(window.location.pathname);
|
||||||
|
this.element.querySelectorAll('a:not(.nav-foot)').forEach(link => {
|
||||||
|
link.className = this.inactiveStyles;
|
||||||
|
if (window.location.pathname === (new URL(link.href)).pathname || window.location.pathname.startsWith( (new URL(link.href)).pathname + '/' ) ) {
|
||||||
|
link.className = this.activeStyles;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setActive() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -20,7 +20,7 @@ export default class extends Controller {
|
|||||||
"provider": "",
|
"provider": "",
|
||||||
}
|
}
|
||||||
|
|
||||||
static outlets = ['movie-results', 'tv-results']
|
static outlets = ['movie-results', 'tv-results', 'tv-episode-list']
|
||||||
static targets = ['resolution', 'codec', 'language', 'provider', 'season', 'selectAll', 'downloadSelected']
|
static targets = ['resolution', 'codec', 'language', 'provider', 'season', 'selectAll', 'downloadSelected']
|
||||||
static values = {
|
static values = {
|
||||||
'media-type': String,
|
'media-type': String,
|
||||||
@@ -127,6 +127,10 @@ export default class extends Controller {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setSeason(event) {
|
||||||
|
this.tvEpisodeListOutlet.setSeason(event.target.value);
|
||||||
|
}
|
||||||
|
|
||||||
uncheckSelectAllBtn() {
|
uncheckSelectAllBtn() {
|
||||||
this.selectAllTarget.checked = false;
|
this.selectAllTarget.checked = false;
|
||||||
}
|
}
|
||||||
|
|||||||
51
assets/controllers/tv_episode_list_controller.js
Normal file
@@ -0,0 +1,51 @@
|
|||||||
|
import { Controller } from '@hotwired/stimulus';
|
||||||
|
import { getComponent } from '@symfony/ux-live-component';
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The following line makes this controller "lazy": it won't be downloaded until needed
|
||||||
|
* See https://symfony.com/bundles/StimulusBundle/current/index.html#lazy-stimulus-controllers
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* stimulusFetch: 'lazy' */
|
||||||
|
export default class extends Controller {
|
||||||
|
|
||||||
|
async initialize() {
|
||||||
|
this.component = await getComponent(this.element);
|
||||||
|
this.component.on('render:finished', (component) => {
|
||||||
|
console.log(component);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setSeason(season) {
|
||||||
|
this.element.querySelectorAll(".episode-container").forEach(element => element.remove());
|
||||||
|
this.component.set('pageNumber', 1);
|
||||||
|
this.component.set('season', parseInt(season));
|
||||||
|
this.component.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
paginate(event) {
|
||||||
|
this.element.querySelectorAll(".episode-container").forEach(element => element.remove());
|
||||||
|
this.component.action('paginate', {page: event.params.page});
|
||||||
|
this.component.render();
|
||||||
|
}
|
||||||
|
|
||||||
|
connect() {
|
||||||
|
// Called every time the controller is connected to the DOM
|
||||||
|
// (on page load, when it's added to the DOM, moved in the DOM, etc.)
|
||||||
|
|
||||||
|
// Here you can add event listeners on the element or target elements,
|
||||||
|
// add or remove classes, attributes, dispatch custom events, etc.
|
||||||
|
// this.fooTarget.addEventListener('click', this._fooBar)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add custom controller actions here
|
||||||
|
// fooBar() { this.fooTarget.classList.toggle(this.bazClass) }
|
||||||
|
|
||||||
|
disconnect() {
|
||||||
|
// Called anytime its element is disconnected from the DOM
|
||||||
|
// (on page change, when it's removed from or moved in the DOM, etc.)
|
||||||
|
|
||||||
|
// Here you should remove all event listeners added in "connect()"
|
||||||
|
// this.fooTarget.removeEventListener('click', this._fooBar)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,49 +18,61 @@ export default class extends Controller {
|
|||||||
active: Boolean,
|
active: Boolean,
|
||||||
};
|
};
|
||||||
|
|
||||||
static targets = ['list', 'count', 'episodeSelector']
|
static targets = ['list', 'count', 'episodeSelector', 'toggleButton', 'listContainer']
|
||||||
static outlets = ['loading-icon']
|
static outlets = ['loading-icon']
|
||||||
|
|
||||||
options = []
|
options = []
|
||||||
optionsLoaded = false
|
optionsLoaded = false
|
||||||
|
isOpen = false
|
||||||
|
|
||||||
async connect() {
|
async connect() {
|
||||||
await this.setOptions();
|
await this.setOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
async setOptions() {
|
async setOptions() {
|
||||||
if (true === this.activeValue && this.optionsLoaded === false) {
|
if (this.optionsLoaded === false) {
|
||||||
this.optionsLoaded = true;
|
this.optionsLoaded = true;
|
||||||
await fetch(`/torrentio/tvshows/${this.tmdbIdValue}/${this.imdbIdValue}/${this.seasonValue}/${this.episodeValue}`)
|
let response;
|
||||||
.then(res => res.text())
|
|
||||||
.then(response => {
|
try {
|
||||||
this.element.innerHTML = response;
|
response = await fetch(`/torrentio/tvshows/${this.tmdbIdValue}/${this.imdbIdValue}/${this.seasonValue}/${this.episodeValue}`)
|
||||||
this.options = this.element.querySelectorAll('tbody tr');
|
} catch (error) {
|
||||||
if (this.options.length > 0) {
|
console.log('There was an error', error);
|
||||||
this.options.forEach((option) => option.querySelector('.download-btn').dataset['title'] = this.titleValue);
|
}
|
||||||
this.options[0].querySelector('input[type="checkbox"]').checked = true;
|
|
||||||
} else {
|
if (response?.ok) {
|
||||||
this.episodeSelectorTarget.disabled = true;
|
response = await response.text()
|
||||||
}
|
this.listContainerTarget.innerHTML = response;
|
||||||
this.loadingIconOutlet.increaseCount();
|
this.options = this.element.querySelectorAll('tbody tr');
|
||||||
});
|
if (this.options.length > 0) {
|
||||||
|
this.options.forEach((option) => option.querySelector('.download-btn').dataset['title'] = this.titleValue);
|
||||||
|
this.options[0].querySelector('input[type="checkbox"]').checked = true;
|
||||||
|
} else {
|
||||||
|
this.countTarget.innerText = 0;
|
||||||
|
this.episodeSelectorTarget.disabled = true;
|
||||||
|
}
|
||||||
|
this.loadingIconOutlet.increaseCount();
|
||||||
|
} else {
|
||||||
|
console.log(`HTTP Response Code: ${response?.status}`)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// async clearCache() {
|
||||||
|
// await fetch(`/torrentio/tvshows/clear/${this.tmdbIdValue}/${this.imdbIdValue}/${this.seasonValue}/${this.episodeValue}`)
|
||||||
|
// .then(res => res.text())
|
||||||
|
// .then(response => {});
|
||||||
|
// }
|
||||||
|
|
||||||
async setActive() {
|
async setActive() {
|
||||||
this.activeValue = true;
|
|
||||||
this.element.classList.remove('hidden');
|
|
||||||
if (false === this.optionsLoaded) {
|
if (false === this.optionsLoaded) {
|
||||||
await this.setOptions();
|
await this.setOptions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async setInActive() {
|
async setInActive() {
|
||||||
this.activeValue = false;
|
|
||||||
// if (true === this.hasEpisodeSelectorTarget()) {
|
|
||||||
this.episodeSelectorTarget.checked = false;
|
this.episodeSelectorTarget.checked = false;
|
||||||
// }
|
|
||||||
this.element.classList.add('hidden');
|
|
||||||
}
|
}
|
||||||
|
|
||||||
isActive() {
|
isActive() {
|
||||||
@@ -78,7 +90,16 @@ export default class extends Controller {
|
|||||||
}
|
}
|
||||||
|
|
||||||
toggleList() {
|
toggleList() {
|
||||||
|
// if (!this.isOpen) {
|
||||||
|
// this.toggleButtonTarget.classList.add('rotate-180');
|
||||||
|
// this.toggleButtonTarget.classList.remove('-rotate-180');
|
||||||
|
// } else {
|
||||||
|
// this.toggleButtonTarget.classList.add('-rotate-180');
|
||||||
|
// this.toggleButtonTarget.classList.remove('rotate-180');
|
||||||
|
// }
|
||||||
this.listTarget.classList.toggle('hidden');
|
this.listTarget.classList.toggle('hidden');
|
||||||
|
this.toggleButtonTarget.classList.toggle('rotate-90');
|
||||||
|
this.toggleButtonTarget.classList.toggle('-rotate-90');
|
||||||
}
|
}
|
||||||
|
|
||||||
download() {
|
download() {
|
||||||
|
|||||||
1
assets/icons/hugeicons/loading-01.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="https://www.w3.org/2000/svg" viewBox="0 0 24 24"><g fill="none" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="1.5" color="currentColor"><path d="M17.201 2H6.8c-1.458 0-2.737.985-2.795 2.404c-.074 1.785 1.182 2.97 2.5 4.083c1.825 1.54 2.737 2.31 2.832 3.284q.023.229 0 .458c-.095.975-1.007 1.744-2.832 3.284c-1.355 1.143-2.578 2.207-2.5 4.083C4.062 21.016 5.34 22 6.799 22H17.2c1.458 0 2.737-.985 2.796-2.404c.046-1.13-.373-2.254-1.262-3.036c-.405-.357-.826-.698-1.24-1.047c-1.824-1.54-2.736-2.31-2.831-3.284a2.3 2.3 0 0 1 0-.458c.095-.975 1.008-1.744 2.832-3.284c1.34-1.131 2.577-2.229 2.5-4.083C19.939 2.984 18.66 2 17.202 2"/><path d="M9 21.638c0-.442 0-.663.088-.856a1 1 0 0 1 .046-.09c.107-.183.288-.312.65-.571c1.006-.719 1.51-1.078 2.081-1.116q.135-.009.27 0c.572.038 1.075.397 2.08 1.116c.363.259.544.388.651.571q.026.045.046.09c.088.193.088.414.088.856V22H9z"/></g></svg>
|
||||||
|
After Width: | Height: | Size: 928 B |
1
assets/icons/ic/twotone-cancel.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="https://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" d="M12 4c-4.41 0-8 3.59-8 8s3.59 8 8 8s8-3.59 8-8s-3.59-8-8-8m5 11.59L15.59 17L12 13.41L8.41 17L7 15.59L10.59 12L7 8.41L8.41 7L12 10.59L15.59 7L17 8.41L13.41 12z" opacity=".3"/><path fill="currentColor" d="M12 2C6.47 2 2 6.47 2 12s4.47 10 10 10s10-4.47 10-10S17.53 2 12 2m0 18c-4.41 0-8-3.59-8-8s3.59-8 8-8s8 3.59 8 8s-3.59 8-8 8m3.59-13L12 10.59L8.41 7L7 8.41L10.59 12L7 15.59L8.41 17L12 13.41L15.59 17L17 15.59L13.41 12L17 8.41z"/></svg>
|
||||||
|
After Width: | Height: | Size: 526 B |
1
assets/icons/icon-park-twotone/pause-one.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="https://www.w3.org/2000/svg" viewBox="0 0 48 48"><defs><mask id="ipTPauseOne0"><g fill="none" stroke="#fff" stroke-linejoin="round" stroke-width="4"><path fill="#555" d="M24 44c11.046 0 20-8.954 20-20S35.046 4 24 4S4 12.954 4 24s8.954 20 20 20Z"/><path stroke-linecap="round" d="M19 18v12m10-12v12"/></g></mask></defs><path fill="currentColor" d="M0 0h48v48H0z" mask="url(#ipTPauseOne0)"/></svg>
|
||||||
|
After Width: | Height: | Size: 407 B |
1
assets/icons/icon-park-twotone/play.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="https://www.w3.org/2000/svg" viewBox="0 0 48 48"><defs><mask id="ipTPlay0"><g fill="#555" stroke="#fff" stroke-linejoin="round" stroke-width="4"><path d="M24 44c11.046 0 20-8.954 20-20S35.046 4 24 4S4 12.954 4 24s8.954 20 20 20Z"/><path d="M20 24v-6.928l6 3.464L32 24l-6 3.464l-6 3.464z"/></g></mask></defs><path fill="currentColor" d="M0 0h48v48H0z" mask="url(#ipTPlay0)"/></svg>
|
||||||
|
After Width: | Height: | Size: 392 B |
1
assets/icons/line-md/circle-twotone.svg
Normal file
@@ -0,0 +1 @@
|
|||||||
|
<svg xmlns="https://www.w3.org/2000/svg" viewBox="0 0 24 24"><path fill="currentColor" fill-opacity="0" stroke="currentColor" stroke-dasharray="64" stroke-dashoffset="64" stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M3 12c0 -4.97 4.03 -9 9 -9c4.97 0 9 4.03 9 9c0 4.97 -4.03 9 -9 9c-4.97 0 -9 -4.03 -9 -9Z"><animate fill="freeze" attributeName="fill-opacity" begin="0.6s" dur="0.15s" values="0;0.3"/><animate fill="freeze" attributeName="stroke-dashoffset" dur="0.6s" values="64;0"/></path></svg>
|
||||||
|
After Width: | Height: | Size: 517 B |
@@ -10,4 +10,63 @@
|
|||||||
h2 {
|
h2 {
|
||||||
font-size: var(--text-xl);
|
font-size: var(--text-xl);
|
||||||
}
|
}
|
||||||
|
.rounded-ms {
|
||||||
|
border-radius: 0.275rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@layer components {
|
||||||
|
.alert {
|
||||||
|
@apply text-white text-sm min-w-[250px] border px-4 py-3 rounded-md
|
||||||
|
}
|
||||||
|
.alert-success {
|
||||||
|
@apply bg-green-950 hover:bg-green-900 border-green-500
|
||||||
|
}
|
||||||
|
.alert-warning {
|
||||||
|
@apply bg-yellow-500/70 hover:bg-yellow-600 border-yellow-400 text-black
|
||||||
|
}
|
||||||
|
|
||||||
|
.primary-btn {
|
||||||
|
@apply px-1 py-1 rounded-md bg-orange-500 self-end text-white w-16 ml-2 hover:bg-orange-600
|
||||||
|
}
|
||||||
|
.secondary-btn {
|
||||||
|
@apply px-1 py-1 rounded-md self-end w-16 hover:bg-stone-100
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Prevent scrolling while dialog is open */
|
||||||
|
body:has(dialog[data-dialog-target="dialog"][open]) {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Customize the dialog backdrop */
|
||||||
|
dialog {
|
||||||
|
box-shadow: 0 0 0 100vw rgb(0 0 0 / 0.5);
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fade-in {
|
||||||
|
0% {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fade-out {
|
||||||
|
0% {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
100% {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Add animations */
|
||||||
|
dialog[data-dialog-target="dialog"][open] {
|
||||||
|
animation: fade-in 200ms forwards;
|
||||||
|
}
|
||||||
|
|
||||||
|
dialog[data-dialog-target="dialog"][closing] {
|
||||||
|
animation: fade-out 200ms forwards;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
# $1 = movies/tvshows/etc, $2 = title of media, $3 = URL of download
|
|
||||||
cd /var/download/${1} && if [ ! -d "${2}" ]; then mkdir "${2}"; fi && cd "${2}" && wget "${3}"
|
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
echo "> Building ${IMG} for linux/amd64"
|
echo "> Building ${IMG} for linux/amd64"
|
||||||
docker buildx build --platform linux/amd64 -f Dockerfile.prod -t ${IMG} .
|
docker buildx build --platform linux/amd64 -f Dockerfile.app -t "${IMG}-app" .
|
||||||
|
docker buildx build --platform linux/amd64 -f Dockerfile.worker -t "${IMG}-worker" .
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
echo "> Building ${IMG} for linux/arm/v8"
|
echo "> Building ${IMG} for linux/arm/v8"
|
||||||
docker buildx build --platform linux/arm/v8 -f Dockerfile.prod -t ${IMG} .
|
docker buildx build --platform linux/arm/v8 -f Dockerfile.app -t "${IMG}-app" .
|
||||||
|
docker buildx build --platform linux/arm/v8 -f Dockerfile.app -t "${IMG}-worker" .
|
||||||
@@ -1,2 +1,3 @@
|
|||||||
echo "> Pushing ${IMG}"
|
echo "> Pushing ${IMG}"
|
||||||
docker push ${IMG}
|
docker push "${IMG}-app"
|
||||||
|
docker push "${IMG}-worker"
|
||||||
@@ -2,5 +2,5 @@ dev.caldwell.digital:443
|
|||||||
|
|
||||||
tls /etc/ssl/wildcard.crt /etc/ssl/wildcard.pem
|
tls /etc/ssl/wildcard.crt /etc/ssl/wildcard.pem
|
||||||
|
|
||||||
reverse_proxy php:80
|
reverse_proxy app:80
|
||||||
|
|
||||||
|
|||||||
@@ -1,23 +0,0 @@
|
|||||||
<VirtualHost *:80>
|
|
||||||
ServerName localhost
|
|
||||||
|
|
||||||
DocumentRoot /var/www/public
|
|
||||||
DirectoryIndex /index.php
|
|
||||||
|
|
||||||
<LocationMatch "/hub/">
|
|
||||||
ProxyPass http://mercure:80/
|
|
||||||
ProxyPassReverse http://mercure:80/
|
|
||||||
</LocationMatch>
|
|
||||||
|
|
||||||
<Directory /var/www/public>
|
|
||||||
AllowOverride None
|
|
||||||
Order Allow,Deny
|
|
||||||
Allow from All
|
|
||||||
|
|
||||||
FallbackResource /index.php
|
|
||||||
</Directory>
|
|
||||||
|
|
||||||
<Directory /var/www/public/bundles>
|
|
||||||
FallbackResource disabled
|
|
||||||
</Directory>
|
|
||||||
</VirtualHost>
|
|
||||||
37
build.xml
@@ -1,14 +1,20 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project name="Caldwell Digital Symfony Template" default="build">
|
<project name="Torsearch" default="build">
|
||||||
<!-- build dev for dev envs -->
|
<!-- build dev for dev envs -->
|
||||||
<target name="build" depends="setEnv,composer,compileAssets,migrateDb" />
|
<target name="build" depends="setEnv,composer,compileAssets,migrateDb,clearCache" />
|
||||||
|
|
||||||
<target name="composer" description="Run composer">
|
<target name="composer" description="Run composer">
|
||||||
<exec executable="composer">
|
<exec executable="composer">
|
||||||
<arg value="install" />
|
<arg value="install" />
|
||||||
|
<arg value="--ignore-platform-reqs" />
|
||||||
</exec>
|
</exec>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
<target name="setEnv" description="Set the database configuration">
|
||||||
|
<copy file="${project.basedir}/.env.properties" tofile="${project.basedir}/.env.local" overwrite="true">
|
||||||
|
</copy>
|
||||||
|
</target>
|
||||||
|
|
||||||
<target name="compileAssets" description="Run composer">
|
<target name="compileAssets" description="Run composer">
|
||||||
<exec executable="php">
|
<exec executable="php">
|
||||||
<arg value="bin/console" />
|
<arg value="bin/console" />
|
||||||
@@ -20,25 +26,6 @@
|
|||||||
</exec>
|
</exec>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
<target name="setEnv" description="Set the database configuration">
|
|
||||||
<copy file="${project.basedir}/.env.dist" tofile="${project.basedir}/.env.local" overwrite="true">
|
|
||||||
<filterchain>
|
|
||||||
<replacetokens begintoken="%%" endtoken="%%">
|
|
||||||
<token key="app_secret" value="${APP_SECRET}" />
|
|
||||||
<token key="db_url" value="${DATABASE_URL}" />
|
|
||||||
<token key="download_dir" value="${DOWNLOAD_DIR}" />
|
|
||||||
<token key="rd_key" value="${REAL_DEBRID_KEY}" />
|
|
||||||
<token key="tmdb_api" value="${TMDB_API}" />
|
|
||||||
<token key="mercure_url" value="${MERCURE_URL}" />
|
|
||||||
<token key="mercure_public_url" value="${MERCURE_PUBLIC_URL}" />
|
|
||||||
<token key="mercure_jwt_secret" value="${MERCURE_JWT_SECRET}" />
|
|
||||||
<token key="jellyfin_url" value="${JELLYFIN_URL}" />
|
|
||||||
<token key="jellyfin_token" value="${JELLYFIN_TOKEN}" />
|
|
||||||
</replacetokens>
|
|
||||||
</filterchain>
|
|
||||||
</copy>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
<target name="migrateDb" description="Migrate the database">
|
<target name="migrateDb" description="Migrate the database">
|
||||||
<exec executable="php">
|
<exec executable="php">
|
||||||
<arg value="bin/console" />
|
<arg value="bin/console" />
|
||||||
@@ -46,4 +33,12 @@
|
|||||||
<arg value="doctrine:migrations:migrate" />
|
<arg value="doctrine:migrations:migrate" />
|
||||||
</exec>
|
</exec>
|
||||||
</target>
|
</target>
|
||||||
|
|
||||||
|
<target name="clearCache" description="Clear the application cache">
|
||||||
|
<exec executable="php">
|
||||||
|
<arg value="bin/console" />
|
||||||
|
<arg value="cache:pool:clear" />
|
||||||
|
<arg value="cache.app" />
|
||||||
|
</exec>
|
||||||
|
</target>
|
||||||
</project>
|
</project>
|
||||||
|
|||||||
73
compose.yml
@@ -12,34 +12,56 @@ services:
|
|||||||
- $PWD/bash/caddy:/etc/caddy
|
- $PWD/bash/caddy:/etc/caddy
|
||||||
- $PWD/bash/certs:/etc/ssl
|
- $PWD/bash/certs:/etc/ssl
|
||||||
|
|
||||||
php:
|
|
||||||
|
app:
|
||||||
build: .
|
build: .
|
||||||
|
restart: unless-stopped
|
||||||
volumes:
|
volumes:
|
||||||
- ./:/var/www
|
- $PWD:/app
|
||||||
|
- $PWD/var/download:/var/download
|
||||||
|
- mercure_data:/data
|
||||||
|
- mercure_config:/config
|
||||||
|
tty: true
|
||||||
|
environment:
|
||||||
|
TZ: America/Chicago
|
||||||
|
MERCURE_PUBLISHER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
|
||||||
|
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
|
||||||
|
depends_on:
|
||||||
|
database:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
|
|
||||||
worker:
|
worker:
|
||||||
build: .
|
build: .
|
||||||
volumes:
|
|
||||||
- ./:/var/www
|
|
||||||
- ./var/download:/var/download
|
|
||||||
command: php ./bin/console messenger:consume async -v --time-limit=3600 --limit=10
|
|
||||||
|
|
||||||
mercure:
|
|
||||||
image: dunglas/mercure
|
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
ports:
|
|
||||||
- "3000:80"
|
|
||||||
environment:
|
|
||||||
SERVER_NAME: ':80'
|
|
||||||
MERCURE_PUBLISHER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
|
|
||||||
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
|
|
||||||
MERCURE_EXTRA_DIRECTIVES: |
|
|
||||||
cors_origins *
|
|
||||||
anonymous
|
|
||||||
command: /usr/bin/caddy run --config /etc/caddy/dev.Caddyfile
|
|
||||||
volumes:
|
volumes:
|
||||||
- mercure_data:/data
|
- $PWD:/app
|
||||||
- mercure_config:/config
|
- $PWD/var/download:/var/download
|
||||||
|
tty: true
|
||||||
|
environment:
|
||||||
|
TZ: America/Chicago
|
||||||
|
command: php /app/bin/console messenger:consume media_cache -vv --time-limit=3600
|
||||||
|
|
||||||
|
|
||||||
|
scheduler:
|
||||||
|
build: .
|
||||||
|
restart: unless-stopped
|
||||||
|
volumes:
|
||||||
|
- $PWD:/app
|
||||||
|
environment:
|
||||||
|
TZ: America/Chicago
|
||||||
|
command: php /app/bin/console messenger:consume scheduler_monitor -vv
|
||||||
|
tty: true
|
||||||
|
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:latest
|
||||||
|
volumes:
|
||||||
|
- redis_data:/data
|
||||||
|
command: redis-server --maxmemory 512MB
|
||||||
|
restart: unless-stopped
|
||||||
|
environment:
|
||||||
|
TZ: America/Chicago
|
||||||
|
|
||||||
|
|
||||||
database:
|
database:
|
||||||
@@ -49,17 +71,26 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- mysql:/var/lib/mysql
|
- mysql:/var/lib/mysql
|
||||||
environment:
|
environment:
|
||||||
|
TZ: America/Chicago
|
||||||
MYSQL_DATABASE: app
|
MYSQL_DATABASE: app
|
||||||
MYSQL_USERNAME: app
|
MYSQL_USERNAME: app
|
||||||
MYSQL_PASSWORD: password
|
MYSQL_PASSWORD: password
|
||||||
MYSQL_ROOT_PASSWORD: password
|
MYSQL_ROOT_PASSWORD: password
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
|
||||||
|
|
||||||
adminer:
|
adminer:
|
||||||
image: adminer
|
image: adminer
|
||||||
ports:
|
ports:
|
||||||
- "8081:8080"
|
- "8081:8080"
|
||||||
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
mysql:
|
mysql:
|
||||||
mercure_data:
|
mercure_data:
|
||||||
mercure_config:
|
mercure_config:
|
||||||
|
redis_data:
|
||||||
|
|||||||
@@ -4,37 +4,51 @@
|
|||||||
"minimum-stability": "stable",
|
"minimum-stability": "stable",
|
||||||
"prefer-stable": true,
|
"prefer-stable": true,
|
||||||
"require": {
|
"require": {
|
||||||
"php": ">=8.2",
|
"php": ">=8.4",
|
||||||
"ext-ctype": "*",
|
"ext-ctype": "*",
|
||||||
"ext-iconv": "*",
|
"ext-iconv": "*",
|
||||||
"1tomany/rich-bundle": "^1.8",
|
"1tomany/rich-bundle": "^1.8",
|
||||||
"aimeos/map": "^3.12",
|
"aimeos/map": "^3.12",
|
||||||
|
"chrisullyott/php-filesize": "^4.2",
|
||||||
"doctrine/dbal": "^3",
|
"doctrine/dbal": "^3",
|
||||||
"doctrine/doctrine-bundle": "^2.14",
|
"doctrine/doctrine-bundle": "^2.14",
|
||||||
|
"doctrine/doctrine-fixtures-bundle": "^4.1",
|
||||||
"doctrine/doctrine-migrations-bundle": "^3.4",
|
"doctrine/doctrine-migrations-bundle": "^3.4",
|
||||||
"doctrine/orm": "^3.3",
|
"doctrine/orm": "^3.3",
|
||||||
|
"dragonmantank/cron-expression": "^3.4",
|
||||||
|
"guzzlehttp/guzzle": "^7.9",
|
||||||
|
"league/pipeline": "^1.1",
|
||||||
|
"nesbot/carbon": "^3.9",
|
||||||
"nihilarr/parse-torrent-name": "^0.0.1",
|
"nihilarr/parse-torrent-name": "^0.0.1",
|
||||||
"nyholm/psr7": "*",
|
"nyholm/psr7": "*",
|
||||||
"p3k/emoji-detector": "^1.2",
|
"p3k/emoji-detector": "^1.2",
|
||||||
|
"php-http/cache-plugin": "^2.0",
|
||||||
"php-tmdb/api": "^4.1",
|
"php-tmdb/api": "^4.1",
|
||||||
"symfony/asset": "7.2.*",
|
"predis/predis": "^2.4",
|
||||||
"symfony/console": "7.2.*",
|
"runtime/frankenphp-symfony": "^0.2.0",
|
||||||
"symfony/doctrine-messenger": "7.2.*",
|
"stof/doctrine-extensions-bundle": "^1.14",
|
||||||
"symfony/dotenv": "7.2.*",
|
"symfony/asset": "7.3.*",
|
||||||
|
"symfony/console": "7.3.*",
|
||||||
|
"symfony/doctrine-messenger": "7.3.*",
|
||||||
|
"symfony/dotenv": "7.3.*",
|
||||||
|
"symfony/filesystem": "7.3.*",
|
||||||
|
"symfony/finder": "7.3.*",
|
||||||
"symfony/flex": "^2",
|
"symfony/flex": "^2",
|
||||||
"symfony/form": "7.2.*",
|
"symfony/form": "7.3.*",
|
||||||
"symfony/framework-bundle": "7.2.*",
|
"symfony/framework-bundle": "7.3.*",
|
||||||
|
"symfony/ldap": "7.3.*",
|
||||||
"symfony/mercure-bundle": "^0.3.9",
|
"symfony/mercure-bundle": "^0.3.9",
|
||||||
"symfony/messenger": "7.2.*",
|
"symfony/messenger": "7.3.*",
|
||||||
"symfony/runtime": "7.2.*",
|
"symfony/runtime": "7.3.*",
|
||||||
"symfony/security-bundle": "7.2.*",
|
"symfony/scheduler": "7.3.*",
|
||||||
|
"symfony/security-bundle": "7.3.*",
|
||||||
"symfony/stimulus-bundle": "^2.24",
|
"symfony/stimulus-bundle": "^2.24",
|
||||||
"symfony/twig-bundle": "7.2.*",
|
"symfony/twig-bundle": "7.3.*",
|
||||||
"symfony/ux-icons": "^2.24",
|
"symfony/ux-icons": "^2.24",
|
||||||
"symfony/ux-live-component": "^2.24",
|
"symfony/ux-live-component": "^2.24",
|
||||||
"symfony/ux-turbo": "^2.24",
|
"symfony/ux-turbo": "^2.24",
|
||||||
"symfony/ux-twig-component": "^2.24",
|
"symfony/ux-twig-component": "^2.24",
|
||||||
"symfony/yaml": "7.2.*",
|
"symfony/yaml": "7.3.*",
|
||||||
"symfonycasts/tailwind-bundle": "^0.10.0",
|
"symfonycasts/tailwind-bundle": "^0.10.0",
|
||||||
"twig/extra-bundle": "^2.12|^3.0",
|
"twig/extra-bundle": "^2.12|^3.0",
|
||||||
"twig/twig": "^2.12|^3.0"
|
"twig/twig": "^2.12|^3.0"
|
||||||
@@ -45,6 +59,9 @@
|
|||||||
"symfony/flex": true,
|
"symfony/flex": true,
|
||||||
"symfony/runtime": true
|
"symfony/runtime": true
|
||||||
},
|
},
|
||||||
|
"platform": {
|
||||||
|
"php": "8.4"
|
||||||
|
},
|
||||||
"bump-after-update": true,
|
"bump-after-update": true,
|
||||||
"sort-packages": true
|
"sort-packages": true
|
||||||
},
|
},
|
||||||
@@ -80,7 +97,7 @@
|
|||||||
"post-update-cmd": [
|
"post-update-cmd": [
|
||||||
"@auto-scripts"
|
"@auto-scripts"
|
||||||
],
|
],
|
||||||
"sym": "docker compose exec php ./bin/console"
|
"sym": "docker compose exec app ./bin/console"
|
||||||
},
|
},
|
||||||
"conflict": {
|
"conflict": {
|
||||||
"symfony/symfony": "*"
|
"symfony/symfony": "*"
|
||||||
@@ -88,12 +105,13 @@
|
|||||||
"extra": {
|
"extra": {
|
||||||
"symfony": {
|
"symfony": {
|
||||||
"allow-contrib": false,
|
"allow-contrib": false,
|
||||||
"require": "7.2.*"
|
"require": "7.3.*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"require-dev": {
|
"require-dev": {
|
||||||
|
"phpstan/phpstan": "^2.1",
|
||||||
"symfony/maker-bundle": "^1.62",
|
"symfony/maker-bundle": "^1.62",
|
||||||
"symfony/stopwatch": "7.2.*",
|
"symfony/stopwatch": "7.3.*",
|
||||||
"symfony/web-profiler-bundle": "7.2.*"
|
"symfony/web-profiler-bundle": "7.3.*"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2898
composer.lock
generated
@@ -17,4 +17,6 @@ return [
|
|||||||
Symfony\Bundle\MercureBundle\MercureBundle::class => ['all' => true],
|
Symfony\Bundle\MercureBundle\MercureBundle::class => ['all' => true],
|
||||||
Symfony\UX\Turbo\TurboBundle::class => ['all' => true],
|
Symfony\UX\Turbo\TurboBundle::class => ['all' => true],
|
||||||
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
|
Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
|
||||||
|
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true],
|
||||||
|
Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle::class => ['all' => true],
|
||||||
];
|
];
|
||||||
|
|||||||
57
config/dist/ldap.security.yaml
vendored
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
security:
|
||||||
|
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
|
||||||
|
password_hashers:
|
||||||
|
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
|
||||||
|
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
|
||||||
|
providers:
|
||||||
|
users_in_memory: { memory: null }
|
||||||
|
app_local:
|
||||||
|
entity:
|
||||||
|
class: App\User\Framework\Entity\User
|
||||||
|
property: email
|
||||||
|
|
||||||
|
app_ldap:
|
||||||
|
id: App\User\Framework\Security\LdapUserProvider
|
||||||
|
|
||||||
|
firewalls:
|
||||||
|
dev:
|
||||||
|
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
||||||
|
security: false
|
||||||
|
main:
|
||||||
|
lazy: true
|
||||||
|
provider: app_ldap
|
||||||
|
form_login_ldap:
|
||||||
|
login_path: app_login
|
||||||
|
check_path: app_login
|
||||||
|
enable_csrf: true
|
||||||
|
service: Symfony\Component\Ldap\Ldap
|
||||||
|
dn_string: '%env(LDAP_DN_STRING)%'
|
||||||
|
logout:
|
||||||
|
path: app_logout
|
||||||
|
|
||||||
|
# activate different ways to authenticate
|
||||||
|
# https://symfony.com/doc/current/security.html#the-firewall
|
||||||
|
|
||||||
|
# https://symfony.com/doc/current/security/impersonating_user.html
|
||||||
|
# switch_user: true
|
||||||
|
|
||||||
|
# Easy way to control access for large sections of your site
|
||||||
|
# Note: Only the *first* access control that matches will be used
|
||||||
|
access_control:
|
||||||
|
- { path: ^/getting-started, roles: PUBLIC_ACCESS }
|
||||||
|
- { path: ^/register, roles: PUBLIC_ACCESS }
|
||||||
|
- { path: ^/login, roles: PUBLIC_ACCESS }
|
||||||
|
- { path: ^/, roles: ROLE_USER } # Or ROLE_ADMIN, ROLE_SUPER_ADMIN,
|
||||||
|
|
||||||
|
when@test:
|
||||||
|
security:
|
||||||
|
password_hashers:
|
||||||
|
# By default, password hashers are resource intensive and take time. This is
|
||||||
|
# important to generate secure password hashes. In tests however, secure hashes
|
||||||
|
# are not important, waste resources and increase test times. The following
|
||||||
|
# reduces the work factor to the lowest possible values.
|
||||||
|
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
|
||||||
|
algorithm: auto
|
||||||
|
cost: 4 # Lowest possible value for bcrypt
|
||||||
|
time_cost: 3 # Lowest possible value for argon
|
||||||
|
memory_cost: 10 # Lowest possible value for argon
|
||||||
55
config/dist/local.security.yaml
vendored
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
security:
|
||||||
|
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
|
||||||
|
password_hashers:
|
||||||
|
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
|
||||||
|
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
|
||||||
|
providers:
|
||||||
|
users_in_memory: { memory: null }
|
||||||
|
app_local:
|
||||||
|
entity:
|
||||||
|
class: App\User\Framework\Entity\User
|
||||||
|
property: email
|
||||||
|
|
||||||
|
app_ldap:
|
||||||
|
id: App\User\Framework\Security\LdapUserProvider
|
||||||
|
|
||||||
|
firewalls:
|
||||||
|
dev:
|
||||||
|
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
||||||
|
security: false
|
||||||
|
main:
|
||||||
|
lazy: true
|
||||||
|
provider: app_local
|
||||||
|
form_login:
|
||||||
|
login_path: app_login
|
||||||
|
check_path: app_login
|
||||||
|
enable_csrf: true
|
||||||
|
logout:
|
||||||
|
path: app_logout
|
||||||
|
|
||||||
|
# activate different ways to authenticate
|
||||||
|
# https://symfony.com/doc/current/security.html#the-firewall
|
||||||
|
|
||||||
|
# https://symfony.com/doc/current/security/impersonating_user.html
|
||||||
|
# switch_user: true
|
||||||
|
|
||||||
|
# Easy way to control access for large sections of your site
|
||||||
|
# Note: Only the *first* access control that matches will be used
|
||||||
|
access_control:
|
||||||
|
- { path: ^/getting-started, roles: PUBLIC_ACCESS }
|
||||||
|
- { path: ^/register, roles: PUBLIC_ACCESS }
|
||||||
|
- { path: ^/login, roles: PUBLIC_ACCESS }
|
||||||
|
- { path: ^/, roles: ROLE_USER } # Or ROLE_ADMIN, ROLE_SUPER_ADMIN,
|
||||||
|
|
||||||
|
when@test:
|
||||||
|
security:
|
||||||
|
password_hashers:
|
||||||
|
# By default, password hashers are resource intensive and take time. This is
|
||||||
|
# important to generate secure password hashes. In tests however, secure hashes
|
||||||
|
# are not important, waste resources and increase test times. The following
|
||||||
|
# reduces the work factor to the lowest possible values.
|
||||||
|
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
|
||||||
|
algorithm: auto
|
||||||
|
cost: 4 # Lowest possible value for bcrypt
|
||||||
|
time_cost: 3 # Lowest possible value for argon
|
||||||
|
memory_cost: 10 # Lowest possible value for argon
|
||||||
@@ -8,12 +8,18 @@ framework:
|
|||||||
# Other options include:
|
# Other options include:
|
||||||
|
|
||||||
# Redis
|
# Redis
|
||||||
#app: cache.adapter.redis
|
app: cache.adapter.redis
|
||||||
#default_redis_provider: redis://localhost
|
default_redis_provider: '%app.cache.redis.host%'
|
||||||
|
|
||||||
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
|
# APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues)
|
||||||
#app: cache.adapter.apcu
|
#app: cache.adapter.apcu
|
||||||
|
|
||||||
# Namespaced pools use the above "app" backend by default
|
# Namespaced pools use the above "app" backend by default
|
||||||
#pools:
|
pools:
|
||||||
#my.dedicated.cache: null
|
torrentio.cache:
|
||||||
|
adapter: cache.app
|
||||||
|
tmdb.cache:
|
||||||
|
adapter: cache.app
|
||||||
|
default_lifetime: 2592000
|
||||||
|
page.cache:
|
||||||
|
adapter: cache.app
|
||||||
|
|||||||
@@ -30,6 +30,12 @@ doctrine:
|
|||||||
dir: '%kernel.project_dir%/src/User/Framework/Entity'
|
dir: '%kernel.project_dir%/src/User/Framework/Entity'
|
||||||
prefix: 'App\User\Framework\Entity'
|
prefix: 'App\User\Framework\Entity'
|
||||||
alias: User
|
alias: User
|
||||||
|
Monitor:
|
||||||
|
type: attribute
|
||||||
|
is_bundle: false
|
||||||
|
dir: '%kernel.project_dir%/src/Monitor/Framework/Entity'
|
||||||
|
prefix: 'App\Monitor\Framework\Entity'
|
||||||
|
alias: Download
|
||||||
controller_resolver:
|
controller_resolver:
|
||||||
auto_mapping: false
|
auto_mapping: false
|
||||||
|
|
||||||
|
|||||||
@@ -2,12 +2,16 @@
|
|||||||
framework:
|
framework:
|
||||||
secret: '%env(APP_SECRET)%'
|
secret: '%env(APP_SECRET)%'
|
||||||
|
|
||||||
|
serializer:
|
||||||
|
default_context:
|
||||||
|
enable_max_depth: true
|
||||||
|
|
||||||
trusted_proxies: 'private_ranges'
|
trusted_proxies: 'private_ranges'
|
||||||
# trust *all* "X-Forwarded-*" headers
|
# trust *all* "X-Forwarded-*" headers
|
||||||
trusted_headers: [ 'x-forwarded-for', 'x-forwarded-host', 'x-forwarded-proto', 'x-forwarded-port', 'x-forwarded-prefix' ]
|
trusted_headers: [ 'x-forwarded-for', 'x-forwarded-host', 'x-forwarded-proto', 'x-forwarded-port', 'x-forwarded-prefix' ]
|
||||||
|
|
||||||
session:
|
session:
|
||||||
handler_id: Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler
|
handler_id: '%env(REDIS_HOST)%'
|
||||||
|
|
||||||
#esi: true
|
#esi: true
|
||||||
#fragments: true
|
#fragments: true
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
mercure:
|
mercure:
|
||||||
hubs:
|
hubs:
|
||||||
default:
|
default:
|
||||||
url: '%env(MERCURE_URL)%'
|
url: '%app.mercure.url%'
|
||||||
public_url: '%env(MERCURE_PUBLIC_URL)%'
|
public_url: '%app.mercure.public_url%'
|
||||||
jwt:
|
jwt:
|
||||||
secret: '%env(MERCURE_JWT_SECRET)%'
|
secret: '%env(MERCURE_JWT_SECRET)%'
|
||||||
publish: '*'
|
publish: '*'
|
||||||
|
|||||||
@@ -1,11 +1,31 @@
|
|||||||
framework:
|
framework:
|
||||||
messenger:
|
messenger:
|
||||||
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
|
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
|
||||||
# failure_transport: failed
|
failure_transport: failed
|
||||||
|
|
||||||
transports:
|
transports:
|
||||||
# https://symfony.com/doc/current/messenger.html#transport-configuration
|
# https://symfony.com/doc/current/messenger.html#transport-configuration
|
||||||
async: '%env(MESSENGER_TRANSPORT_DSN)%'
|
async:
|
||||||
|
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
|
||||||
|
options:
|
||||||
|
use_notify: true
|
||||||
|
check_delayed_interval: 60000
|
||||||
|
queue_name: default
|
||||||
|
retry_strategy:
|
||||||
|
max_retries: 1
|
||||||
|
multiplier: 1
|
||||||
|
|
||||||
|
media_cache:
|
||||||
|
dsn: '%env(MESSENGER_TRANSPORT_DSN)%'
|
||||||
|
options:
|
||||||
|
use_notify: true
|
||||||
|
check_delayed_interval: 60000
|
||||||
|
queue_name: media_cache
|
||||||
|
retry_strategy:
|
||||||
|
max_retries: 1
|
||||||
|
multiplier: 1
|
||||||
|
|
||||||
|
|
||||||
failed: 'doctrine://default?queue_name=failed'
|
failed: 'doctrine://default?queue_name=failed'
|
||||||
|
|
||||||
default_bus: messenger.bus.default
|
default_bus: messenger.bus.default
|
||||||
@@ -17,6 +37,11 @@ framework:
|
|||||||
# Route your messages to the transports
|
# Route your messages to the transports
|
||||||
# 'App\Message\YourMessage': async
|
# 'App\Message\YourMessage': async
|
||||||
'App\Download\Action\Command\DownloadMediaCommand': async
|
'App\Download\Action\Command\DownloadMediaCommand': async
|
||||||
|
'App\Monitor\Action\Command\MonitorTvEpisodeCommand': async
|
||||||
|
'App\Monitor\Action\Command\MonitorTvSeasonCommand': async
|
||||||
|
'App\Monitor\Action\Command\MonitorTvShowCommand': async
|
||||||
|
'App\Monitor\Action\Command\MonitorMovieCommand': async
|
||||||
|
'App\Torrentio\Action\Command\GetTvShowOptionsCommand': media_cache
|
||||||
|
|
||||||
# when@test:
|
# when@test:
|
||||||
# framework:
|
# framework:
|
||||||
|
|||||||
3
config/packages/property_info.yaml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
framework:
|
||||||
|
property_info:
|
||||||
|
with_constructor_extractor: true
|
||||||
@@ -5,26 +5,27 @@ security:
|
|||||||
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
|
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
|
||||||
providers:
|
providers:
|
||||||
users_in_memory: { memory: null }
|
users_in_memory: { memory: null }
|
||||||
app_user_provider:
|
app_local:
|
||||||
entity:
|
entity:
|
||||||
class: App\User\Framework\Entity\User
|
class: App\User\Framework\Entity\User
|
||||||
property: email
|
property: email
|
||||||
|
|
||||||
|
app_ldap:
|
||||||
|
id: App\User\Framework\Security\LdapUserProvider
|
||||||
|
|
||||||
firewalls:
|
firewalls:
|
||||||
dev:
|
dev:
|
||||||
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
||||||
security: false
|
security: false
|
||||||
main:
|
main:
|
||||||
lazy: true
|
lazy: true
|
||||||
provider: app_user_provider
|
provider: app_local
|
||||||
form_login:
|
form_login:
|
||||||
login_path: app_login
|
login_path: app_login
|
||||||
check_path: app_login
|
check_path: app_login
|
||||||
enable_csrf: true
|
enable_csrf: true
|
||||||
logout:
|
logout:
|
||||||
path: app_logout
|
path: app_logout
|
||||||
# where to redirect after logout
|
|
||||||
# target: app_any_route
|
|
||||||
|
|
||||||
# activate different ways to authenticate
|
# activate different ways to authenticate
|
||||||
# https://symfony.com/doc/current/security.html#the-firewall
|
# https://symfony.com/doc/current/security.html#the-firewall
|
||||||
@@ -35,6 +36,7 @@ security:
|
|||||||
# Easy way to control access for large sections of your site
|
# Easy way to control access for large sections of your site
|
||||||
# Note: Only the *first* access control that matches will be used
|
# Note: Only the *first* access control that matches will be used
|
||||||
access_control:
|
access_control:
|
||||||
|
- { path: ^/getting-started, roles: PUBLIC_ACCESS }
|
||||||
- { path: ^/register, roles: PUBLIC_ACCESS }
|
- { path: ^/register, roles: PUBLIC_ACCESS }
|
||||||
- { path: ^/login, roles: PUBLIC_ACCESS }
|
- { path: ^/login, roles: PUBLIC_ACCESS }
|
||||||
- { path: ^/, roles: ROLE_USER } # Or ROLE_ADMIN, ROLE_SUPER_ADMIN,
|
- { path: ^/, roles: ROLE_USER } # Or ROLE_ADMIN, ROLE_SUPER_ADMIN,
|
||||||
|
|||||||
7
config/packages/stof_doctrine_extensions.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
# Read the documentation: https://symfony.com/doc/current/bundles/StofDoctrineExtensionsBundle/index.html
|
||||||
|
# See the official DoctrineExtensions documentation for more details: https://github.com/doctrine-extensions/DoctrineExtensions/tree/main/doc
|
||||||
|
stof_doctrine_extensions:
|
||||||
|
default_locale: en_US
|
||||||
|
orm:
|
||||||
|
default:
|
||||||
|
timestampable: true
|
||||||
7
config/packages/translation.yaml
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
framework:
|
||||||
|
default_locale: en
|
||||||
|
translator:
|
||||||
|
default_path: '%kernel.project_dir%/translations'
|
||||||
|
fallbacks:
|
||||||
|
- en
|
||||||
|
providers:
|
||||||
@@ -1,5 +1,10 @@
|
|||||||
twig:
|
twig:
|
||||||
|
globals:
|
||||||
|
version: '%app.version%'
|
||||||
file_name_pattern: '*.twig'
|
file_name_pattern: '*.twig'
|
||||||
|
date:
|
||||||
|
format: 'm/d/Y'
|
||||||
|
timezone: '%env(default:app.default.timezone:TZ)%'
|
||||||
|
|
||||||
when@test:
|
when@test:
|
||||||
twig:
|
twig:
|
||||||
|
|||||||
@@ -13,3 +13,28 @@ controllersUser:
|
|||||||
type: attribute
|
type: attribute
|
||||||
defaults:
|
defaults:
|
||||||
schemes: ['https']
|
schemes: ['https']
|
||||||
|
|
||||||
|
controllersDownload:
|
||||||
|
resource:
|
||||||
|
path: ../src/Download/Framework/Controller
|
||||||
|
namespace: App\Download\Framework\Controller
|
||||||
|
type: attribute
|
||||||
|
defaults:
|
||||||
|
schemes: [ 'https' ]
|
||||||
|
|
||||||
|
controllersMonitor:
|
||||||
|
resource:
|
||||||
|
path: ../src/Monitor/Framework/Controller
|
||||||
|
namespace: App\Monitor\Framework\Controller
|
||||||
|
type: attribute
|
||||||
|
defaults:
|
||||||
|
schemes: ['https']
|
||||||
|
|
||||||
|
controllersTorrentio:
|
||||||
|
resource:
|
||||||
|
path: ../src/Torrentio/Framework/Controller
|
||||||
|
namespace: App\Torrentio\Framework\Controller
|
||||||
|
type: attribute
|
||||||
|
defaults:
|
||||||
|
schemes: [ 'https' ]
|
||||||
|
|
||||||
|
|||||||
61
config/security.yaml
Normal file
@@ -0,0 +1,61 @@
|
|||||||
|
security:
|
||||||
|
# https://symfony.com/doc/current/security.html#registering-the-user-hashing-passwords
|
||||||
|
password_hashers:
|
||||||
|
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface: 'auto'
|
||||||
|
# https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider
|
||||||
|
providers:
|
||||||
|
users_in_memory: { memory: null }
|
||||||
|
app_local:
|
||||||
|
entity:
|
||||||
|
class: App\User\Framework\Entity\User
|
||||||
|
property: email
|
||||||
|
|
||||||
|
app_ldap:
|
||||||
|
id: App\User\Framework\Security\LdapUserProvider
|
||||||
|
|
||||||
|
firewalls:
|
||||||
|
dev:
|
||||||
|
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
||||||
|
security: false
|
||||||
|
main:
|
||||||
|
lazy: true
|
||||||
|
provider: app_ldap
|
||||||
|
entry_point: form_login_ldap
|
||||||
|
form_login_ldap:
|
||||||
|
login_path: app_login
|
||||||
|
check_path: app_login
|
||||||
|
enable_csrf: true
|
||||||
|
service: Symfony\Component\Ldap\Ldap
|
||||||
|
dn_string: '%env(LDAP_DN_STRING)%'
|
||||||
|
form_login:
|
||||||
|
login_path: app_login
|
||||||
|
check_path: app_login
|
||||||
|
enable_csrf: true
|
||||||
|
logout:
|
||||||
|
path: app_logout
|
||||||
|
|
||||||
|
# activate different ways to authenticate
|
||||||
|
# https://symfony.com/doc/current/security.html#the-firewall
|
||||||
|
|
||||||
|
# https://symfony.com/doc/current/security/impersonating_user.html
|
||||||
|
# switch_user: true
|
||||||
|
|
||||||
|
# Easy way to control access for large sections of your site
|
||||||
|
# Note: Only the *first* access control that matches will be used
|
||||||
|
access_control:
|
||||||
|
- { path: ^/register, roles: PUBLIC_ACCESS }
|
||||||
|
- { path: ^/login, roles: PUBLIC_ACCESS }
|
||||||
|
- { path: ^/, roles: ROLE_USER } # Or ROLE_ADMIN, ROLE_SUPER_ADMIN,
|
||||||
|
|
||||||
|
when@test:
|
||||||
|
security:
|
||||||
|
password_hashers:
|
||||||
|
# By default, password hashers are resource intensive and take time. This is
|
||||||
|
# important to generate secure password hashes. In tests however, secure hashes
|
||||||
|
# are not important, waste resources and increase test times. The following
|
||||||
|
# reduces the work factor to the lowest possible values.
|
||||||
|
Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface:
|
||||||
|
algorithm: auto
|
||||||
|
cost: 4 # Lowest possible value for bcrypt
|
||||||
|
time_cost: 3 # Lowest possible value for argon
|
||||||
|
memory_cost: 10 # Lowest possible value for argon
|
||||||
@@ -4,6 +4,28 @@
|
|||||||
# Put parameters here that don't need to change on each machine where the app is deployed
|
# Put parameters here that don't need to change on each machine where the app is deployed
|
||||||
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
|
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
|
||||||
parameters:
|
parameters:
|
||||||
|
# Media
|
||||||
|
media.base_path: '/var/download'
|
||||||
|
media.default_movies_dir: movies
|
||||||
|
media.default_tvshows_dir: tvshows
|
||||||
|
media.movies_path: '/var/download/%env(default:media.default_movies_dir:MOVIES_PATH)%'
|
||||||
|
media.tvshows_path: '/var/download/%env(default:media.default_tvshows_dir:TVSHOWS_PATH)%'
|
||||||
|
|
||||||
|
# Mercure
|
||||||
|
app.mercure.url: 'http://app/.well-known/mercure'
|
||||||
|
app.mercure.public_url: '%env(APP_URL)%/.well-known/mercure'
|
||||||
|
|
||||||
|
# Cache
|
||||||
|
app.cache.adapter: '%env(default:app.cache.adapter.default:CACHE_ADAPTER)%'
|
||||||
|
app.cache.redis.host: '%env(default:app.cache.redis.host.default:REDIS_HOST)%'
|
||||||
|
app.cache.adapter.default: 'filesystem'
|
||||||
|
app.cache.redis.host.default: 'redis://redis'
|
||||||
|
|
||||||
|
# Various configs
|
||||||
|
app.default.version: '0.dev'
|
||||||
|
app.default.timezone: 'America/Chicago'
|
||||||
|
|
||||||
|
app.version: '%env(default:app.default.version:APP_VERSION)%'
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# default configuration for services in *this* file
|
# default configuration for services in *this* file
|
||||||
@@ -24,6 +46,38 @@ services:
|
|||||||
# please note that last definitions always *replace* previous ones
|
# please note that last definitions always *replace* previous ones
|
||||||
App\Download\Downloader\DownloaderInterface: "@App\\Download\\Downloader\\ProcessDownloader"
|
App\Download\Downloader\DownloaderInterface: "@App\\Download\\Downloader\\ProcessDownloader"
|
||||||
|
|
||||||
|
# Session
|
||||||
Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler:
|
Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler:
|
||||||
arguments:
|
arguments:
|
||||||
- '%env(DATABASE_URL)%'
|
- '%env(DATABASE_URL)%'
|
||||||
|
|
||||||
|
# LDAP
|
||||||
|
App\User\Framework\Security\LdapUserProvider:
|
||||||
|
arguments:
|
||||||
|
$registerLdapUserHandler: '@App\User\Action\Handler\RegisterLdapUserHandler'
|
||||||
|
$userRepository: '@App\User\Framework\Repository\UserRepository'
|
||||||
|
$ldap: '@Symfony\Component\Ldap\LdapInterface'
|
||||||
|
$baseDn: '%env(LDAP_BASE_DN)%'
|
||||||
|
$searchDn: '%env(LDAP_BIND_USER)%'
|
||||||
|
$searchPassword: '%env(LDAP_BIND_PASS)%'
|
||||||
|
$defaultRoles: ['ROLE_USER']
|
||||||
|
$uidKey: '%env(LDAP_UID_KEY)%'
|
||||||
|
# $passwordAttribute: '%env(LDAP_PASSWORD_ATTRIBUTE)%'
|
||||||
|
|
||||||
|
|
||||||
|
Symfony\Component\Ldap\LdapInterface: '@Symfony\Component\Ldap\Ldap'
|
||||||
|
|
||||||
|
Symfony\Component\Ldap\Ldap:
|
||||||
|
arguments: [ '@Symfony\Component\Ldap\Adapter\ExtLdap\Adapter' ]
|
||||||
|
tags:
|
||||||
|
- ldap
|
||||||
|
|
||||||
|
Symfony\Component\Ldap\Adapter\ExtLdap\Adapter:
|
||||||
|
arguments:
|
||||||
|
- host: '%env(LDAP_HOST)%'
|
||||||
|
port: '%env(LDAP_PORT)%'
|
||||||
|
encryption: '%env(LDAP_ENCRYPTION)%'
|
||||||
|
options:
|
||||||
|
protocol_version: 3
|
||||||
|
referrals: false
|
||||||
|
|
||||||
|
|||||||
@@ -1,36 +1,58 @@
|
|||||||
services:
|
services:
|
||||||
php:
|
app:
|
||||||
image: registry.caldwell.digital/home/torsearch/app:${TAG}
|
image: registry.caldwell.digital/home/torsearch-app:${TAG}
|
||||||
ports:
|
ports:
|
||||||
- "8001:80"
|
- '8001:80'
|
||||||
deploy:
|
|
||||||
replicas: 2
|
|
||||||
|
|
||||||
worker:
|
|
||||||
image: registry.caldwell.digital/home/torsearch/app:${TAG}
|
|
||||||
volumes:
|
|
||||||
- /mnt/media/downloads:/var/download
|
|
||||||
command: php ./bin/console messenger:consume async -v --time-limit=3600 --limit=10
|
|
||||||
deploy:
|
|
||||||
replicas: 2
|
|
||||||
|
|
||||||
mercure:
|
|
||||||
image: dunglas/mercure
|
|
||||||
restart: unless-stopped
|
|
||||||
ports:
|
|
||||||
- "3000:80"
|
|
||||||
environment:
|
environment:
|
||||||
SERVER_NAME: ':80'
|
|
||||||
MERCURE_PUBLISHER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
|
MERCURE_PUBLISHER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
|
||||||
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
|
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
|
||||||
MERCURE_EXTRA_DIRECTIVES: |
|
tty: true
|
||||||
cors_origins *
|
deploy:
|
||||||
anonymous
|
replicas: 2
|
||||||
command: /usr/bin/caddy run --config /etc/caddy/dev.Caddyfile
|
|
||||||
volumes:
|
volumes:
|
||||||
|
- /mnt/media/downloads/movies:/var/download/movies
|
||||||
|
- /mnt/media/downloads/tvshows:/var/download/tvshows
|
||||||
- mercure_data:/data
|
- mercure_data:/data
|
||||||
- mercure_config:/config
|
- mercure_config:/config
|
||||||
|
depends_on:
|
||||||
|
- database
|
||||||
|
|
||||||
|
|
||||||
|
worker:
|
||||||
|
image: registry.caldwell.digital/home/torsearch-worker:${TAG}
|
||||||
|
volumes:
|
||||||
|
- /mnt/media/downloads/movies:/var/download/movies
|
||||||
|
- /mnt/media/downloads/tvshows:/var/download/tvshows
|
||||||
|
restart: always
|
||||||
|
command: -vv --time-limit=3600 --limit=10
|
||||||
|
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
|
||||||
|
restart: always
|
||||||
|
command: -vv
|
||||||
|
depends_on:
|
||||||
|
- app
|
||||||
|
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:latest
|
||||||
|
volumes:
|
||||||
|
- redis_data:/data
|
||||||
|
command: redis-server --maxmemory 512MB
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
mysql:
|
||||||
mercure_config:
|
mercure_config:
|
||||||
mercure_data:
|
mercure_data:
|
||||||
|
redis_data:
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ assets
|
|||||||
bash
|
bash
|
||||||
bin
|
bin
|
||||||
config
|
config
|
||||||
|
docker
|
||||||
migrations
|
migrations
|
||||||
public
|
public
|
||||||
src
|
src
|
||||||
|
|||||||
25
docker/Dockerfile.app
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
FROM dunglas/frankenphp
|
||||||
|
|
||||||
|
ENV SERVER_NAME=":80"
|
||||||
|
ENV CADDY_GLOBAL_OPTIONS="auto_https off"
|
||||||
|
ENV APP_RUNTIME="Runtime\\FrankenPhpSymfony\\Runtime"
|
||||||
|
|
||||||
|
ARG APP_VERSION="0.dev"
|
||||||
|
ENV APP_VERSION="${APP_VERSION}"
|
||||||
|
|
||||||
|
RUN install-php-extensions \
|
||||||
|
pdo_mysql \
|
||||||
|
gd \
|
||||||
|
intl \
|
||||||
|
zip \
|
||||||
|
opcache
|
||||||
|
|
||||||
|
COPY . /app
|
||||||
|
COPY --chmod=775 docker/app/entrypoint.sh /usr/local/bin/docker-entrypoint
|
||||||
|
COPY docker/app/Caddyfile /etc/frankenphp/Caddyfile
|
||||||
|
|
||||||
|
ENTRYPOINT [ "/usr/local/bin/docker-entrypoint" ]
|
||||||
|
|
||||||
|
CMD [ "frankenphp", "run", "--config", "/etc/frankenphp/Caddyfile" ]
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=3s --timeout=3s --retries=10 CMD [ "php", "/app/bin/console", "startup:status" ]
|
||||||
21
docker/Dockerfile.scheduler
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
FROM dunglas/frankenphp:php8.4-alpine
|
||||||
|
|
||||||
|
ENV SERVER_NAME=":80"
|
||||||
|
ENV CADDY_GLOBAL_OPTIONS="auto_https off"
|
||||||
|
ENV APP_RUNTIME="Runtime\\FrankenPhpSymfony\\Runtime"
|
||||||
|
|
||||||
|
ARG APP_VERSION="0.dev"
|
||||||
|
ENV APP_VERSION="${APP_VERSION}"
|
||||||
|
|
||||||
|
RUN install-php-extensions \
|
||||||
|
pdo_mysql \
|
||||||
|
gd \
|
||||||
|
intl \
|
||||||
|
zip \
|
||||||
|
opcache
|
||||||
|
|
||||||
|
COPY . /app
|
||||||
|
|
||||||
|
ENTRYPOINT [ "php", "/app/bin/console", "messenger:consume", "scheduler_monitor" ]
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=3s --timeout=3s --retries=10 CMD return 0
|
||||||
23
docker/Dockerfile.worker
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
FROM dunglas/frankenphp:php8.4-alpine
|
||||||
|
|
||||||
|
ENV SERVER_NAME=":80"
|
||||||
|
ENV CADDY_GLOBAL_OPTIONS="auto_https off"
|
||||||
|
ENV APP_RUNTIME="Runtime\\FrankenPhpSymfony\\Runtime"
|
||||||
|
|
||||||
|
ARG APP_VERSION="0.dev"
|
||||||
|
ENV APP_VERSION="${APP_VERSION}"
|
||||||
|
|
||||||
|
RUN install-php-extensions \
|
||||||
|
pdo_mysql \
|
||||||
|
gd \
|
||||||
|
intl \
|
||||||
|
zip \
|
||||||
|
opcache
|
||||||
|
|
||||||
|
RUN apk add --no-cache wget
|
||||||
|
|
||||||
|
COPY . /app
|
||||||
|
|
||||||
|
ENTRYPOINT [ "php", "/app/bin/console", "messenger:consume", "async" ]
|
||||||
|
|
||||||
|
HEALTHCHECK --interval=3s --timeout=3s --retries=10 CMD return 0
|
||||||
59
docker/app/Caddyfile
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
{
|
||||||
|
{$CADDY_GLOBAL_OPTIONS}
|
||||||
|
|
||||||
|
frankenphp {
|
||||||
|
{$FRANKENPHP_CONFIG}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
{$CADDY_EXTRA_CONFIG}
|
||||||
|
|
||||||
|
{$SERVER_NAME:localhost} {
|
||||||
|
log {
|
||||||
|
{$CADDY_SERVER_LOG_OPTIONS}
|
||||||
|
# Redact the authorization query parameter that can be set by Mercure
|
||||||
|
format filter {
|
||||||
|
request>uri query {
|
||||||
|
replace authorization REDACTED
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
root /app/public
|
||||||
|
encode zstd br gzip
|
||||||
|
|
||||||
|
mercure {
|
||||||
|
# Publisher JWT key
|
||||||
|
publisher_jwt {env.MERCURE_PUBLISHER_JWT_KEY} {env.MERCURE_PUBLISHER_JWT_ALG}
|
||||||
|
# Subscriber JWT key
|
||||||
|
subscriber_jwt {env.MERCURE_SUBSCRIBER_JWT_KEY} {env.MERCURE_SUBSCRIBER_JWT_ALG}
|
||||||
|
# Allow anonymous subscribers (double-check that it's what you want)
|
||||||
|
anonymous
|
||||||
|
# Enable the subscription API (double-check that it's what you want)
|
||||||
|
subscriptions
|
||||||
|
# Custmo cors
|
||||||
|
cors_origins *
|
||||||
|
# Extra directives
|
||||||
|
{$MERCURE_EXTRA_DIRECTIVES}
|
||||||
|
}
|
||||||
|
|
||||||
|
vulcain
|
||||||
|
|
||||||
|
{$CADDY_SERVER_EXTRA_DIRECTIVES}
|
||||||
|
|
||||||
|
# Disable Topics tracking if not enabled explicitly: https://github.com/jkarlin/topics
|
||||||
|
header ?Permissions-Policy "browsing-topics=()"
|
||||||
|
|
||||||
|
@phpRoute {
|
||||||
|
not path /.well-known/mercure*
|
||||||
|
not file {path}
|
||||||
|
}
|
||||||
|
rewrite @phpRoute index.php
|
||||||
|
|
||||||
|
@frontController path index.php
|
||||||
|
php @frontController
|
||||||
|
|
||||||
|
file_server {
|
||||||
|
hide *.php
|
||||||
|
}
|
||||||
|
}
|
||||||
12
docker/app/entrypoint.sh
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Sleep for a second to ensure DB is awake and ready
|
||||||
|
SLEEP_TIME=$(shuf -i 2-4 -n 1)
|
||||||
|
echo "> Sleeping for ${SLEEP_TIME} seconds to wait for the database"
|
||||||
|
sleep $SLEEP_TIME
|
||||||
|
|
||||||
|
# Provision database
|
||||||
|
php /app/bin/console doctrine:migrations:migrate --no-interaction
|
||||||
|
php /app/bin/console db:seed
|
||||||
|
|
||||||
|
exec docker-php-entrypoint "$@"
|
||||||
12
docker/app/messenger-worker@.service
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[Unit]
|
||||||
|
Description=Torsearch media cache warming services
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
ExecStart=php /app/bin/console messenger:consume media_cache --time-limit=3600
|
||||||
|
# for Redis, set a custom consumer name for each instance
|
||||||
|
Environment="MESSENGER_CONSUMER_NAME=symfony-%n-%i"
|
||||||
|
Restart=always
|
||||||
|
RestartSec=30
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=default.target
|
||||||
57
docs/examples/.env
Normal file
@@ -0,0 +1,57 @@
|
|||||||
|
# App must be served over HTTPS (requirement of Mercure)
|
||||||
|
# Either serve behind an SSL terminating reverse proxy
|
||||||
|
# or pass your certificates into the 'app' container.
|
||||||
|
# Please omit any trailing slashes. The APP_URL is
|
||||||
|
# used to generate the Mercure URL behind the scenes.
|
||||||
|
APP_URL="https://torsearch.idocode.io"
|
||||||
|
APP_SECRET="70169beadfbc8101c393cbfbba27a313"
|
||||||
|
APP_ENV=prod
|
||||||
|
|
||||||
|
# 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
|
||||||
|
DATABASE_URL="mysql://root:password@database:3306/app?serverVersion=10.6.19.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
|
||||||
|
# else and is passed to Torrentio
|
||||||
|
# to retrieve download options
|
||||||
|
#REAL_DEBRID_KEY=""
|
||||||
|
|
||||||
|
# Enter you 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=
|
||||||
|
|
||||||
|
REAL_DEBRID_KEY=""
|
||||||
|
TMDB_API=eyJhbGciOiJIUzI1NiJ9.eyJhdWQiOiI0ZTJjYjJhOGUzOGJhNjdiNjVhOGU1NGM0ZWI1MzhmOCIsIm5iZiI6MTczNzkyNjA0NC41NjQsInN1YiI6IjY3OTZhNTljYzdiMDFiNzJjNzIzZWM5YiIsInNjb3BlcyI6WyJhcGlfcmVhZCJdLCJ2ZXJzaW9uIjoxfQ.e8DbNe9qrSBC1y-ANRv-VWBAtls-ZS2r7aNCiI68mpw
|
||||||
|
|
||||||
|
|
||||||
|
MERCURE_JWT_SECRET="!ChangeThisMercureHubJWTSecretKey!"
|
||||||
|
|
||||||
|
# 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"
|
||||||
|
|
||||||
|
# LDAP Config: To use LDAP, enter the below fields
|
||||||
|
# and run 'php bin/console config:set auth.method ldap'
|
||||||
|
LDAP_HOST=
|
||||||
|
LDAP_PORT=
|
||||||
|
LDAP_ENCRYPTION=
|
||||||
|
LDAP_BASE_DN=
|
||||||
|
LDAP_BIND_USER=
|
||||||
|
LDAP_BIND_PASS=
|
||||||
|
LDAP_DN_STRING=
|
||||||
|
LDAP_UID_KEY="uid"
|
||||||
|
# LDAP group that identifies an Admin
|
||||||
|
# Users with this LDAP group will automatically
|
||||||
|
# get the admin role in this system.
|
||||||
|
LDAP_ADMIN_ROLE_DN=""
|
||||||
|
LDAP_EMAIL_ATTRIBUTE=mail
|
||||||
|
LDAP_USERNAME_ATTRIBUTE=uid
|
||||||
|
LDAP_NAME_ATTRIBUTE=displayname
|
||||||
99
docs/examples/compose.yml
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
services:
|
||||||
|
# The "entrypoint" into the application. This reverse proxy
|
||||||
|
# proxies traffic back to their respective services. If not
|
||||||
|
# running behind a reverse proxy inject your SSL certificates
|
||||||
|
# into this container.
|
||||||
|
# This container runs the actual web app in a php:8.4-fpm
|
||||||
|
# base container.
|
||||||
|
app:
|
||||||
|
image: code.caldwell.digital/home/torsearch-app:latest
|
||||||
|
ports:
|
||||||
|
- '8006:80'
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
volumes:
|
||||||
|
- /mnt/media/downloads/movies:/var/download/movies
|
||||||
|
- /mnt/media/downloads/tvshows:/var/download/tvshows
|
||||||
|
environment:
|
||||||
|
TZ: America/Chicago
|
||||||
|
MERCURE_PUBLISHER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
|
||||||
|
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
|
||||||
|
depends_on:
|
||||||
|
database:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
|
# Downloads happen in this container. Replicate this
|
||||||
|
# container to run multiple downloads simultaneously.
|
||||||
|
# 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:
|
||||||
|
image: code.caldwell.digital/home/torsearch-worker:latest
|
||||||
|
volumes:
|
||||||
|
- /mnt/media/downloads/movies:/var/download/movies
|
||||||
|
- /mnt/media/downloads/tvshows:/var/download/tvshows
|
||||||
|
environment:
|
||||||
|
TZ: America/Chicago
|
||||||
|
command: -vvv
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
app:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
|
# This container handles the monitoring for new media. When new
|
||||||
|
# monitors are added, jobs are periodically dispatched to this
|
||||||
|
# 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:
|
||||||
|
image: code.caldwell.digital/home/torsearch-scheduler:latest
|
||||||
|
volumes:
|
||||||
|
- /mnt/media/downloads/movies:/var/download/movies
|
||||||
|
- /mnt/media/downloads/tvshows:/var/download/tvshows
|
||||||
|
env_file:
|
||||||
|
- .env
|
||||||
|
environment:
|
||||||
|
TZ: America/Chicago
|
||||||
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
app:
|
||||||
|
condition: service_healthy
|
||||||
|
|
||||||
|
database:
|
||||||
|
image: mariadb:10.11.2
|
||||||
|
volumes:
|
||||||
|
- mysql:/var/lib/mysql
|
||||||
|
environment:
|
||||||
|
MYSQL_DATABASE: app
|
||||||
|
MYSQL_USERNAME: app
|
||||||
|
MYSQL_PASSWORD: password
|
||||||
|
MYSQL_ROOT_PASSWORD: password
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:latest
|
||||||
|
volumes:
|
||||||
|
- redis_data:/data
|
||||||
|
command: redis-server --maxmemory 512MB
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
# **Optional**
|
||||||
|
# Provides a simple method of viewing the database
|
||||||
|
adminer:
|
||||||
|
image: adminer
|
||||||
|
ports:
|
||||||
|
- "8081:8080"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
mysql:
|
||||||
|
mercure_config:
|
||||||
|
mercure_data:
|
||||||
|
redis_data:
|
||||||
115
docs/examples/swarm.compose.yml
Normal file
@@ -0,0 +1,115 @@
|
|||||||
|
services:
|
||||||
|
# The "entrypoint" into the application. This reverse proxy
|
||||||
|
# proxies traffic back to their respective services. If not
|
||||||
|
# running behind a reverse proxy inject your SSL certificates
|
||||||
|
# into this container.
|
||||||
|
# This container runs the actual web app in a php:8.4-fpm
|
||||||
|
# base container.
|
||||||
|
app:
|
||||||
|
image: code.caldwell.digital/home/torsearch-app:latest
|
||||||
|
ports:
|
||||||
|
- '8006:80'
|
||||||
|
configs:
|
||||||
|
- env_file
|
||||||
|
deploy:
|
||||||
|
replicas: 2
|
||||||
|
depends_on:
|
||||||
|
- database
|
||||||
|
|
||||||
|
# Downloads happen in this container. Replicate this
|
||||||
|
# container to run multiple downloads simultaneously.
|
||||||
|
# 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:
|
||||||
|
image: code.caldwell.digital/home/torsearch-worker:latest
|
||||||
|
configs:
|
||||||
|
- source: env_file
|
||||||
|
target: /app/bin/.env.local
|
||||||
|
volumes:
|
||||||
|
- /mnt/media/downloads/movies:/var/download/movies
|
||||||
|
- /mnt/media/downloads/tvshows:/var/download/tvshows
|
||||||
|
restart: always
|
||||||
|
command: -vv
|
||||||
|
deploy:
|
||||||
|
replicas: 4
|
||||||
|
depends_on:
|
||||||
|
- app
|
||||||
|
|
||||||
|
# This container handles the monitoring for new media. When new
|
||||||
|
# monitors are added, jobs are periodically dispatched to this
|
||||||
|
# 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:
|
||||||
|
image: code.caldwell.digital/home/torsearch-scheduler:latest
|
||||||
|
configs:
|
||||||
|
- env_file
|
||||||
|
volumes:
|
||||||
|
- ./downloads:/var/download
|
||||||
|
restart: always
|
||||||
|
depends_on:
|
||||||
|
- app
|
||||||
|
|
||||||
|
# This container facilitates viewing the progress of downloads
|
||||||
|
# in realtime. It also handles sending alerts and notifications.
|
||||||
|
# The MERCURE_PUBLISHER_JWT key & MERCURE_SUBSCRIBER_JWT_KEY should
|
||||||
|
# match the MERCURE_JWT_SECRET environment variable.
|
||||||
|
mercure:
|
||||||
|
image: dunglas/mercure
|
||||||
|
restart: unless-stopped
|
||||||
|
ports:
|
||||||
|
- "3001:80"
|
||||||
|
environment:
|
||||||
|
SERVER_NAME: ':80'
|
||||||
|
MERCURE_PUBLISHER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
|
||||||
|
MERCURE_SUBSCRIBER_JWT_KEY: '!ChangeThisMercureHubJWTSecretKey!'
|
||||||
|
MERCURE_EXTRA_DIRECTIVES: |
|
||||||
|
cors_origins *
|
||||||
|
anonymous
|
||||||
|
command: /usr/bin/caddy run --config /etc/caddy/dev.Caddyfile
|
||||||
|
volumes:
|
||||||
|
- mercure_data:/data
|
||||||
|
- mercure_config:/config
|
||||||
|
|
||||||
|
database:
|
||||||
|
image: mariadb:10.11.2
|
||||||
|
volumes:
|
||||||
|
- mysql:/var/lib/mysql
|
||||||
|
environment:
|
||||||
|
MYSQL_DATABASE: app
|
||||||
|
MYSQL_USERNAME: app
|
||||||
|
MYSQL_PASSWORD: password
|
||||||
|
MYSQL_ROOT_PASSWORD: password
|
||||||
|
healthcheck:
|
||||||
|
test: [ "CMD", "mysqladmin" ,"ping", "-h", "localhost" ]
|
||||||
|
interval: 5s
|
||||||
|
timeout: 5s
|
||||||
|
retries: 10
|
||||||
|
|
||||||
|
redis:
|
||||||
|
image: redis:latest
|
||||||
|
volumes:
|
||||||
|
- redis_data:/data
|
||||||
|
command: redis-server --maxmemory 512MB
|
||||||
|
restart: unless-stopped
|
||||||
|
|
||||||
|
# **Optional**
|
||||||
|
# Provides a simple method of viewing the database
|
||||||
|
adminer:
|
||||||
|
image: adminer
|
||||||
|
ports:
|
||||||
|
- "8081:8080"
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
mysql:
|
||||||
|
mercure_config:
|
||||||
|
mercure_data:
|
||||||
|
redis_data:
|
||||||
|
|
||||||
|
configs:
|
||||||
|
env_file:
|
||||||
|
file: $PWD/.env
|
||||||
|
|
||||||
BIN
docs/img/torsearch_filter_download.png
Normal file
|
After Width: | Height: | Size: 200 KiB |
BIN
docs/img/torsearch_homepage.png
Normal file
|
After Width: | Height: | Size: 421 KiB |
BIN
docs/img/torsearch_inception_results.png
Normal file
|
After Width: | Height: | Size: 654 KiB |
BIN
docs/img/torsearch_monitor.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
docs/img/torsearch_severance.png
Normal file
|
After Width: | Height: | Size: 568 KiB |
BIN
docs/img/torsearch_severance_episodes.png
Normal file
|
After Width: | Height: | Size: 889 KiB |
BIN
docs/img/torsearch_severance_media.png
Normal file
|
After Width: | Height: | Size: 643 KiB |
BIN
docs/img/torsearch_severance_results.png
Normal file
|
After Width: | Height: | Size: 438 KiB |
@@ -28,4 +28,16 @@ return [
|
|||||||
'@hotwired/turbo' => [
|
'@hotwired/turbo' => [
|
||||||
'version' => '7.3.0',
|
'version' => '7.3.0',
|
||||||
],
|
],
|
||||||
|
'@stimulus-components/popover' => [
|
||||||
|
'version' => '7.0.0',
|
||||||
|
],
|
||||||
|
'@stimulus-components/dialog' => [
|
||||||
|
'version' => '1.0.1',
|
||||||
|
],
|
||||||
|
'@stimulus-components/dropdown' => [
|
||||||
|
'version' => '3.0.0',
|
||||||
|
],
|
||||||
|
'stimulus-use' => [
|
||||||
|
'version' => '0.52.2',
|
||||||
|
],
|
||||||
];
|
];
|
||||||
|
|||||||
41
migrations/Version20250503034641.php
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20250503034641 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
CREATE TABLE movie_monitor (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, title VARCHAR(255) DEFAULT NULL, imdb_id VARCHAR(255) NOT NULL, tmdb_id VARCHAR(255) NOT NULL, status VARCHAR(255) NOT NULL, search_count INT DEFAULT NULL, last_search DATETIME DEFAULT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', downloaded_at DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)', INDEX IDX_C183DBABA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE movie_monitor ADD CONSTRAINT FK_C183DBABA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE movie_monitor DROP FOREIGN KEY FK_C183DBABA76ED395
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
DROP TABLE movie_monitor
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
}
|
||||||
53
migrations/Version20250505211458.php
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20250505211458 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
CREATE TABLE monitor (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, title VARCHAR(255) DEFAULT NULL, imdb_id VARCHAR(255) NOT NULL, tmdb_id VARCHAR(255) NOT NULL, status VARCHAR(255) NOT NULL, search_count INT DEFAULT NULL, last_search DATETIME DEFAULT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', downloaded_at DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)', monitor_type VARCHAR(255) NOT NULL, season INT DEFAULT NULL, episode INT DEFAULT NULL, INDEX IDX_E1159985A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE monitor ADD CONSTRAINT FK_E1159985A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE movie_monitor DROP FOREIGN KEY FK_C183DBABA76ED395
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
DROP TABLE movie_monitor
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
CREATE TABLE movie_monitor (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, title VARCHAR(255) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_unicode_ci`, imdb_id VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, tmdb_id VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, status VARCHAR(255) CHARACTER SET utf8mb4 NOT NULL COLLATE `utf8mb4_unicode_ci`, search_count INT DEFAULT NULL, last_search DATETIME DEFAULT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime_immutable)', downloaded_at DATETIME DEFAULT NULL COMMENT '(DC2Type:datetime_immutable)', INDEX IDX_C183DBABA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB COMMENT = ''
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE movie_monitor ADD CONSTRAINT FK_C183DBABA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE monitor DROP FOREIGN KEY FK_E1159985A76ED395
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
DROP TABLE monitor
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
}
|
||||||
35
migrations/Version20250510185814.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20250510185814 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE user ADD username VARCHAR(255) DEFAULT NULL
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE user DROP username
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
}
|
||||||
47
migrations/Version20250511050008.php
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20250511050008 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE download ADD user_id INT DEFAULT NULL
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE download ADD CONSTRAINT FK_781A8270A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
CREATE INDEX IDX_781A8270A76ED395 ON download (user_id)
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE download DROP FOREIGN KEY FK_781A8270A76ED395
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
DROP INDEX IDX_781A8270A76ED395 ON download
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE download DROP user_id
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
}
|
||||||
35
migrations/Version20250519193350.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20250519193350 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE preference ADD type VARCHAR(255) DEFAULT NULL
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE preference DROP type
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
}
|
||||||
35
migrations/Version20250610195448.php
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20250610195448 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE download ADD created_at DATETIME NULL, ADD updated_at DATETIME NULL
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE download DROP created_at, DROP updated_at
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
}
|
||||||
50
migrations/Version20250610222503.php
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace DoctrineMigrations;
|
||||||
|
|
||||||
|
use Doctrine\DBAL\Schema\Schema;
|
||||||
|
use Doctrine\Migrations\AbstractMigration;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Auto-generated Migration: Please modify to your needs!
|
||||||
|
*/
|
||||||
|
final class Version20250610222503 extends AbstractMigration
|
||||||
|
{
|
||||||
|
public function getDescription(): string
|
||||||
|
{
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
public function up(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this up() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE monitor ADD parent_id INT DEFAULT NULL
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE monitor ADD CONSTRAINT FK_E1159985727ACA70 FOREIGN KEY (parent_id) REFERENCES monitor (id)
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
CREATE INDEX IDX_E1159985727ACA70 ON monitor (parent_id)
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(Schema $schema): void
|
||||||
|
{
|
||||||
|
// this down() migration is auto-generated, please modify it to your needs
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE monitor DROP FOREIGN KEY FK_E1159985727ACA70
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
DROP INDEX IDX_E1159985727ACA70 ON monitor
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE monitor DROP parent_id
|
||||||
|
SQL);
|
||||||
|
$this->addSql(<<<'SQL'
|
||||||
|
ALTER TABLE download CHANGE created_at created_at DATETIME DEFAULT NULL, CHANGE updated_at updated_at DATETIME DEFAULT NULL
|
||||||
|
SQL);
|
||||||
|
}
|
||||||
|
}
|
||||||
129
nomad.deploy.hcl
Normal file
@@ -0,0 +1,129 @@
|
|||||||
|
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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
8
phpstan.dist.neon
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
parameters:
|
||||||
|
level: 6
|
||||||
|
paths:
|
||||||
|
- bin/
|
||||||
|
- config/
|
||||||
|
- public/
|
||||||
|
- src/
|
||||||
|
- tests/
|
||||||
58
src/Command/ConfigSetCommand.php
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Command;
|
||||||
|
|
||||||
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
|
#[AsCommand(
|
||||||
|
name: 'config:set',
|
||||||
|
description: 'Add a short description for your command',
|
||||||
|
)]
|
||||||
|
class ConfigSetCommand extends Command
|
||||||
|
{
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function configure(): void
|
||||||
|
{
|
||||||
|
$this
|
||||||
|
->addArgument('key', InputArgument::REQUIRED, 'Config key')
|
||||||
|
->addArgument('value', InputArgument::REQUIRED, 'Config value')
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
$key = $input->getArgument('key');
|
||||||
|
$handlers = [
|
||||||
|
'auth.method' => 'setAuthMethod',
|
||||||
|
];
|
||||||
|
|
||||||
|
$handler = $handlers[$key];
|
||||||
|
$this->$handler($input, $io);
|
||||||
|
|
||||||
|
$io->success('Success: "' . $input->getArgument('key') . '" set to "' . $input->getArgument('value') . '"');
|
||||||
|
|
||||||
|
return Command::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function setAuthMethod(InputInterface $input, SymfonyStyle $io)
|
||||||
|
{
|
||||||
|
$config = [
|
||||||
|
'local' => 'config/dist/local.security.yaml',
|
||||||
|
'ldap' => 'config/dist/ldap.security.yaml',
|
||||||
|
];
|
||||||
|
$authMethod = $input->getArgument('value');
|
||||||
|
$io->text('> Setting auth method to: ' . $authMethod);
|
||||||
|
copy($config[$authMethod], 'config/packages/security.yaml');
|
||||||
|
}
|
||||||
|
}
|
||||||
171
src/Command/SeedDatabaseCommand.php
Normal file
@@ -0,0 +1,171 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Command;
|
||||||
|
|
||||||
|
use App\User\Framework\Repository\PreferenceOptionRepository;
|
||||||
|
use App\User\Framework\Repository\PreferencesRepository;
|
||||||
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
|
#[AsCommand(
|
||||||
|
name: 'db:seed',
|
||||||
|
description: 'Seed the database with required data.',
|
||||||
|
)]
|
||||||
|
class SeedDatabaseCommand extends Command
|
||||||
|
{
|
||||||
|
private PreferencesRepository $preferenceRepository;
|
||||||
|
private PreferenceOptionRepository $preferenceOptionRepository;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
PreferencesRepository $preferenceRepository,
|
||||||
|
PreferenceOptionRepository $preferenceOptionRepository,
|
||||||
|
) {
|
||||||
|
parent::__construct();
|
||||||
|
$this->preferenceRepository = $preferenceRepository;
|
||||||
|
$this->preferenceOptionRepository = $preferenceOptionRepository;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
|
$this->seedPreferences($io);
|
||||||
|
$this->seedPreferenceOptions($io);
|
||||||
|
|
||||||
|
return Command::SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function seedPreferences(SymfonyStyle $io)
|
||||||
|
{
|
||||||
|
$io->info('[SeedDatabaseCommand] > Seeding preferences...');
|
||||||
|
$preferences = $this->getPreferences();
|
||||||
|
|
||||||
|
foreach ($preferences as $preference) {
|
||||||
|
if ($this->preferenceRepository->find($preference['id'])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->preferenceRepository->getEntityManager()->persist((new \App\User\Framework\Entity\Preference())
|
||||||
|
->setId($preference['id'])
|
||||||
|
->setName($preference['name'])
|
||||||
|
->setDescription($preference['description'])
|
||||||
|
->setEnabled($preference['enabled'])
|
||||||
|
->setType($preference['type'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->preferenceRepository->getEntityManager()->flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getPreferences(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'id' => 'codec',
|
||||||
|
'name' => 'Codec',
|
||||||
|
'description' => null,
|
||||||
|
'enabled' => true,
|
||||||
|
'type' => 'media',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 'resolution',
|
||||||
|
'name' => 'Resolution',
|
||||||
|
'description' => null,
|
||||||
|
'enabled' => true,
|
||||||
|
'type' => 'media',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 'language',
|
||||||
|
'name' => 'Language',
|
||||||
|
'description' => null,
|
||||||
|
'enabled' => true,
|
||||||
|
'type' => 'media',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 'provider',
|
||||||
|
'name' => 'Provider',
|
||||||
|
'description' => null,
|
||||||
|
'enabled' => true,
|
||||||
|
'type' => 'media',
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'id' => 'movie_folder',
|
||||||
|
'name' => 'Create new folder for Movies',
|
||||||
|
'description' => 'When downloading a movie, store it in a new folder in your base \'movies\' folder. (e.g.: .../movies/Inception/Inception.2160p.h265.mkv)',
|
||||||
|
'enabled' => true,
|
||||||
|
'type' => 'download'
|
||||||
|
],
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function seedPreferenceOptions(SymfonyStyle $io)
|
||||||
|
{
|
||||||
|
$io->info('[SeedDatabaseCommand] > Seeding preference options...');
|
||||||
|
$options = $this->getPreferenceOptions();
|
||||||
|
|
||||||
|
foreach ($options as $option) {
|
||||||
|
if ($this->preferenceOptionRepository->findBy([
|
||||||
|
'preference' => $option['preference_id'],
|
||||||
|
'name' => $option['name'],
|
||||||
|
'value' => $option['value'],
|
||||||
|
'enabled' => $option['enabled'],
|
||||||
|
])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$this->preferenceOptionRepository->getEntityManager()->persist(
|
||||||
|
(new \App\User\Framework\Entity\PreferenceOption())
|
||||||
|
->setPreference($this->preferenceRepository->find($option['preference_id']))
|
||||||
|
->setName($option['name'])
|
||||||
|
->setValue($option['value'])
|
||||||
|
->setEnabled($option['enabled'])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->preferenceOptionRepository->getEntityManager()->flush();
|
||||||
|
}
|
||||||
|
|
||||||
|
private function getPreferenceOptions(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[
|
||||||
|
'preference_id' => 'resolution',
|
||||||
|
'name' => '720p',
|
||||||
|
'value' => '720p',
|
||||||
|
'enabled' => true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'preference_id' => 'resolution',
|
||||||
|
'name' => '1080p',
|
||||||
|
'value' => '1080p',
|
||||||
|
'enabled' => true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'preference_id' => 'resolution',
|
||||||
|
'name' => '2160p',
|
||||||
|
'value' => '2160p',
|
||||||
|
'enabled' => true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'preference_id' => 'codec',
|
||||||
|
'name' => '-',
|
||||||
|
'value' => '-',
|
||||||
|
'enabled' => true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'preference_id' => 'codec',
|
||||||
|
'name' => 'h264',
|
||||||
|
'value' => 'h264',
|
||||||
|
'enabled' => true
|
||||||
|
],
|
||||||
|
[
|
||||||
|
'preference_id' => 'codec',
|
||||||
|
'name' => 'h265/HEVC',
|
||||||
|
'value' => 'h265',
|
||||||
|
'enabled' => true
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
48
src/Command/StartupStatusCommand.php
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Command;
|
||||||
|
|
||||||
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use Symfony\Component\Console\Attribute\AsCommand;
|
||||||
|
use Symfony\Component\Console\Command\Command;
|
||||||
|
use Symfony\Component\Console\Input\InputArgument;
|
||||||
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||||
|
|
||||||
|
#[AsCommand(
|
||||||
|
name: 'startup:status',
|
||||||
|
description: 'Add a short description for your command',
|
||||||
|
)]
|
||||||
|
class StartupStatusCommand extends Command
|
||||||
|
{
|
||||||
|
private EntityManagerInterface $entityManager;
|
||||||
|
|
||||||
|
public function __construct(EntityManagerInterface $entityManager)
|
||||||
|
{
|
||||||
|
parent::__construct();
|
||||||
|
$this->entityManager = $entityManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function execute(InputInterface $input, OutputInterface $output): int
|
||||||
|
{
|
||||||
|
$io = new SymfonyStyle($input, $output);
|
||||||
|
|
||||||
|
$ready = true;
|
||||||
|
$messengerTableExists = $this->doesMessengerTableExist();
|
||||||
|
|
||||||
|
if (false === $messengerTableExists) {
|
||||||
|
$ready = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (true === $ready) ? Command::SUCCESS : Command::FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
private function doesMessengerTableExist()
|
||||||
|
{
|
||||||
|
return $this->entityManager->getConnection()
|
||||||
|
->createSchemaManager()
|
||||||
|
->tablesExist('messenger_messages');
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,34 +2,25 @@
|
|||||||
|
|
||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
|
use App\Util\Broadcaster;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Mercure\HubInterface;
|
|
||||||
use Symfony\Component\Mercure\Update;
|
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
use Twig\Environment;
|
|
||||||
|
|
||||||
final class AlertController extends AbstractController
|
final class AlertController extends AbstractController
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
#[Autowire(service: 'twig')] private readonly Environment $renderer,
|
private readonly Broadcaster $broadcaster,
|
||||||
private readonly HubInterface $hub,
|
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
#[Route('/alert', name: 'app_alert')]
|
#[Route('/alert', name: 'app_alert')]
|
||||||
public function index(): Response
|
public function index(): Response
|
||||||
{
|
{
|
||||||
$update = new Update(
|
$this->broadcaster->alert(
|
||||||
'alerts',
|
'Added to queue',
|
||||||
$this->renderer->render('broadcast/Alert.html.twig', [
|
'This is a testy test!'
|
||||||
'alert_id' => 1,
|
|
||||||
'title' => 'Added to queue',
|
|
||||||
'message' => 'This is a testy test!',
|
|
||||||
])
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->hub->publish($update);
|
|
||||||
return $this->json([
|
return $this->json([
|
||||||
'Success' => 'Published'
|
'Success' => 'Published'
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -1,40 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Controller;
|
|
||||||
|
|
||||||
use App\Download\Action\Input\DownloadMediaInput;
|
|
||||||
use App\Download\Framework\Repository\DownloadRepository;
|
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
|
||||||
use Symfony\Component\Messenger\MessageBusInterface;
|
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
|
||||||
|
|
||||||
class DownloadController extends AbstractController
|
|
||||||
{
|
|
||||||
public function __construct(
|
|
||||||
private DownloadRepository $downloadRepository,
|
|
||||||
private MessageBusInterface $bus,
|
|
||||||
) {}
|
|
||||||
|
|
||||||
#[Route('/download', name: 'app_download', methods: ['POST'])]
|
|
||||||
public function download(
|
|
||||||
DownloadMediaInput $input,
|
|
||||||
): Response {
|
|
||||||
$download = $this->downloadRepository->insert(
|
|
||||||
$input->url,
|
|
||||||
$input->title,
|
|
||||||
$input->filename,
|
|
||||||
$input->imdbId,
|
|
||||||
$input->mediaType,
|
|
||||||
"",
|
|
||||||
);
|
|
||||||
$input->downloadId = $download->getId();
|
|
||||||
try {
|
|
||||||
$this->bus->dispatch($input->toCommand());
|
|
||||||
} catch (\Throwable $exception) {
|
|
||||||
return $this->json(['error' => $exception->getMessage()], Response::HTTP_INTERNAL_SERVER_ERROR);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this->json(['status' => 200, 'message' => 'Added to Queue']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -3,26 +3,36 @@
|
|||||||
namespace App\Controller;
|
namespace App\Controller;
|
||||||
|
|
||||||
use App\Download\Framework\Repository\DownloadRepository;
|
use App\Download\Framework\Repository\DownloadRepository;
|
||||||
|
use App\Monitor\Action\Command\MonitorTvShowCommand;
|
||||||
|
use App\Monitor\Action\Handler\MonitorTvShowHandler;
|
||||||
use App\Tmdb\Tmdb;
|
use App\Tmdb\Tmdb;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|
||||||
final class IndexController extends AbstractController
|
final class IndexController extends AbstractController
|
||||||
{
|
{
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private readonly DownloadRepository $downloadRepository,
|
|
||||||
private readonly Tmdb $tmdb,
|
private readonly Tmdb $tmdb,
|
||||||
|
private readonly MonitorTvShowHandler $monitorTvShowHandler,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
#[Route('/', name: 'app_index')]
|
#[Route('/', name: 'app_index')]
|
||||||
public function index(): Response
|
public function index(Request $request): Response
|
||||||
{
|
{
|
||||||
return $this->render('index/index.html.twig', [
|
return $this->render('index/index.html.twig', [
|
||||||
'active_downloads' => $this->downloadRepository->getActivePaginated(),
|
'active_downloads' => $this->getUser()->getActiveDownloads(),
|
||||||
'recent_downloads' => $this->downloadRepository->latest(5),
|
'recent_downloads' => $this->getUser()->getDownloads(),
|
||||||
'popular_movies' => $this->tmdb->popularMovies(1, 6),
|
'popular_movies' => $this->tmdb->popularMovies(1, 6),
|
||||||
'popular_tvshows' => $this->tmdb->popularTvShows(1, 6),
|
'popular_tvshows' => $this->tmdb->popularTvShows(1, 6),
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[Route('/test', name: 'app_test')]
|
||||||
|
public function test()
|
||||||
|
{
|
||||||
|
$result = $this->monitorTvShowHandler->handle(new MonitorTvShowCommand(355));
|
||||||
|
return $this->json($result);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,8 +6,12 @@ use App\Search\Action\Handler\GetMediaInfoHandler;
|
|||||||
use App\Search\Action\Handler\SearchHandler;
|
use App\Search\Action\Handler\SearchHandler;
|
||||||
use App\Search\Action\Input\GetMediaInfoInput;
|
use App\Search\Action\Input\GetMediaInfoInput;
|
||||||
use App\Search\Action\Input\SearchInput;
|
use App\Search\Action\Input\SearchInput;
|
||||||
|
use App\Tmdb\TmdbResult;
|
||||||
|
use App\Torrentio\Action\Command\GetMovieOptionsCommand;
|
||||||
|
use App\Torrentio\Action\Command\GetTvShowOptionsCommand;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
|
use Symfony\Component\Messenger\MessageBusInterface;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
|
||||||
final class SearchController extends AbstractController
|
final class SearchController extends AbstractController
|
||||||
@@ -15,6 +19,7 @@ final class SearchController extends AbstractController
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
private SearchHandler $searchHandler,
|
private SearchHandler $searchHandler,
|
||||||
private GetMediaInfoHandler $getMediaInfoHandler,
|
private GetMediaInfoHandler $getMediaInfoHandler,
|
||||||
|
private MessageBusInterface $bus,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
#[Route('/search', name: 'app_search', methods: ['GET'])]
|
#[Route('/search', name: 'app_search', methods: ['GET'])]
|
||||||
@@ -28,11 +33,12 @@ final class SearchController extends AbstractController
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/result/{mediaType}/{tmdbId}', name: 'app_search_result')]
|
#[Route('/result/{mediaType}/{imdbId}/{season}', name: 'app_search_result')]
|
||||||
public function result(
|
public function result(
|
||||||
GetMediaInfoInput $getDownloadOptionsInput,
|
GetMediaInfoInput $input,
|
||||||
|
?int $season = null,
|
||||||
): Response {
|
): Response {
|
||||||
$result = $this->getMediaInfoHandler->handle($getDownloadOptionsInput->toCommand());
|
$result = $this->getMediaInfoHandler->handle($input->toCommand());
|
||||||
|
|
||||||
return $this->render('search/result.html.twig', [
|
return $this->render('search/result.html.twig', [
|
||||||
'results' => $result,
|
'results' => $result,
|
||||||
@@ -46,4 +52,32 @@ final class SearchController extends AbstractController
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function warmDownloadOptionCache(TmdbResult $result)
|
||||||
|
{
|
||||||
|
if ($result->mediaType === 'tvshows') {
|
||||||
|
// dispatches a job to get the download options
|
||||||
|
// for each episode and load them in cache
|
||||||
|
foreach ($result->episodes as $season => $episodes) {
|
||||||
|
// Only do the first 2 seasons, so we reduce
|
||||||
|
// getting rate-limited by Torrentio
|
||||||
|
if ($season > 2) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
foreach ($episodes as $episode) {
|
||||||
|
$this->bus->dispatch(new GetTvShowOptionsCommand(
|
||||||
|
tmdbId: $result->tmdbId,
|
||||||
|
imdbId: $result->imdbId,
|
||||||
|
season: $season,
|
||||||
|
episode: $episode['episode_number'],
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} elseif ($result->mediaType === 'movies') {
|
||||||
|
$this->bus->dispatch(new GetMovieOptionsCommand(
|
||||||
|
$result->tmdbId,
|
||||||
|
$result->imdbId,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,34 +6,110 @@ use App\Torrentio\Action\Handler\GetMovieOptionsHandler;
|
|||||||
use App\Torrentio\Action\Handler\GetTvShowOptionsHandler;
|
use App\Torrentio\Action\Handler\GetTvShowOptionsHandler;
|
||||||
use App\Torrentio\Action\Input\GetMovieOptionsInput;
|
use App\Torrentio\Action\Input\GetMovieOptionsInput;
|
||||||
use App\Torrentio\Action\Input\GetTvShowOptionsInput;
|
use App\Torrentio\Action\Input\GetTvShowOptionsInput;
|
||||||
|
use App\Torrentio\Exception\TorrentioRateLimitException;
|
||||||
|
use App\Util\Broadcaster;
|
||||||
|
use Carbon\Carbon;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\HttpFoundation\Response;
|
use Symfony\Component\HttpFoundation\Response;
|
||||||
use Symfony\Component\Routing\Attribute\Route;
|
use Symfony\Component\Routing\Attribute\Route;
|
||||||
|
use Symfony\Contracts\Cache\CacheInterface;
|
||||||
|
use Symfony\Contracts\Cache\ItemInterface;
|
||||||
|
use Symfony\Contracts\Cache\TagAwareCacheInterface;
|
||||||
|
|
||||||
final class TorrentioController extends AbstractController
|
final class TorrentioController 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 Broadcaster $broadcaster,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
#[Route('/torrentio/movies/{tmdbId}/{imdbId}', name: 'app_torrentio_movies')]
|
#[Route('/torrentio/movies/{tmdbId}/{imdbId}', name: 'app_torrentio_movies')]
|
||||||
public function movieOptions(GetMovieOptionsInput $input): Response
|
public function movieOptions(GetMovieOptionsInput $input, TagAwareCacheInterface $pageCache): Response
|
||||||
{
|
{
|
||||||
$results = $this->getMovieOptionsHandler->handle($input->toCommand());
|
$cacheId = sprintf(
|
||||||
|
"page.torrentio.movies.%s.%s",
|
||||||
|
$input->tmdbId,
|
||||||
|
$input->imdbId
|
||||||
|
);
|
||||||
|
|
||||||
return $this->render('torrentio/movies.html.twig', [
|
try {
|
||||||
'results' => $results,
|
return $pageCache->get($cacheId, function (ItemInterface $item) use ($input) {
|
||||||
]);
|
$item->expiresAt(Carbon::now()->addHour()->setMinute(0)->setSecond(0));
|
||||||
|
$item->tag(['page', 'page.torrentio', 'page.torrentio.movies', "page.torrentio.movies.$input->tmdbId.$input->imdbId", 'torrentio', 'torrentio.movies', "torrentio.movies.$input->tmdbId.$input->imdbId"]);
|
||||||
|
$results = $this->getMovieOptionsHandler->handle($input->toCommand());
|
||||||
|
return $this->render('torrentio/movies.html.twig', [
|
||||||
|
'results' => $results,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
} catch (TorrentioRateLimitException $exception) {
|
||||||
|
$this->broadcaster->alert('Warning', 'Torrentio has rate limited your requests. Please wait a few minutes before trying again.', 'warning');
|
||||||
|
return $this->render('bare.html.twig',
|
||||||
|
[],
|
||||||
|
new Response('Too many requests',
|
||||||
|
Response::HTTP_TOO_MANY_REQUESTS,
|
||||||
|
['Retry-After' => 4000]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Route('/torrentio/tvshows/{tmdbId}/{imdbId}/{season?}/{episode?}', name: 'app_torrentio_tvshows')]
|
#[Route('/torrentio/tvshows/{tmdbId}/{imdbId}/{season?}/{episode?}', name: 'app_torrentio_tvshows')]
|
||||||
public function tvShowOptions(GetTvShowOptionsInput $input): Response
|
public function tvShowOptions(GetTvShowOptionsInput $input, TagAwareCacheInterface $pageCache): Response
|
||||||
{
|
{
|
||||||
$results = $this->getTvShowOptionsHandler->handle($input->toCommand());
|
$cacheId = sprintf(
|
||||||
|
"page.torrentio.tvshows.%s.%s.%s.%s",
|
||||||
|
$input->tmdbId,
|
||||||
|
$input->imdbId,
|
||||||
|
$input->season,
|
||||||
|
$input->episode,
|
||||||
|
);
|
||||||
|
|
||||||
return $this->render('torrentio/tvshows.html.twig', [
|
try {
|
||||||
'results' => $results,
|
return $pageCache->get($cacheId, function (ItemInterface $item) use ($input) {
|
||||||
]);
|
$item->expiresAt(Carbon::now()->addHour()->setMinute(0)->setSecond(0));
|
||||||
|
$item->tag(['page', 'page.torrentio', 'page.torrentio.tvshows', "page.torrentio.tvshows.$input->tmdbId.$input->imdbId", "page.torrentio.tvshows.$input->tmdbId.$input->imdbId.$input->season", "page.torrentio.tvshows.$input->tmdbId.$input->imdbId.$input->season.$input->episode", 'torrentio', 'torrentio.tvshows', "torrentio.tvshows.$input->tmdbId.$input->imdbId", "torrentio.tvshows.$input->tmdbId.$input->imdbId.$input->season", "torrentio.tvshows.$input->tmdbId.$input->imdbId.$input->season.$input->episode", $input->imdbId, $input->tmdbId]);
|
||||||
|
$results = $this->getTvShowOptionsHandler->handle($input->toCommand());
|
||||||
|
return $this->render('torrentio/tvshows.html.twig', [
|
||||||
|
'results' => $results,
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
} catch (TorrentioRateLimitException $exception) {
|
||||||
|
$this->broadcaster->alert('Warning', 'Torrentio has rate limited your requests. Please wait a few minutes before trying again.', 'warning');
|
||||||
|
return $this->render('bare.html.twig',
|
||||||
|
[],
|
||||||
|
new Response('Too many requests',
|
||||||
|
Response::HTTP_TOO_MANY_REQUESTS,
|
||||||
|
['Retry-After' => 4000]
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Route('/torrentio/tvshows/clear/{tmdbId}/{imdbId}/{season?}/{episode?}', name: 'app_clear_torrentio_tvshows')]
|
||||||
|
public function clearTvShowOptions(GetTvShowOptionsInput $input, CacheInterface $cache, Request $request): Response
|
||||||
|
{
|
||||||
|
$cacheId = sprintf(
|
||||||
|
"page.torrentio.tvshows.%s.%s.%s.%s",
|
||||||
|
$input->tmdbId,
|
||||||
|
$input->imdbId,
|
||||||
|
$input->season,
|
||||||
|
$input->episode,
|
||||||
|
);
|
||||||
|
$cache->delete($cacheId);
|
||||||
|
|
||||||
|
$this->broadcaster->alert(
|
||||||
|
title: 'Success',
|
||||||
|
message: 'Torrentio cache Cleared.'
|
||||||
|
);
|
||||||
|
|
||||||
|
return $cache->get($cacheId, function (ItemInterface $item) use ($input) {
|
||||||
|
$item->expiresAt(Carbon::now()->addHour()->setMinute(0)->setSecond(0));
|
||||||
|
$results = $this->getTvShowOptionsHandler->handle($input->toCommand());
|
||||||
|
return $this->render('torrentio/tvshows.html.twig', [
|
||||||
|
'results' => $results,
|
||||||
|
]);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
15
src/Download/Action/Command/DeleteDownloadCommand.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Download\Action\Command;
|
||||||
|
|
||||||
|
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implements CommandInterface<DeleteDownloadCommand>
|
||||||
|
*/
|
||||||
|
class DeleteDownloadCommand implements CommandInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public int $downloadId,
|
||||||
|
) {}
|
||||||
|
}
|
||||||
@@ -15,6 +15,7 @@ class DownloadMediaCommand implements CommandInterface
|
|||||||
public string $filename,
|
public string $filename,
|
||||||
public string $mediaType,
|
public string $mediaType,
|
||||||
public string $imdbId,
|
public string $imdbId,
|
||||||
|
public int $userId,
|
||||||
public ?int $downloadId = null,
|
public ?int $downloadId = null,
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
15
src/Download/Action/Command/PauseDownloadCommand.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Download\Action\Command;
|
||||||
|
|
||||||
|
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implements CommandInterface<PauseDownloadCommand>
|
||||||
|
*/
|
||||||
|
class PauseDownloadCommand implements CommandInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public int $downloadId,
|
||||||
|
) {}
|
||||||
|
}
|
||||||
15
src/Download/Action/Command/ResumeDownloadCommand.php
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Download\Action\Command;
|
||||||
|
|
||||||
|
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @implements CommandInterface<ResumeDownloadCommand>
|
||||||
|
*/
|
||||||
|
class ResumeDownloadCommand implements CommandInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public int $downloadId,
|
||||||
|
) {}
|
||||||
|
}
|
||||||
26
src/Download/Action/Handler/DeleteDownloadHandler.php
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Download\Action\Handler;
|
||||||
|
|
||||||
|
use App\Download\Action\Command\DeleteDownloadCommand;
|
||||||
|
use App\Download\Action\Result\DeleteDownloadResult;
|
||||||
|
use App\Download\Framework\Repository\DownloadRepository;
|
||||||
|
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||||
|
use OneToMany\RichBundle\Contract\HandlerInterface;
|
||||||
|
use OneToMany\RichBundle\Contract\ResultInterface;
|
||||||
|
|
||||||
|
/** @implements HandlerInterface<DeleteDownloadCommand, DeleteDownloadResult> */
|
||||||
|
readonly class DeleteDownloadHandler implements HandlerInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private DownloadRepository $downloadRepository,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function handle(CommandInterface $command): ResultInterface
|
||||||
|
{
|
||||||
|
$download = $this->downloadRepository->find($command->downloadId);
|
||||||
|
$this->downloadRepository->delete($command->downloadId);
|
||||||
|
|
||||||
|
return new DeleteDownloadResult(200, 'Success', $download);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,6 +6,7 @@ use App\Download\Action\Command\DownloadMediaCommand;
|
|||||||
use App\Download\Action\Result\DownloadMediaResult;
|
use App\Download\Action\Result\DownloadMediaResult;
|
||||||
use App\Download\Framework\Repository\DownloadRepository;
|
use App\Download\Framework\Repository\DownloadRepository;
|
||||||
use App\Download\Downloader\DownloaderInterface;
|
use App\Download\Downloader\DownloaderInterface;
|
||||||
|
use App\User\Framework\Repository\UserRepository;
|
||||||
use OneToMany\RichBundle\Contract\CommandInterface;
|
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||||
use OneToMany\RichBundle\Contract\HandlerInterface;
|
use OneToMany\RichBundle\Contract\HandlerInterface;
|
||||||
use OneToMany\RichBundle\Contract\ResultInterface;
|
use OneToMany\RichBundle\Contract\ResultInterface;
|
||||||
@@ -17,12 +18,14 @@ readonly class DownloadMediaHandler implements HandlerInterface
|
|||||||
public function __construct(
|
public function __construct(
|
||||||
private DownloaderInterface $downloader,
|
private DownloaderInterface $downloader,
|
||||||
private DownloadRepository $downloadRepository,
|
private DownloadRepository $downloadRepository,
|
||||||
|
private UserRepository $userRepository,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public function handle(CommandInterface $command): ResultInterface
|
public function handle(CommandInterface $command): ResultInterface
|
||||||
{
|
{
|
||||||
if (null === $command->downloadId) {
|
if (null === $command->downloadId) {
|
||||||
$download = $this->downloadRepository->insert(
|
$download = $this->downloadRepository->insert(
|
||||||
|
$this->userRepository->find($command->userId),
|
||||||
$command->url,
|
$command->url,
|
||||||
$command->title,
|
$command->title,
|
||||||
$command->filename,
|
$command->filename,
|
||||||
@@ -34,9 +37,10 @@ readonly class DownloadMediaHandler implements HandlerInterface
|
|||||||
$download = $this->downloadRepository->find($command->downloadId);
|
$download = $this->downloadRepository->find($command->downloadId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$this->downloadRepository->updateStatus($download->getId(), 'In Progress');
|
if ($download->getStatus() !== 'Paused') {
|
||||||
|
$this->downloadRepository->updateStatus($download->getId(), 'In Progress');
|
||||||
|
}
|
||||||
|
|
||||||
$this->downloader->download(
|
$this->downloader->download(
|
||||||
$command->mediaType,
|
$command->mediaType,
|
||||||
@@ -45,7 +49,9 @@ readonly class DownloadMediaHandler implements HandlerInterface
|
|||||||
$download->getId()
|
$download->getId()
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->downloadRepository->updateStatus($download->getId(), 'Complete');
|
if ($download->getStatus() !== 'Paused') {
|
||||||
|
$this->downloadRepository->updateStatus($download->getId(), 'Complete');
|
||||||
|
}
|
||||||
|
|
||||||
} catch (\Throwable $exception) {
|
} catch (\Throwable $exception) {
|
||||||
throw new UnrecoverableMessageHandlingException($exception->getMessage(), 500);
|
throw new UnrecoverableMessageHandlingException($exception->getMessage(), 500);
|
||||||
|
|||||||
33
src/Download/Action/Handler/PauseDownloadHandler.php
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Download\Action\Handler;
|
||||||
|
|
||||||
|
use App\Download\Action\Command\PauseDownloadCommand;
|
||||||
|
use App\Download\Action\Result\PauseDownloadResult;
|
||||||
|
use App\Download\Framework\Entity\Download;
|
||||||
|
use App\Download\Framework\Repository\DownloadRepository;
|
||||||
|
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||||
|
use OneToMany\RichBundle\Contract\HandlerInterface;
|
||||||
|
use OneToMany\RichBundle\Contract\ResultInterface;
|
||||||
|
use Symfony\Contracts\Cache\CacheInterface;
|
||||||
|
|
||||||
|
/** @implements HandlerInterface<PauseDownloadCommand, PauseDownloadResult> */
|
||||||
|
readonly class PauseDownloadHandler implements HandlerInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private DownloadRepository $downloadRepository,
|
||||||
|
private CacheInterface $cache,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function handle(CommandInterface $command): ResultInterface
|
||||||
|
{
|
||||||
|
/** @var Download $download */
|
||||||
|
$download = $this->downloadRepository->find($command->downloadId);
|
||||||
|
|
||||||
|
$this->cache->get('download.pause.' . $download->getId(), function () {
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
|
||||||
|
return new PauseDownloadResult(200, 'Success', $download);
|
||||||
|
}
|
||||||
|
}
|
||||||
40
src/Download/Action/Handler/ResumeDownloadHandler.php
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Download\Action\Handler;
|
||||||
|
|
||||||
|
use App\Download\Action\Command\DownloadMediaCommand;
|
||||||
|
use App\Download\Action\Command\ResumeDownloadCommand;
|
||||||
|
use App\Download\Action\Result\ResumeDownloadResult;
|
||||||
|
use App\Download\Framework\Entity\Download;
|
||||||
|
use App\Download\Framework\Repository\DownloadRepository;
|
||||||
|
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||||
|
use OneToMany\RichBundle\Contract\HandlerInterface;
|
||||||
|
use OneToMany\RichBundle\Contract\ResultInterface;
|
||||||
|
use Symfony\Component\Messenger\MessageBusInterface;
|
||||||
|
|
||||||
|
/** @implements HandlerInterface<ResumeDownloadCommand, ResumeDownloadResult> */
|
||||||
|
readonly class ResumeDownloadHandler implements HandlerInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
private DownloadRepository $downloadRepository,
|
||||||
|
private MessageBusInterface $messageBus,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function handle(CommandInterface $command): ResultInterface
|
||||||
|
{
|
||||||
|
/** @var Download $download */
|
||||||
|
$download = $this->downloadRepository->find($command->downloadId);
|
||||||
|
|
||||||
|
$this->messageBus->dispatch(new DownloadMediaCommand(
|
||||||
|
$download->getUrl(),
|
||||||
|
$download->getTitle(),
|
||||||
|
$download->getFilename(),
|
||||||
|
$download->getMediaType(),
|
||||||
|
$download->getImdbId(),
|
||||||
|
$download->getUser()->getId(),
|
||||||
|
$download->getId()
|
||||||
|
));
|
||||||
|
|
||||||
|
return new ResumeDownloadResult(200, 'Success', $download);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/Download/Action/Input/DeleteDownloadInput.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Download\Action\Input;
|
||||||
|
|
||||||
|
use App\Download\Action\Command\DeleteDownloadCommand;
|
||||||
|
use OneToMany\RichBundle\Attribute\SourceRoute;
|
||||||
|
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||||
|
use OneToMany\RichBundle\Contract\InputInterface;
|
||||||
|
|
||||||
|
/** @implements InputInterface<DeleteDownloadInput> */
|
||||||
|
class DeleteDownloadInput implements InputInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
#[SourceRoute('downloadId')]
|
||||||
|
public int $downloadId,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function toCommand(): CommandInterface
|
||||||
|
{
|
||||||
|
return new DeleteDownloadCommand(
|
||||||
|
$this->downloadId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,6 +26,11 @@ class DownloadMediaInput implements InputInterface
|
|||||||
#[SourceRequest('imdbId')]
|
#[SourceRequest('imdbId')]
|
||||||
public string $imdbId,
|
public string $imdbId,
|
||||||
|
|
||||||
|
#[SourceRequest('episodeId', nullify: true)]
|
||||||
|
public ?string $episodeId = null,
|
||||||
|
|
||||||
|
public ?int $userId = null,
|
||||||
|
|
||||||
public ?int $downloadId = null,
|
public ?int $downloadId = null,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
@@ -37,6 +42,7 @@ class DownloadMediaInput implements InputInterface
|
|||||||
$this->filename,
|
$this->filename,
|
||||||
$this->mediaType,
|
$this->mediaType,
|
||||||
$this->imdbId,
|
$this->imdbId,
|
||||||
|
$this->userId,
|
||||||
$this->downloadId,
|
$this->downloadId,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
24
src/Download/Action/Input/PauseDownloadInput.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Download\Action\Input;
|
||||||
|
|
||||||
|
use App\Download\Action\Command\PauseDownloadCommand;
|
||||||
|
use OneToMany\RichBundle\Attribute\SourceRoute;
|
||||||
|
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||||
|
use OneToMany\RichBundle\Contract\InputInterface;
|
||||||
|
|
||||||
|
/** @implements InputInterface<PauseDownloadInput, PauseDownloadCommand> */
|
||||||
|
class PauseDownloadInput implements InputInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
#[SourceRoute('downloadId')]
|
||||||
|
public int $downloadId,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function toCommand(): CommandInterface
|
||||||
|
{
|
||||||
|
return new PauseDownloadCommand(
|
||||||
|
$this->downloadId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
24
src/Download/Action/Input/ResumeDownloadInput.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Download\Action\Input;
|
||||||
|
|
||||||
|
use App\Download\Action\Command\PauseDownloadCommand;
|
||||||
|
use OneToMany\RichBundle\Attribute\SourceRoute;
|
||||||
|
use OneToMany\RichBundle\Contract\CommandInterface;
|
||||||
|
use OneToMany\RichBundle\Contract\InputInterface;
|
||||||
|
|
||||||
|
/** @implements InputInterface<PauseDownloadInput, PauseDownloadCommand> */
|
||||||
|
class ResumeDownloadInput implements InputInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
#[SourceRoute('downloadId')]
|
||||||
|
public int $downloadId,
|
||||||
|
) {}
|
||||||
|
|
||||||
|
public function toCommand(): CommandInterface
|
||||||
|
{
|
||||||
|
return new PauseDownloadCommand(
|
||||||
|
$this->downloadId,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
16
src/Download/Action/Result/DeleteDownloadResult.php
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Download\Action\Result;
|
||||||
|
|
||||||
|
use App\Download\Framework\Entity\Download;
|
||||||
|
use OneToMany\RichBundle\Contract\ResultInterface;
|
||||||
|
|
||||||
|
/** @implements ResultInterface<DownloadMediaResult> */
|
||||||
|
class DeleteDownloadResult implements ResultInterface
|
||||||
|
{
|
||||||
|
public function __construct(
|
||||||
|
public int $status,
|
||||||
|
public string $message,
|
||||||
|
public Download $download,
|
||||||
|
) {}
|
||||||
|
}
|
||||||