Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature request: library #106

Open
darkralts opened this issue May 17, 2024 · 0 comments
Open

feature request: library #106

darkralts opened this issue May 17, 2024 · 0 comments

Comments

@darkralts
Copy link

image
i have this script that sorts my books folder like this, i think its cool, maybe make an official feature? :D

import os
import subprocess
from blessed import Terminal

def list_epub_files(directory):
    return [f for f in os.listdir(directory) if f.endswith('.epub')]

def open_epub(file):
    subprocess.run(['epy', file])

def main():
    term = Terminal()
    directory = 'Documents/Books/'  # Adjust the directory as per your setup

    files = list_epub_files(directory)

    with term.fullscreen(), term.cbreak():
        key = ''
        index = 0

        while key.lower() != 'q':
            output = term.clear() + term.center(term.bold('Epub Library')) + '\n\n'

            for i, file in enumerate(files):
                if i == index:
                    output += term.reverse(f'{i+1}. {file}\n')
                else:
                    output += f'{i+1}. {file}\n'

            print(output)

            with term.cbreak():
                key = term.inkey()

            if key.name == 'KEY_DOWN':
                index = min(index + 1, len(files) - 1)
            elif key.name == 'KEY_UP':
                index = max(index - 1, 0)
            elif key == '\n':
                open_epub(os.path.join(directory, files[index]))

if __name__ == "__main__":
    main()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant