66import cv2
77import numpy as np
88
9- from aperturedb import ParallelLoader
9+ from aperturedb import Parallelizer
1010from aperturedb import CSVParser
1111from aperturedb import ProgressBar
1212
@@ -61,11 +61,11 @@ def validate(self):
6161 self .has_filename = True
6262
6363
64- class VideoDownloader (ParallelLoader . ParallelLoader ):
64+ class VideoDownloader (Parallelizer . Parallelizer ):
6565
66- def __init__ (self , db , dry_run = False ):
66+ def __init__ (self , ):
6767
68- super ().__init__ (db , dry_run = dry_run )
68+ super ().__init__ ()
6969
7070 self .type = "video"
7171
@@ -81,7 +81,7 @@ def check_if_video_is_ok(self, filename, url):
8181 if a .isOpened () == False :
8282 print ("Video present but error reading it:" , url )
8383 return False
84- except :
84+ except BaseException :
8585 print ("Video present but error decoding:" , url )
8686 return False
8787
@@ -110,7 +110,7 @@ def download_video(self, url, filename):
110110 print ("Downloaded Video size error:" , url )
111111 os .remove (filename )
112112 self .error_counter += 1
113- except :
113+ except BaseException :
114114 print ("Downloaded Video cannot be decoded:" , url )
115115 os .remove (filename )
116116 self .error_counter += 1
@@ -122,20 +122,14 @@ def download_video(self, url, filename):
122122
123123 def worker (self , thid , generator , start , end ):
124124
125- if thid == 0 and self .stats :
126- pb = ProgressBar .ProgressBar ("download_progress.txt" )
127-
128125 for i in range (start , end ):
129126
130127 url , filename = generator [i ]
131128
132129 self .download_video (url , filename )
133130
134131 if thid == 0 and self .stats :
135- pb .update ((i - start ) / (end - start ))
136-
137- if thid == 0 and self .stats :
138- pb .update (1 )
132+ self .pb .update ((i - start ) / (end - start ))
139133
140134 def print_stats (self ):
141135
@@ -147,8 +141,8 @@ def print_stats(self):
147141 print ("Avg download throughput (videos/s)):" ,
148142 1 / np .mean (times ) * self .numthreads )
149143
150- print ("Total time(s):" , self .ingestion_time )
144+ print ("Total time(s):" , self .total_actions_time )
151145 print ("Overall throughput (videos/s):" ,
152- self .total_elements / self .ingestion_time )
146+ self .total_actions / self .total_actions_time )
153147 print ("Total errors encountered:" , self .error_counter )
154148 print ("=============================================" )
0 commit comments