forked from hang333/HbookerAppNovelDownloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bookshelf.py
52 lines (42 loc) · 1.54 KB
/
bookshelf.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
from book import *
BookShelfList = []
def get_bookshelf_by_index(shelf_index):
for shelf in BookShelfList:
if shelf.shelf_index == shelf_index:
return shelf
return None
class BookShelf:
shelf_id = None
reader_id = None
shelf_name = None
shelf_index = None
book_limit = None
BookList = None
def __init__(self, data):
self.shelf_id = data['shelf_id']
self.reader_id = data['reader_id']
self.shelf_name = data['shelf_name']
self.shelf_index = data['shelf_index']
self.book_limit = data['book_limit']
self.BookList = []
def show_info(self):
print('书架编号:', self.shelf_index, ', 书架名:', self.shelf_name)
def get_book_list(self):
response = HbookerAPI.BookShelf.get_shelf_book_list(self.shelf_id)
if response.get('code') == '100000':
self.BookList.clear()
i = 1
for data in response['data']['book_list']:
self.BookList.append(Book(str(i), data['book_info']))
i += 1
def show_book_list(self):
for book in self.BookList:
print('书籍编号:', book.index, ', 标题:', book.book_name, ', 作者:',
book.author_name)
print(' 最新章节:', book.last_chapter_info['chapter_title'], ', 更新时间:',
book.last_chapter_info['uptime'])
def get_book(self, index):
for book in self.BookList:
if book.index == index:
return book
return None