mashirozx / bili2toot

b站动态搬运到长毛象的脚本 Demo:

Home Page:https://hello.2heng.xin/@arknights

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

bili2toot

A simple script that transport dynamic from bilibili to Mastodon. Based on the Twitter RSS feed powered by RSSHub.

一个将bilibili动态搬运到长毛象的脚本——基于RSSHub生成的B站动态RSS。

PS. 动态中的表情处理方法

B 站动态里的表情处理是一个比较麻烦的事情,RSSHub的默认处理方法是将表情转成 <img>,这样会导致 bili2toot 误将表情作为图片上传,为了解决这个问题,对 RSSHub 进行了一些改造(mashirozx/RSSHub,一键部署:Dockerhub),相对原有路由 /bilibili/user/dynamic/:uid,新增一个路由 /bilibili/user/dynamic_mstdn/:uid 来对表情处理,将在 RSS 订阅中直接将表情转为 Mastodon 的短代码,mastodon短代码和bilibili原有短代码映射储存在一个外部的 json 文件中,具体原理可以看这里,而json文件及转换脚本都放这个仓库里了:mashirozx/bilibili_emojis,需要用到的表情包都打包到该仓库的四个 .tar.gz 文件中了,可用tootctl直接导入,不过请留意表情前缀,emoji.tar.gz 须加上 bili_emoji_ 前缀,剩下三个须加上 bili_ 前缀。

pip3 install -r requirements.txt
cp conf.sample.ini conf.ini
nano conf.ini
python3 run.py

crontab job setting:

crontab -e

or (Ubuntu 18.04)

nano /etc/crontab
/etc/init.d/cron restart

Recommand do job hourly:

#m h dom mon dow user  command
13 *    * * *   root    cd /bili2toot && python3 run.py

About

b站动态搬运到长毛象的脚本 Demo:

https://hello.2heng.xin/@arknights

License:MIT License


Languages

Language:Python 100.0%