diff --git a/comet/templates/index.html b/comet/templates/index.html index 2178d15..bd899d0 100644 --- a/comet/templates/index.html +++ b/comet/templates/index.html @@ -780,18 +780,26 @@ } function populateFormFromSettings(settings) { - document.getElementById("maxResults").value = settings.maxResults; - document.getElementById("maxResultsPerResolution").value = settings.maxResultsPerResolution; - document.getElementById("maxSize").value = settings.maxSize / 1073741824; // Convert back from bytes to GB - document.getElementById("debridService").value = settings.debridService; - document.getElementById("debridApiKey").value = settings.debridApiKey; - document.getElementById("debridStreamProxyPassword").value = settings.debridStreamProxyPassword; - document.getElementById("indexers").value = settings.indexers; - if (settings.languages != "All") + console.log(settings.maxResultsPerResolution); + if (settings.maxResults !== null) + document.getElementById("maxResults").value = settings.maxResults; + if (settings.maxResultsPerResolution !== null) + document.getElementById("maxResultsPerResolution").value = settings.maxResultsPerResolution; + if (settings.maxSize !== null) + document.getElementById("maxSize").value = settings.maxSize / 1073741824; + if (settings.debridService !== null) + document.getElementById("debridService").value = settings.debridService; + if (settings.debridApiKey !== null) + document.getElementById("debridApiKey").value = settings.debridApiKey; + if (settings.debridStreamProxyPassword !== null) + document.getElementById("debridStreamProxyPassword").value = settings.debridStreamProxyPassword; + if (settings.indexers !== null) + document.getElementById("indexers").value = settings.indexers; + if (settings.languages !== null && settings.languages != "All") document.getElementById("languages").value = settings.languages; - if (settings.resolutions != "All") + if (settings.resolutions !== null && settings.resolutions != "All") document.getElementById("resolutions").value = settings.resolutions; - if (settings.resultFormat != "All") + if (settings.resultFormat !== null && settings.resultFormat != "All") document.getElementById("resultFormat").value = settings.resultFormat; } diff --git a/comet/utils/models.py b/comet/utils/models.py index bce3c78..7c0e1c2 100644 --- a/comet/utils/models.py +++ b/comet/utils/models.py @@ -93,18 +93,27 @@ def check_indexers(cls, v, values): @field_validator("maxResults") def check_max_results(cls, v): + if not isinstance(v, int): + v = 0 + if v < 0: v = 0 return v @field_validator("maxResultsPerResolution") def check_max_results_per_resolution(cls, v): + if not isinstance(v, int): + v = 0 + if v < 0: v = 0 return v @field_validator("maxSize") def check_max_size(cls, v): + if not isinstance(v, int): + v = 0 + if v < 0: v = 0 return v diff --git a/pyproject.toml b/pyproject.toml index 69a4cc9..222dbe4 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ orjson = "*" asyncpg = "*" aiosqlite = "*" jinja2 = "*" -rank-torrent-name = "1.2.3" +rank-torrent-name = "*" parsett = "*"