Skip to content

Commit 1a697aa

Browse files
authored
Merge pull request #14 from feedly/tag-base-delete-tags
TagBase.delete_tags
2 parents 74e6854 + 9d8fe44 commit 1a697aa

1 file changed

Lines changed: 20 additions & 1 deletion

File tree

feedly/api_client/data.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,25 @@ def tag_entries(self, entry_ids: List[str]):
7676
self._client.do_api_request(f'/v3/tags/{quote_plus(self["id"])}', method='put',
7777
data={'entryIds': [entry_id for entry_id in entry_ids]})
7878

79+
def delete_tags(self, options: StreamOptions = None):
80+
"""
81+
*** WARNING *** Non-reversible operation
82+
Given a TagBase Streamable, remove tags corresponding to this tag stream, for all articles downloaded
83+
with options StreamOptions. If User is part of a Team, this will also delete the teammate tags that correspond
84+
to this board
85+
:param options: specify high max_count to empty the board.
86+
:return:
87+
"""
88+
a_ids = [a["id"] for a in self.stream_contents(options)]
89+
tag_id = self._get_id()
90+
while len(a_ids) > 0:
91+
batch_size = 50 # limitation due to the url length: articles are "de-tagged" by batch of 50.
92+
to_delete = a_ids[:batch_size]
93+
a_ids = a_ids[batch_size:]
94+
self._client.do_api_request(
95+
f'/v3/tags/{quote_plus(tag_id)}/{",".join([quote_plus(d) for d in to_delete])}', method='DELETE'
96+
)
97+
7998

8099
class UserCategory(Streamable):
81100

@@ -310,7 +329,7 @@ def delete_tags(self, streamable: Streamable, options: StreamOptions = None):
310329
if tagged_by_user == self['id']:
311330
a_ids += [a["id"]]
312331
while len(a_ids)>0:
313-
batch_size = 10 # limitation due to the url length: articles are "de-tagged" by batch of 10.
332+
batch_size = 50 # limitation due to the url length: articles are "de-tagged" by batch of 50.
314333
to_delete = a_ids[:batch_size]
315334
a_ids = a_ids[batch_size:]
316335
self._client.do_api_request(

0 commit comments

Comments
 (0)