-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
77 lines (70 loc) · 2.34 KB
/
main.py
File metadata and controls
77 lines (70 loc) · 2.34 KB
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
import wget
import os
import configparser
# Import Config
config = configparser.ConfigParser()
if (os.path.exists('config.ini')):
config.read('config.ini')
print("config.ini file was found")
print('\n')
else:
config.read(os.path.dirname(__file__) + os.path.sep + 'config.ini')
# Check for Links
if (os.path.exists('links.txt')):
print("links.txt file was found")
print('\n')
else:
while True:
print("Because there was no links.txt file found, this session will pull all links from the default list from GitHub.")
print('\n')
links_input = input("Do you wish to continue? (y/n) ")
print('\n')
parsed_links_input = links_input.lower()
if parsed_links_input == 'y':
default_link_list = 'https://github.com/Piblokto/FileSmasher.py/lists/list.txt'
wget.download(default_link_list)
print('The default link list has been downloaded')
print('\n')
break
elif parsed_links_input == 'n':
open('links.txt', 'w+')
print("A links.txt file has been made in this directory...")
print("Please refer to the documentation.")
print('\n')
exit()
else:
print("Unable to read response.")
exit()
break
# Download File Loop
def main():
with open("links.txt", "r") as links:
for line in links:
stripped = line.strip()
url = stripped
filename = wget.download(url)
print("File Downloaded")
print('\n')
os.remove(filename)
print("File Deleted")
print('\n')
# Parse loop from config
loopconf = config.get("Config", "loop")
parsedloopconf = loopconf.lower()
# Run depending on loop variable from config
if parsedloopconf == '1':
print("Loop Config Loaded. The download will now repeat indefinitely, please close Python if you wish to stop.")
print('\n')
while True:
main()
elif parsedloopconf == '0':
print("Loop Config Loaded. The download will now repeat once.")
print('\n')
main()
print("Download Finished")
exit()
else:
print("Unable to read loop configuration...")
print("Please refer to the documentation.")
print('\n')
exit()