Datasets:
File size: 1,578 Bytes
caba9f1 6d2f6d1 caba9f1 1fdeb7b 6d2f6d1 1fdeb7b 68a8b0d 1fdeb7b 68a8b0d 1fdeb7b 1316877 6d2f6d1 1316877 1fdeb7b caba9f1 6d2f6d1 caba9f1 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
import random
import pyperclip
def read_random_lines(artist_file="artist.txt", sheet_file="Sheet1.txt"):
with open(artist_file, "r") as artist, open(sheet_file, "r") as sheet:
artist_lines = artist.readlines()
sheet_lines = [line.strip() for line in sheet.readlines()]
user_input = ""
while True:
if user_input:
matching_lines = [line for line in sheet_lines if user_input in line]
if matching_lines:
sheet_line = random.choice(matching_lines)
else:
sheet_line = random.choice(sheet_lines)
else:
sheet_line = random.choice(sheet_lines)
splits = sheet_line.split(", ")
if splits[0] in ["1girl", "1boy", "1other"]:
insertion_index = 3
else:
insertion_index = 2
num_artist_lines = random.randint(1, 4)
selected_artist_lines = random.sample(artist_lines, num_artist_lines)
pre_artists = ", ".join(splits[:insertion_index])
artist_section = ", ".join(line.strip() for line in selected_artist_lines)
post_artists = ", ".join(splits[insertion_index:])
result = f"{pre_artists}, {artist_section}, {post_artists}" if post_artists else f"{pre_artists}, {artist_section}"
result = result.rstrip(", ")
print(result)
pyperclip.copy(result)
print("\nContent copied to clipboard.")
user_input = input("\nPress Enter for random or type search term...\n").strip()
read_random_lines() |