-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
49 lines (42 loc) · 1.32 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
from Page import Page
from Reader import Reader
import os
def pull():
url = str(input("Enter the url for the first page of the reader: "))
firstPage = Page(url)
page = firstPage
while page.get_next():
if page.get_next():
page = Page(page.get_next())
else:
print("End of chapters")
path = os.path.join(os.getcwd(), 'novels', firstPage.title, "lastRead.txt")
with open(path, 'w', encoding='utf-8') as info:
info.write("{}\n".format(firstPage.title))
info.write("{}\n".format(firstPage.name))
info.write(str(0))
def read():
path = os.path.join(os.getcwd(), 'novels')
novels = os.listdir(path)
for index, novel in enumerate(novels):
print("{}. {}".format(index + 1, novel))
choice = int(input("Choose a title: "))
title = novels[choice - 1]
numOfChapters = int(input("How many chapters do you want me to read?"))
reader = Reader(title)
for i in range(numOfChapters):
reader.read_page()
while True:
print(" 1. Pull Chapters")
print(" 2. Read Chapters")
print(" 0. Exit")
choice = int(input(" Enter a choice: "))
if choice == 1:
pull()
elif choice == 2:
read()
elif choice == 0:
break
else:
print(" Error!!!")
print(" Try again")