Merge branch 'cc-5709-airtime-analyzer' into cc-5709-airtime-analyzer-saas

Conflicts:
	airtime_mvc/locale/cs_CZ/LC_MESSAGES/airtime.po
	airtime_mvc/locale/de_AT/LC_MESSAGES/airtime.po
	airtime_mvc/locale/de_DE/LC_MESSAGES/airtime.po
	airtime_mvc/locale/el_GR/LC_MESSAGES/airtime.po
	airtime_mvc/locale/en_CA/LC_MESSAGES/airtime.po
	airtime_mvc/locale/en_GB/LC_MESSAGES/airtime.po
	airtime_mvc/locale/en_US/LC_MESSAGES/airtime.po
	airtime_mvc/locale/es_ES/LC_MESSAGES/airtime.po
	airtime_mvc/locale/fr_FR/LC_MESSAGES/airtime.po
	airtime_mvc/locale/hr_HR/LC_MESSAGES/airtime.po
	airtime_mvc/locale/hu_HU/LC_MESSAGES/airtime.po
	airtime_mvc/locale/it_IT/LC_MESSAGES/airtime.po
	airtime_mvc/locale/ko_KR/LC_MESSAGES/airtime.po
	airtime_mvc/locale/nl_NL/LC_MESSAGES/airtime.po
	airtime_mvc/locale/pl_PL/LC_MESSAGES/airtime.po
	airtime_mvc/locale/pt_BR/LC_MESSAGES/airtime.po
	airtime_mvc/locale/ru_RU/LC_MESSAGES/airtime.po
	airtime_mvc/locale/sr_RS/LC_MESSAGES/airtime.po
	airtime_mvc/locale/sr_RS@latin/LC_MESSAGES/airtime.po
	airtime_mvc/locale/template/airtime.po
	airtime_mvc/locale/zh_CN/LC_MESSAGES/airtime.po
This commit is contained in:
Albert Santoni 2014-04-25 00:43:22 -04:00
commit 446eca057c
20 changed files with 257 additions and 71 deletions

View file

@ -1,6 +1,7 @@
import time
import datetime
import mutagen
import logging
from analyzer import Analyzer
class MetadataAnalyzer(Analyzer):
@ -52,7 +53,7 @@ class MetadataAnalyzer(Analyzer):
try:
#Special handling for getting the # of channels from MP3s. It's in the "mode" field
#which is 0=Stereo, 1=Joint Stereo, 2=Dual Channel, 3=Mono. Part of the ID3 spec...
if metadata["mime"] == "audio/mpeg":
if metadata["mime"] in ["audio/mpeg", 'audio/mp3']:
if info.mode == 3:
metadata["channels"] = 1
else:
@ -92,6 +93,7 @@ class MetadataAnalyzer(Analyzer):
'genre': 'genre',
'isrc': 'isrc',
'label': 'label',
'organization': 'label',
#'length': 'length',
'language': 'language',
'last_modified':'last_modified',

View file

@ -45,6 +45,13 @@ def process_http_requests(ipc_queue, http_retry_queue_path):
pass
else:
raise e
except Exception as e:
# If we fail to unpickle a saved queue of failed HTTP requests, then we'll just log an error
# and continue because those HTTP requests are lost anyways. The pickled file will be
# overwritten the next time the analyzer is shut down too.
logging.error("Failed to unpickle %s. Continuing..." % http_retry_queue_path)
pass
while not shutdown:
try:
@ -91,7 +98,8 @@ def send_http_request(picklable_request, retry_queue):
logging.error("HTTP request failed with unhandled exception. %s" % str(e))
# Don't put the request into the retry queue, just give up on this one.
# I'm doing this to protect against us getting some pathological request
# that breaks our code. I don't want us having
# that breaks our code. I don't want us pickling data that potentially
# breaks airtime_analyzer.

View file

@ -28,7 +28,7 @@ def test_basic():
assert metadata['album_title'] == u'Test Album'
assert metadata['year'] == u'1999'
assert metadata['genre'] == u'Test Genre'
assert metadata['mime'] == 'audio/mpeg' # Not unicode because MIMEs aren't.
assert metadata['mime'] == 'audio/mp3' # Not unicode because MIMEs aren't.
assert abs(metadata['length_seconds'] - 3.9) < 0.1
assert metadata["length"] == str(datetime.timedelta(seconds=metadata["length_seconds"]))
assert os.path.exists(DEFAULT_IMPORT_DEST)

View file

@ -26,7 +26,7 @@ def test_mp3_mono():
assert metadata['channels'] == 1
assert metadata['bit_rate'] == 64000
assert abs(metadata['length_seconds'] - 3.9) < 0.1
assert metadata['mime'] == 'audio/mpeg' # Not unicode because MIMEs aren't.
assert metadata['mime'] == 'audio/mp3' # Not unicode because MIMEs aren't.
assert metadata['track_total'] == u'10' # MP3s can have a track_total
#Mutagen doesn't extract comments from mp3s it seems
@ -36,7 +36,7 @@ def test_mp3_jointstereo():
assert metadata['channels'] == 2
assert metadata['bit_rate'] == 128000
assert abs(metadata['length_seconds'] - 3.9) < 0.1
assert metadata['mime'] == 'audio/mpeg'
assert metadata['mime'] == 'audio/mp3'
assert metadata['track_total'] == u'10' # MP3s can have a track_total
def test_mp3_simplestereo():
@ -45,7 +45,7 @@ def test_mp3_simplestereo():
assert metadata['channels'] == 2
assert metadata['bit_rate'] == 128000
assert abs(metadata['length_seconds'] - 3.9) < 0.1
assert metadata['mime'] == 'audio/mpeg'
assert metadata['mime'] == 'audio/mp3'
assert metadata['track_total'] == u'10' # MP3s can have a track_total
def test_mp3_dualmono():
@ -54,7 +54,7 @@ def test_mp3_dualmono():
assert metadata['channels'] == 2
assert metadata['bit_rate'] == 128000
assert abs(metadata['length_seconds'] - 3.9) < 0.1
assert metadata['mime'] == 'audio/mpeg'
assert metadata['mime'] == 'audio/mp3'
assert metadata['track_total'] == u'10' # MP3s can have a track_total
@ -64,7 +64,7 @@ def test_ogg_mono():
assert metadata['channels'] == 1
assert metadata['bit_rate'] == 80000
assert abs(metadata['length_seconds'] - 3.8) < 0.1
assert metadata['mime'] == 'application/ogg'
assert metadata['mime'] == 'audio/vorbis'
assert metadata['comment'] == u'Test Comment'
def test_ogg_stereo():
@ -73,7 +73,7 @@ def test_ogg_stereo():
assert metadata['channels'] == 2
assert metadata['bit_rate'] == 112000
assert abs(metadata['length_seconds'] - 3.8) < 0.1
assert metadata['mime'] == 'application/ogg'
assert metadata['mime'] == 'audio/vorbis'
assert metadata['comment'] == u'Test Comment'
''' faac and avconv can't seem to create a proper mono AAC file... ugh
@ -85,7 +85,7 @@ def test_aac_mono():
assert metadata['channels'] == 1
assert metadata['bit_rate'] == 80000
assert abs(metadata['length_seconds'] - 3.8) < 0.1
assert metadata['mime'] == 'video/mp4'
assert metadata['mime'] == 'audio/mp4'
assert metadata['comment'] == u'Test Comment'
'''
@ -95,7 +95,7 @@ def test_aac_stereo():
assert metadata['channels'] == 2
assert metadata['bit_rate'] == 102619
assert abs(metadata['length_seconds'] - 3.8) < 0.1
assert metadata['mime'] == 'video/mp4'
assert metadata['mime'] == 'audio/mp4'
assert metadata['comment'] == u'Test Comment'
def test_mp3_utf8():
@ -111,7 +111,7 @@ def test_mp3_utf8():
assert metadata['channels'] == 2
assert metadata['bit_rate'] == 128000
assert abs(metadata['length_seconds'] - 3.9) < 0.1
assert metadata['mime'] == 'audio/mpeg'
assert metadata['mime'] == 'audio/mp3'
assert metadata['track_total'] == u'10' # MP3s can have a track_total
# Make sure the parameter checking works
@ -145,7 +145,7 @@ def test_mp3_bad_channels():
assert metadata['bit_rate'] == 64000
print metadata['length_seconds']
assert abs(metadata['length_seconds'] - 3.9) < 0.1
assert metadata['mime'] == 'audio/mpeg' # Not unicode because MIMEs aren't.
assert metadata['mime'] == 'audio/mp3' # Not unicode because MIMEs aren't.
assert metadata['track_total'] == u'10' # MP3s can have a track_total
#Mutagen doesn't extract comments from mp3s it seems