From c173fe02be6fd7034017666f7672ace6190387aa Mon Sep 17 00:00:00 2001 From: Edouard360 Date: Mon, 29 Jul 2019 12:31:53 -0700 Subject: [PATCH 1/2] TagBase.delete_tags --- feedly/api_client/data.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/feedly/api_client/data.py b/feedly/api_client/data.py index 5ee3e0f..e0e9e61 100644 --- a/feedly/api_client/data.py +++ b/feedly/api_client/data.py @@ -76,6 +76,24 @@ def tag_entries(self, entry_ids: List[str]): self._client.do_api_request(f'/v3/tags/{quote_plus(self["id"])}', method='put', data={'entryIds': [entry_id for entry_id in entry_ids]}) + def delete_tags(self, options: StreamOptions = None): + """ + *** WARNING *** Non-reversible operation + Given a TagBas Streamable, remove tags corresponding to this tag stream, whichever user saved it, for + all articles downloaded with options StreamOptions. + :param options: specify high max_count to empty the board. + :return: + """ + a_ids = [a["id"] for a in self.stream_contents(options)] + tag_id = self._get_id() + while len(a_ids) > 0: + batch_size = 50 # limitation due to the url length: articles are "de-tagged" by batch of 10. + to_delete = a_ids[:batch_size] + a_ids = a_ids[batch_size:] + self._client.do_api_request( + f'/v3/tags/{quote_plus(tag_id)}/{",".join([quote_plus(d) for d in to_delete])}', method='DELETE' + ) + class UserCategory(Streamable): From 9d8fe44ecd63b710f1f306918a6730e1431aa1bc Mon Sep 17 00:00:00 2001 From: Edouard360 Date: Mon, 29 Jul 2019 14:32:02 -0700 Subject: [PATCH 2/2] comments --- feedly/api_client/data.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/feedly/api_client/data.py b/feedly/api_client/data.py index e0e9e61..432dcfd 100644 --- a/feedly/api_client/data.py +++ b/feedly/api_client/data.py @@ -79,15 +79,16 @@ def tag_entries(self, entry_ids: List[str]): def delete_tags(self, options: StreamOptions = None): """ *** WARNING *** Non-reversible operation - Given a TagBas Streamable, remove tags corresponding to this tag stream, whichever user saved it, for - all articles downloaded with options StreamOptions. + Given a TagBase Streamable, remove tags corresponding to this tag stream, for all articles downloaded + with options StreamOptions. If User is part of a Team, this will also delete the teammate tags that correspond + to this board :param options: specify high max_count to empty the board. :return: """ a_ids = [a["id"] for a in self.stream_contents(options)] tag_id = self._get_id() while len(a_ids) > 0: - batch_size = 50 # limitation due to the url length: articles are "de-tagged" by batch of 10. + batch_size = 50 # limitation due to the url length: articles are "de-tagged" by batch of 50. to_delete = a_ids[:batch_size] a_ids = a_ids[batch_size:] self._client.do_api_request( @@ -328,7 +329,7 @@ def delete_tags(self, streamable: Streamable, options: StreamOptions = None): if tagged_by_user == self['id']: a_ids += [a["id"]] while len(a_ids)>0: - batch_size = 10 # limitation due to the url length: articles are "de-tagged" by batch of 10. + batch_size = 50 # limitation due to the url length: articles are "de-tagged" by batch of 50. to_delete = a_ids[:batch_size] a_ids = a_ids[batch_size:] self._client.do_api_request(