From 3de2027861d854ee4aa351c9a365ceb8fb68cd5a Mon Sep 17 00:00:00 2001 From: mhdzumair Date: Fri, 24 Jan 2025 23:14:36 +0530 Subject: [PATCH] Add configurable toggles for torrent metadata and seeders jobs --- api/scheduler.py | 17 +++++++++-------- db/config.py | 2 ++ docs/configuration.md | 1 + utils/torrent.py | 4 ++++ 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/api/scheduler.py b/api/scheduler.py index 0953c00..27df2bb 100644 --- a/api/scheduler.py +++ b/api/scheduler.py @@ -134,14 +134,15 @@ def setup_scheduler(scheduler: AsyncIOScheduler): }, ) - scheduler.add_job( - update_torrent_seeders.send, - CronTrigger.from_crontab(settings.update_seeders_crontab), - name="update_seeders", - kwargs={ - "crontab_expression": settings.update_seeders_crontab, - }, - ) + if not settings.disable_update_seeders: + scheduler.add_job( + update_torrent_seeders.send, + CronTrigger.from_crontab(settings.update_seeders_crontab), + name="update_seeders", + kwargs={ + "crontab_expression": settings.update_seeders_crontab, + }, + ) if not settings.disable_arab_torrents_scheduler: scheduler.add_job( diff --git a/db/config.py b/db/config.py index 162ef92..8892fa3 100644 --- a/db/config.py +++ b/db/config.py @@ -128,6 +128,7 @@ class Settings(BaseSettings): store_stremthru_magnet_cache: bool = False is_scrap_from_yts: bool = True scrape_with_aka_titles: bool = True + enable_fetching_torrent_metadata_from_p2p: bool = True # Content Filtering adult_content_regex_keywords: str = ( @@ -166,6 +167,7 @@ class Settings(BaseSettings): motogp_tgx_scheduler_crontab: str = "0 5 * * *" disable_motogp_tgx_scheduler: bool = False update_seeders_crontab: str = "0 0 * * *" + disable_update_seeders: bool = True arab_torrents_scheduler_crontab: str = "0 0 * * *" disable_arab_torrents_scheduler: bool = False wwe_tgx_scheduler_crontab: str = "10 */3 * * *" diff --git a/docs/configuration.md b/docs/configuration.md index 57925f1..24c3b9b 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -127,6 +127,7 @@ These settings define the basic configuration and identity of your MediaFusion i - **store_stremthru_magnet_cache** (default: `False`): Store StremThru magnet cache. - **is_scrap_from_yts** (default: `True`): Enable/disable YTS scraping. - **scrape_with_aka_titles** (default: `True`): Include alternative titles in scraping. +- **enable_fetching_torrent_metadata_from_p2p** (default: `False`): Enable fetching torrent metadata from P2P, Cautions: It may raise DMCA issues. ## Time-related Settings diff --git a/utils/torrent.py b/utils/torrent.py index 7eb1577..243a3e4 100644 --- a/utils/torrent.py +++ b/utils/torrent.py @@ -209,6 +209,10 @@ async def info_hashes_to_torrent_metadata( ) -> list[dict]: torrents_data = [] + if not settings.enable_fetching_torrent_metadata_from_p2p: + logging.info("Fetching torrent metadata from P2P is disabled") + return torrents_data + demagnetizer = Demagnetizer() async with acollect( coros=[