import praw
import webbrowser
import sys
import os
import math
from Converter import Converter

# Validate Input
if(len(sys.argv) < 2):
    print ("Invalid input, please include subreddit name(s)")
    sys.exit()

# Use specified subreddits or the top from the list
if(len(sys.argv) == 2 and sys.argv[1] == "top"):
    subreddit_list = Converter.makeSubredditList()
else:
    subreddit_list = sys.argv[1:]
	
# Diagnostics
for subreddit_name in subreddit_list:
    print ("Search: /r/", subreddit_name)
	
# Open the reddit bot
user_agent = ("RedditTitlePrediction - j1davenp")
r = praw.Reddit(user_agent = user_agent)

# Create the directory for the training files if it does not exists
if not os.path.exists("Training_Files"):
    os.makedirs("Training_Files")

# Open the file to build the overall dictionary