
数据集下载
https://allenheartcore.github.io/assets/bili/mygo_danmaku.zip
数据示例
PROGRESS,CTIME,ID,HASH,COLOR,MODE,FONTSIZE,TEXT
0.0,2023-08-11 19:43:01,1413322056778563840,e997dd79,#84C0CB,5,25,梦结束的地方
数据字段
PROGRESS - 播放进度(%f,除EP1外不超过1421.0)
CTIME - 发送时间(%Y-%m-%d %H:%M:%S)
ID - 识别码(%19d,设备间存在差异)
HASH - 哈希值(%08x)
COLOR - 颜色(#%06X,如白色为#FFFFFF)
MODE - 类型(%d,1为滚动,5为顶部)
FONTSIZE - 字号(%d,大部分为25)
数据量
EP01: 8605 | EP02: 5191 | EP03: 4940 | EP04: 5312 | EP05: 4625
EP06: 3718 | EP07: 6092 | EP08: 6055 | EP09: 7261 | EP10: 11326
EP11: 9836 | EP12: 8315 | EP13: 22711 | 总集篇 (Digest): 5211
数据源
【自用源】
6763, 4682, 4370, 4612, 4487
3712, 4965, 4994, 6470, 6609
8229, 7093, 6516, 3918
【cv26828506】
https://pan.baidu.com/s/1vpEp66Gkn6ld-HBN5F5CaA?pwd=1145
8363, 5061, 4829, 5188, 4542
3670, 5873, 5886, 7156, 11084
9621, 8161, 21226, 0
【cv26818583】
https://pan.baidu.com/s/1BdF9_lAie-KOPKqPgo5Lcw?pwd=1234
8263, 4982, 4737, 5071, 4437
3571, 5749, 5754, 7020, 10922
9515, 8047, 21058, 5154
【cv26840816】
https://pan.baidu.com/s/1MOTRw0z1m6zRdBbfjH1d0A?pwd=ysz1
6280, 5140, 4893, 5280, 4594
3697, 6032, 6004, 7230, 9828
8240, 7415, 8439, 5204
【cv26618460】
https://adlp.lanzouw.com/iuk9D1adye9c (bsk4)
3778, 3600, 3600, 3600, 3600
3600, 3840, 3681, 3914, 3804
3831, 3770, 7223, 3600
【cv26286057】
https://pan.baidu.com/s/1SSiH-iVb4H_BsE8lH198fw?pwd=mygo
3600, 2782, 2443, 2706, 2424
1859, 3600, 3473, 3600, 3600
3600, 3600, 3600, 0
【cv26831759】
https://pan.baidu.com/s/1XOCt5I5h_ERJcZyKOtZTow?pwd=h672
3600, 3600, 3600, 3600, 3600
3600, 3600, 3600, 3600, 3600
3600, 3600, 3600, 3600
【网页链接】
https://27jg2s-my.sharepoint.com/:f:/g/personal/makiyuu_27jg2s_onmicrosoft_com/EoU4alsaY3dKnd3DHDLZ_BsB_QS-hVZ4O-Q8YzRZIQlqTA (MyGo@772556)
4068, 2792, 2452, 2727, 2444
1867, 3650, 3521, 4949, 3600
3831, 6624, 19485, 0
【网页链接】
https://www.aliyundrive.com/s/LDVaZyMmom3
3600, 3600, 3600, 3600, 3600
3533, 3600, 3600, 3600, 3600
3600, 3600, 3600, 3600

@Bison仓鼠 (UID: 136107) | 网页链接
附录:弹幕下载与清洗程序
import requests
# import pandas as pd
import xml.etree.ElementTree as ET
from datetime import datetime
from tqdm import tqdm
from sys import argv
import warnings
warnings.filterwarnings('ignore')
class Converter:
def __init__(self):
self.base58 = 'fZodR9XQDSUm21yCkr6zBqiveYah8bt4xsWpHnJE7jL5VG3guMTKNPAwcF'
self.digit_map = [11, 10, 3, 8, 4, 6]
self.xor_magic = 177451812
self.add_magic = 8728348608
self.template = list('BV1 4 1 7 ')
def decode(self, cipher):
plain = 0
for i, digit in enumerate(self.digit_map):
plain += self.base58.index(cipher[digit]) * 58 ** i
return 'av%s' % ((plain - self.add_magic) ^ self.xor_magic)
if __name__ == '__main__':
URL = argv[1]
if URL.startswith('http'):
URL = URL.replace('/?', '?').split('?')[0].split('/')[-1]
if URL.startswith('BV'):
assert len(URL) == 12, 'Invalid BV number'
URL = Converter().decode(URL)
if not URL.startswith('av'):
raise ValueError('Invalid input')
cid_api = 'https://api.bilibili.com/x/player/pagelist?aid=%s' % URL[2:]
ret = requests.get(cid_api).json()['data'][0]
cid, title = ret['cid'], ret['part']
dmk_api = 'https://api.bilibili.com/x/v1/dm/list.so?oid=%d' % cid
dmk = requests.get(dmk_api).content
# processed = pd.DataFrame(columns=['PROGRESS', 'CTIME', 'ID', 'HASH', 'COLOR', 'MODE', 'FONTSIZE', 'TEXT'])
processed = []
for elt in tqdm(ET.fromstring(dmk).findall('d')):
progress, mode, fontsize, color, ctime, _, hash, id, *_ = elt.attrib['p'].split(',')
if color == 'undefined':
color = '16777215'
# text = elt.text.replace('\n', ' ').replace('\r', ' ').replace('\t', ' ')
text = elt.text.replace('"', '""').replace('\n', ' ').replace('\r', ' ').replace('\t', ' ')
if '""' in text or ',' in text:
text = '"%s"' % text
# processed = pd.concat([processed, pd.DataFrame({
# 'PROGRESS': '%08.3f' % float(progress),
# 'CTIME': datetime.fromtimestamp(int(ctime)).strftime('%Y-%m-%d %H:%M:%S'),
# 'ID': '%19d' % int(id),
# 'HASH': '%08x' % int(hash, 16),
# 'COLOR': '#%06X' % int(color),
# 'MODE': mode,
# 'FONTSIZE': fontsize,
# 'TEXT': text
# }, index=[0])], ignore_index=True)
processed.append((
'%08.3f' % float(progress),
datetime.fromtimestamp(int(ctime)).strftime('%Y-%m-%d %H:%M:%S'),
'%19d' % int(id),
'%08x' % int(hash, 16),
'#%06X' % int(color),
mode, fontsize, text
))
FILENAME_OUT = 'danmaku_%s_%s_%d.csv' % (URL, title, int(datetime.now().timestamp()))
# processed = processed.drop_duplicates('ID')
# processed = processed.sort_values(['PROGRESS', 'CTIME'])
# processed.to_csv(FILENAME_OUT, index=False, encoding='utf-8')
with open(FILENAME_OUT, 'w', encoding='utf-8') as fout:
fout.write('PROGRESS,CTIME,ID,HASH,COLOR,MODE,FONTSIZE,TEXT\n')
processed = sorted(processed, key=lambda x: x[1])
processed = sorted(processed, key=lambda x: x[0])
for line in processed:
fout.write(','.join(line) + '\n')