Ver código fonte

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

Gamaliel Espinoza 7 anos atrás
pai
commit
9844d85361
2 arquivos alterados com 4 adições e 7 exclusões
  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
 import os
 
 
 AUDIOS_PATH = '/tmp'
 AUDIOS_PATH = '/tmp'
+AHEAD_TIME_AUDIO_TOLERANCE = 1 # second
 
 
 config = parse_config()
 config = parse_config()
 queue = Queue()
 queue = Queue()
@@ -150,11 +151,6 @@ def find_repetitions(results):
                 expect_space = False
                 expect_space = False
 
 
         if found_counter >= segments_needed:
         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.append(results[found_index]['timestamp'])
             found_counter = 0
             found_counter = 0
             expect_space = True
             expect_space = True
@@ -166,7 +162,8 @@ def iterate_audios(dt, station):
     iterate a list of files that are between
     iterate a list of files that are between
     the the date and itself plus 5 minutes;
     the the date and itself plus 5 minutes;
     station must match too """
     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
     to_time = from_time + 3599
 
 
     print('from {} to {}'.format(from_time, to_time))
     print('from {} to {}'.format(from_time, to_time))