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