You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.5 KiB
68 lines
2.5 KiB
import requests |
|
import time |
|
import json |
|
from urllib.parse import urljoin |
|
from lib.sign_key import SignKey |
|
from lib.gzip_base64 import gzip_base64_cmc2dh |
|
from cmc2dh.config import cinema_info, base_url |
|
|
|
|
|
class MoviePublisherInfo: |
|
def __init__(self): |
|
# 初始化签名生成类的对象 |
|
self.sign_key = SignKey() |
|
# 生成请求参数 |
|
self.api_func = 'moviePublisherInfo' |
|
self.current_timestamp = round(time.time() * 1000) # 生成时间戳 |
|
self.current_time = time.strftime('%Y%m%d%H%M%S', time.localtime(int(self.current_timestamp / 1000))) # 生成时间字符串 |
|
|
|
def prepare(self): |
|
pass |
|
|
|
def request(self, gzip=True): |
|
# 初始化原始的请求参数 |
|
origin_data = { |
|
'cinemaCode': cinema_info['code'], |
|
'data': [ |
|
{ |
|
'contactAddress': '宿松宿松宿松宿', |
|
'contactFax': '015554545', |
|
'contactPersonName': '夺大规模 ', |
|
'contactPhone': '01041484434', |
|
'id': '200028', |
|
'operateFlag': 2, |
|
'publisherCode': '200028', |
|
'publisherName': '宿松发行商', |
|
'version': self.current_timestamp |
|
} |
|
], |
|
'extend': { |
|
'timeStamp': self.current_time, |
|
'sign': self.sign_key.sign_dh(cinema_info['code'], self.api_func, self.current_time), |
|
'apiFunc': self.api_func, |
|
'info': json.dumps({'startDatetime': 0, |
|
'cinemaCode': cinema_info['code'], |
|
'flag': 0, |
|
'dataCount': 1, |
|
'endDatetime': self.current_timestamp, |
|
'packageCode': '4c73a88d - db3a - 4109 - a617 - 4202c04fb581'}) |
|
} |
|
} |
|
# 对原始请求进行加密压缩 |
|
req_data = {'data': gzip_base64_cmc2dh(origin_data)} # 请求不压缩数据 |
|
if gzip: |
|
req_data = {'data': gzip_base64_cmc2dh(origin_data)} # 请求压缩数据 |
|
print(origin_data) |
|
print(req_data) |
|
|
|
# 发送请求 |
|
r = requests.post(urljoin('http://' + cinema_info['ip'], base_url), data=req_data) |
|
print(r.json()) |
|
|
|
def handle(self): |
|
pass |
|
|
|
|
|
if __name__ == "__main__": |
|
movie_publisher_info = MoviePublisherInfo() |
|
movie_publisher_info.request()
|
|
|