-
Notifications
You must be signed in to change notification settings - Fork 1
/
settings.py
70 lines (59 loc) · 1.96 KB
/
settings.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
#!/usr/bin/env Python3
import json
import glob
import os
def init():
global ninegag_categories, username, password, wait_time, post_time, login_type, \
post_limit, filesDict, filesCheck, scrape_user, keep_checking, past_images, post_source, counter
# User inputted info set as variables
ninegag_categories = []
username = "cybersecurity.exe"
password = "Posterity007$"
wait_time = 5
post_time = 50
login_type = ""
post_limit = 0
scrape_user = "_codehub_"
past_images = 0
post_source = ""
counter = 0
keep_checking = True
filesDict = {'dict': []}
# Creates images folder if non-existent
if not os.path.exists('images'):
os.makedirs('images')
# Removes images from files if left over from previous runs
# files = glob.glob('images/*')
# for f in files:
# os.remove(f)
# Clears filesDict.JSON on start
# with open('filesDict.json', 'w+', encoding="utf8") as outfile:
# json.dump(filesDict, outfile, ensure_ascii=False)
# Creates filesCheck if not existent
try:
file = open('filesCheck.txt', 'r')
file.close()
except IOError:
file = open('filesCheck.txt', 'w')
file.close()
# Creates user if not existent
try:
file = open(images/scrape_user.json, 'r')
file.close()
except IOError:
file = open(images/scrape_user.json, 'w')
file.close()
# Handles removing old items from filesCheck.txt and filling the filesCheck array
# keeps the 100 most recent downloads
count = 0
with open('filesCheck.txt', 'r') as f:
data = f.read().splitlines(True)
for line in f:
count += 1
count -= 100
with open('filesCheck.txt', 'w') as fout:
fout.writelines(data[count:])
# Array that loads past used files from fileCheck.txt
with open('filesCheck.txt') as f:
filesCheck = [line.rstrip() for line in f]
init()