Skip to content

Instantly share code, notes, and snippets.

@maforget
Created October 11, 2023 02:38
Show Gist options
  • Save maforget/928a558ee37a2fdb850c79db670dcea1 to your computer and use it in GitHub Desktop.
Save maforget/928a558ee37a2fdb850c79db670dcea1 to your computer and use it in GitHub Desktop.
Fixed Proposed Values Script for ComicRack
'''
Description: This script is to filter out any comics with proposed values
as requested by shpanky of the ComicRack forums.
Author: Stonepaw (also known as Atchu), v0.3 by maforget
Version:
0.3
Copyright: This work is not copyrighted. Feel free to use and modify any or all of it.
'''
DEBUG = False
#ComicRack declarations
#@Name Proposed Values
#@Hook CreateBookList
#@Key findProposedValues
#@PCount 1
def findProposedValues(books, a, b):
#a will be a comma separated list of specific fields to locate
#split by commas and filter out valid values.
comics = []
options = set()
validvalues = set(["volume", "series", "count", "format", "number", "title", "year"])
try:
if a:
temp = a.split(",")
for value in temp[:]:
temp[temp.index(value)] = value.lower().strip()
options = set.intersection(validvalues, temp)
#If there were no options specified, then do all options
if len(options) == 0:
options = validvalues
#Main loop
for book in books:
if "series" in options:
if book.ShadowSeries:
if not book.Series:
comics.append(book)
continue
if "volume" in options:
if book.ShadowVolume > -1:
if book.Volume == -1:
comics.append(book)
continue
if "count" in options:
if book.ShadowCount > -1:
if book.Count == -1:
comics.append(book)
continue
if "format" in options:
if book.ShadowFormat:
if not book.Format:
comics.append(book)
continue
if "number" in options:
if book.ShadowNumber:
if not book.Number:
comics.append(book)
continue
if "title" in options:
if book.ShadowTitle:
if not book.Title:
comics.append(book)
continue
if "year" in options:
if book.ShadowYear > -1:
if book.Year == -1:
comics.append(book)
except Exception as ex:
print("Whoops, something went wrong:")
print(ex)
Debug(comics)
return comics
def Debug(book_list):
book_list = book_list if isinstance(book_list, list) else [book_list]
if DEBUG and len(book_list) > 0:
s, sep = 4, 50 #spaces, seperator
print("-" * sep)
fields = ["Series", "Volume", "Number", "Count", "Title", "Year", "Format"]
for book in book_list:
print("Caption: {}".format(book.Caption))
print("EnableProposed: {}".format(str(book.EnableProposed)))
for prop_name in fields:
print("{}:".format(prop_name))
print((" " * s) + "Proposed{0}: \"{1}\"".format(prop_name, getattr(book, 'Proposed' + prop_name, '')))
print((" " * s) + "Shadow{0}: \"{1}\"".format(prop_name, getattr(book, 'Shadow' + prop_name, '')))
print((" " * s) + "{0}: \"{1}\"".format(prop_name, getattr(book, prop_name, '')))
print("-" * sep)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment