def login(): if request.method == 'POST': data = request.get_data() json_data = json.loads(data.decode('utf-8')) username = json_data.get("username") password = json_data.get("password") #print(username, password) lesson_dict = get_info.getInfo(username, password) print(lesson_dict) #print(len(lesson_dict)) #return 'welcome, %s' % json_data.get("username") return json.dumps(lesson_dict)
def pick_msg(s, user): global jump_to_next_counter #切歌请求次数统计 global encode_lock #视频渲染任务锁 global rp_lock if ((user=='晨旭') | (user=='摘希喵喵喵') | (user=='王老菊未来科技种植园')): #debug使用,请自己修改 if(s=='锁定'): rp_lock = True send_dm_long('已锁定点播功能,不响应任何弹幕') if(s=='解锁'): rp_lock = False send_dm_long('已解锁点播功能,开始响应弹幕请求') if(s=='清空列表'): if(encode_lock): send_dm_long('有渲染任务,无法清空') return #获取目录下所有文件 for i in os.listdir(path+'/downloads'): del_file(i) os.system('killall ffmpeg') send_dm_long('已经清空列表~') if((user == '接待喵') | rp_lock): #防止自循环 return #下面的不作解释,很简单一看就懂 if(s.find('mvid+') == 0): if check_night(): return send_dm_long('已收到'+user+'的指令') s = s.replace(' ', '') #剔除弹幕中的所有空格 _thread.start_new_thread(get_download_url, (s.replace('mvid+', '', 1), 'mv',user)) elif (s.find('mv+') == 0): if check_night(): return try: send_dm_long('已收到'+user+'的指令') search_mv(s.replace('mv+', '', 1),user) except: print('[log]mv not found') send_dm_long('出错了:没这mv') elif (s.find('song+') == 0): if check_night(): return try: send_dm_long('已收到'+user+'的指令') search_song(s.replace('song+', '', 1),user) except: print('[log]song not found') send_dm_long('出错了:没这首歌') elif (s.find('id+') == 0): if check_night(): return send_dm_long('已收到'+user+'的指令') s = s.replace(' ', '') #剔除弹幕中的所有空格 _thread.start_new_thread(get_download_url, (s.replace('id+', '', 1), 'id',user)) elif(s.find('mvid') == 0): if check_night(): return send_dm_long('已收到'+user+'的指令') s = s.replace(' ', '') #剔除弹幕中的所有空格 _thread.start_new_thread(get_download_url, (s.replace('mvid', '', 1), 'mv',user)) elif (s.find('mv') == 0): if check_night(): return try: send_dm_long('已收到'+user+'的指令') search_mv(s.replace('mv', '', 1),user) except: print('[log]mv not found') send_dm_long('出错了:没这mv') elif (s.find('song') == 0): if check_night(): return try: send_dm_long('已收到'+user+'的指令') search_song(s.replace('song', '', 1),user) except: print('[log]song not found') send_dm_long('出错了:没这首歌') elif (s.find('id') == 0): if check_night(): return send_dm_long('已收到'+user+'的指令') s = s.replace(' ', '') #剔除弹幕中的所有空格 _thread.start_new_thread(get_download_url, (s.replace('id', '', 1), 'id',user)) elif (s.find('点歌') == 0): if check_night(): return try: send_dm_long('已收到'+user+'的指令') search_song(s.replace('点歌', '', 1),user) except: print('[log]song not found') send_dm_long('出错了:没这首歌') elif (s.find('喵') > -1): replay = ["喵??", "喵喵!", "喵。。喵?", "喵喵喵~", "喵!"] send_dm_long(replay[random.randint(0, len(replay)-1)]) #用于测试是否崩掉 elif (s == '切歌'): #切歌请求 if(encode_lock): #切歌原理为killall ffmpeg,但是如果有渲染任务,kill后也会结束渲染进程,会出错 send_dm_long('有渲染任务,无法切歌') return jump_to_next_counter += 1 #切歌次数统计加一 if((user=='晨旭') | (user=='摘希喵喵喵')): #debug使用,请自己修改 jump_to_next_counter=5 if(jump_to_next_counter < 5): #次数未达到五次 send_dm_long('已收到'+str(jump_to_next_counter)+'次切歌请求,达到五次将切歌') else: #次数达到五次 jump_to_next_counter = 0 #次数统计清零 send_dm_long('已执行切歌动作') os.system('killall ffmpeg') #强行结束ffmpeg进程 elif ((s == '点播列表') or (s == '歌曲列表')): if check_night(): return send_dm_long('已收到'+user+'的指令,正在查询') files = os.listdir(path+'/downloads') #获取目录下所有文件 files.sort() #按文件名(下载时间)排序 songs_count = 0 #项目数量 all_the_text = "" for f in files: if((f.find('.mp3') != -1) and (f.find('.download') == -1)): #如果是mp3文件 try: info_file = open(path+'/downloads/'+f.replace(".mp3",'')+'.info', 'r') #读取相应的info文件 all_the_text = info_file.read() info_file.close() except Exception as e: print(e) if(songs_count < 10): send_dm_long(all_the_text) songs_count += 1 if((f.find('ok.flv') != -1) and (f.find('.download') == -1) and (f.find('rendering') == -1)):#如果是有ok标记的flv文件 try: info_file = open(path+'/downloads/'+f.replace(".flv",'')+'.info', 'r') #读取相应的info文件 all_the_text = info_file.read() info_file.close() except Exception as e: print(e) if(songs_count < 10): send_dm_long(all_the_text) songs_count += 1 if(songs_count <= 10): send_dm_long('点播列表展示完毕,一共'+str(songs_count)+'个') else: send_dm_long('点播列表前十个展示完毕,一共'+str(songs_count)+'个') elif (s == '渲染列表'): if check_night(): return send_dm_long('已收到'+user+'的指令,正在查询') files = os.listdir(path+'/downloads') #获取目录下所有文件 files.sort() #按文件名(下载时间)排序 songs_count = 0 #项目数量 all_the_text = "" for f in files: if(f.find('rendering1.flv') != -1): #如果是没有ok标记的flv文件 try: info_file = open(path+'/downloads/'+f.replace("rendering1.flv",'')+'ok.info', 'r') #读取相应的info文件 all_the_text = info_file.read() info_file.close() except Exception as e: print(e) if(songs_count < 5): send_dm_long(all_the_text) songs_count += 1 if(f.find('.mp4') != -1): #如果是mp4文件 try: info_file = open(path+'/downloads/'+f.replace(".mp4",'')+'ok.info', 'r') #读取相应的info文件 all_the_text = info_file.read() info_file.close() except Exception as e: print(e) if(songs_count < 5): send_dm_long(all_the_text) songs_count += 1 if(songs_count <= 5): send_dm_long('渲染列表展示完毕,一共'+str(songs_count)+'个') else: send_dm_long('渲染列表前5个展示完毕,一共'+str(songs_count)+'个') elif (s.find('av') == 0): if check_night(): return s = s.replace(' ', '') #剔除弹幕中的所有空格 try: if(s.find('p') == -1): send_dm_long('已收到'+user+'的指令') #视频网址格式:https://www.bilibili.com/video/avxxxxx ture_url=s.replace('av','https://www.bilibili.com/video/av') _thread.start_new_thread(download_av, (ture_url,user)) else: send_dm_long('已收到'+user+'的指令') #视频网址格式:https://www.bilibili.com/video/avxxxx/#page=x ture_url=s.replace('p','/#page=') ture_url=ture_url.replace('av','https://www.bilibili.com/video/av') _thread.start_new_thread(download_av, (ture_url,user)) except: print('[log]video not found') elif (s.find('温度') > -1 and deviceType == "pi"): #send_dm_long("CPU "+os.popen('vcgencmd measure_temp').readline()) #读取命令行得到的温度 send_dm_long(get_info.getInfo()) elif (s.find('歌单') == 0): if check_night(): return send_dm_long('已收到'+user+'的指令') s = s.replace(' ', '') #剔除弹幕中的所有空格 _thread.start_new_thread(playlist_download, (s.replace('歌单', '', 1),user)) elif (s.find('查询') == 0): send_dm_long(user+'的瓜子余额还剩'+str(get_coin(user))+'个')
def pick_msg(s, user): global jump_to_next_counter #切歌请求次数统计 global encode_lock #视频渲染任务锁 global rp_lock if ((user=='晨旭') | (user=='摘希喵喵喵')): #debug使用,请自己修改 if(s=='锁定'): rp_lock = True send_dm_long('已锁定点播功能,不响应任何弹幕') if(s=='解锁'): rp_lock = False send_dm_long('已解锁点播功能,开始响应弹幕请求') if((user == '接待喵') | rp_lock): #防止自循环 return #下面的不作解释,很简单一看就懂 if(s.find('mvid+') == 0): if check_night(): return send_dm_long('已收到'+user+'的指令') s = s.replace(' ', '') #剔除弹幕中的所有空格 _thread.start_new_thread(get_download_url, (s.replace('mvid+', '', 1), 'mv',user)) elif (s.find('mv+') == 0): if check_night(): return try: send_dm_long('已收到'+user+'的指令') search_mv(s.replace('mv+', '', 1),user) except: print('[log]mv not found') send_dm_long('出错了:没这mv') elif (s.find('song+') == 0): if check_night(): return try: send_dm_long('已收到'+user+'的指令') search_song(s.replace('song+', '', 1),user) except: print('[log]song not found') send_dm_long('出错了:没这首歌') elif (s.find('id+') == 0): if check_night(): return send_dm_long('已收到'+user+'的指令') s = s.replace(' ', '') #剔除弹幕中的所有空格 _thread.start_new_thread(get_download_url, (s.replace('id+', '', 1), 'id',user)) elif(s.find('mvid') == 0): if check_night(): return send_dm_long('已收到'+user+'的指令') s = s.replace(' ', '') #剔除弹幕中的所有空格 _thread.start_new_thread(get_download_url, (s.replace('mvid', '', 1), 'mv',user)) elif (s.find('mv') == 0): if check_night(): return try: send_dm_long('已收到'+user+'的指令') search_mv(s.replace('mv', '', 1),user) except: print('[log]mv not found') send_dm_long('出错了:没这mv') elif (s.find('song') == 0): if check_night(): return try: send_dm_long('已收到'+user+'的指令') search_song(s.replace('song', '', 1),user) except: print('[log]song not found') send_dm_long('出错了:没这首歌') elif (s.find('id') == 0): if check_night(): return send_dm_long('已收到'+user+'的指令') s = s.replace(' ', '') #剔除弹幕中的所有空格 _thread.start_new_thread(get_download_url, (s.replace('id', '', 1), 'id',user)) elif (s.find('点歌') == 0): if check_night(): return try: send_dm_long('已收到'+user+'的指令') search_song(s.replace('点歌', '', 1),user) except: print('[log]song not found') send_dm_long('出错了:没这首歌') elif (s.find('喵') > -1): replay = ["喵??", "喵喵!", "喵。。喵?", "喵喵喵~", "喵!"] send_dm_long(replay[random.randint(0, len(replay)-1)]) #用于测试是否崩掉 elif (s == '切歌'): #切歌请求 if(encode_lock): #切歌原理为killall ffmpeg,但是如果有渲染任务,kill后也会结束渲染进程,会出错 send_dm_long('有渲染任务,无法切歌') return jump_to_next_counter += 1 #切歌次数统计加一 if((user=='晨旭') | (user=='摘希喵喵喵')): #debug使用,请自己修改 jump_to_next_counter=5 if(jump_to_next_counter < 5): #次数未达到五次 send_dm_long('已收到'+str(jump_to_next_counter)+'次切歌请求,达到五次将切歌') else: #次数未达到五次 jump_to_next_counter = 0 #次数统计清零 send_dm_long('已执行切歌动作') os.system('killall ffmpeg') #强行结束ffmpeg进程 elif ((s == '点播列表') or (s == '歌曲列表')): if check_night(): return send_dm_long('已收到'+user+'的指令,正在查询') files = os.listdir(path+'/downloads') #获取目录下所有文件 files.sort() #按文件名(下载时间)排序 songs_count = 0 #项目数量 all_the_text = "" for f in files: if((f.find('.mp3') != -1) and (f.find('.download') == -1)): #如果是mp3文件 try: info_file = open(path+'/downloads/'+f.replace(".mp3",'')+'.info', 'r') #读取相应的info文件 all_the_text = info_file.read() info_file.close() except Exception as e: print(e) if(songs_count < 10): send_dm_long(all_the_text) songs_count += 1 if((f.find('ok.flv') != -1) and (f.find('.download') == -1) and (f.find('rendering') == -1)):#如果是有ok标记的flv文件 try: info_file = open(path+'/downloads/'+f.replace(".flv",'')+'.info', 'r') #读取相应的info文件 all_the_text = info_file.read() info_file.close() except Exception as e: print(e) if(songs_count < 10): send_dm_long(all_the_text) songs_count += 1 if(songs_count <= 10): send_dm_long('点播列表展示完毕,一共'+str(songs_count)+'个') else: send_dm_long('点播列表前十个展示完毕,一共'+str(songs_count)+'个') elif (s == '渲染列表'): if check_night(): return send_dm_long('已收到'+user+'的指令,正在查询') files = os.listdir(path+'/downloads') #获取目录下所有文件 files.sort() #按文件名(下载时间)排序 songs_count = 0 #项目数量 all_the_text = "" for f in files: if(f.find('rendering1.flv') != -1): #如果是没有ok标记的flv文件 try: info_file = open(path+'/downloads/'+f.replace("rendering1.flv",'')+'ok.info', 'r') #读取相应的info文件 all_the_text = info_file.read() info_file.close() except Exception as e: print(e) if(songs_count < 5): send_dm_long(all_the_text) songs_count += 1 if(f.find('.mp4') != -1): #如果是mp4文件 try: info_file = open(path+'/downloads/'+f.replace(".mp4",'')+'ok.info', 'r') #读取相应的info文件 all_the_text = info_file.read() info_file.close() except Exception as e: print(e) if(songs_count < 5): send_dm_long(all_the_text) songs_count += 1 if(songs_count <= 5): send_dm_long('渲染列表展示完毕,一共'+str(songs_count)+'个') else: send_dm_long('渲染列表前5个展示完毕,一共'+str(songs_count)+'个') elif (s.find('av') == 0): if check_night(): return s = s.replace(' ', '') #剔除弹幕中的所有空格 try: if(s.find('p') == -1): send_dm_long('已收到'+user+'的指令') #视频网址格式:https://www.bilibili.com/video/avxxxxx ture_url=s.replace('av','https://www.bilibili.com/video/av') _thread.start_new_thread(download_av, (ture_url,user)) else: send_dm_long('已收到'+user+'的指令') #视频网址格式:https://www.bilibili.com/video/avxxxx/#page=x ture_url=s.replace('p','/#page=') ture_url=ture_url.replace('av','https://www.bilibili.com/video/av') _thread.start_new_thread(download_av, (ture_url,user)) except: print('[log]video not found') elif (s.find('温度') > -1): #send_dm_long("CPU "+os.popen('vcgencmd measure_temp').readline()) #读取命令行得到的温度 send_dm_long(get_info.getInfo()) try: temp = dht11.get_dht11() send_dm_long("温度:"+str(temp[0])+"℃,湿度:"+str(temp[1])+"%") except Exception as e: #防炸 print('shit') print(e) #send_dm_long("温湿度获取失败") elif (s.find('歌单') == 0): if check_night(): return send_dm_long('已收到'+user+'的指令') s = s.replace(' ', '') #剔除弹幕中的所有空格 _thread.start_new_thread(playlist_download, (s.replace('歌单', '', 1),user)) elif (s.find('查询') == 0): send_dm_long(user+'的瓜子余额还剩'+str(get_coin(user))+'个')