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

last version Solène

parent 6100035a
File added
import requests
import datetime
import time
import ast
url = 'https://api.themoviedb.org/3/discover/movie?api_key=e4c6a6f5fbd60b0316b7ff30e73bec74&language=en-US&sort_by=popularity.desc&include_adult=false&include_video=false&'
......@@ -22,7 +22,7 @@ def get_movie_ids(year):
# 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 = open("./Link-dictionaries/Link-dictionary" + str(year) + ".txt", "w")
# f.write(str(dict_movies))
# f.close()
......@@ -38,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) + "-2.txt", "w")
f = open("./Link-dictionaries/Link-dictionary" + str(year) + "-2.txt", "w")
f.write(str(dict_movies))
f.close()
return dict_movies
......@@ -54,5 +54,34 @@ def get_video_link(movie_id):
return ''
# Helpers
def concatenate_dict():
path = "./Link-dictionaries/Link-dictionary2005-1.txt"
file = open(path, "r").read()
dictyear = ast.literal_eval(file)
print(len(dictyear))
path2 = "./Link-dictionaries/Link-dictionary2005-2.txt"
file2 = open(path2, "r").read()
dict2 = ast.literal_eval(file2)
print(len(dict2), 'dict2')
dictyear.update(dict2)
print(len(dictyear), 'new dictyear')
path3 = "./Link-dictionaries/Link-dictionary2005-3.txt"
file3 = open(path3, "r").read()
dict3 = ast.literal_eval(file3)
print(len(dict3))
dictyear.update(dict3)
print(len(dictyear))
f = open("./Link-dictionaries/Link-dictionary2005.txt", "w")
f.write(str(dictyear))
f.close()
return (dictyear)
concatenate_dict()
print(get_movie_ids(2010))
......@@ -16,11 +16,11 @@ import moviepy.editor as mp
follow = True
queue = Queue()
linkFile = './link-dictionnaries/link-dictionnary2004.txt'
linkFile = './Link-dictionnaries/Link-dictionnary2005-3.txt' #TODO: changer l'année !
linkDict = {}
exceptDict = {}
videoDir = './video/'
spectrumDir = '../spectrumImages/spectrumImages2004/'
spectrumDir = '../spectrumImages/spectrumImages2005/'
countDownload = 1
countSpectrum = 1
......@@ -33,6 +33,7 @@ def downloadTrailer():
'outtmpl': videoDir+'%(id)s.%(ext)s',
'noplaylist': True,
#'max_filesize' : 10000000,
"nocheckcertificate": True,
'save_path' : videoDir }
for key in linkDict.keys():
if not os.path.isfile(spectrumDir+linkDict[key][2]+'.jpg'):
......
import ast
import os
#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))
list_of_eligible_spectrums = []
for file in os.listdir("SpectrumImages2005"):
if str(file)[-4:] == '.jpg':
list_of_eligible_spectrums += [file]
def get_genre_from_link():
path = "./Link-dictionnaries/Link-dictionnary2000.txt"
path = "./Link-dictionaries/Link-dictionary2005.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]
dict_inverse[str(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')
#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()
eligible_links = []
output = []
for link in L:
if link in links_to_be_removed:
L.remove(link)
else:
output += [dict_inverse[link]]
return output
link = str(link)
#print(dict_inverse[str(link)])
if link[-1]==".":
print("do something! Too many points.......")
if link not in links_to_be_removed:
print(link)
print(dict_inverse[link])
#output += [dict_inverse[link]]
eligible_links += [link]
return output, eligible_links
print(get_output_list(L))
\ No newline at end of file
labels, eligible_links = get_output_list(list_of_eligible_spectrums)
This diff is collapsed.
This diff is collapsed.
import cv2
import os
def valid_spectrums():
def valid_spectrums(path):
ok_files = []
for file in os.listdir("Spectrums_sample"):
img = cv2.imread('./Spectrums_sample/' + file, 1)
image = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
length, width, lab = image.shape
colors = []
for i in range(width):
tuple = (image[0][i][0], image[0][i][1], image[0][i][2])
if tuple not in colors:
colors += [tuple]
if len(colors) >= 10:
ok_files += [file]
break
f = open("spectrums_to_keep.txt", "w")
f.write(str(ok_files))
f.close()
for file in os.listdir(path):
if str(file)[-4:] == '.jpg':
print(file)
img = cv2.imread('./'+ path + '/' + file, 1)
image = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
length, width, lab = image.shape
colors = []
for i in range(width):
tuple = (image[0][i][0], image[0][i][1], image[0][i][2])
if tuple not in colors:
colors += [tuple]
if len(colors) >= 10:
ok_files += [file]
break
print(valid_spectrums())
for file in os.listdir(path):
if file not in ok_files:
print('removing', file, '....')
os.remove(path + "/" + file)
print(ok_files)
print(valid_spectrums('spectrumImages2005'))
......@@ -70,7 +70,9 @@
{
"cell_type": "code",
"execution_count": 118,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"#!/usr/bin/python\n",
......@@ -328,7 +330,9 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
......@@ -349,7 +353,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.4"
"version": "3.6.3"
}
},
"nbformat": 4,
......
This source diff could not be displayed because it is too large. You can view the blob instead.
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