diff --git a/airtime_mvc/application/Bootstrap.php b/airtime_mvc/application/Bootstrap.php index c3e2a884f..1698e01d4 100644 --- a/airtime_mvc/application/Bootstrap.php +++ b/airtime_mvc/application/Bootstrap.php @@ -16,6 +16,7 @@ require_once "Database.php"; require_once "Timezone.php"; require_once __DIR__.'/forms/helpers/ValidationTypes.php'; require_once __DIR__.'/controllers/plugins/RabbitMqPlugin.php'; +require_once __DIR__.'/controllers/plugins/Maintenance.php'; require_once (APPLICATION_PATH."/logging/Logging.php"); Logging::setLogPath('/var/log/airtime/zendphp.log'); @@ -198,5 +199,11 @@ class Bootstrap extends Zend_Application_Bootstrap_Bootstrap 'action' => 'password-change', ))); } + + public function _initPlugins() + { + $front = Zend_Controller_Front::getInstance(); + $front->registerPlugin(new Zend_Controller_Plugin_Maintenance()); + } } diff --git a/airtime_mvc/application/controllers/IndexController.php b/airtime_mvc/application/controllers/IndexController.php index 8dcdb3a64..232623bc9 100644 --- a/airtime_mvc/application/controllers/IndexController.php +++ b/airtime_mvc/application/controllers/IndexController.php @@ -18,4 +18,9 @@ class IndexController extends Zend_Controller_Action $this->_helper->layout->setLayout('layout'); } + public function maintenanceAction() + { + $this->getResponse()->setHttpResponseCode(503); + } + } diff --git a/airtime_mvc/application/controllers/UpgradeController.php b/airtime_mvc/application/controllers/UpgradeController.php index 6f454b28b..8d7c3620c 100644 --- a/airtime_mvc/application/controllers/UpgradeController.php +++ b/airtime_mvc/application/controllers/UpgradeController.php @@ -17,6 +17,14 @@ class UpgradeController extends Zend_Controller_Action return; } + //Disable Airtime UI + //create a temporary maintenance notification file + //when this file is on the server, zend framework redirects all + //requests to the maintenance page and sets a 503 response code + $maintenanceFile = '/tmp/maintenance.txt'; + $file = fopen($maintenanceFile, 'w'); + fclose($file); + //Begin upgrade $filename = isset($_SERVER['AIRTIME_CONF']) ? $_SERVER['AIRTIME_CONF'] : "/etc/airtime/airtime.conf"; $values = parse_ini_file($filename, true); @@ -69,6 +77,46 @@ class UpgradeController extends Zend_Controller_Action $file = new SplFileObject($iniFile, "w"); $file->fwrite($beginning."\n".$newLines.$end); + $iniFile = isset($_SERVER['AIRTIME_BASE']) ? $_SERVER['AIRTIME_BASE']."application.ini" : "/usr/share/airtime/application/configs/application.ini"; + + //update application.ini + $newLines = "resources.frontController.moduleDirectory = APPLICATION_PATH '/modules'\n". + "resources.frontController.plugins.putHandler = 'Zend_Controller_Plugin_PutHandler'\n". + ";load everything in the modules directory including models\n". + "resources.modules[] = ''\n"; + + $currentIniFile = file_get_contents($iniFile); + + /* We want to add the new lines immediately after the first line, '[production]' + * We read the first line into $beginning, and the rest of the file into $end. + * Then overwrite the current application.ini file with $beginning, $newLines, and $end + */ + $lines = explode("\n", $currentIniFile); + $beginning = implode("\n", array_slice($lines, 0,1)); + + //check that first line is '[production]' + if ($beginning != '[production]') { + $this->getResponse() + ->setHttpResponseCode(400) + ->appendBody('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini'); + return; + } + $end = implode("\n", array_slice($lines, 1)); + + if (!is_writeable($iniFile)) { + $this->getResponse() + ->setHttpResponseCode(400) + ->appendBody('Upgrade to Airtime 2.5.3 FAILED. Could not upgrade application.ini'); + return; + } + $file = new SplFileObject($iniFile, "w"); + $file->fwrite($beginning."\n".$newLines.$end); + + //delete maintenance.txt to give users access back to Airtime + unlink($maintenanceFile); + + //TODO: clear out the cache + $this->getResponse() ->setHttpResponseCode(200) ->appendBody("Upgrade to Airtime 2.5.3 OK"); @@ -104,12 +152,12 @@ class UpgradeController extends Zend_Controller_Action ->findOne(); $airtime_version = $pref->getValStr(); - if ($airtime_version != '2.5.2') { + if ($airtime_version != '2.5.2' || $airtime_version != '2.5.1') { $this->getResponse() ->setHttpResponseCode(400) - ->appendBody("Upgrade to Airtime 2.5.3 FAILED. You must be using Airtime 2.5.2 to upgrade."); + ->appendBody("Upgrade to Airtime 2.5.3 FAILED. You must be using Airtime 2.5.1 or 2.5.2 to upgrade."); return false; } return true; } -} \ No newline at end of file +} diff --git a/airtime_mvc/application/controllers/plugins/Maintenance.php b/airtime_mvc/application/controllers/plugins/Maintenance.php new file mode 100644 index 000000000..46937f582 --- /dev/null +++ b/airtime_mvc/application/controllers/plugins/Maintenance.php @@ -0,0 +1,15 @@ +maintenanceFile)) { + $request->setModuleName('default') + ->setControllerName('index') + ->setActionName('maintenance') + ->setDispatched(true); + } + } +} \ No newline at end of file diff --git a/airtime_mvc/application/models/Preference.php b/airtime_mvc/application/models/Preference.php index 3288d2c8c..dcf03050f 100644 --- a/airtime_mvc/application/models/Preference.php +++ b/airtime_mvc/application/models/Preference.php @@ -641,6 +641,11 @@ class Application_Model_Preference { return self::getValue("logoImage"); } + + public static function SetUniqueId($id) + { + self::setValue("uniqueId", $id); + } public static function GetUniqueId() { @@ -890,6 +895,11 @@ class Application_Model_Preference return self::getValue("enable_stream_conf"); } + + public static function SetAirtimeVersion($version) + { + self::setValue("system_version", $version); + } public static function GetAirtimeVersion() { diff --git a/airtime_mvc/application/views/scripts/index/maintenance.phtml b/airtime_mvc/application/views/scripts/index/maintenance.phtml new file mode 100644 index 000000000..5a2277989 --- /dev/null +++ b/airtime_mvc/application/views/scripts/index/maintenance.phtml @@ -0,0 +1 @@ +Airtime is down for maintenance. We'll be back soon! diff --git a/airtime_mvc/build/sql/defaultdata.sql b/airtime_mvc/build/sql/defaultdata.sql index 7b9567d19..af82be2b8 100644 --- a/airtime_mvc/build/sql/defaultdata.sql +++ b/airtime_mvc/build/sql/defaultdata.sql @@ -330,16 +330,28 @@ INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('en_GB', 'English (Brit INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('en_US', 'English (USA)'); INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('cs_CZ', 'Český'); INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('de_DE', 'Deutsch'); -INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('de_AT', 'Österreichisches Deutsch'); -INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('hu_HU', 'Magyar'); +INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('de_AT', 'Deutsch (Österreich)'); +INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('el_GR', 'Ελληνικά'); INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('es_ES', 'Español'); INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('fr_FR', 'Français'); +INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('hr_HR', 'Hrvatski'); +INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('hu_HU', 'Magyar'); INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('it_IT', 'Italiano'); INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('ko_KR', '한국어'); INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('pl_PL', 'Polski'); -INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('pt_BR', 'Português Brasileiro'); +INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('pt_BR', 'Português (Brasil)'); INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('ru_RU', 'Русский'); +INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('sr_RS', 'Српски (Ћирилица)'); +INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('sr_RS@latin', 'Srpski (Latinica)'); INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('zh_CN', '简体中文'); -INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('el_GR', 'Ελληνικά'); -- end of added in 2.3 + +-- added in 2.5.2 + +INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', 'UTC'); +INSERT INTO cc_pref (subjid, keystr, valstr) VALUES (1, 'user_timezone', 'UTC'); + +INSERT INTO cc_pref (keystr, valstr) VALUES ('import_timestamp', '0'); + +--end added in 2.5.2 diff --git a/airtime_mvc/public/js/datatables/i18n/hr_HR.txt b/airtime_mvc/public/js/datatables/i18n/hr_HR.txt new file mode 100644 index 000000000..085560961 --- /dev/null +++ b/airtime_mvc/public/js/datatables/i18n/hr_HR.txt @@ -0,0 +1,19 @@ +//Croatian + +{ + "sProcessing": "Procesiram...", + "sLengthMenu": "Prikaži _MENU_ rezultata po stranici", + "sZeroRecords": "Ništa nije pronađeno", + "sInfo": "Prikazano _START_ do _END_ od _TOTAL_ rezultata", + "sInfoEmpty": "Prikazano 0 do 0 od 0 rezultata", + "sInfoFiltered": "(filtrirano iz _MAX_ ukupnih rezultata)", + "sInfoPostFix": "", + "sSearch": "Filter", + "sUrl": "", + "oPaginate": { + "sFirst": "Prva", + "sPrevious": "Nazad", + "sNext": "Naprijed", + "sLast": "Zadnja" + } +} diff --git a/airtime_mvc/public/js/datatables/i18n/sr_RS.txt b/airtime_mvc/public/js/datatables/i18n/sr_RS.txt new file mode 100644 index 000000000..68d36a58a --- /dev/null +++ b/airtime_mvc/public/js/datatables/i18n/sr_RS.txt @@ -0,0 +1,19 @@ +//Serbian Cyrillic + +{ + "sProcessing": "Обрада...", + "sLengthMenu": "_MENU_ Резултати по страници", + "sZeroRecords": "Ништа није пронађено", + "sInfo": "Резултати: _START_ - _END_ Укупно: _TOTAL_", + "sInfoEmpty": "Нула Резултат", + "sInfoFiltered": "(филтрирано из _MAX_ укупних резултата)", + "sInfoPostFix": "", + "sSearch": "Филтер", + "sUrl": "", + "oPaginate": { + "sFirst": "Прва", + "sPrevious": "Назад", + "sNext": "Напред", + "sLast": "Задња" + } +} diff --git a/airtime_mvc/public/js/datatables/i18n/sr_RS@latin.txt b/airtime_mvc/public/js/datatables/i18n/sr_RS@latin.txt new file mode 100644 index 000000000..64fc1bef4 --- /dev/null +++ b/airtime_mvc/public/js/datatables/i18n/sr_RS@latin.txt @@ -0,0 +1,19 @@ +//Serbian Latin + +{ +"sProcessing": "Obrada...", +"sLengthMenu": "_MENU_ Rezultati po stranici", +"sZeroRecords": "Ništa nije pronađeno", +"sInfo": "Rezultati: _START_ - _END_ Ukupno: _TOTAL_", +"sInfoEmpty": "Nula Rezultat", +"sInfoFiltered": "(filtrirano iz _MAX_ ukupnih rezultata)", +"sInfoPostFix": "", +"sSearch": "Filter", +"sUrl": "", +"oPaginate": { +"sFirst": "Prva", +"sPrevious": "Nazad", +"sNext": "Napred", +"sLast": "Zadnja" +} +} \ No newline at end of file diff --git a/airtime_mvc/public/js/plupload/i18n/hr_HR.js b/airtime_mvc/public/js/plupload/i18n/hr_HR.js new file mode 100644 index 000000000..084be51c9 --- /dev/null +++ b/airtime_mvc/public/js/plupload/i18n/hr_HR.js @@ -0,0 +1,25 @@ +// Croatian +plupload.addI18n({ + 'Select files': 'Izaberite datoteke:', + 'Add files to the upload queue and click the start button.': 'Dodajte datoteke u listu i kliknite Upload.', + 'Filename': 'Ime datoteke', + 'Status': 'Status', + 'Size': 'Veličina', + 'Add files': 'Dodajte datoteke', + 'Stop current upload': 'Zaustavi trenutan upload', + 'Start uploading queue': 'Pokreni Upload', + 'Uploaded %d/%d files': 'Uploadano %d/%d datoteka', + 'N/A': 'N/A', + 'Drag files here.': 'Dovucite datoteke ovdje', + 'File extension error.': 'Greška ekstenzije datoteke.', + 'File size error.': 'Greška veličine datoteke.', + 'Init error.': 'Greška inicijalizacije.', + 'HTTP Error.': 'HTTP greška.', + 'Security error.': 'Sigurnosna greška.', + 'Generic error.': 'Generička greška.', + 'IO error.': 'I/O greška.', + 'Stop Upload': 'Zaustavi upload.', + 'Add Files': 'Dodaj datoteke', + 'Start Upload': 'Pokreni upload.', + '%d files queued': '%d datoteka na čekanju.' +}); \ No newline at end of file diff --git a/airtime_mvc/public/js/plupload/i18n/sr_RS.js b/airtime_mvc/public/js/plupload/i18n/sr_RS.js new file mode 100644 index 000000000..29f7177e2 --- /dev/null +++ b/airtime_mvc/public/js/plupload/i18n/sr_RS.js @@ -0,0 +1,14 @@ +// Serbian Cyrillic +plupload.addI18n({ + 'Select files' : 'Изаберите фајлове', + 'Add files to the upload queue and click the start button.' : 'Додајте фајлове у листу и кликните на дугме Старт.', + 'Filename' : 'Назив фајла', + 'Status' : 'Status', + 'Size' : 'Величина', + 'Add Files' : 'Додај фајлове', + 'Stop current upload' : 'Заустави upload', + 'Start uploading queue' : 'Почни upload', + 'Drag files here.' : 'Превуци фајлове овде.', + 'Start Upload': 'Почни upload', + 'Uploaded %d/%d files': 'Снимљено %d/%d фајлова' +}); diff --git a/airtime_mvc/public/js/plupload/i18n/sr_RS@latin.js b/airtime_mvc/public/js/plupload/i18n/sr_RS@latin.js new file mode 100644 index 000000000..65195d14f --- /dev/null +++ b/airtime_mvc/public/js/plupload/i18n/sr_RS@latin.js @@ -0,0 +1,14 @@ +// Serbian Latin +plupload.addI18n({ + 'Select files' : 'Izaberite fajlove', + 'Add files to the upload queue and click the start button.' : 'Dodajte fajlove u listu i kliknite na dugme Start.', + 'Filename' : 'Naziv fajla', + 'Status' : 'Status', + 'Size' : 'Veličina', + 'Add Files' : 'Dodaj fajlove', + 'Stop current upload' : 'Zaustavi upload', + 'Start uploading queue' : 'Počni upload', + 'Drag files here.' : 'Prevucite fajlove ovde.', + 'Start Upload': 'Počni upload', + 'Uploaded %d/%d files': 'Snimljeno %d/%d fajlova' +}); diff --git a/install_minimal/include/AirtimeInstall.php b/install_minimal/include/AirtimeInstall.php index 7f1523137..fd37edb22 100644 --- a/install_minimal/include/AirtimeInstall.php +++ b/install_minimal/include/AirtimeInstall.php @@ -308,62 +308,15 @@ class AirtimeInstall $sql = "DELETE FROM cc_pref WHERE keystr = 'system_version'"; $con->exec($sql); - $sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('system_version', '$p_version')"; - $result = $con->exec($sql); - if ($result < 1) { - return false; - } - return true; + Application_Model_Preference::SetAirtimeVersion($p_version); } public static function SetUniqueId() { - $con = Propel::getConnection(); $uniqueId = md5(uniqid("", true)); - - $sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('uniqueId', '$uniqueId')"; - $result = $con->exec($sql); - if ($result < 1) { - return false; - } - return true; + Application_Model_Preference::SetUniqueId($uniqueId); } - public static function SetDefaultTimezone() - { - $con = Propel::getConnection(); - // we need to run php as commandline because we want to get the timezone in cli php.ini file - //$defaultTimezone = exec("php -r 'echo date_default_timezone_get().PHP_EOL;'"); - $defaultTimezone = exec("cat /etc/timezone"); - $defaultTimezone = trim($defaultTimezone); - if((!in_array($defaultTimezone, DateTimeZone::listIdentifiers()))){ - $defaultTimezone = "UTC"; - } - $sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('timezone', '$defaultTimezone')"; - $result = $con->exec($sql); - if ($result < 1) { - return false; - } - $sql = "INSERT INTO cc_pref (subjid, keystr, valstr) VALUES (1, 'user_timezone', '$defaultTimezone')"; - $result = $con->exec($sql); - if ($result < 1) { - return false; - } - return true; - } - - public static function SetImportTimestamp() - { - $con = Propel::getConnection(); - $sql = "INSERT INTO cc_pref (keystr, valstr) VALUES ('import_timestamp', '0')"; - $result = $con->exec($sql); - if ($result < 1) { - return false; - } - return true; - } - - public static function GetAirtimeVersion() { $con = Propel::getConnection(); diff --git a/install_minimal/include/airtime-db-install.php b/install_minimal/include/airtime-db-install.php index d2aca76a4..cc1905758 100644 --- a/install_minimal/include/airtime-db-install.php +++ b/install_minimal/include/airtime-db-install.php @@ -10,10 +10,19 @@ require_once(__DIR__.'/AirtimeInstall.php'); require_once(__DIR__.'/airtime-constants.php'); require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/configs/conf.php'); + + +//Propel classes. +set_include_path(AirtimeInstall::GetAirtimeSrcDir().'/application/models' . PATH_SEPARATOR . get_include_path()); + $CC_CONFIG = Config::getConfig(); require_once 'propel/runtime/lib/Propel.php'; Propel::init(AirtimeInstall::GetAirtimeSrcDir()."/application/configs/airtime-conf-production.php"); +//use this class to set new values in the cache as well. +require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/common/Database.php'); +require_once(AirtimeInstall::GetAirtimeSrcDir().'/application/models/Preference.php'); + echo PHP_EOL."* Database Installation".PHP_EOL; AirtimeInstall::CreateDatabaseUser(); @@ -56,10 +65,8 @@ AirtimeInstall::SetAirtimeVersion(AIRTIME_VERSION); if (AirtimeInstall::$databaseTablesCreated) { - AirtimeInstall::SetDefaultTimezone(); // set up some keys in DB AirtimeInstall::SetUniqueId(); - AirtimeInstall::SetImportTimestamp(); $ini = parse_ini_file(__DIR__."/airtime-install.ini"); diff --git a/install_minimal/upgrades/airtime-2.5.2/data/upgrade.sql b/install_minimal/upgrades/airtime-2.5.2/data/upgrade.sql new file mode 100644 index 000000000..7ac381fb6 --- /dev/null +++ b/install_minimal/upgrades/airtime-2.5.2/data/upgrade.sql @@ -0,0 +1,8 @@ +INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('hr_HR', 'Hrvatski'); +INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('sr_RS', 'Српски (Ћирилица)'); +INSERT INTO cc_locale (locale_code, locale_lang) VALUES ('sr_RS@latin', 'Srpski (Latinica)'); + +UPDATE cc_locale SET locale_lang='Deutsch (Österreich)' WHERE locale_code='de_AT'; +UPDATE cc_locale SET locale_lang='Português Brasileiro' WHERE locale_code='pt_BR'; + +-- NOTE BECAUSE OF CACHING NOW ANY UPGRADES TO cc_pref MUST NOT BE DONE HERE. diff --git a/python_apps/airtime_analyzer/airtime_analyzer/metadata_analyzer.py b/python_apps/airtime_analyzer/airtime_analyzer/metadata_analyzer.py index e6794fbc9..2d0e09fc2 100644 --- a/python_apps/airtime_analyzer/airtime_analyzer/metadata_analyzer.py +++ b/python_apps/airtime_analyzer/airtime_analyzer/metadata_analyzer.py @@ -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', diff --git a/python_apps/airtime_analyzer/airtime_analyzer/status_reporter.py b/python_apps/airtime_analyzer/airtime_analyzer/status_reporter.py index ee5062943..0e3c71619 100644 --- a/python_apps/airtime_analyzer/airtime_analyzer/status_reporter.py +++ b/python_apps/airtime_analyzer/airtime_analyzer/status_reporter.py @@ -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. diff --git a/python_apps/airtime_analyzer/tests/analyzer_pipeline_tests.py b/python_apps/airtime_analyzer/tests/analyzer_pipeline_tests.py index cafa07b47..54458e33f 100644 --- a/python_apps/airtime_analyzer/tests/analyzer_pipeline_tests.py +++ b/python_apps/airtime_analyzer/tests/analyzer_pipeline_tests.py @@ -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) diff --git a/python_apps/airtime_analyzer/tests/metadata_analyzer_tests.py b/python_apps/airtime_analyzer/tests/metadata_analyzer_tests.py index 6e59ae15a..9215c493a 100644 --- a/python_apps/airtime_analyzer/tests/metadata_analyzer_tests.py +++ b/python_apps/airtime_analyzer/tests/metadata_analyzer_tests.py @@ -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