-
Notifications
You must be signed in to change notification settings - Fork 0
/
Reddit Award Calculator.py
77 lines (63 loc) · 2.58 KB
/
Reddit Award Calculator.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
import csv
import praw
from config import *
# todo comment id finder
# todo .csv file maker
# todo subbreddit id to identify the subreddit
r = praw.Reddit(client_id= REDDIT_CLIENT_ID,
client_secret=REDDIT_CLIENT_SECRET,
user_agent="MyFirstScript")
exceptions = {"Platinum": 700,
"Mindblowingly Cool Post": 700,
"Great Contributions to /r/pics": 700}
def award_calc(id, SorC="s"):
submission = None
if SorC == "s":
submission = r.submission(id)
elif SorC == "c":
submission = r.comment(id)
total_coins = 0
total_premium = 0
total_count = 0
total_coin_reward = 0
for award in submission.all_awardings:
if award["name"] in exceptions:
if award["name"] == "Platinum":
award['coin_reward'] = exceptions["Platinum"]
if award["name"] == "Mindblowingly Cool Post":
award['coin_reward'] = exceptions["Mindblowingly Cool Post"]
if award["name"] == "Great Contributions to /r/pics":
award['coin_reward'] = exceptions["Great Contributions to /r/pics"]
total_coins += int(award['coin_price']) * int(award["count"])
total_count += int(award['count'])
total_coin_reward += int(award['coin_reward']) * int(award["count"])
if int(award['days_of_premium']):
total_premium += int(award['days_of_premium']) * int(award["count"])
print(award['name'], int(award['count']), int(award['days_of_premium'] * award['count']),
int(award['coin_reward']), sep="--")
print(f'''
Total coins spent:{total_coins}
Total premium:{total_premium}
Total count:{total_count}
Total coin reward:{total_coin_reward}
Dollars spent:{total_coins / 500 * 1.99}$
''')
def awards_list(id,SorC="s"):
submission = None
if SorC == "s":
submission = r.submission(id)
elif SorC == "c":
submission = r.comment(id)
f = open(f'Reddit_Awards.csv', 'a', newline='')
writer = csv.writer(f)
if 'Name of award' not in open('Reddit_Awards.csv').read():
writer.writerow(['Name of award', 'Coin Price', 'Days of Premium', 'Coin Reward'])
for award in submission.all_awardings:
if award["name"] in open('Reddit_Awards.csv').read():
pass
else:
writer = csv.writer(f)
writer.writerow([award['name'], award['coin_price'], award['days_of_premium'], award['coin_reward']])
print(award['name'], award['coin_price'], award['days_of_premium'], award['coin_reward'])
f.close()
awards_list('eewq6i', 's')