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 58016722 authored by SoleneDc's avatar SoleneDc

other changes

parent 5082faf9
......@@ -13,19 +13,20 @@ API = 'api_key=a9075982d1f7ce05cc45adec0e5f5358&language=en-US'
def get_movie_ids(year):
now1 = datetime.datetime.now()
url_final = url + 'page=1&year=' + str(year)
req = requests.get(url_final)
# url_final = url + 'page=1&year=' + str(year)
# req = requests.get(url_final)
dict_movies = {}
nb_of_pages = req.json()['total_pages']
for item in req.json()['results']:
movie_id = item['id']
video_link = get_video_link(movie_id)
dict_movies[movie_id] = [item['vote_average'], item["genre_ids"], video_link]
f = open("./Link-dictionnaries/Link-dictionnary" + str(year) + ".txt", "w")
f.write(str(dict_movies))
f.close()
for page in range(2, nb_of_pages+1):
nb_of_pages = 550
# nb_of_pages = req.json()['total_pages']
# for item in req.json()['results']:
# movie_id = item['id']
# video_link = get_video_link(movie_id)
# dict_movies[movie_id] = [item['vote_average'], item["genre_ids"], video_link]
# f = open("./Link-dictionnaries/Link-dictionnary" + str(year) + ".txt", "w")
# f.write(str(dict_movies))
# f.close()
for page in range(163, nb_of_pages+1): #TODO: changer la page if needed
time.sleep(7)
print(dict_movies)
print(len(dict_movies))
......@@ -37,7 +38,7 @@ def get_movie_ids(year):
video_link = get_video_link(movie_id)
if video_link != '':
dict_movies[movie_id] = [item['vote_average'], item["genre_ids"], video_link]
f = open("./Link-dictionnaries/Link-dictionnary"+ str(year) + ".txt", "w")
f = open("./Link-dictionnaries/Link-dictionnary" + str(year) + "-2.txt", "w")
f.write(str(dict_movies))
f.close()
return dict_movies
......@@ -54,4 +55,4 @@ def get_video_link(movie_id):
print(get_movie_ids(2008))
print(get_movie_ids(2010))
import ast
#L = ['Sithad108Og.','fBNpSRtfIUA', '2e-eXJ6HgkQ', 'tN1A2mVnrOM', 'myTaigPrbsg', 'b75lZw8nkvo']
def get_genre_from_link():
path = "./Link-dictionnaries/Link-dictionnary2000.txt"
file = open(path, "r").read()
dictyear = ast.literal_eval(file)
dict_inverse = {}
links_to_be_removed = []
for movie_id in dictyear.keys():
if dictyear[movie_id][1] != []:
dict_inverse[dictyear[movie_id][2]] = dictyear[movie_id][1][0]
else:
print(f'careful, link {dictyear[movie_id][2]} needs to be removed from the list')
links_to_be_removed += [dictyear[movie_id][2]]
return dict_inverse, links_to_be_removed
def get_output_list(L):
dict_inverse, links_to_be_removed = get_genre_from_link()
output = []
for link in L:
if link in links_to_be_removed:
L.remove(link)
else:
output += [dict_inverse[link]]
return output
print(get_output_list(L))
\ No newline at end of file
......@@ -15,7 +15,9 @@ def valid_spectrums():
if len(colors) >= 10:
ok_files += [file]
break
return ok_files
f = open("spectrums_to_keep.txt", "w")
f.write(str(ok_files))
f.close()
print(valid_spectrums())
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