def __init__(self, parent=None): QWidget.__init__(self, parent) self.ui() self.widgetList = [] self.nuberOfCall = 0 self.parent = parent requester = HRequester() postRequester = HPostRequester() self.closeBtn.clicked.connect(lambda: self.parent.widgetsConductor(self, delete=True)) self.btn_unsubscribeEverything.clicked.connect(self.unsubscribeEverything) self.btn_resevedOneFriend.clicked.connect(self.resevedOneFriend) chil = [item for item in self.parent.itemList if item.b.checkState() == 2 and item.frozen == 0] for item in chil: getUrl = UrlAPI(item.token) postRequester(getUrl.execute(), item.session, item, data={'code': self.getCode()}) response = postRequester.request() response.sort(key=lambda r: json.loads(r[0].text)['response'][0]['count']) for r in response: j = json.loads(r[0].text)['response'] item = r[2][0] masSended = [sended for sended in j[1]['items']] masReceived = [received for received in j[2]['items']] self.addAccaunt(item, str(j[0]['count']), str(j[1]['count']), str(j[2]['count']), masSended, masReceived) self.parent.statusBar.showMessage( 'Загруженно акков ' + str(len(response)) + '/' + str(len(chil)))
def getInfoMembers(self): members = [] for i in range(0, divmod(len(self.mas_ids), 5000)[0] + 1): code = 'var mas = [];' for j in range(10): line = self.getLine(j) if line == '''var friends'''+ str(j) +''' = API.users.get({"user_ids":"","fields":"photo_id,online"});''': break else: code += line + 'mas = mas + friends' + str(j) + ';' code += '''return mas;''' print(code) random_chil = random.choice(self.chil) session = random_chil.session getUrl = UrlAPI(random_chil.token) self.postRequester(getUrl.execute(), session, 'null', data={'code': code}) response = self.postRequester.request() for r in response: print(r[0].text) j = json.loads(r[0].text) print(len(j['response'])) [members.append(user) for user in j['response']] print(len(members)) if self.checkBoxOnline.checkState() == 2: members = [user for user in members if user['online'] == 1] return members
def getDialogs(self): self.widgetsConductor(self.listDialog, show=True) self.listDialog.clear() session = self.listAccaunt.itemWidget( self.listAccaunt.currentItem()).session token = self.listAccaunt.itemWidget( self.listAccaunt.currentItem()).token print(session.proxies) print(token) getUrl = UrlAPI(token) urlExecute = getUrl.execute() response = session.post(urlExecute, data={'code': MyData.CODE_DIALOGS}, proxies=session.proxies) try: dataResponse = json.loads(response.text) dialogs = dataResponse['response']['dialogs'] users = dataResponse['response']['users'] except Exception as e: print(e) return print(response.text) # Count unread dialogs if 'unread_dialogs' in dialogs: listItem = QListWidgetItem() listItem.setIcon(QtGui.QIcon('src/envelope.png')) listItem.setText('Непрочитанных: ' + str(dialogs['unread_dialogs'])) self.listDialog.addItem(listItem) # Filling dialogs and mark photos for item in dialogs['items']: if 'chat_id' in item['message']: listItem = QListWidgetItem() listItem.setSizeHint(QtCore.QSize(200, 80)) myListItem = ItemDialog() myListItem.setReadState(item['message']['read_state']) myListItem.setMessage(item['message']['body']) myListItem.setName(item['message']['title'], item['message']['user_id']) self.listDialog.addItem(listItem) self.listDialog.setItemWidget(listItem, myListItem) else: if item['message']['user_id'] == 100: listItem = QListWidgetItem() listItem.setSizeHint(QtCore.QSize(200, 80)) myListItem = ItemDialog() if 'unread' in item: myListItem.setUnread(1) else: myListItem.setReadState(item['message']['read_state']) myListItem.setMessage(item['message']['body']) myListItem.setName('VK', item['message']['user_id']) self.listDialog.addItem(listItem) self.listDialog.setItemWidget(listItem, myListItem) elif item['message']['user_id'] < 0: listItem = QListWidgetItem() listItem.setSizeHint(QtCore.QSize(200, 80)) myListItem = ItemDialog() myListItem.setName('Сообщество', item['message']['user_id']) myListItem.setMessage(item['message']['body']) myListItem.setReadState(item['message']['read_state']) self.listDialog.addItem(listItem) self.listDialog.setItemWidget(listItem, myListItem) else: listItem = QListWidgetItem() listItem.setSizeHint(QtCore.QSize(200, 80)) myListItem = ItemDialog() if 'unread' in item: myListItem.setUnread(1) else: myListItem.setReadState(item['message']['read_state']) myListItem.setMessage(item['message']['body']) [ myListItem.setName( user['first_name'] + ' ' + user['last_name'], item['message']['user_id']) for user in users if user['id'] == item['message']['user_id'] ] self.listDialog.addItem(listItem) self.listDialog.setItemWidget(listItem, myListItem)