瀏覽代碼

audios will be queried from database with 1 second of tolerance to past hour

Gamaliel Espinoza 7 年之前
父節點
當前提交
9844d85361
共有 2 個文件被更改,包括 4 次插入7 次删除
  1. 1 1
      ondemand/__init__.py
  2. 3 6
      ondemand/service.py

+ 1 - 1
ondemand/__init__.py

@@ -1 +1 @@
-__version__ = '1.1.3'
+__version__ = '1.1.4'

+ 3 - 6
ondemand/service.py

@@ -21,6 +21,7 @@ import sys
 import os
 
 AUDIOS_PATH = '/tmp'
+AHEAD_TIME_AUDIO_TOLERANCE = 1 # second
 
 config = parse_config()
 queue = Queue()
@@ -150,11 +151,6 @@ def find_repetitions(results):
                 expect_space = False
 
         if found_counter >= segments_needed:
-            """ TODO: It will be neccessary to improve this
-            further, so it can recognize more than one
-            audio in the same segment of 1 hour. Also the
-            seconds transcurred is important; a time
-            difference is needed """
             found.append(results[found_index]['timestamp'])
             found_counter = 0
             expect_space = True
@@ -166,7 +162,8 @@ def iterate_audios(dt, station):
     iterate a list of files that are between
     the the date and itself plus 5 minutes;
     station must match too """
-    from_time = time.mktime(dt.timetuple())
+    from_time = time.mktime(dt.timetuple()) \
+              - AHEAD_TIME_AUDIO_TOLERANCE
     to_time = from_time + 3599
 
     print('from {} to {}'.format(from_time, to_time))