Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cool new data analysis #22

Merged
merged 21 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,12 +43,11 @@ def get_now_playing_movies(page=1):
movies = tmdb.movies().now_playing(page=page)
return movies


def get_popular_people():
people = tmdb.people().popular()
# Literally worse than the library functions. Why do these functions even exist? Isn't there a way to construct the TMDb object and call functions on it?
def get_popular_people(page=1):
people = tmdb.people().popular(page=page)
return people


def get_person_details(person_id):
person = tmdb.person(person_id)
return person
Expand Down
1,325 changes: 1,325 additions & 0 deletions eda/first_eda.ipynb

Large diffs are not rendered by default.

184 changes: 184 additions & 0 deletions eda/second_eda.ipynb

Large diffs are not rendered by default.

262 changes: 262 additions & 0 deletions eda/third_eda.ipynb

Large diffs are not rendered by default.

54 changes: 54 additions & 0 deletions insert_actors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import downloader
import insert
import time

all_actor_ids = set()
all_actors = []
all_people_popularity = []

START = 1
PAGES = 500

start_time = time.time()

for i in range(START, PAGES + 1):
print(f"Page {i} of {PAGES} started")
for actor in downloader.get_popular_people(i).results:
all_actor_ids.add(actor.id)
all_actors.insert(i, actor)
print(f"Page {i} of {PAGES} finished")

end_time = time.time()
print(f"Iterating through pages took {end_time - start_time} seconds to complete")


start_time = time.time()
print("Downloading popularity details")
for i, actor_ids in enumerate(all_actor_ids):
try:
all_people_popularity.append(downloader.get_person_details(actor_ids))
except Exception as e:
print(f"Could not load actor with id {actor_ids}")
print(e)
if i % 25 == 0:
print(f"{i} of {len(all_actor_ids)} loaded from API")

end_time = time.time()
print(f"Downloading details took {end_time - start_time} seconds to complete")


start_time = time.time()
print("Inserting actors into database")
insert.insert_person(all_actors)

end_time = time.time()
print(f"Inserting actors took {end_time - start_time} seconds to complete")


start_time = time.time()
print("Inserting popularity into database")
people_popularity = [PersonPopularity(person.id, person.popularity) for person in all_people_popularity]
insert.insert_person_popularity(people_popularity)
Nereuxofficial marked this conversation as resolved.
Show resolved Hide resolved

end_time = time.time()
print(f"Inserting popularity took {end_time - start_time} seconds to complete")
12 changes: 10 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
postgres==4.0
themoviedb==0.4.0
themoviedb==0.4.0
psycopg2-binary==2.9.9
plotly
seaborn
matplotlib
gensim
nltk
wordcloud
scikit-learn
pandas
2 changes: 1 addition & 1 deletion script.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
all_movie_ids.add(movie.id)
for changes in downloader.get_changes_for_all_movies(i):
all_movie_ids.add(changes["id"])
all_changes.append(changes)
all_changes.append(changes)
print(f"Page {i} of {PAGES} finished")

end_time = time.time()
Expand Down
Loading