-
Notifications
You must be signed in to change notification settings - Fork 0
/
loliread.py
37 lines (31 loc) · 889 Bytes
/
loliread.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
import webbrowser
import pickle
print('Welcome to LOLiPop')
path = input('Meme path (Without the LOL): ')
with open(path+'.lol', 'rb') as f:
meme = pickle.load(f)
html = """<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>LOLiPop</title>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
text-align: center;
}
</style>
</head>
<body>
"""
for element in meme:
if element['type'] == 'txt':
html += f'<p>{element["data"]}</p>\n'
elif element['type'] == 'img':
html += f'''<img src="{element["data"]}">\n'''
else:
print(f'ELEMENT OF TYPE ({element["type"]}) IS NOT SUPPORTED')
with open(path+'.renderedhtml.html', 'w') as f:
f.write(html)
html += '</body>'
webbrowser.open(path+'.renderedhtml.html')