forked from jctissier/Euro2016_TerminalApp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStreams.py
93 lines (68 loc) · 3.22 KB
/
Streams.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
#!/usr/bin/python
import praw
import re
from termcolor import colored, cprint
import sys
import webbrowser
# variables
user_agent = ("Link Getter")
r = praw.Reddit(user_agent=user_agent)
def login():
r.login('REDDIT_USERNAME', 'REDDIT_PASSWORD', disable_warning=True)
#Enter REDDIT USERNAME AND REDDIT PASSWORD
# NEEDED TO SEARCH FOR ALL THE LINKS
print_login = colored("Logging in...\n", 'yellow')
print(print_login)
def footballHighlights():
subreddit = r.get_subreddit("footballhighlights")
for submission in subreddit.get_hot(limit=15):
print("Highlight:", submission.title)
print_input1 = colored("Which game highlights do you want?\n")
highlight = input(print_input1)
cprint ("~~~~~~HOLD COMMAND + DOUBLE CLICK = Open link in browser ~~~~~~",'red')
for submission in subreddit.get_hot(limit=80):
if re.search(highlight, submission.title, re.IGNORECASE):
print("\nTitle: ", submission.title)
print (submission.selftext)
#Use this code below if you want to see the first comments (generates more links)
#comments = submission.comments
#for comment in comments[0:1]: # first comment is a bot moderator
#print(comment.body) # prints top comments starting from 2nd top comment
#print("\n")
restartProgram()
def sportLinks():
subreddit = r.get_subreddit("soccerstreams")
test = colored("Live games that you can stream...\n", 'yellow')
print(test)
for submission in subreddit.get_hot(limit=12):
print("Game Name:", submission.title)
print_input5 = colored("\n\nName of the game you want to watch: \n", 'red', attrs=['bold'])
user_input = input(print_input5)
cprint ("~~~~~~HOLD COMMAND + DOUBLE CLICK = Open link in browser ~~~~~~",'red')
for submission in subreddit.get_hot(limit=12):
if re.search(user_input, submission.title, re.IGNORECASE):
print("\nTitle: ", submission.title)
print("Link: ", submission.url)
print("Pick your link!")
comments = submission.comments
for comment in comments[1:3]: # first comment is a bot moderator
print(comment.body) # prints top comments starting from 2nd top comment
print("\n")
restartProgram()
def restartProgram():
print_restart = colored("Do you need any other links?\nHighlights 'h', Soccer Streams 's', Logout 'L', Main Menu 'MM'\n", 'red',
attrs=['bold']) # restart search if needed
restart = input(print_restart)
while (restart != "h" and restart != "H" and restart != "s" and restart != "S" and restart != "l" and restart != "L" and restart != "mm"
and restart != "MM"): # testing for wrong user input
print_restart = colored("Highlights 'h', Soccer Streams 's', Logout 'L', Main Menu 'MM'\n", 'red',
attrs=['bold']) # restart search if needed
restart = input(print_restart)
restartProgram()
if (restart == "h" or restart == "H"):
footballHighlights()
if (restart == "s" or restart == "S"):
sportLinks()
if (restart == "l" or restart == "L"):
print("Bye")
sys.exit()