aboutsummaryrefslogtreecommitdiff
path: root/snooper.py
blob: 489ea3777f625277fba73a212d7a0f636ecaf5c5 (plain)
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
import praw
import readability
import os
import time
from vaderSentiment.vaderSentiment import SentimentIntensityAnalyzer

def donotcolourmeplease():
	global red, yellow, green, purple, white, reset, blue
	red = ""
	green = ""
	yellow = ""
	purple = ""
	white = ""
	reset = ""
	blue = ""

def colourmeplease():
	global red, purple, green, yellow, white, reset, blue
	red = "\033[1;31m"
	green = "\033[1;32m"
	blue = "\033[1;34m"
	yellow = "\033[1;33m"
	purple = "\033[1;35m"
	white = "\033[1;37m"
	reset = "\033[39m"



analyser = SentimentIntensityAnalyzer()

reddit = praw.Reddit(client_id='0YYkleuCm6H9yQ', client_secret='aljmxJ3YbkDheiEt8KknwpsKVqo',  user_agent='Snooper by navanchauhan')

username = "PrudentWish"

redditor = reddit.redditor(username)


def getCommentsKarma():
	commentsKarma = redditor.comment_karma
	return commentsKarma
def getPostsKarma():
	postsKarma = redditor.link_karma
	return postsKarma
def getComments():
	comments = [  ]
	for i in redditor.comments.new(limit=1000):
		ib = i.body
		comments.append(ib)
	return comments
def getPosts():
	posts = [ ]
	for i in redditor.submissions.new(limit=1000):
		posts.append(i)
	return posts

def isMod():
	answer = redditor.is_mod
	print(white, "Is Mod?", yellow, answer, reset)
def isEmployee():
	answer = redditor.is_employee
	print(white, "Is Employee?", yellow, answer, reset)
def isgold():
	answer = redditor.is_gold
	print(white, "Gilded Currently?", yellow, answer, reset)
def hasVerifiedEmail():
	answer = redditor.has_verified_email
	print(white, "Veriefied Email?", yellow, answer, reset)
def createdOn():
	answer = redditor.created_utc
	answer = time.ctime(answer)
	print(white, "Account Created On:", yellow, answer, reset)

def performMagic():
	comments = []
	scores = []
	text = ""
	for i in redditor.comments.top(limit=1000):
		txt = i.body
		comments.append(txt)
		text += str(", " + i.body)
		score = i.score
		scores.append(score)
	print(white, "Most Downvoted Comment: \n", red, comments[-1], white, "\nScore: \n", red, scores[-1], reset)
	print(white, "Most Upvoted Comment: \n", yellow, comments[0], white, "\nScore: \n", yellow, scores[0], reset) 
	results = readability.getmeasures(text, lang='en')
	print(white, "Reading Ease: ", yellow, results['readability grades']['FleschReadingEase'], reset)
	score = analyser.polarity_scores(text)
	lb = score['compound']
	print(white, "Sentiment Analysis", reset)
	if(lb >= 0.75):
		print(blue, "Cheerful Person", reset)
	elif(lb >= 0.45):
		print(purple, "Neutral boi", reset)
	else:
		print(red, "Depressed Soul", reset)

def printDetails():
	print(username.center(100))
	print("Karma Breakdown")
	print("Comments:", redditor.comment_karma)
	print("Posts:", redditor.link_karma)
	allcomments = []
	for comments in redditor.comments.new(limit=1000):
		allcomments.append(allcomments)
	print("No. of Comments:", len(allcomments))
	allposts = []
	for posts in redditor.submissions.new(limit=1000):
		allposts.append(allposts)
	print("No. of Posts:", len(allposts))


#printDetails()
def calculateEtPrint():
	print(purple)
	print(username.center(100))
	print(reset)
	commentsKarma = getCommentsKarma()
	postsKamra = getPostsKarma()
	Comments = getComments()
	Posts = getPosts()
	AvgCommentKarma = commentsKarma/len(Comments)
	AvgPostKarma = postsKamra/len(Posts)
	print(white, "Total Karma from Comments: ", yellow, commentsKarma, reset)
	print(white, "TotaL Karma from Posts:", yellow,  postsKamra, reset)
	print(white, "Avg. Posts Karma:", yellow, AvgPostKarma, reset)
	print(white, "Avg. Comments Karma", yellow, AvgCommentKarma, reset)
	isMod()
	isEmployee()
	isgold()
	createdOn()
	performMagic()

if(os.name == "posix" or "darwin" or "linux"):
	colourmeplease()
else:
	donotcolourmeplease()

#result()
calculateEtPrint()