Logique de présence de l'année, et corrections orthographiques

This commit is contained in:
redstorm45 2018-02-16 10:16:04 +01:00
parent 47fd1c6141
commit 69f2a6f8a8

10
main.py
View file

@ -85,6 +85,8 @@ def visit_folder(domain, api, rules, tok):
nfo = {} nfo = {}
if ('filable' not in info) or ('filable_type' not in info): if ('filable' not in info) or ('filable_type' not in info):
print('nfo:', info) # le fileable associé a été supprimé print('nfo:', info) # le fileable associé a été supprimé
elif('release_date' not in info['filable']) or info['filable']['release_date'] is None:
print('nfo:', info) # le fileable ne possède pas de date de sortie valide
else: else:
year = int(info['filable']['release_date'][:4]) year = int(info['filable']['release_date'][:4])
nfo['YEAR'] = year nfo['YEAR'] = year
@ -94,7 +96,8 @@ def visit_folder(domain, api, rules, tok):
match = filerule.match_rules(F.path + '/' + F.name, rules) match = filerule.match_rules(F.path + '/' + F.name, rules)
if match: if match:
F.info = match[1] F.info = match[1]
F.info['YEAR'] = nfo['YEAR'] # may not work :-( if 'YEAR' in nfo: # remplace l'année par celle donnée par tmdb (la vraie), si disponible
F.info['YEAR'] = nfo['YEAR']
Lapi.append(F) Lapi.append(F)
print('total api for ', domain['server'] + domain['path'], ':', len(Lapi)) print('total api for ', domain['server'] + domain['path'], ':', len(Lapi))
@ -135,7 +138,7 @@ def handle_films(Lfilm_loc, Lfilm_api, domain, api, rules, tok):
# Fichiers déplacés (ou copiés) localement # Fichiers déplacés (ou copiés) localement
Lunref, _, Lrelink = update_find_by_common(Lunref, Lapi, lambda f: f.name) Lunref, _, Lrelink = update_find_by_common(Lunref, Lapi, lambda f: f.name)
for floc, fapi in Lrelink: for floc, fApi in Lrelink:
if fApi in Lmissing: if fApi in Lmissing:
Lmissing.remove(fApi) Lmissing.remove(fApi)
print('moved/copied:', Lrelink) print('moved/copied:', Lrelink)
@ -459,7 +462,6 @@ def post_markers(api, file_, fileid):
api.post_file_subtitle(fileid, value=sub) api.post_file_subtitle(fileid, value=sub)
time.sleep(1) time.sleep(1)
def main(): def main():
""" """
Fonction principale du programme, réalise toute les opérations Fonction principale du programme, réalise toute les opérations
@ -473,7 +475,7 @@ def main():
folders = api.get_folders() folders = api.get_folders()
rules = api.get_paths() rules = api.get_paths()
for fold in folders[1:]: for fold in folders:
applicable = [filerule.FileRule(re.escape(fold['path']) + '\\/' + r['regex'], conf) for r in rules if applicable = [filerule.FileRule(re.escape(fold['path']) + '\\/' + r['regex'], conf) for r in rules if
int(r['indexer_folder_id']) == fold['id']] int(r['indexer_folder_id']) == fold['id']]
visit_folder(fold, api, applicable, tokens) visit_folder(fold, api, applicable, tokens)