|
@@ -0,0 +1,81 @@
|
|
|
+# -*- coding: utf-8 -*-
|
|
|
+# @Author: wangkun
|
|
|
+# @Time: 2023/5/10
|
|
|
+import uuid, requests
|
|
|
+
|
|
|
+
|
|
|
+class Demo:
|
|
|
+ @classmethod
|
|
|
+ def get_default_user(cls):
|
|
|
+ url = "https://api-internal.piaoquantv.com/user-center/info/getDefaultUserInfo"
|
|
|
+ payload = {"params": {"mid": str(uuid.uuid1())}}
|
|
|
+ headers = {
|
|
|
+ 'Content-Type': 'application/json'
|
|
|
+ }
|
|
|
+ response = requests.request("POST", url, headers=headers, json=payload).json()
|
|
|
+ return response['data']
|
|
|
+
|
|
|
+ @classmethod
|
|
|
+ def create_uid(cls, user_dict, env):
|
|
|
+ """
|
|
|
+ 创建站内虚拟 UID
|
|
|
+ :param user_dict: 字典{'nickName': 用户名, 'avatarUrl': 头像, 'tagName': 站内用户标签}
|
|
|
+ :param env: 环境
|
|
|
+ :return: 站内 UID
|
|
|
+ """
|
|
|
+ if env == 'dev':
|
|
|
+ # 外网
|
|
|
+ url = 'https://videotest.yishihui.com/longvideoapi/user/virtual/crawler/registerVirtualUser'
|
|
|
+ # 内网
|
|
|
+ # url = 'http://videotest-internal.yishihui.com/longvideoapi/user/virtual/crawler/registerVirtualUser'
|
|
|
+ elif env == 'prod':
|
|
|
+ # 外网
|
|
|
+ url = 'https://longvideoapi.piaoquantv.com/longvideoapi/user/virtual/crawler/registerVirtualUser'
|
|
|
+ # 内网
|
|
|
+ # url = 'http://longvideoapi-internal.piaoquantv.com/longvideoapi/user/virtual/crawler/registerVirtualUser'
|
|
|
+ else:
|
|
|
+ # 外网
|
|
|
+ url = 'https://longvideoapi.piaoquantv.com/longvideoapi/user/virtual/crawler/registerVirtualUser'
|
|
|
+ # 内网
|
|
|
+ # url = 'http://longvideoapi-internal.piaoquantv.com/longvideoapi/user/virtual/crawler/registerVirtualUser'
|
|
|
+ params = {
|
|
|
+ # 'count': 1, # (必须)账号个数:传1
|
|
|
+ # 'accountType': 4, # (必须)账号类型 :传 4 app虚拟账号
|
|
|
+ 'recommendStatus': user_dict.get('recommendStatus', -6),
|
|
|
+ 'appRecommendStatus': user_dict.get('appRecommendStatus', -6),
|
|
|
+ 'pwd': '', # 密码 默认 12346
|
|
|
+ 'nickName': user_dict['nickName'], # 昵称 默认 vuser......
|
|
|
+ 'avatarUrl': user_dict['avatarUrl'],
|
|
|
+ # 头像Url 默认 http://weapppiccdn.yishihui.com/resources/images/pic_normal.png
|
|
|
+ # 'tagName': user_dict['tagName'], # 多条数据用英文逗号分割
|
|
|
+ }
|
|
|
+ response = requests.post(url=url, params=params)
|
|
|
+ # print(response.text)
|
|
|
+ user_id = response.json()['data']
|
|
|
+ return user_id
|
|
|
+
|
|
|
+ @classmethod
|
|
|
+ def create_user(cls, env):
|
|
|
+ default_user = cls.get_default_user()
|
|
|
+ # 用来创建our_id的信息
|
|
|
+ user_dict = {
|
|
|
+ 'recommendStatus': -6,
|
|
|
+ 'appRecommendStatus': -6,
|
|
|
+ 'nickName': default_user['nickName'],
|
|
|
+ 'avatarUrl': default_user['avatarUrl'],
|
|
|
+ # 'tagName': f'{tag1},{tag2},{tag3},{tag4},{tag5}',
|
|
|
+ }
|
|
|
+ our_uid = cls.create_uid(user_dict, env)
|
|
|
+ if env == 'prod':
|
|
|
+ our_user_link = f'https://admin.piaoquantv.com/ums/user/{our_uid}/post'
|
|
|
+ else:
|
|
|
+ our_user_link = f'https://testadmin.piaoquantv.com/ums/user/{our_uid}/post'
|
|
|
+ print(our_uid)
|
|
|
+ print(our_user_link)
|
|
|
+
|
|
|
+
|
|
|
+if __name__ == "__main__":
|
|
|
+ print(uuid.uuid1())
|
|
|
+ # for i in range(10):
|
|
|
+ # # 正式环境
|
|
|
+ # Demo.create_user("prod")
|