Skip to content

Commit

Permalink
Fix: Stashbox scene with invalid date value is created in Stash app w…
Browse files Browse the repository at this point in the history
…ithout date instead of printing errors
  • Loading branch information
MinasukiHikimuna committed Aug 22, 2024
1 parent 6f83c32 commit 586250e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 27 deletions.
2 changes: 1 addition & 1 deletion plugins/CompleteTheStash/CompleteTheStash.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: CompleteTheStash
description: Finds missing scenes for selected performers and creates missing scene metadata to another missing Stash instance. You can use either StashDB or TPDB or both as a source for missing scenes.
version: 0.4.4
version: 0.4.5
url: https://github.com/MinasukiHikimuna/MidnightRider-Stash/
exec:
- python
Expand Down
49 changes: 23 additions & 26 deletions plugins/CompleteTheStash/StashCompleter.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,37 +58,32 @@ def create_scene(self, scene, performer_ids, studio_id):
missing_tag = self.missing_stash_client.get_or_create_tag(tag["name"])
tag_ids.append(missing_tag["id"])

new_scene = {
"title": title,
"code": code,
"details": scene["details"],
"url": studio_url,
"studio_id": studio_id,
"performer_ids": performer_ids,
"tag_ids": tag_ids,
"cover_image": cover_image,
"stash_ids": [
{
"endpoint": self.config.get("stashboxEndpoint"),
"stash_id": stash_id,
}
],
}

try:
# Ensure the date is in the correct format
formatted_date = (
datetime.strptime(date, "%Y-%m-%d").date().isoformat() if date else None
)
new_scene["date"] = formatted_date
except ValueError:
self.logger.error(
f"Invalid date format for scene '{title}': {date} (Stashbox ID: {stash_id})"
)
return None

result = self.missing_stash_client.create_scene(
{
"title": title,
"code": code,
"details": scene["details"],
"url": studio_url,
"date": formatted_date,
"studio_id": studio_id,
"performer_ids": performer_ids,
"tag_ids": tag_ids,
"cover_image": cover_image,
"stash_ids": [
{
"endpoint": self.config.get("stashboxEndpoint"),
"stash_id": stash_id,
}
],
}
)
pass

result = self.missing_stash_client.create_scene(new_scene)
if result:
return result["id"]

Expand Down Expand Up @@ -228,7 +223,9 @@ def process_performers(self):
),
None,
)
self.logger.debug(f"Performer {local_performer_name}: Stash ID {performer_stash_id}")
self.logger.debug(
f"Performer {local_performer_name}: Stash ID {performer_stash_id}"
)
if not performer_stash_id:
self.logger.warning(
f"Performer {local_performer_name} does not have a Stashbox ID for endpoint {self.config.get('stashboxEndpoint')}. Skipping..."
Expand Down

0 comments on commit 586250e

Please sign in to comment.