chu-shen / BangumiKomga

A Metadata Provider for Komga using Bangumi
98 stars 9 forks source link

Bangumi metadata scraper for Komga

Introduction

This Script gets a list of every manga available on your Komga instance, looks it up one after another on Bangumi and gets the metadata for the specific series. This metadata then gets converted to be compatible to Komga and then gets sent to the server instance and added to the manga entry.

sample detail

Features

已完成

处理逻辑见DESIGN

TODO

Requirements

快速开始

Warning:

Executing this program will result in the loss of old metadata for series and books

执行此程序将导致书籍系列及单册的旧元数据丢失

  1. Install the requirements using

    # prepare the environment on your own
    conda install --file env_conda.txt
    pip install -r env_pip.txt
    
    # or use docker compose
    version: '3'
    services:
    bangumikomga:
        image: chu1shen/bangumikomga:main
        container_name: bangumikomga
        volumes:
        - /path/BangumiKomga/config.py:/app/config/config.py   # see step.2
        - /path/BangumiKomga/recordsRefreshed.db:/app/recordsRefreshed.db
        - /path/BangumiKomga/refreshMetadata.log:/app/refreshMetadata.log
  2. Rename config/config.template.py to config/config.py and edit the url, email and password to match the ones of your komga instance (User needs to have permission to edit the metadata).

    BANGUMI_ACCESS_TOKEN (可选)用于读取NSFW条目,在 https://next.bgm.tv/demo/access-token 创建个人令牌

    KOMGA_LIBRARY_LIST 处理指定库中的书籍系列。komga界面点击库(对应链接)即可获得,形如:'0B79XX3NP97K9',对应地址:http://IP:PORT/libraries/0B79XX3NP97K9/series。填写时以英文引号''包裹,英文逗号,分割。与KOMGA_COLLECTION_LIST不能同时使用

    KOMGA_COLLECTION_LIST 处理指定收藏中的书籍系列。komga界面点击收藏(对应链接)即可获得,形如:'0B79XX3NP97K9'。填写时以英文引号''包裹,英文逗号,分割。与KOMGA_LIBRARY_LIST不能同时使用

    Tips: 可以搭配`同步阅读进度`实现仅同步部分书籍系列的进度
  3. Run the script using python refreshMetadata.py

Tips:

如果漫画系列数量上千,请考虑使用bangumi/Archive离线数据代替联网查询

消息通知(可选)

消息通知支持Gotify、Webhook(如:飞书)、Healthchecks(定时任务监控)

创建失败收藏(可选)

CREATE_FAILED_COLLECTION配置为True,程序会在刷新完成后,将所有刷新失败的系列添加到指定收藏(默认名:FAILED_COLLECTION)。

每次运行都会根据本次运行数据重新创建此收藏(无失败则跳过)。

Tips:

其他配置说明

如何修正错误元数据

人工修正错误元数据可以使用cbl(Correct Bangumi Link),只需在系列元数据的链接中填入cbl和该漫画系列的 bangumi 地址。此链接将在匹配时最先使用。

下面分三种情况说明具体操作:

为小说添加元数据

Komga 并没有区分漫画与小说。

可以尝试修改代码,使其只应用于 Komga 的小说库:将bangumiApi.py中的manga_metadata["platform"] != "小说"修改为manga_metadata["platform"] == "小说"

同步阅读进度

注意:当前仅为komga至bangumi单向同步

Tips:

推荐使用Tachiyomi更新阅读进度👉Tracking | Tachiyomi

同步内容:

  1. 步骤同刷新元数据
  2. 步骤同刷新元数据

    注意:

    • 如果配置了FORCE_REFRESH_LIST,则仅同步此列表配置的漫画系列进度
    • 如果未配置FORCE_REFRESH_LIST,则同步当前获取的所有系列的漫画进度(当前有3种范围:所有、仅指定库、仅指定收藏)。为避免污染时间线,请谨慎操作
  3. python updateReadProgress.py

命名建议

[漫画名称][作者][出版社][卷数][其他1][其他2]

例如:

[碧蓝之海][井上堅二×吉岡公威][Vol.01-Vol.18]
[相合之物][浅野伦][Vol.01-Vol.13]
[海王但丁][皆川亮二×泉福朗][Vol.01-Vol.13][境外版]

命名建议修改自某喵

Issues & Pull Requests

欢迎提交新规则、问题、功能……

致谢

本项目部分代码及思路来自Pfuenzle/AnisearchKomga,部分代码生成自chatgpt,在此表示感谢!

语料库数据来源,感谢公开:

另外,也感谢以下优秀项目: