-
Notifications
You must be signed in to change notification settings - Fork 0
/
read_ebook.py
37 lines (27 loc) · 851 Bytes
/
read_ebook.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
# -*- coding: utf8 -*-
from mobi import Mobi
from save_file import Files
import os
class ListEbook():
def __init__(self, path_to_folder):
self.path = path_to_folder
files = []
for r, d, f in os.walk(self.path):
for file in f:
if '.mobi' in file:
files.append(os.path.join(r, file))
for f in files:
book = Mobi(f)
book.parse()
try:
title = book.title()
author = book.author()
author = author.decode()
title = title.decode()
result = author + ' - ' + title + "\n"
print(result)
w = Files()
w.save_file(result)
except:
print("pass", f)
l = ListEbook("path_to_folder")