@@ -195,19 +195,30 @@ def fetch_unread(folder, tags, outfile, out_format):
195195 LOGGER .info ("fetched %d articles" , idx )
196196 title = article .title
197197 text = article .text
198+ link = article .link
198199 if out_format == 'json' :
199- print (json .dumps ({'title' : title , 'content' : text }, ensure_ascii = False ), file = fout )
200+ print (json .dumps ({'title' : title , 'content' : text , 'url' : link }, ensure_ascii = False ),
201+ file = fout )
200202 elif out_format == 'csv' :
201- writer .writerow ([title , text ])
203+ writer .writerow ([link , title , text ])
202204 elif out_format == 'plain' :
203205 print ('TITLE: {}' .format (title ), file = fout )
206+ print ("LINK: {}" .format (link ), file = fout )
204207 print ("CONTENT: {}" .format (text ), file = fout )
205208 print (file = fout )
206209 elif out_format == 'markdown' :
207- print ('# {}\n ' .format (title ), file = fout )
210+ if link :
211+ print ('# [{}]({})\n ' .format (title , link ), file = fout )
212+ else :
213+ print ('# {}\n ' .format (title ), file = fout )
208214 print (text + '\n ' , file = fout )
209215 elif out_format == 'org-mode' :
210- print ('* {}\n ' .format (title ), file = fout )
216+ if link :
217+ title = title .replace ('[' , '_' ).replace (']' , '_' )
218+ print ('* [[{}][{}]]\n ' .format (link , title ),
219+ file = fout )
220+ else :
221+ print ('* {}\n ' .format (title ), file = fout )
211222 print (text + '\n ' , file = fout )
212223
213224 LOGGER .info ("fetched %d articles and saved them in %s" , idx + 1 , outfile )
0 commit comments