-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
38 lines (30 loc) · 1.17 KB
/
main.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
import downloadimages
import praw
import requests
import log
import configparser
from datetime import timedelta
from datetime import datetime
def main():
print('Started.')
config = configparser.ConfigParser()
config.read('config.cfg')
image_num = int(config.get('DEFAULTS', 'image_num'))
output_location = config.get('DEFAULTS','output_location')
bot_name = config.get('DEFAULTS','bot')
subreddit_name = config.get('DEFAULTS','subreddit')
time_period = config.get('DEFAULTS','time')
log_location = config.get('DEFAULTS', 'log_location')
logger = log.setup_logging(log_location)
start = datetime.now()
logger.debug('Starting...')
# Setup logging and establish bot connection with Reddit
reddit = praw.Reddit(bot_name)
subreddit = reddit.subreddit(subreddit_name)
print('Getting images... please wait...')
downloadimages.getImages(subreddit, time_period, image_num, output_location)
end = datetime.now()
logger.debug('Completed. Time taken: %s', str(end - start))
print('Completed! The images are stored at \'' + output_location + '\'')
main()
input('Press ENTER to exit')