Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions PixivServer/models/pixiv_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
PixivMasterTag,
PixivMemberPortfolio,
PixivSeriesInfo,
PixivStats,
PixivTagInfo,
PixivTagTranslation,
)
Expand All @@ -30,6 +31,7 @@
"PixivMasterTag",
"PixivMemberPortfolio",
"PixivSeriesInfo",
"PixivStats",
"PixivTagInfo",
"PixivTagTranslation",
]
32 changes: 31 additions & 1 deletion PixivServer/repository/pixivutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
PixivMasterTag,
PixivMemberPortfolio,
PixivSeriesInfo,
PixivStats,
PixivTagInfo,
PixivTagTranslation,
)
Expand Down Expand Up @@ -102,6 +103,9 @@ def get_member_data_by_id(self, member_id: int) -> PixivMemberPortfolio:
]

return PixivMemberPortfolio(member=member, images=images)
except KeyError:
# Expected when the member is not yet in the DB; let the caller decide.
raise
except Exception as e:
logger.error(f"Error getting member data for {member_id}: {e}")
raise
Expand Down Expand Up @@ -531,14 +535,40 @@ def get_image_data_by_id(self, image_id: int) -> PixivImageComplete:
last_update_date=date_row[4]
)

# Get server-mode engagement stats
cursor.execute(
"""SELECT image_id, view_count, like_count, bookmark_count,
comment_count, response_count, created_date, last_update_date
FROM pixiv_stats
WHERE image_id = ?""",
(image_id,)
)
stats_row = cursor.fetchone()
stats = None
if stats_row is not None:
stats = PixivStats(
image_id=stats_row[0],
view_count=stats_row[1],
like_count=stats_row[2],
bookmark_count=stats_row[3],
comment_count=stats_row[4],
response_count=stats_row[5],
created_date=stats_row[6],
last_update_date=stats_row[7]
)

return PixivImageComplete(
image=image,
member=member,
pages=pages,
series=series,
tags=tags,
dates=dates
dates=dates,
stats=stats
)
except KeyError:
# Expected when the image (or its member) is not yet in the DB; let the caller decide.
raise
except Exception as e:
logger.error(f"Error getting image data for {image_id}: {e}")
raise
Expand Down
2 changes: 1 addition & 1 deletion PixivServer/routers/download_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ async def queue_delete_artwork_by_id(

Args:
artwork_id: The Pixiv artwork ID to delete
delete_metadata: If True (default), also deletes metadata (date_info, ai_info, series).
delete_metadata: If True (default), also deletes metadata (date_info, stats, ai_info, series).
If False, only deletes artwork files and basic records.

This is a queue operation as it operates on a sqlite database.
Expand Down
1 change: 1 addition & 0 deletions PixivServer/service/pixiv.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,7 @@ def delete_artwork_by_id(self, request: DeleteArtworkByIdRequest):

if request.delete_metadata:
cursor.execute("DELETE FROM pixiv_date_info WHERE image_id = ?", (request.artwork_id,))
cursor.execute("DELETE FROM pixiv_stats WHERE image_id = ?", (request.artwork_id,))
cursor.execute("DELETE FROM pixiv_ai_info WHERE image_id = ?", (request.artwork_id,))
cursor.execute("DELETE FROM pixiv_image_to_series WHERE image_id = ?", (request.artwork_id,))
PixivHelper.print_and_log("info", f"Deleted artwork and metadata from database: {request.artwork_id}")
Expand Down
2 changes: 2 additions & 0 deletions PixivServerCommon/pixivutil_server_common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
PixivMasterTag,
PixivMemberPortfolio,
PixivSeriesInfo,
PixivStats,
PixivTagInfo,
PixivTagTranslation,
QueueTaskResponse,
Expand All @@ -30,6 +31,7 @@
"PixivMasterTag",
"PixivMemberPortfolio",
"PixivSeriesInfo",
"PixivStats",
"PixivTagInfo",
"PixivTagTranslation",
"QueueTaskResponse",
Expand Down
12 changes: 12 additions & 0 deletions PixivServerCommon/pixivutil_server_common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,17 @@ class PixivDateInfo(BaseModel):
last_update_date: str


class PixivStats(BaseModel):
image_id: int
view_count: int
like_count: int
bookmark_count: int
comment_count: int
response_count: int
created_date: str
last_update_date: str


class PixivTagTranslation(BaseModel):
tag_id: str
translation_type: str
Expand Down Expand Up @@ -134,6 +145,7 @@ class PixivImageComplete(BaseModel):
series: tuple[PixivImageToSeries, PixivMasterSeries] | None = Field(None)
tags: list[tuple[PixivImageToTag, PixivMasterTag, PixivTagTranslation | None]]
dates: PixivDateInfo | None = Field(None)
stats: PixivStats | None = Field(None)


class PixivTagInfo(BaseModel):
Expand Down
2 changes: 2 additions & 0 deletions PixivUtilClient/pixivutil_client/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
PixivMasterTag,
PixivMemberPortfolio,
PixivSeriesInfo,
PixivStats,
PixivTagInfo,
PixivTagTranslation,
QueueTaskResponse,
Expand All @@ -44,6 +45,7 @@
"PixivMasterTag",
"PixivMemberPortfolio",
"PixivSeriesInfo",
"PixivStats",
"PixivTagInfo",
"PixivTagTranslation",
"QueueTaskResponse",
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ license = { file = "LICENSE" }
authors = [
{ name = "psilabs-dev" }
]
version = "2.4.5"
version = "2.4.6"
dependencies = [
"aiofiles>=25.1.0",
"celery>=5.5.3",
Expand Down
2 changes: 1 addition & 1 deletion uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading