Skip to content

Commit

Permalink
fix: webui config
Browse files Browse the repository at this point in the history
  • Loading branch information
g0ldyy committed Nov 18, 2024
1 parent 9d30b6a commit 0487af5
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 11 deletions.
28 changes: 18 additions & 10 deletions comet/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
9 changes: 9 additions & 0 deletions comet/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ orjson = "*"
asyncpg = "*"
aiosqlite = "*"
jinja2 = "*"
rank-torrent-name = "1.2.3"
rank-torrent-name = "*"
parsett = "*"


Expand Down

0 comments on commit 0487af5

Please sign in to comment.