mirror of
https://github.com/g0ldyy/comet.git
synced 2026-01-12 01:16:12 +01:00
feat: ability for the user to toggle trash removal
This commit is contained in:
+9
-9
@@ -196,7 +196,8 @@ async def stream(request: Request, b64config: str, type: str, id: str):
|
||||
|
||||
all_sorted_ranked_files.update(sorted_ranked_files)
|
||||
|
||||
if len(all_sorted_ranked_files) != 0:
|
||||
cached_count = len(all_sorted_ranked_files)
|
||||
if cached_count != 0:
|
||||
debrid_extension = get_debrid_extension(
|
||||
debrid_service, config["debridApiKey"]
|
||||
)
|
||||
@@ -237,11 +238,9 @@ async def stream(request: Request, b64config: str, type: str, id: str):
|
||||
|
||||
results.append(the_stream)
|
||||
|
||||
results_count = len(results)
|
||||
if results_count != 0:
|
||||
logger.info(f"{results_count} cached results found for {log_name}")
|
||||
logger.info(f"{cached_count} cached results found for {log_name}")
|
||||
|
||||
return {"streams": results}
|
||||
return {"streams": results}
|
||||
|
||||
if config["debridApiKey"] == "":
|
||||
return {
|
||||
@@ -349,7 +348,6 @@ async def stream(request: Request, b64config: str, type: str, id: str):
|
||||
aliases = await get_aliases(
|
||||
session, "movies" if type == "movie" else "shows", id
|
||||
)
|
||||
# print(aliases)
|
||||
|
||||
indexed_torrents = [(i, torrents[i]["Title"]) for i in range(len(torrents))]
|
||||
chunk_size = 50
|
||||
@@ -412,12 +410,14 @@ async def stream(request: Request, b64config: str, type: str, id: str):
|
||||
ranked_file = rtn.rank(
|
||||
torrents_by_hash[hash]["Title"],
|
||||
hash,
|
||||
remove_trash=True, # , correct_title=name, remove_trash=True
|
||||
remove_trash=False, # user can choose if he wants to remove it
|
||||
)
|
||||
|
||||
ranked_files.add(ranked_file)
|
||||
except Exception as e:
|
||||
logger.info(f"Filtered out: {e}")
|
||||
# except Exception as e:
|
||||
# logger.info(f"Filtered out: {e}")
|
||||
# pass
|
||||
except:
|
||||
pass
|
||||
|
||||
sorted_ranked_files = sort_torrents(ranked_files)
|
||||
|
||||
@@ -559,6 +559,7 @@
|
||||
|
||||
<sl-details summary="Advanced Settings">
|
||||
<div class="form-item">
|
||||
<sl-checkbox checked id="removeTrash" help-text="Remove all trash from results (Adult Content, CAM, Clean Audio, PDTV, R5, Screener, Size, Telecine and Telesync)">Remove Trash</sl-checkbox>
|
||||
<sl-checkbox id="reverseResultOrder" help-text="Reverse the order of the results for each resolution (useful for those who need small file sizes)">Reverse Result Order</sl-checkbox>
|
||||
<sl-select id="resultFormat" multiple label="Result Format" placeholder="Select what to show in result title" hoist max-options-visible=10>
|
||||
</sl-select>
|
||||
@@ -720,6 +721,7 @@
|
||||
const maxResultsPerResolution = document.getElementById("maxResultsPerResolution").value;
|
||||
const maxSize = document.getElementById("maxSize").value;
|
||||
const reverseResultOrder = document.getElementById("reverseResultOrder").checked;
|
||||
const removeTrash = document.getElementById("removeTrash").checked;
|
||||
const resultFormat = Array.from(document.getElementById("resultFormat").selectedOptions).map(option => option.value);
|
||||
const debridService = document.getElementById("debridService").value;
|
||||
const debridApiKey = document.getElementById("debridApiKey").value;
|
||||
@@ -734,6 +736,7 @@
|
||||
maxResultsPerResolution: parseInt(maxResultsPerResolution),
|
||||
maxSize: parseFloat(maxSize * 1073741824),
|
||||
reverseResultOrder: reverseResultOrder,
|
||||
removeTrash: removeTrash,
|
||||
resultFormat: selectedResultFormat,
|
||||
resolutions: selectedResolutions,
|
||||
languages: selectedLanguages,
|
||||
@@ -788,6 +791,8 @@
|
||||
document.getElementById("maxResults").value = settings.maxResults;
|
||||
if (settings.reverseResultOrder !== null)
|
||||
document.getElementById("reverseResultOrder").checked = settings.reverseResultOrder;
|
||||
if (settings.removeTrash !== null)
|
||||
document.getElementById("removeTrash").checked = settings.removeTrash;
|
||||
if (settings.maxResultsPerResolution !== null)
|
||||
document.getElementById("maxResultsPerResolution").value = settings.maxResultsPerResolution;
|
||||
if (settings.maxSize !== null)
|
||||
|
||||
@@ -482,18 +482,15 @@ async def filter(torrents: list, name: str, year: int, year_end: int, aliases: d
|
||||
name, parsed.parsed_title, aliases=aliases
|
||||
):
|
||||
results.append((index, False))
|
||||
# print(title, "|", parsed.parsed_title, "| title mismatch")
|
||||
continue
|
||||
|
||||
if year and parsed.year:
|
||||
if year_end is not None:
|
||||
if not (year <= parsed.year <= year_end):
|
||||
# print(title, "|", year, "to", year_end, "!=", parsed.year, "| year mismatch")
|
||||
results.append((index, False))
|
||||
continue
|
||||
else:
|
||||
if year < (parsed.year - 1) or year > (parsed.year + 1):
|
||||
# print(title, "|", year, "!=", parsed.year, "| year mismatch")
|
||||
results.append((index, False))
|
||||
continue
|
||||
|
||||
@@ -545,6 +542,7 @@ def get_balanced_hashes(hashes: dict, config: dict):
|
||||
max_size = config["maxSize"]
|
||||
config_resolutions = [resolution.lower() for resolution in config["resolutions"]]
|
||||
include_all_resolutions = "all" in config_resolutions
|
||||
remove_trash = config["removeTrash"]
|
||||
|
||||
languages = [language.lower() for language in config["languages"]]
|
||||
include_all_languages = "all" in languages
|
||||
@@ -557,6 +555,9 @@ def get_balanced_hashes(hashes: dict, config: dict):
|
||||
|
||||
hashes_by_resolution = {}
|
||||
for hash, hash_data in hashes.items():
|
||||
if remove_trash and not hash_data["fetch"]:
|
||||
continue
|
||||
|
||||
hash_info = hash_data["data"]
|
||||
|
||||
if max_size != 0 and hash_info["size"] > max_size:
|
||||
@@ -579,8 +580,9 @@ def get_balanced_hashes(hashes: dict, config: dict):
|
||||
hashes_by_resolution[resolution].append(hash)
|
||||
|
||||
if config["reverseResultOrder"]:
|
||||
for resolution in hashes_by_resolution:
|
||||
hashes_by_resolution[resolution].reverse()
|
||||
hashes_by_resolution = {
|
||||
res: lst[::-1] for res, lst in hashes_by_resolution.items()
|
||||
}
|
||||
|
||||
total_resolutions = len(hashes_by_resolution)
|
||||
if max_results == 0 and max_results_per_resolution == 0 or total_resolutions == 0:
|
||||
|
||||
@@ -70,6 +70,7 @@ class ConfigModel(BaseModel):
|
||||
languages: Optional[List[str]] = ["All"]
|
||||
resolutions: Optional[List[str]] = ["All"]
|
||||
reverseResultOrder: Optional[bool] = False
|
||||
removeTrash: Optional[bool] = True
|
||||
resultFormat: Optional[List[str]] = ["All"]
|
||||
maxResults: Optional[int] = 0
|
||||
maxResultsPerResolution: Optional[int] = 0
|
||||
|
||||
Reference in New Issue
Block a user