sc-common-interface 2.6.6__tar.gz → 2.6.8__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.6.6
3
+ Version: 2.6.8
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -1,4 +1,6 @@
1
1
  import datetime
2
+ import re
3
+
2
4
  import requests
3
5
  import json
4
6
  from jsonpath import jsonpath
@@ -40,14 +42,17 @@ def delete_relate_post(data):
40
42
  # print("response",response)
41
43
  sales_data = response["data"]["list"]
42
44
  # print("sales_data",sales_data)
43
- status = [1,2]
45
+ status = [1,2,4]
46
+ if sales_type.lower()=="post":
47
+ status = [0,1,2]
44
48
  if "status" in data:
45
49
  status = data["status"]
46
50
  for i in sales_data:
47
51
  platforms = i["platforms"]
48
52
  post_sale_status = i["post_sale_status"]
49
53
  live_sdk = i["live_sdk"]
50
- if (platforms==[platform.upper()] or live_sdk==platform.upper()) and post_sale_status in status:
54
+ related_post = i["related_post"]
55
+ if (platforms==[platform.upper()] or live_sdk==platform.upper()) and related_post==True and post_sale_status in status :
51
56
  sales_id = i["id"]
52
57
  data["sales_id"] = sales_id
53
58
  # print(sales_id)
@@ -202,14 +207,28 @@ def send__live_comment(data):
202
207
  post_id = data['post_id']
203
208
  if "group_id" in data:
204
209
  post_id = data['group_id']
210
+ sales_type = "live"
211
+ if "sales_type" in data:
212
+ sales_type = data["sales_type"]
205
213
  if page_id == "" or post_id == "key":
206
214
  info = get_live_info(data)
207
- platform_list = jsonpath(info, "$..relatedPostList..platform")
208
- i = platform_list.index(platform.upper())
209
- page_id = info["data"]["relatedPostList"][i]["page_id"]
210
- platform = info["data"]["relatedPostList"][i]["platform"]
211
- post_id = info["data"]["relatedPostList"][i]["post_id"]
212
- group_id = info["data"]["relatedPostList"][i]["group_id"]
215
+ # print("info",info)
216
+ global platform_list
217
+ if sales_type.lower()=="live":
218
+ platform_list = jsonpath(info, "$..relatedPostList..platform")
219
+ i = platform_list.index(platform.upper())
220
+ page_id = info["data"]["relatedPostList"][i]["page_id"]
221
+ platform = info["data"]["relatedPostList"][i]["platform"]
222
+ post_id = info["data"]["relatedPostList"][i]["post_id"]
223
+ group_id = info["data"]["relatedPostList"][i]["group_id"]
224
+ elif sales_type.lower()=="post":
225
+ platform_list = jsonpath(info, "$..related_post_list..platform")
226
+ i = platform_list.index(platform.upper())
227
+ page_id = info["data"]["related_post_list"][i]["page_id"]
228
+ platform = info["data"]["related_post_list"][i]["platform"]
229
+ post_id = info["data"]["related_post_list"][i]["post_id"]
230
+ group_id = info["data"]["related_post_list"][i]["group_id"]
231
+
213
232
  # info = get_live_info(data)
214
233
  # related_post_list = info["data"]["relatedPostList"][0]
215
234
  # page_id = related_post_list["page_id"]
@@ -246,7 +265,14 @@ def send__live_comment(data):
246
265
  "field": "comments"}]}], "object": "instagram"}
247
266
  elif platform.upper() == "FB_GROUP":
248
267
  t_time = stamp*1000
249
- post_id = post_id.split("_")[-1]
268
+ if "-" in post_id:
269
+ post_id = post_id.split("_")[-1]
270
+ else:
271
+ print("----")
272
+ relationUrl = data["relationUrl"]
273
+ match = re.search(r'groups/(\d+)/posts/(\d+)/', relationUrl)
274
+ group_id = match.group(1)
275
+ post_id = match.group(2)
250
276
  comment_id = "%d%d" % ( stamp, num)
251
277
  body = {"object":"page","entry":[{"id":page_id,"time":t_time,"messaging":[{"recipient":{"id":page_id},"message":keyword,
252
278
  "from":{"id":user_id,"name":name},"group_id":group_id,"post_id":post_id,"comment_id":comment_id,"created_time":stamp,"item":"comment",
@@ -1279,7 +1305,7 @@ def edit_live_info(data):
1279
1305
  }
1280
1306
  }
1281
1307
  }
1282
- print(body)
1308
+ # print(body)
1283
1309
  response = requests.put(url, headers=headers, json=body).json()
1284
1310
  return response
1285
1311
 
@@ -1974,7 +2000,22 @@ def add_all_product_set_to_keyword(data):
1974
2000
 
1975
2001
 
1976
2002
  if __name__=="__main__":
1977
- data = {'env': 'https://front-admin-preview.shoplineapp.com', 'headers': {'Content-Type': 'application/json', 'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJkZmQxYjNiMDc0M2JmYWU4YTFkODk4NzczNjgyZWVkZCIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAiLCJhcHBsaWNhdGlvbl9pZCI6IjVlYjkwMzVhYjA5ZDEyNjU4NTFmOTU2ZiJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMtcHJldmlldy5zaG9wbGluZWFwcC5jb20iLCJhdWQiOltdLCJzdWIiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAifQ.Y90xLfYVAp9yByHo7Vc7A3hHrp6hX9X9Lg4mg_WiE_I', 'lang': 'en'}, 'platform': 'FB_GROUP', 'page_id': '106411048594439', 'relationUrl': 'https://www.facebook.com/groups/3592205981019493/posts/3868975560009199/', 'post_id': ['https://www.facebook.com/groups/3592205981019493/posts/3868976186675803/', 'https://www.facebook.com/groups/3592205981019493/posts/3868975560009199/', 'https://www.facebook.com/groups/3592205981019493/posts/3869121803327908/']}
1978
- data["sales_type"] = "POST"
2003
+ from sc_common_interface.PostCommonInterface import *
2004
+ data = {'env': 'https://front-admin-preview.shoplineapp.com', 'headers': {'Content-Type': 'application/json', 'authorization': 'Bearer eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJkZmQxYjNiMDc0M2JmYWU4YTFkODk4NzczNjgyZWVkZCIsImRhdGEiOnsibWVyY2hhbnRfaWQiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAiLCJhcHBsaWNhdGlvbl9pZCI6IjVlYjkwMzVhYjA5ZDEyNjU4NTFmOTU2ZiJ9LCJpc3MiOiJodHRwczovL2RldmVsb3BlcnMtcHJldmlldy5zaG9wbGluZWFwcC5jb20iLCJhdWQiOltdLCJzdWIiOiI2MWE4N2M5NzYzYjcwYzAwNTEwNmZiZDAifQ.Y90xLfYVAp9yByHo7Vc7A3hHrp6hX9X9Lg4mg_WiE_I', 'lang': 'en'}, 'platform': 'FB_GROUP', 'sales_id': 542794, 'page_id': '106411048594439', 'relationUrl': 'https://www.facebook.com/groups/3592205981019493/posts/3871576623082426/', 'post_id': ['https://www.facebook.com/groups/3592205981019493/posts/3871576623082426/', 'https://www.facebook.com/groups/3592205981019493/posts/3871571433082945/', 'https://www.facebook.com/groups/3592205981019493/posts/3872673686306053/']}
2005
+ sales_id= create_live(data)
2006
+ data["sales_id"] = sales_id
1979
2007
  delete_relate_post(data)
2008
+ add_live(data)
2009
+ data["key"] = "5e3bba98882fc0fb22a0607238bc5b8f"
2010
+ del data["post_id"]
2011
+ send__live_comment(data)
2012
+
2013
+
2014
+
2015
+
2016
+
2017
+
2018
+
2019
+
2020
+
1980
2021
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: sc-common-interface
3
- Version: 2.6.6
3
+ Version: 2.6.8
4
4
  Summary: SC贴文销售公用的接口
5
5
  Home-page: UNKNOWN
6
6
  Author: river
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name='sc-common-interface',
5
- version='2.6.6',
5
+ version='2.6.8',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),