-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
executable file
·120 lines (102 loc) · 3.21 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
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
from tts import tts
from tts import exportAudio
import fs
from kbhit import KBHit
from termcolor import colored
from colorama import init
import command
from math import ceil
init()
kb = KBHit()
reader = tts()
# Wad Check
fs.checkWad()
def export():
books = fs.listBooks()
i = 0
pad = ceil(len(books)/10)
for book in books:
print(f"{str(i).rjust(pad, '0')} ({fs.readLine(book)}/{len(fs.getBook(book))}): {book[0:len(book)-4]}")
i += 1
print("q: Exit")
bookNo = input("-> ")
if bookNo == "q":
return
book = books[int(bookNo)]
text = ""
for line in book: text = text + line
exportAudio(text)
print("Exported audio file")
def readBook():
books = fs.listBooks()
i = 0
pad = ceil(len(books)/10)
for book in books:
if fs.readLine(book) == 0:
print(colored(f"{str(i).rjust(pad, '0')} ({fs.readLine(book)}/{len(fs.getBook(book))}): {book[0:len(book)-4]}", "green"))
elif fs.readLine(book) == len(fs.getBook(book)):
print(f"{str(i).rjust(pad, '0')} ({fs.readLine(book)}/{len(fs.getBook(book))}): {book[0:len(book)-4]}")
else:
print(colored(f"{str(i).rjust(pad, '0')} ({fs.readLine(book)}/{len(fs.getBook(book))}): {book[0:len(book)-4]}", "yellow"))
i += 1
print("q: Exit")
bookNo = input("-> ")
if bookNo == "q":
return
# And the Golden Shit award goes to...
try:
_ = int(bookNo)
except:
return
book = books[int(bookNo)]
reader.setBook(book)
# Book reading loop
print(f'Reading {book[0:len(book)-4]}. Press "Esc" and "Enter" to stop at the end of the line')
while True:
if kb.kbhit():
c = kb.getch()
if ord(c) == 27: # ESC
break
kb.set_normal_term()
if not reader.readLine(): return
def manageFics():
while True:
fics = fs.getFics()
print(colored(f'found {len(fics)} works synced with AO3:', 'blue'))
i = 0
for name, id in fics:
print(f'{i}| ID:{id} Name:"{name}"')
i += 1
print()
print('a: Add new synced AO3 fic')
print('d: Delete sync')
print('s: Sync fic(s)')
print('q: Return to main menu')
uin = input("-> ")
if uin == "a":
name = input('Fic name \n-> ')
fId = int(input('Fic id \n-> '))
fics.append((name, fId))
fs.addFic(fics)
elif uin == "d":
fId = int(input('Sync ID\n-> '))
fics.pop(fId)
fs.addFic(fics)
elif uin == "s":
for name, id in fics:
command.clear()
command.scrapeWork(name, id)
command.clear()
elif uin == "q": return
while True:
print(colored("Bob's fan fic reader rev 1", 'blue'))
print('r: Read')
print('m: Manage synced fics')
print('e: Export audio')
print('q: Quit')
uin = input("-> ")
command.clear()
if uin == "r": readBook()
elif uin == "e": export()
elif uin == "m": manageFics()
elif uin == "q": break