Created
February 23, 2025 17:21
-
-
Save GlazedBelmont/40a2f373e39c4a49048d823fd9e48b56 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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