pass bar into add_imdb_data_to_viewings method
This commit is contained in:
parent
98bc78b142
commit
46c4faf118
|
@ -31,7 +31,9 @@ def update_films_by_year_page(token_id, token_secret):
|
|||
print("Retrieving VCinema viewings")
|
||||
viewings = VCinemaUtils.get_vcinema_viewings(token_id, token_secret)
|
||||
|
||||
VCinemaUtils.add_imdb_data_to_viewings(viewings, ['year'])
|
||||
viewing_count = len(viewings)
|
||||
with Bar('Retrieving movie data', max=viewing_count, suffix='%(percent).1f%% - %(eta)ds remaining') as bar:
|
||||
VCinemaUtils.add_imdb_data_to_viewings(viewings, ['year'], bar)
|
||||
|
||||
viewings_by_year = VCinemaUtils.filter_viewings(viewings, 'year')
|
||||
|
||||
|
|
|
@ -52,20 +52,15 @@ def get_vcinema_viewings(token_id, token_secret, combine_repeat_viewings=True):
|
|||
def get_imdb(imdb_id, bar):
|
||||
imdb_entry = IMDbUtils.get_movie(imdb_id)
|
||||
|
||||
if bar is not None:
|
||||
bar.next()
|
||||
|
||||
return imdb_entry
|
||||
|
||||
|
||||
def add_imdb_data_to_viewings(viewings, field_names):
|
||||
sys.stdout.write("\rRetrieving movie data")
|
||||
sys.stdout.flush()
|
||||
|
||||
viewing_count = len(viewings)
|
||||
|
||||
with Bar('Retrieving movie data', max=viewing_count, suffix='%(percent).1f%% - %(eta)ds remaining') as bar:
|
||||
def add_imdb_data_to_viewings(viewings, field_names, progressbar=None):
|
||||
with ThreadPoolExecutor(4) as executor:
|
||||
future_to_url = {executor.submit(get_imdb, viewing['imdb_id'], bar) for viewing in viewings}
|
||||
future_to_url = {executor.submit(get_imdb, viewing['imdb_id'], progressbar) for viewing in viewings}
|
||||
|
||||
for future in as_completed(future_to_url):
|
||||
imdb_data = future.result()
|
||||
|
|
Loading…
Reference in New Issue