Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

Commit 388e7a4e authored by Hachemin Pierre-Yves's avatar Hachemin Pierre-Yves

clean of master

parent 5a5807bf
......@@ -21,3 +21,4 @@ spectrumImages2015/
spectrumImages2016/
spectrumImages2017/
spectrumImages/
Spectrums_sample/
import ast
import os
import cv2
import requests
import matplotlib.pyplot as plt
#L = ['Sithad108Og.','fBNpSRtfIUA', '2e-eXJ6HgkQ', 'tN1A2mVnrOM', 'myTaigPrbsg', 'b75lZw8nkvo']
......@@ -91,3 +93,56 @@ for file in eligible_links:
dict_inverse[file]['image'] += [img]
print('coucocu')
url = "https://api.themoviedb.org/3/genre/movie/list?"
API = 'api_key=a9075982d1f7ce05cc45adec0e5f5358&language=en-US'
def get_genres(year):
path = "./Link-dictionaries/Link-dictionary" + str(year) +".txt"
file = open(path, "r").read()
dictyear = ast.literal_eval(file)
dict_genres = {}
for movie_id in dictyear.keys():
genre_ids = dictyear[movie_id][1]
for genre_id in genre_ids:
if genre_id in dict_genres.keys():
dict_genres[genre_id] += 1
else:
dict_genres[genre_id] = 1
return dict_genres
def translate_genre():
url_final = url + API
req = requests.get(url_final)
print(req.json()["genres"])
def sum_genre(list_years):
final_dict_genre = {}
for year in list_years:
print(f'dealing with {year}...')
dict_genre = get_genres(year)
for key in dict_genre.keys():
if key in final_dict_genre.keys():
final_dict_genre[key] += dict_genre[key]
else:
final_dict_genre[key] = dict_genre[key]
return final_dict_genre
# print(get_genres(2001).keys())
# #print(get_genres(2002).keys())
# print(get_genres(2003).keys())
# print(get_genres(2004).keys())
# print(get_genres(2005).keys())
#print(translate_genre())
sum_genre = sum_genre(range(2003, 2014))
L = []
for key in sum_genre.keys():
L += [str(key)]
print(L, list(sum_genre.values()))
print(sum(list(sum_genre.values())))
plt.bar(L, list(sum_genre.values()))
plt.show()
This diff is collapsed.
This diff is collapsed.
import ast
import requests
import matplotlib.pyplot as plt
url = "https://api.themoviedb.org/3/genre/movie/list?"
API = 'api_key=a9075982d1f7ce05cc45adec0e5f5358&language=en-US'
def get_genres(year):
path = "./Link-dictionaries/Link-dictionary" + str(year) +".txt"
file = open(path, "r").read()
dictyear = ast.literal_eval(file)
dict_genres = {}
for movie_id in dictyear.keys():
genre_ids = dictyear[movie_id][1]
for genre_id in genre_ids:
if genre_id in dict_genres.keys():
dict_genres[genre_id] += 1
else:
dict_genres[genre_id] = 1
return dict_genres
def translate_genre():
url_final = url + API
req = requests.get(url_final)
print(req.json()["genres"])
def sum_genre(list_years):
final_dict_genre = {}
for year in list_years:
print(f'dealing with {year}...')
dict_genre = get_genres(year)
for key in dict_genre.keys():
if key in final_dict_genre.keys():
final_dict_genre[key] += dict_genre[key]
else:
final_dict_genre[key] = dict_genre[key]
return final_dict_genre
# print(get_genres(2001).keys())
# #print(get_genres(2002).keys())
# print(get_genres(2003).keys())
# print(get_genres(2004).keys())
# print(get_genres(2005).keys())
#print(translate_genre())
sum_genre = sum_genre(range(2003, 2014))
L = []
for key in sum_genre.keys():
L += [str(key)]
print(L, list(sum_genre.values()))
print(sum(list(sum_genre.values())))
plt.bar(L, list(sum_genre.values()))
plt.show()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment