Skip to content

Commit

Permalink
Update config.py and play_book.py
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Aug 23, 2023
1 parent c4838a9 commit c2a4d45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 2 additions & 0 deletions bot/plugins/commands/config.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import os

# from tinydb import TinyDB, Query
from pyrogram.types import Message
from bot import assistant, kreacher
from pyrogram import filters, Client
from bot.decorators.only_admins import only_admins

# from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup

c = os.path.dirname(os.path.abspath(__file__))
Expand Down
10 changes: 7 additions & 3 deletions bot/plugins/commands/play_book.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,17 @@ async def _(client: Client, message: Message):
return await msg.edit("**__This is not a number__**")
text += pdf.pages[int(page_number)].extract_text()
elif " " in message.text and "epub" in file_type:
index = 0
epub = epublib.read_epub(f)
page_number = message.text.split(maxsplit=1)[1]
if not page_number.isdigit():
return await msg.edit("**__This is not a number__**")
# h.feed(epub.get_items().get_body_content().decode())
# text += h.text
# text += epub.get_items_of_type(ITEM_DOCUMENT)
for item in epub.get_items():
index += 1
if index == page_number and item.get_type() == ITEM_DOCUMENT:
h.feed(item.get_body_content().decode())
text += h.text
break
await sleep(2)
await msg.edit("**__Generating an audiobook__**")
await tts(text=text, output_file=audiobook)
Expand Down

0 comments on commit c2a4d45

Please sign in to comment.