forked from zhangfei28/TTBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathuser.py
46 lines (39 loc) · 1.43 KB
/
user.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#coding:utf-8
import json
from util.tools import time_to_date
from util.jstool import py_to_js
from settings import URL_HOST,URL_ARTICLE_ITEM,\
F_PARAMS,signature_js_path,signature_js_func
def published_data_cleaner(item):
item['behot_time'] = time_to_date(item.get('behot_time'))
item['image_url'] = 'http:' + item.get('image_url','')
item['media_url'] = URL_HOST + item.get('media_url','')
item['source_url'] = URL_HOST + item.get('source_url','')
item['url'] = URL_ARTICLE_ITEM.format(item_id=item.get('item_id',''))
return item
def weitt_cleaner(item):
result = {}
data = item.get('concern_talk_cell')
_data = item.get('stream_cell')
if data:
result['wid'] = data.get('id')
json_str = data.get('packed_json_str')
json_data = json.loads(json_str)
result.update(json_data)
result['create_time'] = time_to_date(json_data.get('create_time'))
elif _data:
result['wid'] = _data.get('id')
raw_data = json.loads(_data.get('raw_data'))
result.update(raw_data)
return result
def f_cleaner(item):
item['open_url'] = URL_HOST + item.get('open_url')
item['avatar_url'] = 'http:' + item.get('avatar_url')
return item
def payload_for_relation(uid,cursor):
F_PARAMS.update({
'user_id': uid,
'cursor': cursor,
'_signature': py_to_js(signature_js_path, signature_js_func, (uid, cursor)),
})
return F_PARAMS