@@ -137,3 +137,33 @@ def fetch_unread(self, folder=None, tags=None):
137137 continue
138138 yield Article .from_json (data )
139139 continuation = resp .json ().get ('continuation' )
140+
141+ def add_general_label (self , articles , label ):
142+ if not self .auth_token :
143+ raise NotLoginError
144+
145+ url = urljoin (BASE_URL , 'edit-tag' )
146+ for start in range (0 , len (articles ), 10 ):
147+ end = min (start + 10 , len (articles ))
148+ params = {
149+ 'a' : label ,
150+ 'i' : [articles [idx ].id for idx in range (start , end )]
151+ }
152+ resp = self .session .post (url , params = params )
153+ if resp .status_code != 200 :
154+ raise APIError (resp .text )
155+
156+ def add_tag (self , articles , tag ):
157+ self .add_general_label (articles , 'user/-/label/{}' .format (tag ))
158+
159+ def mark_as_read (self , articles ):
160+ self .add_general_label (articles , 'user/-/state/com.google/read' )
161+
162+ def mark_as_starred (self , articles ):
163+ self .add_general_label (articles , 'user/-/state/com.google/starred' )
164+
165+ def mark_as_liked (self , articles ):
166+ self .add_general_label (articles , 'user/-/state/com.google/like' )
167+
168+ def broadcast (self , articles ):
169+ self .add_general_label (articles , 'user/-/state/com.google/broadcast' )
0 commit comments