I try to understand how it works. There is several broken links on the help page.
I ve almost finished what i would to do.
When i enable the plugin i made, it modify labelplus conf if label.conf and labelplus conf have ~ a label similar. (i check if the name is capitalized or not).
The orphan torrent under labelplus are moved in the labelplus label... But.
1st : the counter of the targetted labelplus label is not updated.
2nd: i have perhaps found why, but to modify the conf was not enough because i couln't add after a sublabel, it abort all the time. I have tried to disable then enable labelplus plugin when i had this problem to try to refresh the counter. I stopped to do that.
3: now that i use
Code: Select all
labelplus_plugin = deluge.component.get("CorePlugin.LabelPlus")
labelplus_plugin.update()
So i ask to myself, is there a common def to all the plugin, like enable, disable ? Or i must check in the plugin if there is something... ?
Here is my code, for the moment it's just a draft
Code: Select all
def update_lbplus(self):
# lecture d'un fichier conf tiers.
chronos = time.strftime("%d/%m/%Y %H:%M:%S")
try:
self.label_config = deluge.configmanager.ConfigManager("label.conf")
self.labelPlus_config = deluge.configmanager.ConfigManager("labelplus.conf")
# Récupération des liaisons noms : bind dans labelplus
labelPCats={}
for cat in self.labelPlus_config['labels']:
# Récupération uniquement des catégories maitresses
if ':' in cat: continue
#print(categorie)
nom = self.labelPlus_config['labels'][cat]['name']
labelPCats[nom] = cat
# fin
# Récupération des catégories de label
i=0
labelCat = {}
for cat in self.label_config['labels']:
labelCat[cat]=i
i+=1
# fin
# Nombre de torrents dans labelplus
avant = len(self.labelPlus_config['mappings'])
countlbp = 0
ignored = 0
modif = 0
# Go
torrent_labels = self.label_config['torrent_labels']
for tor in torrent_labels: # lecture de tous les torrents ajoutés
if tor in self.labelPlus_config['mappings']: # si le torrent de label est dans les torrents mappings de labelplus
countlbp +=1
else: # Le torrent n'est pas mappé dans labelplus
# Recherche de correspondance des catégories
idlab = torrent_labels[tor]
idLAB = idlab.capitalize()
if idLAB in labelPCats:
self.labelPlus_config['mappings'][tor] = labelPCats[idLAB]
modif+=1
elif idlab in labelPCats:
self.labelPlus_config['mappings'][tor] = labelPCats[idlab]
modif+=1
# TODO: perhaps si to create label
else:
ignored +=1
self.write('Déja triés: {}'.format(countlbp))
self.write('modifiés: {}'.format( modif))
self.write('Non traités: {}'.format(ignored))
except Exception as e:
import sys
log.error( "myplugin3: {0}{1}".format( e, sys.exc_info()[-1].tb_lineno ))
else:
if not modif ==0:
self.labelPlus_config.save()
labelplus_plugin = deluge.component.get("CorePlugin.LabelPlus")
labelplus_plugin.update()