-
Notifications
You must be signed in to change notification settings - Fork 3
/
meme.py
152 lines (101 loc) · 3.3 KB
/
meme.py
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
import requests
from bs4 import BeautifulSoup as bs
import math
username = '' #imgflip account username
password = '' #imgflip account password
search = 'https://imgflip.com/memesearch?q='
lang = dict(map(reversed, LANGUAGES.items()))
#this existss only cause imgflip is a piece of shit who doesnt have the search integrated into their api
def SearchMeme(name):
search = 'https://imgflip.com/memesearch?q='
x = name.split()
for i in range(len(x)):
if i == 0:
search = search + x[i]
else:
search = search + '+' + x[i]
search = search + "&nsfw=on"
page = requests.get(search)
soup = bs(page.content, 'html5lib')
s = soup.findAll('a')
links = []
for i in s:
links.append(i['href'])
ids = []
for i in links:
x = i.split('/')
for i in range(0,len(x)):
if x[i] == "memetemplate":
ids.append(x[i+1])
try:
print(ids)
return ids[0]
except:
return "```template not found```"
#actually generates the meme using the imgflip api
def GenerateMeme(id,*args):
URL = 'https://api.imgflip.com/caption_image'
params = {
'username':username,
'password':password,
'template_id':id,
'text0':" ",
'text1':" ",
}
for i in range(0,len(args)):
params['text'+str(i)] = args[i]
response = requests.request('POST',URL,params=params).json()
data = response['data']
return(data['url'])
#just create the meme with the imgflip api cant add more than 2 texts cause their api is shit
def GetMeme(name,*args):
id = SearchMeme(name)
link = GenerateMeme(id,*args)
return link
def SearchEmoji(name):
search = 'https://api.kaomoji.moe/web/search?search='
x = name.split()
for i in range(len(x)):
if i == 0:
search = search + x[i]
else:
search = search + '+' + x[i]
page = requests.get(search)
soup = bs(page.content, 'html5lib')
s = soup.find('body').text
return(s)
#i dont know why i coded this im sorry
def generateUwU(input_text):
length = len(input_text)
output_text = ''
for i in range(length):
current_char = input_text[i]
previous_char = '&# 092;&# 048;'
if i > 0:
previous_char = input_text[i - 1]
if current_char == 'L' or current_char == 'R':
output_text += 'W'
elif current_char == 'l' or current_char == 'r':
output_text += 'w'
elif current_char == 'O' or current_char == 'o':
if previous_char == 'N' or previous_char == 'n' or previous_char == 'M' or previous_char == 'm':
output_text += "yo"
else:
output_text += current_char
else:
output_text += current_char
return output_text
#BUNNY
def bunny(inStr):
words = inStr.split(' ')
signLen = max([len(x) for x in words])
padLen = 0 if signLen >= 14 else math.floor((14 - signLen)/2)
out = " " * padLen + '┌' + "─" * signLen + "┐\n"
for i in words:
out += " " * padLen + "│" + i.ljust(signLen, ' ') + "│\n"
out += " " * padLen + "└" + "─" * signLen + """┘
(\__/) ││
(•ㅅ•) ││
/ づ"""
return out
print(bunny("this shit better work"))