-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathadd_meme.py
More file actions
29 lines (23 loc) · 709 Bytes
/
add_meme.py
File metadata and controls
29 lines (23 loc) · 709 Bytes
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
import json
data = json.loads(open("data/data.json", encoding="utf-8").read())
title = input("What is the title of the meme: ")
url = input("What is the url of the meme NOTE:Add ./ if it is a local file: ")
hashtags = [
"#programming",
"#programminghumor",
"#programmingmemes"
]
while True:
hashtag = input("Enter hashtag (press 'q' to stop): ")
if hashtag == 'q': break
hashtags.append(hashtag)
data.append({
"title": title,
"url": url,
"twitter_hahstags": hashtags
})
memes = json.dumps(data, indent=4)
memes = memes.replace(u"\u2018", "'").replace(u"\u2019", "'")
file = open("data/data.json", 'w', encoding="utf-8")
file.write(memes)
file.close()