mimizukari commited on
Commit
bd8fcb0
·
verified ·
1 Parent(s): dd9cdfe

bug fixes to newly added functions.

Browse files
Files changed (1) hide show
  1. randumbizer.py +22 -6
randumbizer.py CHANGED
@@ -59,7 +59,8 @@ class ContentGenerator:
59
  def _format_characters(self, lines, artists):
60
  counts = {"girl": 0, "boy": 0, "other": 0}
61
  characters = []
62
- sources = set()
 
63
 
64
  for line in lines:
65
  splits = line.split(", ")
@@ -79,7 +80,10 @@ class ContentGenerator:
79
 
80
  source_idx = 2 if char_type in ["girl", "boy", "other"] else 1
81
  if source_idx < len(splits):
82
- sources.add(splits[source_idx])
 
 
 
83
  splits.pop(source_idx)
84
  splits[0] = char_type
85
  characters.append(", ".join(splits))
@@ -105,6 +109,9 @@ class ContentGenerator:
105
 
106
  def main():
107
  generator = ContentGenerator()
 
 
 
108
  while True:
109
  user_input = input("\nEnter 'a' for artists, 'c' for anime, '1-6' [+tags], or search term: ").strip()
110
 
@@ -113,10 +120,19 @@ def main():
113
  elif user_input == "c":
114
  generator.get_anime_screenshot()
115
  elif user_input and user_input[0].isdigit():
116
- parts = user_input.split(maxsplit=1)
117
- num = min(int(parts[0]), 6)
118
- tags = [tag.strip() for tag in parts[1].split(',')] if len(parts) > 1 else None
119
- generator.process_character_lines(num, tags)
 
 
 
 
 
 
 
 
 
120
  else:
121
  generator.process_default(user_input if user_input else None)
122
 
 
59
  def _format_characters(self, lines, artists):
60
  counts = {"girl": 0, "boy": 0, "other": 0}
61
  characters = []
62
+ sources = []
63
+ seen_sources = set() # To track duplicates while preserving order
64
 
65
  for line in lines:
66
  splits = line.split(", ")
 
80
 
81
  source_idx = 2 if char_type in ["girl", "boy", "other"] else 1
82
  if source_idx < len(splits):
83
+ source = splits[source_idx]
84
+ if source not in seen_sources: # Only add if not seen before
85
+ sources.append(source)
86
+ seen_sources.add(source)
87
  splits.pop(source_idx)
88
  splits[0] = char_type
89
  characters.append(", ".join(splits))
 
109
 
110
  def main():
111
  generator = ContentGenerator()
112
+ # Immediate random output on start
113
+ generator.process_default()
114
+
115
  while True:
116
  user_input = input("\nEnter 'a' for artists, 'c' for anime, '1-6' [+tags], or search term: ").strip()
117
 
 
120
  elif user_input == "c":
121
  generator.get_anime_screenshot()
122
  elif user_input and user_input[0].isdigit():
123
+ # Check if input is just a number from 1-6
124
+ if user_input in ["1", "2", "3", "4", "5", "6"]:
125
+ num = int(user_input)
126
+ generator.process_character_lines(num)
127
+ # Check if there's a space after the number for tags
128
+ elif " " in user_input:
129
+ parts = user_input.split(maxsplit=1)
130
+ num = min(int(parts[0]), 6)
131
+ tags = [tag.strip() for tag in parts[1].split(',')]
132
+ generator.process_character_lines(num, tags)
133
+ else:
134
+ # Treat entire input as search term if no space and not just 1-6
135
+ generator.process_default(user_input)
136
  else:
137
  generator.process_default(user_input if user_input else None)
138