ybw2016v / bilibili2notes

A python bot which can transfer bilibili dynamic to Misskey notes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bilibili2notes

A python bot which can transfer bilibili dynamic to Misskey notes

一个用于搬运B站动态的Misskey机器人


Warn: The code may be uncomfortable , make sure that the emergency medicine is reachable before read the code.

警告:源代码可能会引起不适,在阅读前准备好降压药。

移除了与RSSHub有关的部分,直接从B站API获取动态相关信息。没有必要为了简单获取B站动态信息而搞一个RSSHub。

The code which is related to RSSHub is removed, and the information of the dynamic is obtained directly from Bilibili API. Because it is not necessary to install a RSSHub to get Bilibili dynamic information.

信息源

使用RssHub作为B站动态的信息来源,如果RssHub主站连接不畅通可以更换其他RssHub站点,返回XML信息格式一致应该没问题。

Information Source

The bilibili dynamic information is from RssHub , which can return the bili dynamic in the xml format.Other website which can offer the information in the same format is also suitable.

More Information about RssHub and bilibili https://docs.rsshub.app/social-media.html#bilibili.

安装

  1. requests升级到最新版本
pip3 install requests --upgrade
  1. 下载
git clone https://github.com/ybw2016v/bilibili2notes.git

使用方法

  1. 将ini格式的配置文件放置在conf

conf目录下可放置多个不同的配置文件,每个文件配置一个机器人。

配置文件说明

[dog]
;机器人名称


PostUrl=https://example.com/
;Misskey实例url

Uid=167446465
;B站用户uid


ApiKey=Your ApiKey
;misskey机器人的apikey

Pex=
;Pex=机器人转发
;机器人发布前缀,无特殊需求留空

Afr=
;Afr=本条消息由机器人转发
;机器人发布后缀,无特殊需求留空

Extime=1209600
;设置图片的过期时间,超过1209600秒之后的过期图片将会被删除,以节约存储空间,如不清除历史图片,可设置为-1
  1. 设置定时任务
crontab -e

添加定时任务,RSShub的缓存时间大约为20分钟,设置执行间隔大于这个数应该不会出问题。

# m h  dom mon dow   command
30 * * * * cd /path/to/bilibili2notes && python3 bili2notes.py

每小时的第三十分钟会进行检查与更新。

Install

  1. Get the nearest version of requests
pip3 install requests --upgrade
  1. Git Clone
git clone https://github.com/ybw2016v/bilibili2notes.git

Usage

  1. Put the configuration file to conf

More than one configuration files can be arranged in conf. Each configuration file control a different bot.

[dog]
;Bot name


PostUrl=https://example.com/
;the url of misskey instance to post notes


Uid=167446465
;the uid of bilibili user

ApiKey=Your ApiKey
;apikey

Pex=
;Pex=From Bot
;The prefix of the notes which will be added to the front of notes,it might be null if  there is no special needs

Afr=
;The postfix of the notes which will be added to the end of notes,it might be null if  there is no special needs

Extime=1209600
;The time of image. All images which upload before this time (secend) will be deleted. Set -1 to disable this.
  1. Set a timed task
crontab -e

Add a task

# m h  dom mon dow   command
30 * * * * cd /path/to/bilibili2notes && python3 bili2notes.py

The script will run at 30 min in every hour.

Change Log

  • 2022-06-09 : 添加对256type的音频动态的支持

About

A python bot which can transfer bilibili dynamic to Misskey notes

License:GNU General Public License v3.0


Languages

Language:Python 99.4%Language:Shell 0.6%