Added hash matching
This commit is contained in:
parent
1fcfe6009e
commit
03d1c784c8
6
ED2K.py
6
ED2K.py
|
@ -77,11 +77,7 @@ import binascii
|
|||
from collections import namedtuple
|
||||
|
||||
|
||||
#MetEntry = namedtuple('met_entry',
|
||||
# ['Filename', 'ED2KHash', 'LastChanged', 'Filesize', 'Transfered', 'Requested', 'Accepted',
|
||||
# 'Transfered_HI', 'PartFilename', 'AICHashCount', 'AICHash'])
|
||||
|
||||
METENTRY_FIELDS = ('FT_FILENNAME', 'ED2KHASH', 'NUMPARTS', 'LASTCHANGED', 'PARTHASHES', 'FT_FILESIZE',
|
||||
METENTRY_FIELDS = ('FT_FILENAME', 'ED2KHASH', 'NUMPARTS', 'LASTCHANGED', 'PARTHASHES', 'FT_FILESIZE',
|
||||
'FT_ATTRANSFERRED', 'FT_ATREQUESTED', 'FT_ATACCEPTED', 'FT_ATTRANSFERREDHI', 'FT_PARTFILENAME',
|
||||
'FT_AICHHASHSET', 'FT_AICH_HASH', 'FT_ULPRIORITY', 'FT_KADLASTPUBLISHSRC')
|
||||
MetEntry = namedtuple('met_entry', METENTRY_FIELDS)
|
||||
|
|
|
@ -65,6 +65,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
self.actionFile_open.triggered.connect(self.slot_load_met_file)
|
||||
self.actionExit.triggered.connect(self.close)
|
||||
|
||||
# Init functionality and other features
|
||||
self.hashsets = load_hashsets('Hashsets')
|
||||
|
||||
def createED2KModel(self, parent):
|
||||
model = QStandardItemModel(0, len(self.Headers), parent)
|
||||
for i, fields in enumerate(self.Headers):
|
||||
|
@ -74,29 +77,30 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
def addED2K(self, model, metinfo):
|
||||
model.insertRow(0)
|
||||
for i, field in enumerate(self.Headers):
|
||||
print(i, field)
|
||||
if field[2] is None:
|
||||
# print(i, field)
|
||||
if field[2] == None:
|
||||
if i == 0:
|
||||
root = self.treeModel.invisibleRootItem()
|
||||
row_count = root.rowCount()
|
||||
model.setData(model.index(0, i), row_count+1)
|
||||
if i == 3:
|
||||
found_in = []
|
||||
for hashset, hashes in self.hashsets.items():
|
||||
if metinfo.ED2KHASH.upper() in hashes:
|
||||
found_in.append(hashset)
|
||||
break
|
||||
# TODO Hash lookup
|
||||
model.setData(model.index(0, i), '<TODO>')
|
||||
model.setData(model.index(0, i), ', '.join(found_in))
|
||||
else:
|
||||
value = getattr(metinfo, field[1]) or field[3]
|
||||
if field[2] is QDateTime:
|
||||
last_changed = QDateTime.fromSecsSinceEpoch(value, 0)
|
||||
print(last_changed.toString('dd.MM.yyyy hh:mm:ss'))
|
||||
model.setData(model.index(0, i), last_changed.toString('dd.MM.yyyy hh:mm:ss'))
|
||||
elif field[2] is int:
|
||||
print(value)
|
||||
model.setData(model.index(0, i), '{0:,}'.format(value))
|
||||
elif field[2] is list:
|
||||
print(''.join(value))
|
||||
model.setData(model.index(0, i), ''.join(value))
|
||||
else:
|
||||
print(value)
|
||||
model.setData(model.index(0, i), value)
|
||||
model.item(0, i).setTextAlignment(field[4])
|
||||
|
||||
|
|
Loading…
Reference in New Issue