作者 陈俊学

2.2.7

增加'我的照片翻页获取','删除照片'接口
@@ -4,5 +4,5 @@ SERVER: @@ -4,5 +4,5 @@ SERVER:
4 reconnect_interval: 3 4 reconnect_interval: 3
5 5
6 VERSION: 6 VERSION:
7 - code: 116  
8 - name: 2.2.6  
  7 + code: 117
  8 + name: 2.2.7
@@ -25,6 +25,7 @@ import retrying @@ -25,6 +25,7 @@ import retrying
25 from bs4 import BeautifulSoup 25 from bs4 import BeautifulSoup
26 from fbchat import (Client, FBchatException, FBchatUserError, Message, Sticker, 26 from fbchat import (Client, FBchatException, FBchatUserError, Message, Sticker,
27 ThreadType, _exception, _graphql, _util, log) 27 ThreadType, _exception, _graphql, _util, log)
  28 +from furl import furl
28 29
29 from lib import common, download, google_map, graph 30 from lib import common, download, google_map, graph
30 from lib._mqtt import MqttClient 31 from lib._mqtt import MqttClient
@@ -2025,8 +2026,10 @@ class FacebookClient(Client): @@ -2025,8 +2026,10 @@ class FacebookClient(Client):
2025 pic_id = li.attrs.get('data-fbid', None) 2026 pic_id = li.attrs.get('data-fbid', None)
2026 url = li.attrs.get('data-starred-src', None) 2027 url = li.attrs.get('data-starred-src', None)
2027 label = li.a.attrs.get('aria-label', None) 2028 label = li.a.attrs.get('aria-label', None)
  2029 + set_id = furl(li.a.attrs['href']).args.get('set', None)
2028 data = { 2030 data = {
2029 'pic_id': pic_id, 2031 'pic_id': pic_id,
  2032 + 'set_id': set_id,
2030 'url': url, 2033 'url': url,
2031 'label': label 2034 'label': label
2032 } 2035 }
@@ -2039,7 +2042,7 @@ class FacebookClient(Client): @@ -2039,7 +2042,7 @@ class FacebookClient(Client):
2039 else: 2042 else:
2040 num_list = cache.get(f'{self.email}:AllPhotosAppCollectionPagelet') 2043 num_list = cache.get(f'{self.email}:AllPhotosAppCollectionPagelet')
2041 pagelet_token = cache.get(f'{self.email}:AllPhotosAppCollectionPagelet:pagelet_token') 2044 pagelet_token = cache.get(f'{self.email}:AllPhotosAppCollectionPagelet:pagelet_token')
2042 - assert num_list is not None, '游标失效,请重新获取首页游标。' 2045 + assert num_list is not None, 'cursor失效。'
2043 get_data = {"collection_token": f"{num_list[0]}:{num_list[1]}:{num_list[2]}", 2046 get_data = {"collection_token": f"{num_list[0]}:{num_list[1]}:{num_list[2]}",
2044 "cursor": cursor, 2047 "cursor": cursor,
2045 "disablepager": False, "overview": False, "profile_id": num_list[0], 2048 "disablepager": False, "overview": False, "profile_id": num_list[0],
@@ -2058,15 +2061,17 @@ class FacebookClient(Client): @@ -2058,15 +2061,17 @@ class FacebookClient(Client):
2058 f = self._state._get(url, {}) 2061 f = self._state._get(url, {})
2059 except Exception as err: 2062 except Exception as err:
2060 print(err) 2063 print(err)
2061 - soup = BeautifulSoup(f, 'lxml') 2064 + soup = BeautifulSoup(f['payload'], 'lxml')
2062 lis = soup.find_all("li", {"class": "fbPhotoStarGridElement"}) 2065 lis = soup.find_all("li", {"class": "fbPhotoStarGridElement"})
2063 data_list = list() 2066 data_list = list()
2064 for li in lis: 2067 for li in lis:
2065 pic_id = li.attrs.get('data-fbid', None) 2068 pic_id = li.attrs.get('data-fbid', None)
2066 url = li.attrs.get('data-starred-src', None) 2069 url = li.attrs.get('data-starred-src', None)
2067 label = li.a.attrs.get('aria-label', None) 2070 label = li.a.attrs.get('aria-label', None)
  2071 + set_id = furl(li.a.attrs['href']).args.get('set', None)
2068 data = { 2072 data = {
2069 'pic_id': pic_id, 2073 'pic_id': pic_id,
  2074 + 'set_id': set_id,
2070 'url': url, 2075 'url': url,
2071 'label': label 2076 'label': label
2072 } 2077 }
@@ -2077,6 +2082,28 @@ class FacebookClient(Client): @@ -2077,6 +2082,28 @@ class FacebookClient(Client):
2077 } 2082 }
2078 return res 2083 return res
2079 2084
  2085 + def delete_dialog(self, pic_id, set_id):
  2086 + """
  2087 + 删除照片
  2088 + """
  2089 + data = {
  2090 + 'fbid': pic_id,
  2091 + 'version': '9',
  2092 + 'set': set_id,
  2093 + 'next': '3143051995809753',
  2094 + 'dpr': '2',
  2095 + 'fb_dtsg': self._state.fb_dtsg_ag,
  2096 + 'jazoest': self._state.jazoest,
  2097 + 'confirmed': 1
  2098 + }
  2099 +
  2100 + url = '/ajax/photos/photo/delete/dialog.php'
  2101 + try:
  2102 + res = self._post(url, data)
  2103 + return {"success": True}
  2104 + except:
  2105 + return {"success": False}
  2106 +
2080 ###############graph接口 start ############## 2107 ###############graph接口 start ##############
2081 2108
2082 def checkVaild(self): 2109 def checkVaild(self):