diff --git a/comet/api/endpoints/stream.py b/comet/api/endpoints/stream.py
index c464e72..417c571 100644
--- a/comet/api/endpoints/stream.py
+++ b/comet/api/endpoints/stream.py
@@ -320,6 +320,7 @@ async def stream(
is_first = await is_first_search(media_id)
has_cached_results = len(torrent_manager.torrents) > 0
+ sort_mixed = config["sortCachedUncachedTogether"]
cached_results = []
non_cached_results = []
@@ -529,9 +530,14 @@ async def stream(
f"{request.url.scheme}://{request.url.netloc}/{b64config}/playback/{info_hash}/{torrent['fileIndex'] if torrent['cached'] and torrent['fileIndex'] is not None else 'n'}/{result_season}/{result_episode}/{quote(torrent_title)}?name={quote(title)}"
)
- if torrent["cached"]:
+ if sort_mixed:
+ cached_results.append(the_stream)
+ elif torrent["cached"]:
cached_results.append(the_stream)
else:
non_cached_results.append(the_stream)
+ if sort_mixed:
+ return {"streams": cached_results}
+
return {"streams": cached_results + non_cached_results}
diff --git a/comet/core/models.py b/comet/core/models.py
index a5a1a29..26dbf6e 100644
--- a/comet/core/models.py
+++ b/comet/core/models.py
@@ -683,6 +683,7 @@ rtn_ranking_default = DefaultRanking()
class ConfigModel(BaseModel):
cachedOnly: Optional[bool] = False
+ sortCachedUncachedTogether: Optional[bool] = False
removeTrash: Optional[bool] = True
resultFormat: Optional[List[str]] = ["all"]
maxResultsPerResolution: Optional[int] = 0
diff --git a/comet/templates/index.html b/comet/templates/index.html
index c1475b8..02f9caf 100644
--- a/comet/templates/index.html
+++ b/comet/templates/index.html
@@ -450,6 +450,7 @@
help-text="Torrents ranked below this value will be excluded from results.">
Show Cached
Only
+ Sort Cached and Uncached Together
Allow
English in Languages
@@ -756,6 +757,7 @@
const maxResultsPerResolution = document.getElementById("maxResultsPerResolution").value;
const maxSize = document.getElementById("maxSize").value;
const cachedOnly = document.getElementById("cachedOnly").checked;
+ const sortCachedUncachedTogether = document.getElementById("sortCachedUncachedTogether").checked;
const removeTrash = document.getElementById("removeTrash").checked;
const allowEnglishInLanguages = document.getElementById("allowEnglishInLanguages").checked;
const removeUnknownLanguages = document.getElementById("removeUnknownLanguages").checked;
@@ -773,6 +775,7 @@
maxResultsPerResolution: parseInt(maxResultsPerResolution),
maxSize: parseFloat(maxSize * 1073741824),
cachedOnly: cachedOnly,
+ sortCachedUncachedTogether: sortCachedUncachedTogether,
removeTrash: removeTrash,
resultFormat: selectedResultFormat,
debridService: debridService,
@@ -835,6 +838,8 @@
function populateFormFromSettings(settings) {
if (settings.cachedOnly !== null)
document.getElementById("cachedOnly").checked = settings.cachedOnly;
+ if (settings.sortCachedUncachedTogether !== undefined && settings.sortCachedUncachedTogether !== null)
+ document.getElementById("sortCachedUncachedTogether").checked = settings.sortCachedUncachedTogether;
if (settings.removeTrash !== null)
document.getElementById("removeTrash").checked = settings.removeTrash;
if (settings.maxResultsPerResolution !== null)