sc-common-interface 2.6.6__tar.gz → 2.6.7__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.7
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
@@ -202,14 +204,28 @@ def send__live_comment(data):
202
204
  post_id = data['post_id']
203
205
  if "group_id" in data:
204
206
  post_id = data['group_id']
207
+ sales_type = "live"
208
+ if "sales_type" in data:
209
+ sales_type = data["sales_type"]
205
210
  if page_id == "" or post_id == "key":
206
211
  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"]
212
+ # print("info",info)
213
+ global platform_list
214
+ if sales_type.lower()=="live":
215
+ platform_list = jsonpath(info, "$..relatedPostList..platform")
216
+ i = platform_list.index(platform.upper())
217
+ page_id = info["data"]["relatedPostList"][i]["page_id"]
218
+ platform = info["data"]["relatedPostList"][i]["platform"]
219
+ post_id = info["data"]["relatedPostList"][i]["post_id"]
220
+ group_id = info["data"]["relatedPostList"][i]["group_id"]
221
+ elif sales_type.lower()=="post":
222
+ platform_list = jsonpath(info, "$..related_post_list..platform")
223
+ i = platform_list.index(platform.upper())
224
+ page_id = info["data"]["related_post_list"][i]["page_id"]
225
+ platform = info["data"]["related_post_list"][i]["platform"]
226
+ post_id = info["data"]["related_post_list"][i]["post_id"]
227
+ group_id = info["data"]["related_post_list"][i]["group_id"]
228
+
213
229
  # info = get_live_info(data)
214
230
  # related_post_list = info["data"]["relatedPostList"][0]
215
231
  # page_id = related_post_list["page_id"]
@@ -246,7 +262,13 @@ def send__live_comment(data):
246
262
  "field": "comments"}]}], "object": "instagram"}
247
263
  elif platform.upper() == "FB_GROUP":
248
264
  t_time = stamp*1000
249
- post_id = post_id.split("_")[-1]
265
+ if "-" in post_id:
266
+ post_id = post_id.split("_")[-1]
267
+ else:
268
+ relationUrl = data["relationUrl"]
269
+ match = re.search(r'groups/(\d+)/posts/(\d+)/', relationUrl)
270
+ group_id = match.group(1)
271
+ post_id = match.group(2)
250
272
  comment_id = "%d%d" % ( stamp, num)
251
273
  body = {"object":"page","entry":[{"id":page_id,"time":t_time,"messaging":[{"recipient":{"id":page_id},"message":keyword,
252
274
  "from":{"id":user_id,"name":name},"group_id":group_id,"post_id":post_id,"comment_id":comment_id,"created_time":stamp,"item":"comment",
@@ -1974,7 +1996,24 @@ def add_all_product_set_to_keyword(data):
1974
1996
 
1975
1997
 
1976
1998
  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"
1999
+ from sc_common_interface.PostCommonInterface import *
2000
+ 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/'], 'sales_type': 'POST'}
2001
+ __,sales_id = create_general_post(data)
2002
+ print(data)
1979
2003
  delete_relate_post(data)
2004
+ data["sales_id"] = sales_id
2005
+ res = relate_post(data)
2006
+ print(res)
2007
+ data["quantity"] = 100
2008
+ modelone_create_single_product(data)
2009
+ del data["post_id"]
2010
+ publish_post(data)
2011
+
2012
+
2013
+
2014
+
2015
+
2016
+
2017
+
2018
+
1980
2019
 
@@ -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.7
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.7',
6
6
  description='SC贴文销售公用的接口',
7
7
  author='river',
8
8
  packages=find_packages(),