Garde en mémoire les films non postés

This commit is contained in:
redstorm45 2017-12-09 16:04:40 +01:00
parent 3b7d260011
commit 8f531febc5

28
main.py
View file

@ -222,27 +222,31 @@ def visit_folder(domain, api, rules, tok):
print('film '+film.title+' not added') print('film '+film.title+' not added')
raise Exception('end') raise Exception('end')
# Poste tout les films locaux # Poste tout les films locaux (doit faire une reqête Tmdb, qui peut ne pas marcher)
i = 0 i = 0
Lcannot_post = []
for film in Lunref: for film in Lunref:
i += 1 i += 1
print('['+str(i)+'/'+str(len(Lunref))+']'+'post:', film.title, str(film.info.get('YEAR'))) print('['+str(i)+'/'+str(len(Lunref))+']'+'post:', film.title, str(film.info.get('YEAR')))
try: try:
posted = False posted = False
if 'YEAR' in film.info: if 'YEAR' in film.info: # tente avec l'année spécifié en premier
resp = api.post_film(title=film.title, year=film.info['YEAR']) resp = api.post_film(title=film.title, year=film.info['YEAR'])
if "id" in resp: if "id" in resp: # id du film
print('post: path=',domain['server']+film.path)
resp = api.post_file(path=domain['server']+film.path, name=film.name, type='film', type_id=resp["id"])
if 'id' in resp:
post_markers(api, film, resp['id'])
posted = True posted = True
if not posted: if not posted:
resp = api.post_film(title=film.title) resp = api.post_film(title=film.title)
if "id" in resp: if "id" in resp: # id du film
resp = api.post_file(path=domain['server']+film.path, name=film.name, type='film', type_id=resp["id"]) posted = True
if 'id' in resp:
post_markers(api, film, resp['id']) if posted:
print('post: path=',domain['server']+film.path)
resp = api.post_file(path=domain['server']+film.path, name=film.name, type='film', type_id=resp["id"])
if 'id' in resp: # id du file
post_markers(api, film, resp['id'])
else:
Lcannot_post.append(film)
print('response:', resp) print('response:', resp)
time.sleep(1) time.sleep(1)
except Exception as e: except Exception as e:
@ -250,6 +254,8 @@ def visit_folder(domain, api, rules, tok):
print('film '+film.title+' not posted') print('film '+film.title+' not posted')
raise Exception('end') raise Exception('end')
# TODO: traiter les films non postés
print('visit finished') print('visit finished')
def post_markers(api, file_, fileid): def post_markers(api, file_, fileid):