1717from  bdfr .configuration  import  Configuration 
1818from  bdfr .connector  import  RedditConnector 
1919from  bdfr .exceptions  import  ArchiverError 
20+ from  bdfr .progress_bar  import  Progress 
2021from  bdfr .resource  import  Resource 
2122
2223logger  =  logging .getLogger (__name__ )
@@ -27,24 +28,28 @@ def __init__(self, args: Configuration):
2728        super (Archiver , self ).__init__ (args )
2829
2930    def  download (self ):
30-         for  generator  in  self .reddit_lists :
31-             for  submission  in  generator :
32-                 try :
33-                     if  (submission .author  and  submission .author .name  in  self .args .ignore_user ) or  (
34-                         submission .author  is  None  and  "DELETED"  in  self .args .ignore_user 
35-                     ):
36-                         logger .debug (
37-                             f"Submission { submission .id } { submission .subreddit .display_name }  
38-                             f" due to { submission .author .name  if  submission .author  else  'DELETED' }  
39-                         )
40-                         continue 
41-                     if  submission .id  in  self .excluded_submission_ids :
42-                         logger .debug (f"Object { submission .id }  )
43-                         continue 
44-                     logger .debug (f"Attempting to archive submission { submission .id }  )
45-                     self .write_entry (submission )
46-                 except  prawcore .PrawcoreException  as  e :
47-                     logger .error (f"Submission { submission .id } { e }  )
31+         progress  =  Progress (self .args .progress_bar )
32+         with  progress .context ():
33+             for  generator  in  progress .wrap_subreddit_iter (self .reddit_lists ):
34+                 for  submission  in  progress .wrap_post_iter (generator ):
35+                     try :
36+                         if  (submission .author  and  submission .author .name  in  self .args .ignore_user ) or  (
37+                             submission .author  is  None  and  "DELETED"  in  self .args .ignore_user 
38+                         ):
39+                             logger .debug (
40+                                 f"Submission { submission .id } { submission .subreddit .display_name }  
41+                                 f" due to { submission .author .name  if  submission .author  else  'DELETED' }  
42+                             )
43+                             continue 
44+                         if  submission .id  in  self .excluded_submission_ids :
45+                             logger .debug (f"Object { submission .id }  )
46+                             continue 
47+                         logger .debug (f"Attempting to archive submission { submission .id }  )
48+                         self .write_entry (submission )
49+                         progress .post_log (submission , True )
50+                     except  prawcore .PrawcoreException  as  e :
51+                         logger .error (f"Submission { submission .id } { e }  )
52+                         progress .post_log (submission , False )
4853
4954    def  get_submissions_from_link (self ) ->  list [list [praw .models .Submission ]]:
5055        supplied_submissions  =  []
0 commit comments