You've already forked XiguaLiveDanmakuHelper
Compare commits
9 Commits
v0.1.4-bet
...
v0.2-beta.
Author | SHA1 | Date | |
---|---|---|---|
89edd10dc2 | |||
ebe01566c0 | |||
a0f76eb00b | |||
f81c2811ce | |||
c12d8cf4bb | |||
77d7f35d25 | |||
84ca4d0a62 | |||
4a59cbcf82 | |||
1b920fa55c |
2
Gift.py
2
Gift.py
@ -27,7 +27,7 @@ class Gift:
|
||||
elif "present_end_info" in json["extra"] and json["extra"]['present_end_info'] is not None:
|
||||
self.ID = int(json["extra"]['present_end_info']['id'])
|
||||
self.count = json["extra"]['present_end_info']['count']
|
||||
if self.ID in self.giftList:
|
||||
if self.ID != 0 and self.ID in self.giftList:
|
||||
self.amount = self.giftList[self.ID]["Price"] * self.count
|
||||
else:
|
||||
self.update()
|
||||
|
19
Lottery.py
19
Lottery.py
@ -1,5 +1,5 @@
|
||||
import requests
|
||||
|
||||
import time
|
||||
from LuckyUser import LuckyUser
|
||||
|
||||
|
||||
@ -11,13 +11,14 @@ class Lottery:
|
||||
luckyUsers = []
|
||||
joinedUserCount = 0
|
||||
prizeName = ""
|
||||
finish:int = 0
|
||||
|
||||
def __init__(self, json=None):
|
||||
if json:
|
||||
self.parse(json)
|
||||
|
||||
def parse(self, json):
|
||||
if "lottery_info" not in json or json["lottery_info"] is not None:
|
||||
if "lottery_info" in json and json["lottery_info"] is not None:
|
||||
self.isActive = int(json["lottery_info"]["status"]) > 0
|
||||
self.ID = json["lottery_info"]["lottery_id"]
|
||||
for i in json["lottery_info"]['conditions']:
|
||||
@ -26,6 +27,18 @@ class Lottery:
|
||||
self.content = i["content"]
|
||||
self.joinedUserCount = int(json["lottery_info"]["candidate_num"])
|
||||
self.prizeName = json["lottery_info"]["prize_info"]["name"]
|
||||
_delta = int(json["lottery_info"]["draw_time"]) - int(json["lottery_info"]["current_time"])
|
||||
self.finish = time.time()+_delta+1
|
||||
elif "extra" in json and json["extra"] is not None:
|
||||
if "lottery_info" in json["extra"] and json["extra"]["lottery_info"] is not None:
|
||||
return self.parse(json["extra"])
|
||||
|
||||
def update(self):
|
||||
if self.isActive:
|
||||
if not self.isFinished and self.finish > time.time():
|
||||
self.checkFinished()
|
||||
return True
|
||||
return False
|
||||
|
||||
def checkFinished(self):
|
||||
p = requests.get("https://i.snssdk.com/videolive/lottery/check_user_right?lottery_id={}"
|
||||
@ -37,7 +50,7 @@ class Lottery:
|
||||
self.isActive = False
|
||||
self.isFinished = False
|
||||
return
|
||||
self.isActive = int(d["lottery_info"]["status"]) == 1
|
||||
self.isActive = int(d["lottery_info"]["status"]) > 0
|
||||
self.isFinished = int(d["lottery_info"]["status"]) == 2
|
||||
self.joinedUserCount = int(d["lottery_info"]["candidate_num"])
|
||||
if self.isFinished:
|
||||
|
16
api.py
16
api.py
@ -104,12 +104,13 @@ class XiGuaLiveApi:
|
||||
p = s.get("https://security.snssdk.com/video/app/search/live/?version_code=730&device_platform=android"
|
||||
"&format=json&keyword={}".format(self.name))
|
||||
d = p.json()
|
||||
if "data" in d:
|
||||
if "data" in d and d["data"] is not None:
|
||||
for i in d["data"]:
|
||||
if i["block_type"] != 0:
|
||||
continue
|
||||
if len(i["cells"]) == 0:
|
||||
return
|
||||
self.isValidRoom = True
|
||||
self.isLive = i["cells"][0]["anchor"]["user_info"]["is_living"]
|
||||
self.roomID = int(i["cells"][0]["anchor"]["room_id"])
|
||||
self.roomLiver = User(i["cells"][0])
|
||||
@ -145,6 +146,7 @@ class XiGuaLiveApi:
|
||||
|
||||
def getDanmaku(self):
|
||||
if not self.isValidRoom:
|
||||
self.updRoomInfo()
|
||||
return
|
||||
p = s.get("https://i.snssdk.com/videolive/im/get_msg?cursor={cursor}&room_id={roomID}"
|
||||
"&version_code=730&device_platform=android".format(
|
||||
@ -187,13 +189,15 @@ class XiGuaLiveApi:
|
||||
self.onLike(User(i))
|
||||
else:
|
||||
pass
|
||||
if self.lottery is None or self.lottery.ID == 0:
|
||||
self.lottery = Lottery(i)
|
||||
self._updRoomCount += 1
|
||||
if self.lottery is not None and self.lottery.ID != 0:
|
||||
self.lottery.update()
|
||||
if self.lottery.isFinished:
|
||||
self.onLottery(self.lottery)
|
||||
self.lottery = None
|
||||
if self._updRoomCount > 120 or len(d['data']) == 0:
|
||||
if self.lottery is not None:
|
||||
self.lottery.checkFinished()
|
||||
if self.lottery.isFinished:
|
||||
self.onLottery(self.lottery)
|
||||
self.lottery = None
|
||||
self.updRoomInfo()
|
||||
self._updRoomCount = 0
|
||||
return
|
||||
|
13
bilibili.py
13
bilibili.py
@ -2,6 +2,7 @@
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
from datetime import datetime
|
||||
|
||||
import rsa
|
||||
@ -11,6 +12,8 @@ import hashlib
|
||||
import requests
|
||||
from urllib import parse
|
||||
|
||||
from config import config
|
||||
|
||||
|
||||
class VideoPart:
|
||||
def __init__(self, path, title='', desc=''):
|
||||
@ -322,8 +325,12 @@ class Bilibili:
|
||||
"videos": self.videos}
|
||||
)
|
||||
print(r.text)
|
||||
for _p in self.files:
|
||||
shutil.move(_p.path, "/tmp/oss/")
|
||||
if config["mv"]:
|
||||
for _p in self.files:
|
||||
shutil.move(_p.path, config["mtd"])
|
||||
elif config["del"]:
|
||||
for _p in self.files:
|
||||
os.remove(_p.path)
|
||||
|
||||
def appendUpload(self,
|
||||
aid,
|
||||
@ -422,8 +429,6 @@ class Bilibili:
|
||||
"videos": self.videos}
|
||||
)
|
||||
print(r.text)
|
||||
for _p in self.files:
|
||||
os.remove(_p.path)
|
||||
|
||||
def addChannel(self, name, intro=''):
|
||||
"""
|
||||
|
@ -23,13 +23,16 @@ class downloader(XiGuaLiveApi):
|
||||
self.updPlayList()
|
||||
|
||||
def updPlayList(self):
|
||||
if "stream_url" not in self._rawRoomInfo:
|
||||
if self.playlist is None:
|
||||
self.apiChangedError("无法获取直播链接")
|
||||
self.playlist = False
|
||||
if self.isLive:
|
||||
if "stream_url" not in self._rawRoomInfo:
|
||||
if self.playlist is None:
|
||||
self.apiChangedError("无法获取直播链接")
|
||||
self.playlist = False
|
||||
else:
|
||||
self.playlist = self._rawRoomInfo["stream_url"]["alternate_pull_url"]
|
||||
self.playlist = self.playlist.replace("_uhd","").replace("_sd","").replace("_ld","")
|
||||
else:
|
||||
self.playlist = self._rawRoomInfo["stream_url"]["alternate_pull_url"]
|
||||
self.playlist = self.playlist.replace("_uhd","").replace("_sd","").replace("_ld","")
|
||||
print("未开播,等待开播")
|
||||
|
||||
def onLike(self, user):
|
||||
pass
|
||||
|
Reference in New Issue
Block a user