Google Drive

In addition to saving chapters to local storage, Enma now supports saving chapters directly to Google Drive. This is particularly useful if you want to store your downloaded manga in the cloud for easy access across multiple devices.

Installation

To use the Google Drive storage option, you need to install additional dependencies:

pip install enma[google_drive]

Setting Up Credentials

You'll need to set up Google Drive API credentials to allow Enma to upload files to your Google Drive account. Follow these steps:

  1. Selecione o Projeto

  • No menu superior, clique no nome do projeto atual para abrir a lista de projetos e selecione o projeto onde deseja criar a Service Account.

  1. Acesse a Página de Service Accounts

  • No menu de navegação lateral, clique em IAM & Admin > Service Accounts.

  1. Crie uma Nova Service Account

  • Na página de Service Accounts, clique no botĂŁo Create Service Account (Criar Conta de Serviço).

  • Preencha o Service Account Name (Nome da Conta de Serviço), que será o identificador da sua conta. Opcionalmente, vocĂŞ pode adicionar uma descrição.

  • Clique em Create and Continue (Criar e Continuar).

  1. Pule a Etapa de Permissões

  • Quando solicitado para adicionar permissões Ă  Service Account, nĂŁo adicione nenhuma permissĂŁo. Apenas clique em Done (ConcluĂ­do) para criar a Service Account sem permissões associadas.

  1. Revisão e Finalização

  • ApĂłs criar a Service Account, vocĂŞ voltará para a página principal de contas de serviço. A nova conta estará listada, mas sem permissões.

  1. Baixe a Chave JSON

  • Se precisar de uma chave para autenticar usando a Service Account, clique na conta recĂ©m-criada, vá para a aba Keys (Chaves) e clique em Add Key > Create New Key. Escolha o formato JSON para baixar a chave. Guarde o arquivo com segurança, pois ele concede acesso para autenticação.

  1. Share Google Drive Folder with Service Account:

  • In Google Drive, create a new folder or use an existing one.

  • Right-click the folder and select Share.

  • Share the folder with the service account's email address (found in the credentials JSON under client_email).

Example Usage

Here's how you can use the GoogleDriveStorage adapter:

from enma import (Enma,
                  ManganatoDownloader,
                  GoogleDriveStorage,
                  Threaded)

enma = Enma()
enma.source_manager.set_source('manganato')
manga = enma.get(identifier='manga-wb999684')

downloader = ManganatoDownloader()
google_drive_storage = GoogleDriveStorage(
    credentials_path='path/to/your/service_account_credentials.json',
    root_shared_folder='your_root_folder_id_in_google_drive'
)

if manga:
    enma.download_chapter(
        path=f'folder/subfolder/{manga.title.english}',
        chapter=manga.chapters[0],
        downloader=downloader,
        saver=google_drive_storage,
        threaded=Threaded(use_threads=True, number_of_threads=5)
    )

In this example:

  • Replace path/to/your/service_account_credentials.json with the path to your downloaded service account JSON credentials.

  • Replace your_root_folder_id_in_google_drive with the ID of the Google Drive folder where you want to save the chapters.

    • To get the folder ID, navigate to the folder in Google Drive and copy the ID from the URL (it's the string after folders/).

  • The path parameter specifies the folder structure within your root Google Drive folder where the chapter will be saved.

Last updated

Was this helpful?