From aeace870c3a1027c622036051dd857b0cc8b42b3 Mon Sep 17 00:00:00 2001 From: chenjunxue <1523825571@qq.com> Date: Sat, 29 Aug 2020 15:49:07 +0800 Subject: [PATCH] 2.2.7 增加'我的照片翻页获取','删除照片'接口 --- conf/config.yaml | 4 ++-- lib/facebook.py | 31 +++++++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/conf/config.yaml b/conf/config.yaml index bec8a80..084eb56 100644 --- a/conf/config.yaml +++ b/conf/config.yaml @@ -4,5 +4,5 @@ SERVER: reconnect_interval: 3 VERSION: - code: 116 - name: 2.2.6 \ No newline at end of file + code: 117 + name: 2.2.7 \ No newline at end of file diff --git a/lib/facebook.py b/lib/facebook.py index 12992ea..7d1b00a 100644 --- a/lib/facebook.py +++ b/lib/facebook.py @@ -25,6 +25,7 @@ import retrying from bs4 import BeautifulSoup from fbchat import (Client, FBchatException, FBchatUserError, Message, Sticker, ThreadType, _exception, _graphql, _util, log) +from furl import furl from lib import common, download, google_map, graph from lib._mqtt import MqttClient @@ -2025,8 +2026,10 @@ class FacebookClient(Client): pic_id = li.attrs.get('data-fbid', None) url = li.attrs.get('data-starred-src', None) label = li.a.attrs.get('aria-label', None) + set_id = furl(li.a.attrs['href']).args.get('set', None) data = { 'pic_id': pic_id, + 'set_id': set_id, 'url': url, 'label': label } @@ -2039,7 +2042,7 @@ class FacebookClient(Client): else: num_list = cache.get(f'{self.email}:AllPhotosAppCollectionPagelet') pagelet_token = cache.get(f'{self.email}:AllPhotosAppCollectionPagelet:pagelet_token') - assert num_list is not None, '游标失效,请重新获取首页游标。' + assert num_list is not None, 'cursor失效。' get_data = {"collection_token": f"{num_list[0]}:{num_list[1]}:{num_list[2]}", "cursor": cursor, "disablepager": False, "overview": False, "profile_id": num_list[0], @@ -2058,15 +2061,17 @@ class FacebookClient(Client): f = self._state._get(url, {}) except Exception as err: print(err) - soup = BeautifulSoup(f, 'lxml') + soup = BeautifulSoup(f['payload'], 'lxml') lis = soup.find_all("li", {"class": "fbPhotoStarGridElement"}) data_list = list() for li in lis: pic_id = li.attrs.get('data-fbid', None) url = li.attrs.get('data-starred-src', None) label = li.a.attrs.get('aria-label', None) + set_id = furl(li.a.attrs['href']).args.get('set', None) data = { 'pic_id': pic_id, + 'set_id': set_id, 'url': url, 'label': label } @@ -2077,6 +2082,28 @@ class FacebookClient(Client): } return res + def delete_dialog(self, pic_id, set_id): + """ + 删除照片 + """ + data = { + 'fbid': pic_id, + 'version': '9', + 'set': set_id, + 'next': '3143051995809753', + 'dpr': '2', + 'fb_dtsg': self._state.fb_dtsg_ag, + 'jazoest': self._state.jazoest, + 'confirmed': 1 + } + + url = '/ajax/photos/photo/delete/dialog.php' + try: + res = self._post(url, data) + return {"success": True} + except: + return {"success": False} + ###############graph接口 start ############## def checkVaild(self): -- libgit2 0.24.0