Skip to content

Instantly share code, notes, and snippets.

@GlazedBelmont
Created February 23, 2025 17:21
Show Gist options
  • Save GlazedBelmont/40a2f373e39c4a49048d823fd9e48b56 to your computer and use it in GitHub Desktop.
Save GlazedBelmont/40a2f373e39c4a49048d823fd9e48b56 to your computer and use it in GitHub Desktop.
python:
import re
def evaluate(book, context):
filename = ""
if book.series:
book.series = book.series.replace('+','and')
book.series = re.sub('[,:]', " -", book.series)
book.title = book.title.replace('+','and')
book.title = book.title.replace('"','')
book.title = book.title.replace('!','')
book.title = re.sub('[,:]', " -", book.title)
if not book.series: # If the book doesn't have a series (one-shots, etc)
filename = book.title
elif book.series == book.title: # Mangas, magazines, comics, etc
filename = book.series + "/" + book.series + ' - Vol. ' + str(int(book.series_index)).zfill(2)
else: # Named books
filename = book.series + "/" + book.series + ' - Vol. ' + str(int(book.series_index)).zfill(2) + ' - ' + book.title
# filename = book.series + "/" + book.series + ' - Vol. ' + str(int(book.series_index)).zfill(2) + ' - ' + book.title
return filename
#{series}/{series}{series_index:0>2s| - Vol. |} {series:contains({title},,- {title})}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment