Skip to main content

Async manga parser-converter from mangalib to telegraph pages

Project description

Mangagraph

From Mangalib to Telegraph with ❤️

Асинхронный парсер-конвертер манги из mangalib api в telegraph

Принцип работы

Даем ссылку на мангу (такого типа: https://mangalib.me/ru/manga/{slug_url}) и название бд куда мы сохраняем (том, главу, наименование главы, ссылку на главу для чтения и зеркало на случаи если главная ссылка не доступна) -> получаем полные данные о главах -> генерируем телеграф страницы на каждую главу -> ссылки на страницу сохраняем в SQLite бд, с использованием SQLAlchemy

-> На выходе получаем базу данных готовую к любому использованию и конечную ссылку телеграфа с зеркалом (оглавление) внутри которой находятся все главы с именами и ссылкой для чтения

Пример страницы главы: https://graph.org/Vanpanchmen--Opasnoe-sushchestvo-01-22-4

Пример оглавления: https://graph.org/Vanpanchmen-01-22-3 (ссылки на оглавление также сохраняются в бд, в таблицу ToC_url)

Установка

pip install -U mangagraph

Использование

CLI

mangagraph --url https://mangalib.me/ru/manga/706--onepunchman

или

python mangagraph --url https://mangalib.me/ru/manga/706--onepunchman

Обработка одной конкретной главы (к примеру вторая)

Важно! При обработки одной главы не создается БД и оглавление, возвращается только кортеж из двух строк (главной ссылки и зеркала)

python mangagraph --url https://mangalib.me/ru/manga/706--onepunchman --c 2

Поиск манги

python mangagraph --q "Berserk" --limit 10

Raw

from mangagraph import Mangagraph
from mangagraph.exceptions import MangagraphError

async def main():
    try:
        mgraph = Mangagraph()
        # Поиск манги по ключевому слову и с лимитом
        results = await mgraph.search_manga("Berserk", limit=3)

        for idx, result in enumerate(results, 1):
            print(f"{idx}. {result.name} / {result.rus_name}")
            print(f"   Рейтинг: {result.rating.raw_average} ({result.rating.raw_votes} отзывов)")
            print(f"   Год: {result.release_year} | Тип: {result.type} | Статус: {result.status}")
            print(f"   Ссылка: https://mangalib.me/ru/manga/{result.slug_url}")
            print()

        # Парсинг одной конкретной главы
        chapter_num = 97
        url, mirror_url = await mgraph.process_chapter(
            'https://mangalib.me/ru/manga/7965--chainsaw-man',
            chapter_num
        )
        print(f'Бензочел, глава номер {chapter_num}: {url} | {mirror_url}')

        # Парсинг манги и загрузка телеграф
        toc_url, mirror_toc_url = await mgraph.process_manga('https://mangalib.me/ru/manga/706--onepunchman')

        print(f"Table of Contents: {toc_url}")
        print(f"Mirror: {mirror_toc_url}")
    except MangagraphError as e:
        print(f"Parser error: {e}")
    except Exception as e:
        print(f"Unexpected error: {e}")

import asyncio

asyncio.run(main())

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mangagraph-0.0.3.post5.tar.gz (13.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mangagraph-0.0.3.post5-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

Details for the file mangagraph-0.0.3.post5.tar.gz.

File metadata

  • Download URL: mangagraph-0.0.3.post5.tar.gz
  • Upload date:
  • Size: 13.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for mangagraph-0.0.3.post5.tar.gz
Algorithm Hash digest
SHA256 8d18dc857d15bc32215ad35d44303c86d13a01d63aba0892a9f1ca7630e03900
MD5 b99bce4b652987cb9d3b5b62dfff8c10
BLAKE2b-256 42b2a276b95dccbdbd879f3527db2551bac1197b85647416eb366fa1b8a58363

See more details on using hashes here.

File details

Details for the file mangagraph-0.0.3.post5-py3-none-any.whl.

File metadata

File hashes

Hashes for mangagraph-0.0.3.post5-py3-none-any.whl
Algorithm Hash digest
SHA256 a6d7d52747c0b19babc3ee1016d01258a8801d45f5c9ac4d43ebec810d04b888
MD5 eae940d6c24a714ff58de1c39bda5d62
BLAKE2b-256 1ac2fbe48e2cacb4134e525a970b07a75f9889ab1863d9bdde750dd0dbc96164

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page