@@ -32,6 +32,7 @@ class InoreaderClient(object):
3232 SUBSCRIPTION_LIST_PATH = 'subscription/list'
3333 STREAM_CONTENTS_PATH = 'stream/contents/'
3434 EDIT_TAG_PATH = 'edit-tag'
35+ EDIT_SUBSCRIPTION_PATH = 'subscription/edit'
3536
3637 # tags
3738 GENERAL_TAG_TEMPLATE = 'user/-/label/{}'
@@ -151,7 +152,7 @@ def get_stream_contents(self, stream_id, c='', limit=None):
151152 for a in articles :
152153 try :
153154 yield Article .from_json (a )
154- fetched_count += 1
155+ fetched_count += 1
155156 except Exception as e :
156157 print (e )
157158 continue
@@ -160,7 +161,6 @@ def get_stream_contents(self, stream_id, c='', limit=None):
160161 break
161162 if c is None :
162163 break
163-
164164
165165 def __get_stream_contents (self , stream_id , continuation = '' ):
166166 self .check_token ()
@@ -227,7 +227,6 @@ def fetch_articles(self, folder=None, tags=None, unread=True, starred=False, lim
227227 break
228228
229229 continuation = response .get ('continuation' )
230-
231230
232231 def fetch_unread (self , folder = None , tags = None , limit = None ):
233232 for article in self .fetch_articles (folder = folder , tags = tags , unread = True ):
@@ -285,3 +284,27 @@ def remove_liked(self, articles):
285284
286285 def broadcast (self , articles ):
287286 self .add_general_label (articles , self .BROADCAST_TAG )
287+
288+ def edit_subscription (self , stream_id , action , title = None , add_folder = None , remove_folder = None ):
289+ self .check_token ()
290+ url = urljoin (BASE_URL , self .EDIT_SUBSCRIPTION_PATH )
291+ # https://us.inoreader.com/developers/edit-subscription
292+ # The documentation looks a bit outdated, `follow`/`unfollow` don't work
293+ action = {'follow' : 'subscribe' , 'unfollow' : 'unsubscribe' }.get (action ) or action
294+ params = {'ac' : action , 's' : stream_id }
295+ if title :
296+ params ['t' ] = title
297+
298+ if add_folder :
299+ params ['a' ] = add_folder
300+
301+ if remove_folder :
302+ params ['r' ] = remove_folder
303+
304+ r = self .session .post (url , params = params , proxies = self .proxies )
305+ response = self .parse_response (
306+ r ,
307+ # self.session.post(url, params=params, proxies=self.proxies),
308+ json_data = False
309+ )
310+ return response
0 commit comments