You've already forked XiguaLiveDanmakuHelper
							
							更改状态图片,更改liveDownloader的连接池,api使用连接池
This commit is contained in:
		
							
								
								
									
										12
									
								
								api.py
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								api.py
									
									
									
									
									
								
							| @@ -10,7 +10,6 @@ from Struct.Lottery import Lottery | |||||||
| import requests | import requests | ||||||
| import time | import time | ||||||
|  |  | ||||||
| s = requests.Session() |  | ||||||
|  |  | ||||||
| DEBUG = False | DEBUG = False | ||||||
|  |  | ||||||
| @@ -27,6 +26,7 @@ class XiGuaLiveApi: | |||||||
|     _cursor = "0" |     _cursor = "0" | ||||||
|     _updRoomCount = 0 |     _updRoomCount = 0 | ||||||
|     lottery = None |     lottery = None | ||||||
|  |     s = requests.session() | ||||||
|  |  | ||||||
|     def __init__(self, name: str = "永恒de草薙"): |     def __init__(self, name: str = "永恒de草薙"): | ||||||
|         """ |         """ | ||||||
| @@ -153,7 +153,7 @@ class XiGuaLiveApi: | |||||||
|         :return: |         :return: | ||||||
|         """ |         """ | ||||||
|         try: |         try: | ||||||
|             p = s.get("https://security.snssdk.com/video/app/search/live/?version_code=730&device_platform=android" |             p = self.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() | ||||||
|         except json.decoder.JSONDecodeError as e: |         except json.decoder.JSONDecodeError as e: | ||||||
| @@ -186,7 +186,7 @@ class XiGuaLiveApi: | |||||||
|         :return: |         :return: | ||||||
|         """ |         """ | ||||||
|         try: |         try: | ||||||
|             p = s.post("https://i.snssdk.com/videolive/room/enter?version_code=730" |             p = self.s.post("https://i.snssdk.com/videolive/room/enter?version_code=730" | ||||||
|                        "&device_platform=android", |                        "&device_platform=android", | ||||||
|                        data="room_id={roomID}&version_code=730" |                        data="room_id={roomID}&version_code=730" | ||||||
|                             "&device_platform=android".format(roomID=self.roomID), |                             "&device_platform=android".format(roomID=self.roomID), | ||||||
| @@ -232,7 +232,7 @@ class XiGuaLiveApi: | |||||||
|         :param userId: 用户ID |         :param userId: 用户ID | ||||||
|         :return: XiGuaLiveApi |         :return: XiGuaLiveApi | ||||||
|         """ |         """ | ||||||
|         p = s.get("https://live.ixigua.com/api/room?anchorId={room}".format(room=userId)) |         p = requests.get("https://live.ixigua.com/api/room?anchorId={room}".format(room=userId)) | ||||||
|         if DEBUG: |         if DEBUG: | ||||||
|             print(p.text) |             print(p.text) | ||||||
|         d = p.json() |         d = p.json() | ||||||
| @@ -249,7 +249,7 @@ class XiGuaLiveApi: | |||||||
|         :return: array: 搜索结果 |         :return: array: 搜索结果 | ||||||
|         """ |         """ | ||||||
|         ret = [] |         ret = [] | ||||||
|         p = s.get("https://security.snssdk.com/video/app/search/live/?version_code=730&device_platform=android" |         p = requests.get("https://security.snssdk.com/video/app/search/live/?version_code=730&device_platform=android" | ||||||
|                   "&format=json&keyword={}".format(keyword)) |                   "&format=json&keyword={}".format(keyword)) | ||||||
|         d = p.json() |         d = p.json() | ||||||
|         if "data" in d: |         if "data" in d: | ||||||
| @@ -266,7 +266,7 @@ class XiGuaLiveApi: | |||||||
|         if not self.isValidRoom: |         if not self.isValidRoom: | ||||||
|             self.updRoomInfo() |             self.updRoomInfo() | ||||||
|             return |             return | ||||||
|         p = s.get("https://i.snssdk.com/videolive/im/get_msg?cursor={cursor}&room_id={roomID}" |         p = self.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( | ||||||
|                       roomID=self.roomID, |                       roomID=self.roomID, | ||||||
|                       cursor=self._cursor |                       cursor=self._cursor | ||||||
|   | |||||||
| @@ -15,11 +15,12 @@ isDownload = False | |||||||
| def download(): | def download(): | ||||||
|     global isDownload |     global isDownload | ||||||
|     while Common.api.isLive and not Common.forceNotDownload: |     while Common.api.isLive and not Common.forceNotDownload: | ||||||
|  |         session = requests.session() | ||||||
|         if not Common.streamUrl: |         if not Common.streamUrl: | ||||||
|             Common.appendError("Download with No StreamUrl Specific") |             Common.appendError("Download with No StreamUrl Specific") | ||||||
|             break |             break | ||||||
|         path = datetime.strftime(datetime.now(), "%Y%m%d_%H%M.flv") |         path = datetime.strftime(datetime.now(), "%Y%m%d_%H%M.flv") | ||||||
|         p = requests.get(Common.streamUrl, stream=True) |         p = session.get(Common.streamUrl, stream=True, timeout=10) | ||||||
|         if p.status_code != 200: |         if p.status_code != 200: | ||||||
|             Common.appendDownloadStatus("Download with Response {}".format(p.status_code)) |             Common.appendDownloadStatus("Download with Response {}".format(p.status_code)) | ||||||
|             break |             break | ||||||
|   | |||||||
| @@ -21,9 +21,9 @@ | |||||||
|             <td style="width: 33%">磁盘近三天</td> |             <td style="width: 33%">磁盘近三天</td> | ||||||
|         </tr> |         </tr> | ||||||
|         <tr> |         <tr> | ||||||
|             <td><img style="width: 100%" src="/images/rrd/df-srv-dev-disk-by-id-usb-Hitachi_HTS541612J9AT00_000000000000-0-0-part1-half_day.png"></td> |             <td><img style="width: 100%" src="/images/rrd/df-srv-dev-disk-by-label-6TB-half_day.png"></td> | ||||||
|             <td><img style="width: 100%" src="/images/rrd/df-srv-dev-disk-by-id-usb-Hitachi_HTS541612J9AT00_000000000000-0-0-part1-day.png"></td> |             <td><img style="width: 100%" src="/images/rrd/df-srv-dev-disk-by-label-6TB-day.png"></td> | ||||||
|             <td><img style="width: 100%" src="/images/rrd/df-srv-dev-disk-by-id-usb-Hitachi_HTS541612J9AT00_000000000000-0-0-part1-three_days.png"></td> |             <td><img style="width: 100%" src="/images/rrd/df-srv-dev-disk-by-label-6TB-three_days.png"></td> | ||||||
|         </tr> |         </tr> | ||||||
|     </table> |     </table> | ||||||
|     <hr/> |     <hr/> | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user