Просмотр исходного кода

Arreglado la busqueda con muchas versiones de un audio

hquijada лет назад: 4
Родитель
Сommit
f1c8fbbde0
2 измененных файлов с 9 добавлено и 3 удалено
  1. 1 1
      ondemand/__init__.py
  2. 8 2
      ondemand/service.py

+ 1 - 1
ondemand/__init__.py

@@ -1 +1 @@
-__version__ = '1.3.3-rc1'
+__version__ = '1.4.0'

+ 8 - 2
ondemand/service.py

@@ -210,10 +210,12 @@ def process_segment(item, audios=None, calibration=None):
     #    y calcular su fingerprint.
     try:
         filenames = []
+        id_by_ad = {}
         x = 0
         for i in item["elementos"]:
             x = x + 1
             log.info('[process_segment] {} downloading ad {}'.format(x, i["anuncio"]))
+            id_by_ad[i['anuncio']] = i['id']
             filename, md5hash = cloud_download(ad_key=i["anuncio"])
             if filename:
                 filenames.append((filename, md5hash))
@@ -282,7 +284,11 @@ def process_segment(item, audios=None, calibration=None):
             for match in dejavu.recognize(recognizer, path, segment_size):
                 name = None
                 try:
-                    name = match['name']
+                    if match['name'] in id_by_ad.keys():
+                        name = id_by_ad[match['name']]
+                    else:
+                        name = match['name']
+
                 except KeyError:
                     pass
 
@@ -308,7 +314,7 @@ def process_segment(item, audios=None, calibration=None):
 
     try:
         for i in item["elementos"]:
-            r = [result for result in results if result["name"] == i["anuncio"]]
+            r = [result for result in results if result["name"] == i["id"]]
             i['encontrados'] = find_repetitions(r, segments_needed=segments_needed, calibration=calibration,)
 
         item["archivos_perdidos"] = (12 - audios_counter) if audios_counter < 12 else 0