From e9968209acbb03b8391d8f9343c009fae91b34c9 Mon Sep 17 00:00:00 2001 From: Audionut Date: Sat, 31 Aug 2024 20:21:54 +1000 Subject: [PATCH] Allow use, edit or discard uni3d description --- requirements.txt | 3 ++- src/trackers/COMMON.py | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index b20352a43..c63a8c332 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,4 +19,5 @@ pyoxipng rich Jinja2 pyotp -str2bool \ No newline at end of file +str2bool +click \ No newline at end of file diff --git a/src/trackers/COMMON.py b/src/trackers/COMMON.py index 02b059fe5..41413fa75 100644 --- a/src/trackers/COMMON.py +++ b/src/trackers/COMMON.py @@ -3,6 +3,7 @@ import requests import re import json +import click from src.bbcode import BBCODE from src.console import console @@ -184,6 +185,21 @@ async def unit3d_torrent_info(self, tracker, torrent_url, search_url, id=None, f bbcode = BBCODE() description, imagelist = bbcode.clean_unit3d_description(description, torrent_url) console.print(f"[green]Successfully grabbed description from {tracker}") + + # Allow user to edit or discard the description + console.print("[cyan]Do you want to edit or discard the description?[/cyan]") + edit_choice = input("[cyan]Enter 'e' to edit, 'd' to discard, or press Enter to keep it as is: [/cyan]") + + if edit_choice.lower() == 'e': + edited_description = click.edit(description) + if edited_description: + description = edited_description.strip() + console.print(f"[green]Final description after editing:[/green] {description}") + elif edit_choice.lower() == 'd': + description = None + console.print("[yellow]Description discarded.[/yellow]") + else: + console.print(f"[green]Keeping the original description.[/green]") else: console.print(f"[yellow]No description found for {tracker}.[/yellow]") else: @@ -193,6 +209,9 @@ async def unit3d_torrent_info(self, tracker, torrent_url, search_url, id=None, f console.print_exception() console.print(f"[yellow]Invalid Response from {tracker} API. Error: {str(e)}[/yellow]") + if description: # Ensure description is only printed if it's not None + console.print(f"[green]Final description to be returned:[/green] {description}") + return tmdb, imdb, tvdb, mal, description, category, infohash, imagelist, file_name async def parseCookieFile(self, cookiefile):