[civitai] add 'sort' & 'period' options (#8426)
This commit is contained in:
@@ -2098,6 +2098,45 @@ Description
|
|||||||
``None`` and ``Soft`` rated images,
|
``None`` and ``Soft`` rated images,
|
||||||
|
|
||||||
|
|
||||||
|
extractor.civitai.period
|
||||||
|
------------------------
|
||||||
|
Type
|
||||||
|
``string``
|
||||||
|
Default
|
||||||
|
``"AllTime"``
|
||||||
|
Description
|
||||||
|
Sets the ``period`` parameter
|
||||||
|
when paginating over results.
|
||||||
|
Supported Values
|
||||||
|
* ``"AllTime"``
|
||||||
|
* ``"Year"``
|
||||||
|
* ``"Month"``
|
||||||
|
* ``"Week"``
|
||||||
|
* ``"Day"``
|
||||||
|
|
||||||
|
|
||||||
|
extractor.civitai.sort
|
||||||
|
----------------------
|
||||||
|
Type
|
||||||
|
``string``
|
||||||
|
Default
|
||||||
|
``"Newest"``
|
||||||
|
Description
|
||||||
|
Sets the ``sort`` parameter
|
||||||
|
when paginating over results.
|
||||||
|
Supported Values
|
||||||
|
* ``"Newest"``
|
||||||
|
* ``"Oldest"``
|
||||||
|
* ``"Most Reactions"``
|
||||||
|
* ``"Most Comments"``
|
||||||
|
* ``"Most Collected"``
|
||||||
|
Special Values
|
||||||
|
``"asc"``
|
||||||
|
Ascending order (``"Oldest"``)
|
||||||
|
``"desc"`` | ``"reverse"``
|
||||||
|
Descending order (``"Newest"``)
|
||||||
|
|
||||||
|
|
||||||
extractor.civitai.quality
|
extractor.civitai.quality
|
||||||
-------------------------
|
-------------------------
|
||||||
Type
|
Type
|
||||||
|
|||||||
@@ -215,6 +215,8 @@
|
|||||||
"include" : ["user-images", "user-videos"],
|
"include" : ["user-images", "user-videos"],
|
||||||
"metadata": false,
|
"metadata": false,
|
||||||
"nsfw" : true,
|
"nsfw" : true,
|
||||||
|
"period" : "AllTime",
|
||||||
|
"sort" : "Newest",
|
||||||
"quality" : "original=true",
|
"quality" : "original=true",
|
||||||
"quality-videos": "quality=100"
|
"quality-videos": "quality=100"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -342,9 +342,9 @@ class CivitaiModelExtractor(CivitaiExtractor):
|
|||||||
params = {
|
params = {
|
||||||
"modelVersionId": version["id"],
|
"modelVersionId": version["id"],
|
||||||
"prioritizedUserIds": (user["id"],),
|
"prioritizedUserIds": (user["id"],),
|
||||||
"period": "AllTime",
|
"period" : self.api._param_period(),
|
||||||
"sort": "Most Reactions",
|
"sort" : self.api._param_sort(),
|
||||||
"limit": 20,
|
"limit" : 20,
|
||||||
"pending": True,
|
"pending": True,
|
||||||
}
|
}
|
||||||
images = self.api.images(params, defaults=False)
|
images = self.api.images(params, defaults=False)
|
||||||
@@ -391,8 +391,8 @@ class CivitaiCollectionExtractor(CivitaiExtractor):
|
|||||||
|
|
||||||
params = {
|
params = {
|
||||||
"collectionId" : cid,
|
"collectionId" : cid,
|
||||||
"period" : "AllTime",
|
"period" : self.api._param_period(),
|
||||||
"sort" : "Newest",
|
"sort" : self.api._param_sort(),
|
||||||
"browsingLevel" : self.api.nsfw,
|
"browsingLevel" : self.api.nsfw,
|
||||||
"include" : ("cosmetics",),
|
"include" : ("cosmetics",),
|
||||||
}
|
}
|
||||||
@@ -719,8 +719,8 @@ class CivitaiTrpcAPI():
|
|||||||
if defaults:
|
if defaults:
|
||||||
params = self._merge_params(params, {
|
params = self._merge_params(params, {
|
||||||
"useIndex" : True,
|
"useIndex" : True,
|
||||||
"period" : "AllTime",
|
"period" : self._param_period(),
|
||||||
"sort" : "Newest",
|
"sort" : self._param_sort(),
|
||||||
"withMeta" : False, # Metadata Only
|
"withMeta" : False, # Metadata Only
|
||||||
"fromPlatform" : False, # Made On-Site
|
"fromPlatform" : False, # Made On-Site
|
||||||
"browsingLevel": self.nsfw,
|
"browsingLevel": self.nsfw,
|
||||||
@@ -733,8 +733,8 @@ class CivitaiTrpcAPI():
|
|||||||
def images_gallery(self, model, version, user):
|
def images_gallery(self, model, version, user):
|
||||||
endpoint = "image.getImagesAsPostsInfinite"
|
endpoint = "image.getImagesAsPostsInfinite"
|
||||||
params = {
|
params = {
|
||||||
"period" : "AllTime",
|
"period" : self._param_period(),
|
||||||
"sort" : "Newest",
|
"sort" : self._param_sort(),
|
||||||
"modelVersionId": version["id"],
|
"modelVersionId": version["id"],
|
||||||
"modelId" : model["id"],
|
"modelId" : model["id"],
|
||||||
"hidden" : False,
|
"hidden" : False,
|
||||||
@@ -768,9 +768,9 @@ class CivitaiTrpcAPI():
|
|||||||
|
|
||||||
if defaults:
|
if defaults:
|
||||||
params = self._merge_params(params, {
|
params = self._merge_params(params, {
|
||||||
"period" : "AllTime",
|
"period" : self._param_period(),
|
||||||
"periodMode" : "published",
|
"periodMode" : "published",
|
||||||
"sort" : "Newest",
|
"sort" : self._param_sort(),
|
||||||
"pending" : False,
|
"pending" : False,
|
||||||
"hidden" : False,
|
"hidden" : False,
|
||||||
"followed" : False,
|
"followed" : False,
|
||||||
@@ -797,9 +797,9 @@ class CivitaiTrpcAPI():
|
|||||||
if defaults:
|
if defaults:
|
||||||
params = self._merge_params(params, {
|
params = self._merge_params(params, {
|
||||||
"browsingLevel": self.nsfw,
|
"browsingLevel": self.nsfw,
|
||||||
"period" : "AllTime",
|
"period" : self._param_period(),
|
||||||
"periodMode" : "published",
|
"periodMode" : "published",
|
||||||
"sort" : "Newest",
|
"sort" : self._param_sort(),
|
||||||
"followed" : False,
|
"followed" : False,
|
||||||
"draftOnly" : False,
|
"draftOnly" : False,
|
||||||
"pending" : True,
|
"pending" : True,
|
||||||
@@ -821,7 +821,7 @@ class CivitaiTrpcAPI():
|
|||||||
if defaults:
|
if defaults:
|
||||||
params = self._merge_params(params, {
|
params = self._merge_params(params, {
|
||||||
"browsingLevel": self.nsfw,
|
"browsingLevel": self.nsfw,
|
||||||
"sort" : "Newest",
|
"sort" : self._param_sort(),
|
||||||
})
|
})
|
||||||
|
|
||||||
params = self._type_params(params)
|
params = self._type_params(params)
|
||||||
@@ -835,7 +835,7 @@ class CivitaiTrpcAPI():
|
|||||||
def orchestrator_queryGeneratedImages(self):
|
def orchestrator_queryGeneratedImages(self):
|
||||||
endpoint = "orchestrator.queryGeneratedImages"
|
endpoint = "orchestrator.queryGeneratedImages"
|
||||||
params = {
|
params = {
|
||||||
"ascending": False,
|
"ascending": True if self._param_sort() == "Oldest" else False,
|
||||||
"tags" : ("gen",),
|
"tags" : ("gen",),
|
||||||
"authed" : True,
|
"authed" : True,
|
||||||
}
|
}
|
||||||
@@ -908,6 +908,21 @@ class CivitaiTrpcAPI():
|
|||||||
params[name] = [type(item) for item in value]
|
params[name] = [type(item) for item in value]
|
||||||
return params
|
return params
|
||||||
|
|
||||||
|
def _param_period(self):
|
||||||
|
if period := self.extractor.config("period"):
|
||||||
|
return period
|
||||||
|
return "AllTime"
|
||||||
|
|
||||||
|
def _param_sort(self):
|
||||||
|
if sort := self.extractor.config("sort"):
|
||||||
|
s = sort[0].lower()
|
||||||
|
if s in "drn":
|
||||||
|
return "Newest"
|
||||||
|
if s in "ao":
|
||||||
|
return "Oldest"
|
||||||
|
return sort
|
||||||
|
return "Newest"
|
||||||
|
|
||||||
|
|
||||||
def _bool(value):
|
def _bool(value):
|
||||||
return value == "true"
|
return value == "true"
|
||||||
|
|||||||
Reference in New Issue
Block a user