正在显示
3 个修改的文件
包含
45 行增加
和
6 行删除
| @@ -13,7 +13,7 @@ from lib import common | @@ -13,7 +13,7 @@ from lib import common | ||
| 13 | import uuid | 13 | import uuid |
| 14 | from base64 import b64decode | 14 | from base64 import b64decode |
| 15 | 15 | ||
| 16 | -from lib.common import WorkPlace | 16 | +from lib.common import WorkPlace, College |
| 17 | 17 | ||
| 18 | 18 | ||
| 19 | def _send_msg(local_func, remote_func, to, content, thread_type, suffix): | 19 | def _send_msg(local_func, remote_func, to, content, thread_type, suffix): |
| @@ -164,8 +164,11 @@ class Executor(): | @@ -164,8 +164,11 @@ class Executor(): | ||
| 164 | return objects | 164 | return objects |
| 165 | 165 | ||
| 166 | def addWork(self, work_detail, privacy='EVERYONE'): | 166 | def addWork(self, work_detail, privacy='EVERYONE'): |
| 167 | - print(work_detail) | ||
| 168 | work = WorkPlace.from_dict(work_detail) | 167 | work = WorkPlace.from_dict(work_detail) |
| 169 | - print(work) | ||
| 170 | res = self.client.addWorkPlace(work, privacy) | 168 | res = self.client.addWorkPlace(work, privacy) |
| 171 | return res | 169 | return res |
| 170 | + | ||
| 171 | + def addSchool(self, school_detail, privacy="EVERYONE"): | ||
| 172 | + school = College.from_dict(school_detail) | ||
| 173 | + res = self.client.addCollege(school, privacy) | ||
| 174 | + return res |
| @@ -105,6 +105,31 @@ class College(): | @@ -105,6 +105,31 @@ class College(): | ||
| 105 | return data | 105 | return data |
| 106 | 106 | ||
| 107 | 107 | ||
| 108 | + @classmethod | ||
| 109 | + def from_dict(cls, data: dict): | ||
| 110 | + self = cls() | ||
| 111 | + for k, v in data.items(): | ||
| 112 | + if hasattr(self, k): | ||
| 113 | + setattr(self, k, v) | ||
| 114 | + | ||
| 115 | + start_time = [] | ||
| 116 | + end_time = [] | ||
| 117 | + for x in ['year', 'month', 'day']: | ||
| 118 | + if data.get(f'date_start[{x}]'): | ||
| 119 | + start_time.append(int(data.get(f'date_start[{x}]'))) | ||
| 120 | + | ||
| 121 | + if data.get(f'date_end[{x}]'): | ||
| 122 | + end_time.append(int(data.get(f'date_end[{x}]'))) | ||
| 123 | + if start_time: | ||
| 124 | + self.start_time = datetime.date(*start_time) | ||
| 125 | + | ||
| 126 | + if end_time: | ||
| 127 | + self.end_time = datetime.date(*end_time) | ||
| 128 | + self.graduated = True | ||
| 129 | + | ||
| 130 | + return self | ||
| 131 | + | ||
| 132 | + | ||
| 108 | class TaskStatus(): | 133 | class TaskStatus(): |
| 109 | EXCEPTION = -2 | 134 | EXCEPTION = -2 |
| 110 | FAILED = -1 | 135 | FAILED = -1 |
| @@ -336,8 +336,10 @@ class FacebookClient(Client): | @@ -336,8 +336,10 @@ class FacebookClient(Client): | ||
| 336 | 'error': res['jsmods']['require'] | 336 | 'error': res['jsmods']['require'] |
| 337 | } | 337 | } |
| 338 | 338 | ||
| 339 | - def addCollege(self, college: College): | 339 | + def addCollege(self, college: College, value='EVERYONE'): |
| 340 | '''添加教育记录''' | 340 | '''添加教育记录''' |
| 341 | + | ||
| 342 | + value = PostParam.__dict__.get(value).value | ||
| 341 | data = { | 343 | data = { |
| 342 | 'experience_type': '2004', | 344 | 'experience_type': '2004', |
| 343 | 'degree_id': '0', | 345 | 'degree_id': '0', |
| @@ -345,10 +347,19 @@ class FacebookClient(Client): | @@ -345,10 +347,19 @@ class FacebookClient(Client): | ||
| 345 | 'ref': 'about_tab', | 347 | 'ref': 'about_tab', |
| 346 | 'action_type': 'add', | 348 | 'action_type': 'add', |
| 347 | 'experience_id': '0', | 349 | 'experience_id': '0', |
| 348 | - 'privacy[1588594478034907]': PostParam.EVERYONE.value} | 350 | + 'privacy[1588594478034907]': value} |
| 349 | data.update(college.to_dict()) | 351 | data.update(college.to_dict()) |
| 350 | res = self._post('/profile/edit/edu/save/', data) | 352 | res = self._post('/profile/edit/edu/save/', data) |
| 351 | - return res | 353 | + try: |
| 354 | + return { | ||
| 355 | + 'success': True, | ||
| 356 | + 'setting': res['jsmods']['require'][1][3][0]['props'] | ||
| 357 | + } | ||
| 358 | + except: | ||
| 359 | + return { | ||
| 360 | + 'success': False, | ||
| 361 | + 'error': res['jsmods']['require'] | ||
| 362 | + } | ||
| 352 | 363 | ||
| 353 | def setCurrentCity(self, city_id, city_name): | 364 | def setCurrentCity(self, city_id, city_name): |
| 354 | ''' | 365 | ''' |
-
请 注册 或 登录 后发表评论