-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgen.py
More file actions
155 lines (142 loc) Β· 5.3 KB
/
gen.py
File metadata and controls
155 lines (142 loc) Β· 5.3 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
import supabase
from dotenv import load_dotenv
import requests
import os
from uuid import uuid4
from io import BytesIO
import random
load_dotenv()
url = os.environ.get("SUPABASE_URL")
key = os.environ.get("SUPABASE_KEY")
supabase = supabase.create_client(url, key)
users = supabase.table("zap_users")
posts_ = supabase.table("zap_posts")
tags_ = [
"CutePets",
"PetLovers",
"PetsOfInstagram",
"PetPhotography",
"FurryFriends",
"AnimalLovers",
"Instapets",
"PetGoals",
"FurBabies",
"BestFriends",
"PetCuteness",
"Pawsome",
"Fluffy",
"PetSnuggles"
]
captions = [
"Purrfectly content with my feline friend πΎ",
"Life is better with a cat by your side π±",
"Pawsitively adorable moments with my kitty π»",
"Whiskers and purrs make everything better π",
"Feline good with this little furball πΎ",
"Cat naps and cozy cuddles π€π±",
"A house isn't a home without a cat π β€οΈ",
"Paws and reflect: cats make life purrfect πΎ",
"Living that cat life π±β¨",
"Every cat is a masterpiece πΌοΈπ±",
"Whisker Wednesday π±β¨",
"Just another day in paradise with my cat π΄π±",
"Caught in a purrfect moment πΎ",
"Cats are like potato chips, you canβt have just one π±",
"Fur real though, my cat is the cutest π»",
"The more people I meet, the more I love my cat π±β€οΈ",
"Purring into the weekend like... πΊπ",
"Cats leave paw prints on your heart πΎβ€οΈ",
"You had me at meow π±π",
"Just a girl/boy and her/his cat πΎ",
"Home is where the cat is π‘π±",
"My therapist has whiskers and a tail π",
"Adopt a cat, gain a best friend πΎ",
"Kittens are angels with whiskers π±π",
"Having a purrfectly good time πΎ",
"Pawsitive vibes only π±β¨",
"Not all heroes wear capes, some have fur π¦ΈββοΈπ±",
"My cat is my best friend and my pillow πΊποΈ",
"Meow is the time for a catnap π€",
"Love me, love my cat π±β€οΈ",
"Catitude: having a cat-like attitude πΎ",
"Caturday vibes every day π±π",
"Happiness is a warm cat π±π₯",
"Whiskers, purrs, and playful pounces πΎ",
"Live, love, purr π±β€οΈ",
"Cats are the purrfect companions πΎ",
"Cat hair, don't care π±",
"Fur-tunately, I have a cat π±β¨",
"Feline fine today πΎ",
"Cats make life meowgical π±β¨",
"Snuggle time with my furry friend πΎ",
"Every day is Caturday with my cat π±",
"My cat thinks I'm pawsome πΎ",
"Purrfection in every whisker π±",
"Cat's out of the bag πΎ",
"My cat completes me π±β€οΈ",
"In a purrfect world, every home would have a cat πΎ",
"Napping like a cat π±π€",
"Paws and enjoy the moment πΎ",
"Cats: because people suck sometimes π±",
"Keep calm and love cats πΎ",
"Living my best cat life π±β¨",
"Crazy cat person? More like dedicated cat lover πΎ",
"The purrfect companion π±β€οΈ",
"Purrs and whisker kisses πΎ",
"Fur-iendship goals π±β¨",
"My heart belongs to my cat πΎ",
"Whisker kisses are the best π½",
"Cats rule, dogs drool π±",
"Pawsome adventures with my cat πΎ",
"Kneading some love π±β€οΈ",
"Just a cat and her/his human πΎ",
"I work hard so my cat can have a better life π±",
"Cat kisses fix everything πΎ",
"Purrspective is everything π±β¨",
"A cat's love is fur real πΎ",
"In ancient times, cats were worshipped. They haven't forgotten this π±",
]
def create_user():
data = requests.get("https://randomuser.me/api/").json()['results'][0]
user_obj = {
"_id": str(uuid4()),
"name": f"{data['name']['first']} {data['name']['last']}",
"email": data['email'],
"username": data['login']['username'],
"bio": f"My name is {data['name']['title']} {data['name']['first']} {data['name']['last']}, I live in {data['location']['street']['name']} street, {data['location']['city']}, {data['location']['state']}, {data['location']['postcode']}, {data['location']['country']}",
"posts": [],
"history": [],
"followers": [],
"following": []
}
users.insert(user_obj).execute()
return user_obj
def upload_file(location, file, content_type):
key = supabase.storage.from_("Zap")\
.upload(file=file,
path=location,
file_options={"content-type": content_type}).json()['Key']
return f"{os.environ.get('SUPABASE_URL')}/storage/v1/object/public/{key}"
def create_post(user):
post_id = str(uuid4())
img = requests.get(f"https://cataas.com/cat").content
tags = random.sample(tags_, 4)
mime = "image/jpg"
url = upload_file(f"Posts/{post_id}.{mime.split('/')[1]}", img, mime)
post = {
"_id": post_id,
"caption": random.choice(captions),
"img_url": url,
"user": user,
"likes": [],
"comments": [],
"tags": tags
}
posts_.insert(post).execute()
posts = users.select("posts").eq("_id", user).execute().model_dump()['data'][0]['posts']
posts.append(post_id)
users.update({"posts": posts}).eq("_id", user).execute()
for i in range(10):
usr = create_user()
for j in range(10):
create_post(usr['_id'])