Media_add_index
This commit is contained in:
parent
e83f58163b
commit
4fe4bfd47c
@ -27,9 +27,11 @@ class DBHandler(MicroHandler, MediaHandler, OpenIMContactHandler, PublicMsgHandl
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
# 加速查询索引
|
||||||
self.Micro_add_index()
|
self.Micro_add_index()
|
||||||
self.Msg_add_index()
|
self.Msg_add_index()
|
||||||
self.PublicMsg_add_index()
|
self.PublicMsg_add_index()
|
||||||
|
self.Media_add_index()
|
||||||
|
|
||||||
def get_user(self, word=None, wxids=None, labels=None):
|
def get_user(self, word=None, wxids=None, labels=None):
|
||||||
"""
|
"""
|
||||||
|
@ -13,6 +13,13 @@ class MediaHandler(DatabaseBase):
|
|||||||
_class_name = "MediaMSG"
|
_class_name = "MediaMSG"
|
||||||
Media_required_tables = ["Media"]
|
Media_required_tables = ["Media"]
|
||||||
|
|
||||||
|
def Media_add_index(self):
|
||||||
|
"""
|
||||||
|
添加索引, 加快查询速度
|
||||||
|
"""
|
||||||
|
if self.tables_exist("Media"):
|
||||||
|
self.execute("CREATE INDEX IF NOT EXISTS MsgSvrID ON Media(Reserved0)")
|
||||||
|
|
||||||
def get_audio(self, MsgSvrID, is_play=False, is_wave=False, save_path=None, rate=24000):
|
def get_audio(self, MsgSvrID, is_play=False, is_wave=False, save_path=None, rate=24000):
|
||||||
if not self.tables_exist("Media"):
|
if not self.tables_exist("Media"):
|
||||||
return False
|
return False
|
||||||
|
@ -9,23 +9,14 @@ from .dbbase import DatabaseBase
|
|||||||
from .utils import silk2audio
|
from .utils import silk2audio
|
||||||
|
|
||||||
|
|
||||||
class MediaHandler(DatabaseBase):
|
class SnsHandler(DatabaseBase):
|
||||||
_class_name = "MediaMSG"
|
_class_name = "Sns"
|
||||||
Media_required_tables = ["Media"]
|
Media_required_tables = ["AdFeedsV8", "FeedsV20", "CommentV20", "NotificationV7", "SnsConfigV20", "SnsFailureV5",
|
||||||
|
"SnsGroupInfoV5", "SnsNoNotifyV5"]
|
||||||
def get_audio(self, MsgSvrID, is_play=False, is_wave=False, save_path=None, rate=24000):
|
"""
|
||||||
if not self.tables_exist("Media"):
|
FeedsV20:朋友圈的XML数据
|
||||||
return False
|
CommentV20:朋友圈点赞或评论记录
|
||||||
|
NotificationV7:朋友圈通知
|
||||||
sql = "select Buf from Media where Reserved0=? "
|
SnsConfigV20:一些配置信息,能读懂的是其中有你的朋友圈背景图
|
||||||
DBdata = self.execute(sql, (MsgSvrID,))
|
SnsGroupInfoV5:猜测是旧版微信朋友圈可见范围的可见或不可见名单
|
||||||
if not DBdata:
|
"""
|
||||||
return False
|
|
||||||
if len(DBdata) == 0:
|
|
||||||
return False
|
|
||||||
data = DBdata[0][0] # [1:] + b'\xFF\xFF'
|
|
||||||
try:
|
|
||||||
pcm_data = silk2audio(buf_data=data, is_play=is_play, is_wave=is_wave, save_path=save_path, rate=rate)
|
|
||||||
return pcm_data
|
|
||||||
except Exception as e:
|
|
||||||
return False
|
|
||||||
|
Loading…
Reference in New Issue
Block a user