-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
39 lines (36 loc) · 1.66 KB
/
main.py
File metadata and controls
39 lines (36 loc) · 1.66 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
#!/usr/bin/env python3
from menu import main_menu
from setup import init_db
from os import getcwd, path
from glob import glob
from opml import opmlImport
from simple_term_menu import TerminalMenu
from common import addFeed, validateURL
from config import configValues
opml_directory_path = getcwd()
if __name__ == "__main__":
try:
if init_db() > 0:
print("Database initialized successfully!")
print("First run of pyfeedmanager, please decide if you want to import an opml file or add feeds manually")
options = ["Import OPML", "Add feed manually", "Exit"]
terminal_menu = TerminalMenu(options)
match terminal_menu.show():
case 0:
opmlFiles = glob(path.join(opml_directory_path, configValues.opml_wildcard_pattern))
if opmlFiles == []:
print('ERROR: No opml file could be found, please put your opml file in the directory of this script, make sure the python process can read it and it follows the following pattern: ' + configValues.opml_wildcard_pattern)
for opmlFile in opmlFiles:
opmlImport(opmlFile)
print('OPML import finished')
case 1:
unsafeAddChoice = input('Please add the name/URL you want to add ')
safeInput = validateURL(unsafeAddChoice)
if safeInput[0] == False:
print(safeInput[1])
addFeed(safeInput[0],safeInput[1],safeInput[2])
case _:
exit()
main_menu()
except KeyboardInterrupt:
exit()