add get_hidden_themes script
This commit is contained in:
parent
2f3f3320a4
commit
d0ad869d81
37
get_hidden_themes.py
Normal file
37
get_hidden_themes.py
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
from imdb_utils import IMDbUtils
|
||||||
|
|
||||||
|
import argparse
|
||||||
|
from progress.bar import IncrementalBar
|
||||||
|
|
||||||
|
|
||||||
|
def get_hidden_themes(imdb_ids):
|
||||||
|
hidden_themes = set()
|
||||||
|
is_first = True
|
||||||
|
|
||||||
|
with IncrementalBar('Retrieving movie data', max=len(imdb_ids), suffix='%(percent).1f%% - %(eta)ds remaining', check_tty=False) as bar:
|
||||||
|
for imdb_id in imdb_ids:
|
||||||
|
movie_data = IMDbUtils.get_movie_keywords(imdb_id)
|
||||||
|
|
||||||
|
if 'keywords' in movie_data:
|
||||||
|
keywords = set(movie_data['keywords'])
|
||||||
|
if is_first:
|
||||||
|
hidden_themes = keywords
|
||||||
|
is_first = False
|
||||||
|
else:
|
||||||
|
hidden_themes = hidden_themes.intersection(keywords)
|
||||||
|
|
||||||
|
bar.next()
|
||||||
|
|
||||||
|
return hidden_themes
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
parser = argparse.ArgumentParser()
|
||||||
|
parser.add_argument('imdb_ids', nargs="+", default=[])
|
||||||
|
|
||||||
|
args = parser.parse_args()
|
||||||
|
|
||||||
|
hidden_themes = get_hidden_themes(args.imdb_ids)
|
||||||
|
|
||||||
|
print(hidden_themes)
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user