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.post6.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.post6-py3-none-any.whl (14.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mangagraph-0.0.3.post6.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.post6.tar.gz
Algorithm Hash digest
SHA256 84c0068d1c9ccfa7448237825055e6606825f117282d752103d39cf977b19afb
MD5 3a9d2bb77295029473262e7b34d753f3
BLAKE2b-256 3ba66593ab679d456304a9260382d73722316ccd79e688caa93868d5ad7b1fd9

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for mangagraph-0.0.3.post6-py3-none-any.whl
Algorithm Hash digest
SHA256 bd24509e54dcffaf15d31021cb0dcd3287e43bece2a82a86bcb953d98432dfdd
MD5 52f7fb381e3d010974c4a3b7c0101c5d
BLAKE2b-256 b3e0c65dea9b5b7e435721949f0d98bf39089a69d77b31fc622badef0d7ff7d6

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