You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
41 lines
855 B
Python
41 lines
855 B
Python
2 years ago
|
import json
|
||
|
import requests
|
||
|
import base64
|
||
|
|
||
|
with open('cfg.json', 'r') as f:
|
||
|
cfg_dict = json.load(f)
|
||
|
|
||
|
|
||
|
def send_result(file_path, url):
|
||
|
"""
|
||
|
发送视频
|
||
|
Args:
|
||
|
file_path:
|
||
|
url:
|
||
|
|
||
|
Returns:
|
||
|
|
||
|
"""
|
||
|
username = cfg_dict['username']
|
||
|
password = cfg_dict['password']
|
||
|
headers = {'Content-type': 'video/mp4', 'Authorization': 'Basic ' + f'<{username}>:<{password}>'}
|
||
|
files = {'file': open(file_path, 'rb')}
|
||
|
response = requests.post(url, files=files, headers=headers)
|
||
|
return response
|
||
|
|
||
|
|
||
|
def encode_info(info):
|
||
|
"""
|
||
|
加密
|
||
|
"""
|
||
|
encoded_info = base64.b64encode(info.encode('utf-8')).decode("utf-8")
|
||
|
return encoded_info
|
||
|
|
||
|
|
||
|
def decode_info(encoded_info):
|
||
|
"""
|
||
|
解密
|
||
|
"""
|
||
|
info = base64.b64decode(encoded_info.encode('utf-8')).decode('utf-8')
|
||
|
return info
|