feat: configure cue points analysis per track type

This commit is contained in:
jo 2023-02-10 22:55:54 +01:00 committed by Kyle Robbertze
parent 3a9ca109c3
commit f5e46c6f3d
22 changed files with 246 additions and 42 deletions

View File

@ -7,7 +7,7 @@ import pika
from loguru import logger from loguru import logger
from .config import Config from .config import Config
from .pipeline import Pipeline, PipelineStatus from .pipeline import Pipeline, PipelineOptions, PipelineStatus
from .status_reporter import StatusReporter from .status_reporter import StatusReporter
EXCHANGE = "airtime-uploads" EXCHANGE = "airtime-uploads"
@ -111,17 +111,19 @@ class MessageListener:
body = body.decode() body = body.decode()
except (UnicodeDecodeError, AttributeError): except (UnicodeDecodeError, AttributeError):
pass pass
msg_dict = json.loads(body) msg_dict: dict = json.loads(body)
file_id = msg_dict["file_id"] file_id = msg_dict["file_id"]
audio_file_path = msg_dict["tmp_file_path"] audio_file_path = msg_dict["tmp_file_path"]
original_filename = msg_dict["original_filename"] original_filename = msg_dict["original_filename"]
import_directory = msg_dict["import_directory"] import_directory = msg_dict["import_directory"]
options = msg_dict.get("options", {})
metadata = MessageListener.spawn_analyzer_process( metadata = MessageListener.spawn_analyzer_process(
audio_file_path, audio_file_path,
import_directory, import_directory,
original_filename, original_filename,
options,
) )
callback_url = f"{self.config.general.public_url}/rest/media/{file_id}" callback_url = f"{self.config.general.public_url}/rest/media/{file_id}"
@ -161,6 +163,7 @@ class MessageListener:
audio_file_path, audio_file_path,
import_directory, import_directory,
original_filename, original_filename,
options: dict,
): ):
metadata = {} metadata = {}
@ -171,6 +174,7 @@ class MessageListener:
audio_file_path, audio_file_path,
import_directory, import_directory,
original_filename, original_filename,
PipelineOptions(**options),
) )
metadata = queue.get() metadata = queue.get()
except Exception as exception: except Exception as exception:

View File

@ -1 +1 @@
from .pipeline import Pipeline, PipelineStatus from .pipeline import Pipeline, PipelineOptions, PipelineStatus

View File

@ -3,6 +3,7 @@ from queue import Queue
from typing import Any, Dict, Protocol from typing import Any, Dict, Protocol
from loguru import logger from loguru import logger
from pydantic import BaseModel
from .analyze_cuepoint import analyze_cuepoint, analyze_duration from .analyze_cuepoint import analyze_cuepoint, analyze_duration
from .analyze_metadata import analyze_metadata from .analyze_metadata import analyze_metadata
@ -23,6 +24,10 @@ class PipelineStatus(int, Enum):
FAILED = 2 FAILED = 2
class PipelineOptions(BaseModel):
analyze_cue_points: bool = True
class Pipeline: class Pipeline:
"""Analyzes and imports an audio file into the Airtime library. """Analyzes and imports an audio file into the Airtime library.
@ -33,10 +38,11 @@ class Pipeline:
@staticmethod @staticmethod
def run_analysis( def run_analysis(
queue, queue: Queue,
audio_file_path, audio_file_path: str,
import_directory, import_directory: str,
original_filename, original_filename: str,
options: PipelineOptions,
): ):
"""Analyze and import an audio file, and put all extracted metadata into queue. """Analyze and import an audio file, and put all extracted metadata into queue.
@ -78,7 +84,8 @@ class Pipeline:
metadata = {} metadata = {}
metadata = analyze_metadata(audio_file_path, metadata) metadata = analyze_metadata(audio_file_path, metadata)
metadata = analyze_duration(audio_file_path, metadata) metadata = analyze_duration(audio_file_path, metadata)
metadata = analyze_cuepoint(audio_file_path, metadata) if options.analyze_cue_points:
metadata = analyze_cuepoint(audio_file_path, metadata)
metadata = analyze_replaygain(audio_file_path, metadata) metadata = analyze_replaygain(audio_file_path, metadata)
metadata = analyze_playability(audio_file_path, metadata) metadata = analyze_playability(audio_file_path, metadata)

View File

@ -4,7 +4,7 @@ from queue import Queue
import pytest import pytest
from libretime_analyzer.pipeline import Pipeline from libretime_analyzer.pipeline import Pipeline, PipelineOptions
from ..conftest import AUDIO_FILENAME, AUDIO_IMPORT_DEST from ..conftest import AUDIO_FILENAME, AUDIO_IMPORT_DEST
@ -16,6 +16,7 @@ def test_run_analysis(src_dir: Path, dest_dir: Path):
str(src_dir / AUDIO_FILENAME), str(src_dir / AUDIO_FILENAME),
str(dest_dir), str(dest_dir),
AUDIO_FILENAME, AUDIO_FILENAME,
PipelineOptions(),
) )
metadata = queue.get() metadata = queue.get()

View File

@ -0,0 +1,27 @@
# pylint: disable=invalid-name
from django.db import migrations
from ._migrations import legacy_migration_factory
UP = """
alter table "cc_track_types" add column "analyze_cue_points" boolean default 't' not null;
"""
DOWN = """
alter table "cc_track_types" drop column if exists "analyze_cue_points";
"""
class Migration(migrations.Migration):
dependencies = [
("legacy", "0043_remove_cors_preference"),
]
operations = [
migrations.RunPython(
code=legacy_migration_factory(
target="44",
sql=UP,
)
)
]

View File

@ -1,2 +1,2 @@
# The schema version is defined using the migration file prefix number # The schema version is defined using the migration file prefix number
LEGACY_SCHEMA_VERSION = "43" LEGACY_SCHEMA_VERSION = "44"

View File

@ -95,6 +95,7 @@ CREATE TABLE "cc_track_types"
"visibility" BOOLEAN DEFAULT 't' NOT NULL, "visibility" BOOLEAN DEFAULT 't' NOT NULL,
"type_name" VARCHAR(64) DEFAULT '' NOT NULL, "type_name" VARCHAR(64) DEFAULT '' NOT NULL,
"description" VARCHAR(255) DEFAULT '' NOT NULL, "description" VARCHAR(255) DEFAULT '' NOT NULL,
"analyze_cue_points" BOOLEAN DEFAULT 't' NOT NULL,
PRIMARY KEY ("id"), PRIMARY KEY ("id"),
CONSTRAINT "cc_track_types_id_idx" UNIQUE ("id"), CONSTRAINT "cc_track_types_id_idx" UNIQUE ("id"),
CONSTRAINT "cc_track_types_code_idx" UNIQUE ("code") CONSTRAINT "cc_track_types_code_idx" UNIQUE ("code")

View File

@ -16,6 +16,12 @@ class Library(models.Model):
db_column="visibility", db_column="visibility",
) )
analyze_cue_points = models.BooleanField(
blank=True,
default=True,
db_column="analyze_cue_points",
)
class Meta: class Meta:
managed = False managed = False
db_table = "cc_track_types" db_table = "cc_track_types"

View File

@ -5611,6 +5611,8 @@ components:
maxLength: 255 maxLength: 255
enabled: enabled:
type: boolean type: boolean
analyze_cue_points:
type: boolean
required: required:
- code - code
- id - id
@ -5992,6 +5994,8 @@ components:
maxLength: 255 maxLength: 255
enabled: enabled:
type: boolean type: boolean
analyze_cue_points:
type: boolean
PatchedListenerCount: PatchedListenerCount:
type: object type: object
properties: properties:

View File

@ -87,7 +87,7 @@
"js/airtime/showbuilder/main_builder.js": "6db47cc75cb5072b09431fbd6c90b89f", "js/airtime/showbuilder/main_builder.js": "6db47cc75cb5072b09431fbd6c90b89f",
"js/airtime/showbuilder/tabs.js": "a0b5284afde950a6f32c7e9e75550690", "js/airtime/showbuilder/tabs.js": "a0b5284afde950a6f32c7e9e75550690",
"js/airtime/status/status.js": "f8c99b7b30e66c9127470bc8c01fb4b1", "js/airtime/status/status.js": "f8c99b7b30e66c9127470bc8c01fb4b1",
"js/airtime/tracktype/tracktype.js": "6f6107b8e628fe132617795ddb780544", "js/airtime/tracktype/tracktype.js": "cca00731e212727908bec54f21d4be58",
"js/airtime/user/user.js": "58b9a9951aca48bbed1ad080aa318080", "js/airtime/user/user.js": "58b9a9951aca48bbed1ad080aa318080",
"js/airtime/utilities/utilities.js": "ef59f38fbef5a7807c9fe266c58e7a17", "js/airtime/utilities/utilities.js": "ef59f38fbef5a7807c9fe266c58e7a17",
"js/airtime/widgets/table-example.js": "0aa2d9c528ee2d3fdeca997c7e93bdee", "js/airtime/widgets/table-example.js": "0aa2d9c528ee2d3fdeca997c7e93bdee",

View File

@ -52,6 +52,7 @@ class TracktypeController extends Zend_Controller_Action
$tracktype->setTypeName($formData['type_name']); $tracktype->setTypeName($formData['type_name']);
$tracktype->setDescription($formData['description']); $tracktype->setDescription($formData['description']);
$tracktype->setVisibility($formData['visibility']); $tracktype->setVisibility($formData['visibility']);
$tracktype->setAnalyzeCuePoints($formData['analyze_cue_points']);
$tracktype->save(); $tracktype->save();
$form->reset(); $form->reset();

View File

@ -53,6 +53,12 @@ class Application_Form_AddTracktype extends Zend_Form
$visibility->setRequired(true); $visibility->setRequired(true);
$this->addElement($visibility); $this->addElement($visibility);
$analyze_cue_points = new Zend_Form_Element_Checkbox('analyze_cue_points');
$analyze_cue_points->setLabel(_('Analyze cue points:'));
$analyze_cue_points->setAttrib('checked', true);
$analyze_cue_points->setRequired(true);
$this->addElement($analyze_cue_points);
$saveBtn = new Zend_Form_Element_Button('save_tracktype'); $saveBtn = new Zend_Form_Element_Button('save_tracktype');
$saveBtn->setAttrib('class', 'btn right-floated'); $saveBtn->setAttrib('class', 'btn right-floated');
$saveBtn->setIgnore(true); $saveBtn->setIgnore(true);

View File

@ -92,7 +92,8 @@ class Application_Model_RabbitMq
$tmpFilePath, $tmpFilePath,
$importedStorageDirectory, $importedStorageDirectory,
$originalFilename, $originalFilename,
$fileId $fileId,
$fileTrackTypeId
) { ) {
$config = Config::getConfig(); $config = Config::getConfig();
@ -114,6 +115,15 @@ class Application_Model_RabbitMq
$data['import_directory'] = $importedStorageDirectory; $data['import_directory'] = $importedStorageDirectory;
$data['original_filename'] = $originalFilename; $data['original_filename'] = $originalFilename;
$options = [];
if ($fileTrackTypeId) {
$fileTrackType = new Application_Model_Tracktype($fileTrackTypeId);
$options['analyze_cue_points'] = $fileTrackType->getAnalyzeCuePoints();
}
$data['options'] = $options;
$jsonData = json_encode($data); $jsonData = json_encode($data);
// self::sendMessage($exchange, 'topic', false, $jsonData, 'airtime-uploads'); // self::sendMessage($exchange, 'topic', false, $jsonData, 'airtime-uploads');

View File

@ -46,6 +46,12 @@ class Application_Model_Tracktype
$tracktype->setDbVisibility($visibility); $tracktype->setDbVisibility($visibility);
} }
public function setAnalyzeCuePoints($value)
{
$tracktype = $this->_tracktypeInstance;
$tracktype->setDbAnalyzeCuePoints($value);
}
public function getCode() public function getCode()
{ {
$tracktype = $this->_tracktypeInstance; $tracktype = $this->_tracktypeInstance;
@ -74,6 +80,13 @@ class Application_Model_Tracktype
return $tracktype->getDbVisibility(); return $tracktype->getDbVisibility();
} }
public function getAnalyzeCuePoints()
{
$tracktype = $this->_tracktypeInstance;
return $tracktype->getDbAnalyzeCuePoints();
}
public function save() public function save()
{ {
$this->_tracktypeInstance->save(); $this->_tracktypeInstance->save();
@ -162,7 +175,7 @@ class Application_Model_Tracktype
public static function getTracktypeData($id) public static function getTracktypeData($id)
{ {
$sql = <<<'SQL' $sql = <<<'SQL'
SELECT code, type_name, description, visibility, id SELECT code, type_name, description, visibility, id, analyze_cue_points
FROM cc_track_types FROM cc_track_types
WHERE id = :id WHERE id = :id
SQL; SQL;

View File

@ -170,9 +170,10 @@ class CcFiles extends BaseCcFiles
Application_Service_MediaService::importFileToLibrary( Application_Service_MediaService::importFileToLibrary(
$file->getPrimaryKey(), $file->getPrimaryKey(),
$filePath,
$originalFilename,
self::getOwnerId(), self::getOwnerId(),
$file->getDbTrackTypeId(),
$originalFilename,
$filePath,
$copyFile $copyFile
); );

View File

@ -44,6 +44,7 @@ class CcTracktypesTableMap extends TableMap
$this->addColumn('visibility', 'DbVisibility', 'BOOLEAN', true, null, true); $this->addColumn('visibility', 'DbVisibility', 'BOOLEAN', true, null, true);
$this->addColumn('type_name', 'DbTypeName', 'VARCHAR', true, 64, ''); $this->addColumn('type_name', 'DbTypeName', 'VARCHAR', true, 64, '');
$this->addColumn('description', 'DbDescription', 'VARCHAR', true, 255, ''); $this->addColumn('description', 'DbDescription', 'VARCHAR', true, 255, '');
$this->addColumn('analyze_cue_points', 'DbAnalyzeCuePoints', 'BOOLEAN', true, null, true);
// validators // validators
} // initialize() } // initialize()

View File

@ -63,6 +63,13 @@ abstract class BaseCcTracktypes extends BaseObject implements Persistent
*/ */
protected $description; protected $description;
/**
* The value for the analyze_cue_points field.
* Note: this column has a database default value of: true
* @var boolean
*/
protected $analyze_cue_points;
/** /**
* @var PropelObjectCollection|CcFiles[] Collection to store aggregation of CcFiles objects. * @var PropelObjectCollection|CcFiles[] Collection to store aggregation of CcFiles objects.
*/ */
@ -107,6 +114,7 @@ abstract class BaseCcTracktypes extends BaseObject implements Persistent
$this->visibility = true; $this->visibility = true;
$this->type_name = ''; $this->type_name = '';
$this->description = ''; $this->description = '';
$this->analyze_cue_points = true;
} }
/** /**
@ -174,6 +182,17 @@ abstract class BaseCcTracktypes extends BaseObject implements Persistent
return $this->description; return $this->description;
} }
/**
* Get the [analyze_cue_points] column value.
*
* @return boolean
*/
public function getDbAnalyzeCuePoints()
{
return $this->analyze_cue_points;
}
/** /**
* Set the value of [id] column. * Set the value of [id] column.
* *
@ -287,6 +306,35 @@ abstract class BaseCcTracktypes extends BaseObject implements Persistent
return $this; return $this;
} // setDbDescription() } // setDbDescription()
/**
* Sets the value of the [analyze_cue_points] column.
* Non-boolean arguments are converted using the following rules:
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
*
* @param boolean|integer|string $v The new value
* @return CcTracktypes The current object (for fluent API support)
*/
public function setDbAnalyzeCuePoints($v)
{
if ($v !== null) {
if (is_string($v)) {
$v = in_array(strtolower($v), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
} else {
$v = (boolean) $v;
}
}
if ($this->analyze_cue_points !== $v) {
$this->analyze_cue_points = $v;
$this->modifiedColumns[] = CcTracktypesPeer::ANALYZE_CUE_POINTS;
}
return $this;
} // setDbAnalyzeCuePoints()
/** /**
* Indicates whether the columns in this object are only set to default values. * Indicates whether the columns in this object are only set to default values.
* *
@ -313,6 +361,10 @@ abstract class BaseCcTracktypes extends BaseObject implements Persistent
return false; return false;
} }
if ($this->analyze_cue_points !== true) {
return false;
}
// otherwise, everything was equal, so return true // otherwise, everything was equal, so return true
return true; return true;
} // hasOnlyDefaultValues() } // hasOnlyDefaultValues()
@ -340,6 +392,7 @@ abstract class BaseCcTracktypes extends BaseObject implements Persistent
$this->visibility = ($row[$startcol + 2] !== null) ? (boolean) $row[$startcol + 2] : null; $this->visibility = ($row[$startcol + 2] !== null) ? (boolean) $row[$startcol + 2] : null;
$this->type_name = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null; $this->type_name = ($row[$startcol + 3] !== null) ? (string) $row[$startcol + 3] : null;
$this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null; $this->description = ($row[$startcol + 4] !== null) ? (string) $row[$startcol + 4] : null;
$this->analyze_cue_points = ($row[$startcol + 5] !== null) ? (boolean) $row[$startcol + 5] : null;
$this->resetModified(); $this->resetModified();
$this->setNew(false); $this->setNew(false);
@ -349,7 +402,7 @@ abstract class BaseCcTracktypes extends BaseObject implements Persistent
} }
$this->postHydrate($row, $startcol, $rehydrate); $this->postHydrate($row, $startcol, $rehydrate);
return $startcol + 5; // 5 = CcTracktypesPeer::NUM_HYDRATE_COLUMNS. return $startcol + 6; // 6 = CcTracktypesPeer::NUM_HYDRATE_COLUMNS.
} catch (Exception $e) { } catch (Exception $e) {
throw new PropelException("Error populating CcTracktypes object", $e); throw new PropelException("Error populating CcTracktypes object", $e);
@ -606,6 +659,9 @@ abstract class BaseCcTracktypes extends BaseObject implements Persistent
if ($this->isColumnModified(CcTracktypesPeer::DESCRIPTION)) { if ($this->isColumnModified(CcTracktypesPeer::DESCRIPTION)) {
$modifiedColumns[':p' . $index++] = '"description"'; $modifiedColumns[':p' . $index++] = '"description"';
} }
if ($this->isColumnModified(CcTracktypesPeer::ANALYZE_CUE_POINTS)) {
$modifiedColumns[':p' . $index++] = '"analyze_cue_points"';
}
$sql = sprintf( $sql = sprintf(
'INSERT INTO "cc_track_types" (%s) VALUES (%s)', 'INSERT INTO "cc_track_types" (%s) VALUES (%s)',
@ -632,6 +688,9 @@ abstract class BaseCcTracktypes extends BaseObject implements Persistent
case '"description"': case '"description"':
$stmt->bindValue($identifier, $this->description, PDO::PARAM_STR); $stmt->bindValue($identifier, $this->description, PDO::PARAM_STR);
break; break;
case '"analyze_cue_points"':
$stmt->bindValue($identifier, $this->analyze_cue_points, PDO::PARAM_BOOL);
break;
} }
} }
$stmt->execute(); $stmt->execute();
@ -782,6 +841,9 @@ abstract class BaseCcTracktypes extends BaseObject implements Persistent
case 4: case 4:
return $this->getDbDescription(); return $this->getDbDescription();
break; break;
case 5:
return $this->getDbAnalyzeCuePoints();
break;
default: default:
return null; return null;
break; break;
@ -816,6 +878,7 @@ abstract class BaseCcTracktypes extends BaseObject implements Persistent
$keys[2] => $this->getDbVisibility(), $keys[2] => $this->getDbVisibility(),
$keys[3] => $this->getDbTypeName(), $keys[3] => $this->getDbTypeName(),
$keys[4] => $this->getDbDescription(), $keys[4] => $this->getDbDescription(),
$keys[5] => $this->getDbAnalyzeCuePoints(),
); );
$virtualColumns = $this->virtualColumns; $virtualColumns = $this->virtualColumns;
foreach ($virtualColumns as $key => $virtualColumn) { foreach ($virtualColumns as $key => $virtualColumn) {
@ -875,6 +938,9 @@ abstract class BaseCcTracktypes extends BaseObject implements Persistent
case 4: case 4:
$this->setDbDescription($value); $this->setDbDescription($value);
break; break;
case 5:
$this->setDbAnalyzeCuePoints($value);
break;
} // switch() } // switch()
} }
@ -904,6 +970,7 @@ abstract class BaseCcTracktypes extends BaseObject implements Persistent
if (array_key_exists($keys[2], $arr)) $this->setDbVisibility($arr[$keys[2]]); if (array_key_exists($keys[2], $arr)) $this->setDbVisibility($arr[$keys[2]]);
if (array_key_exists($keys[3], $arr)) $this->setDbTypeName($arr[$keys[3]]); if (array_key_exists($keys[3], $arr)) $this->setDbTypeName($arr[$keys[3]]);
if (array_key_exists($keys[4], $arr)) $this->setDbDescription($arr[$keys[4]]); if (array_key_exists($keys[4], $arr)) $this->setDbDescription($arr[$keys[4]]);
if (array_key_exists($keys[5], $arr)) $this->setDbAnalyzeCuePoints($arr[$keys[5]]);
} }
/** /**
@ -920,6 +987,7 @@ abstract class BaseCcTracktypes extends BaseObject implements Persistent
if ($this->isColumnModified(CcTracktypesPeer::VISIBILITY)) $criteria->add(CcTracktypesPeer::VISIBILITY, $this->visibility); if ($this->isColumnModified(CcTracktypesPeer::VISIBILITY)) $criteria->add(CcTracktypesPeer::VISIBILITY, $this->visibility);
if ($this->isColumnModified(CcTracktypesPeer::TYPE_NAME)) $criteria->add(CcTracktypesPeer::TYPE_NAME, $this->type_name); if ($this->isColumnModified(CcTracktypesPeer::TYPE_NAME)) $criteria->add(CcTracktypesPeer::TYPE_NAME, $this->type_name);
if ($this->isColumnModified(CcTracktypesPeer::DESCRIPTION)) $criteria->add(CcTracktypesPeer::DESCRIPTION, $this->description); if ($this->isColumnModified(CcTracktypesPeer::DESCRIPTION)) $criteria->add(CcTracktypesPeer::DESCRIPTION, $this->description);
if ($this->isColumnModified(CcTracktypesPeer::ANALYZE_CUE_POINTS)) $criteria->add(CcTracktypesPeer::ANALYZE_CUE_POINTS, $this->analyze_cue_points);
return $criteria; return $criteria;
} }
@ -987,6 +1055,7 @@ abstract class BaseCcTracktypes extends BaseObject implements Persistent
$copyObj->setDbVisibility($this->getDbVisibility()); $copyObj->setDbVisibility($this->getDbVisibility());
$copyObj->setDbTypeName($this->getDbTypeName()); $copyObj->setDbTypeName($this->getDbTypeName());
$copyObj->setDbDescription($this->getDbDescription()); $copyObj->setDbDescription($this->getDbDescription());
$copyObj->setDbAnalyzeCuePoints($this->getDbAnalyzeCuePoints());
if ($deepCopy && !$this->startCopy) { if ($deepCopy && !$this->startCopy) {
// important: temporarily setNew(false) because this affects the behavior of // important: temporarily setNew(false) because this affects the behavior of
@ -1352,6 +1421,7 @@ abstract class BaseCcTracktypes extends BaseObject implements Persistent
$this->visibility = null; $this->visibility = null;
$this->type_name = null; $this->type_name = null;
$this->description = null; $this->description = null;
$this->analyze_cue_points = null;
$this->alreadyInSave = false; $this->alreadyInSave = false;
$this->alreadyInValidation = false; $this->alreadyInValidation = false;
$this->alreadyInClearAllReferencesDeep = false; $this->alreadyInClearAllReferencesDeep = false;

View File

@ -24,13 +24,13 @@ abstract class BaseCcTracktypesPeer
const TM_CLASS = 'CcTracktypesTableMap'; const TM_CLASS = 'CcTracktypesTableMap';
/** The total number of columns. */ /** The total number of columns. */
const NUM_COLUMNS = 5; const NUM_COLUMNS = 6;
/** The number of lazy-loaded columns. */ /** The number of lazy-loaded columns. */
const NUM_LAZY_LOAD_COLUMNS = 0; const NUM_LAZY_LOAD_COLUMNS = 0;
/** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */ /** The number of columns to hydrate (NUM_COLUMNS - NUM_LAZY_LOAD_COLUMNS) */
const NUM_HYDRATE_COLUMNS = 5; const NUM_HYDRATE_COLUMNS = 6;
/** the column name for the id field */ /** the column name for the id field */
const ID = 'cc_track_types.id'; const ID = 'cc_track_types.id';
@ -47,6 +47,9 @@ abstract class BaseCcTracktypesPeer
/** the column name for the description field */ /** the column name for the description field */
const DESCRIPTION = 'cc_track_types.description'; const DESCRIPTION = 'cc_track_types.description';
/** the column name for the analyze_cue_points field */
const ANALYZE_CUE_POINTS = 'cc_track_types.analyze_cue_points';
/** The default string format for model objects of the related table **/ /** The default string format for model objects of the related table **/
const DEFAULT_STRING_FORMAT = 'YAML'; const DEFAULT_STRING_FORMAT = 'YAML';
@ -66,12 +69,12 @@ abstract class BaseCcTracktypesPeer
* e.g. CcTracktypesPeer::$fieldNames[CcTracktypesPeer::TYPE_PHPNAME][0] = 'Id' * e.g. CcTracktypesPeer::$fieldNames[CcTracktypesPeer::TYPE_PHPNAME][0] = 'Id'
*/ */
protected static $fieldNames = array ( protected static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('DbId', 'DbCode', 'DbVisibility', 'DbTypeName', 'DbDescription', ), BasePeer::TYPE_PHPNAME => array ('DbId', 'DbCode', 'DbVisibility', 'DbTypeName', 'DbDescription', 'DbAnalyzeCuePoints', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbCode', 'dbVisibility', 'dbTypeName', 'dbDescription', ), BasePeer::TYPE_STUDLYPHPNAME => array ('dbId', 'dbCode', 'dbVisibility', 'dbTypeName', 'dbDescription', 'dbAnalyzeCuePoints', ),
BasePeer::TYPE_COLNAME => array (CcTracktypesPeer::ID, CcTracktypesPeer::CODE, CcTracktypesPeer::VISIBILITY, CcTracktypesPeer::TYPE_NAME, CcTracktypesPeer::DESCRIPTION, ), BasePeer::TYPE_COLNAME => array (CcTracktypesPeer::ID, CcTracktypesPeer::CODE, CcTracktypesPeer::VISIBILITY, CcTracktypesPeer::TYPE_NAME, CcTracktypesPeer::DESCRIPTION, CcTracktypesPeer::ANALYZE_CUE_POINTS, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'VISIBILITY', 'TYPE_NAME', 'DESCRIPTION', ), BasePeer::TYPE_RAW_COLNAME => array ('ID', 'CODE', 'VISIBILITY', 'TYPE_NAME', 'DESCRIPTION', 'ANALYZE_CUE_POINTS', ),
BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'visibility', 'type_name', 'description', ), BasePeer::TYPE_FIELDNAME => array ('id', 'code', 'visibility', 'type_name', 'description', 'analyze_cue_points', ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
); );
/** /**
@ -81,12 +84,12 @@ abstract class BaseCcTracktypesPeer
* e.g. CcTracktypesPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0 * e.g. CcTracktypesPeer::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
*/ */
protected static $fieldKeys = array ( protected static $fieldKeys = array (
BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbCode' => 1, 'DbVisibility' => 2, 'DbTypeName' => 3, 'DbDescription' => 4, ), BasePeer::TYPE_PHPNAME => array ('DbId' => 0, 'DbCode' => 1, 'DbVisibility' => 2, 'DbTypeName' => 3, 'DbDescription' => 4, 'DbAnalyzeCuePoints' => 5, ),
BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbCode' => 1, 'dbVisibility' => 2, 'dbTypeName' => 3, 'dbDescription' => 4, ), BasePeer::TYPE_STUDLYPHPNAME => array ('dbId' => 0, 'dbCode' => 1, 'dbVisibility' => 2, 'dbTypeName' => 3, 'dbDescription' => 4, 'dbAnalyzeCuePoints' => 5, ),
BasePeer::TYPE_COLNAME => array (CcTracktypesPeer::ID => 0, CcTracktypesPeer::CODE => 1, CcTracktypesPeer::VISIBILITY => 2, CcTracktypesPeer::TYPE_NAME => 3, CcTracktypesPeer::DESCRIPTION => 4, ), BasePeer::TYPE_COLNAME => array (CcTracktypesPeer::ID => 0, CcTracktypesPeer::CODE => 1, CcTracktypesPeer::VISIBILITY => 2, CcTracktypesPeer::TYPE_NAME => 3, CcTracktypesPeer::DESCRIPTION => 4, CcTracktypesPeer::ANALYZE_CUE_POINTS => 5, ),
BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'VISIBILITY' => 2, 'TYPE_NAME' => 3, 'DESCRIPTION' => 4, ), BasePeer::TYPE_RAW_COLNAME => array ('ID' => 0, 'CODE' => 1, 'VISIBILITY' => 2, 'TYPE_NAME' => 3, 'DESCRIPTION' => 4, 'ANALYZE_CUE_POINTS' => 5, ),
BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'visibility' => 2, 'type_name' => 3, 'description' => 4, ), BasePeer::TYPE_FIELDNAME => array ('id' => 0, 'code' => 1, 'visibility' => 2, 'type_name' => 3, 'description' => 4, 'analyze_cue_points' => 5, ),
BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, ) BasePeer::TYPE_NUM => array (0, 1, 2, 3, 4, 5, )
); );
/** /**
@ -165,12 +168,14 @@ abstract class BaseCcTracktypesPeer
$criteria->addSelectColumn(CcTracktypesPeer::VISIBILITY); $criteria->addSelectColumn(CcTracktypesPeer::VISIBILITY);
$criteria->addSelectColumn(CcTracktypesPeer::TYPE_NAME); $criteria->addSelectColumn(CcTracktypesPeer::TYPE_NAME);
$criteria->addSelectColumn(CcTracktypesPeer::DESCRIPTION); $criteria->addSelectColumn(CcTracktypesPeer::DESCRIPTION);
$criteria->addSelectColumn(CcTracktypesPeer::ANALYZE_CUE_POINTS);
} else { } else {
$criteria->addSelectColumn($alias . '.id'); $criteria->addSelectColumn($alias . '.id');
$criteria->addSelectColumn($alias . '.code'); $criteria->addSelectColumn($alias . '.code');
$criteria->addSelectColumn($alias . '.visibility'); $criteria->addSelectColumn($alias . '.visibility');
$criteria->addSelectColumn($alias . '.type_name'); $criteria->addSelectColumn($alias . '.type_name');
$criteria->addSelectColumn($alias . '.description'); $criteria->addSelectColumn($alias . '.description');
$criteria->addSelectColumn($alias . '.analyze_cue_points');
} }
} }

View File

@ -11,12 +11,14 @@
* @method CcTracktypesQuery orderByDbVisibility($order = Criteria::ASC) Order by the visibility column * @method CcTracktypesQuery orderByDbVisibility($order = Criteria::ASC) Order by the visibility column
* @method CcTracktypesQuery orderByDbTypeName($order = Criteria::ASC) Order by the type_name column * @method CcTracktypesQuery orderByDbTypeName($order = Criteria::ASC) Order by the type_name column
* @method CcTracktypesQuery orderByDbDescription($order = Criteria::ASC) Order by the description column * @method CcTracktypesQuery orderByDbDescription($order = Criteria::ASC) Order by the description column
* @method CcTracktypesQuery orderByDbAnalyzeCuePoints($order = Criteria::ASC) Order by the analyze_cue_points column
* *
* @method CcTracktypesQuery groupByDbId() Group by the id column * @method CcTracktypesQuery groupByDbId() Group by the id column
* @method CcTracktypesQuery groupByDbCode() Group by the code column * @method CcTracktypesQuery groupByDbCode() Group by the code column
* @method CcTracktypesQuery groupByDbVisibility() Group by the visibility column * @method CcTracktypesQuery groupByDbVisibility() Group by the visibility column
* @method CcTracktypesQuery groupByDbTypeName() Group by the type_name column * @method CcTracktypesQuery groupByDbTypeName() Group by the type_name column
* @method CcTracktypesQuery groupByDbDescription() Group by the description column * @method CcTracktypesQuery groupByDbDescription() Group by the description column
* @method CcTracktypesQuery groupByDbAnalyzeCuePoints() Group by the analyze_cue_points column
* *
* @method CcTracktypesQuery leftJoin($relation) Adds a LEFT JOIN clause to the query * @method CcTracktypesQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
* @method CcTracktypesQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query * @method CcTracktypesQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
@ -33,12 +35,14 @@
* @method CcTracktypes findOneByDbVisibility(boolean $visibility) Return the first CcTracktypes filtered by the visibility column * @method CcTracktypes findOneByDbVisibility(boolean $visibility) Return the first CcTracktypes filtered by the visibility column
* @method CcTracktypes findOneByDbTypeName(string $type_name) Return the first CcTracktypes filtered by the type_name column * @method CcTracktypes findOneByDbTypeName(string $type_name) Return the first CcTracktypes filtered by the type_name column
* @method CcTracktypes findOneByDbDescription(string $description) Return the first CcTracktypes filtered by the description column * @method CcTracktypes findOneByDbDescription(string $description) Return the first CcTracktypes filtered by the description column
* @method CcTracktypes findOneByDbAnalyzeCuePoints(boolean $analyze_cue_points) Return the first CcTracktypes filtered by the analyze_cue_points column
* *
* @method array findByDbId(int $id) Return CcTracktypes objects filtered by the id column * @method array findByDbId(int $id) Return CcTracktypes objects filtered by the id column
* @method array findByDbCode(string $code) Return CcTracktypes objects filtered by the code column * @method array findByDbCode(string $code) Return CcTracktypes objects filtered by the code column
* @method array findByDbVisibility(boolean $visibility) Return CcTracktypes objects filtered by the visibility column * @method array findByDbVisibility(boolean $visibility) Return CcTracktypes objects filtered by the visibility column
* @method array findByDbTypeName(string $type_name) Return CcTracktypes objects filtered by the type_name column * @method array findByDbTypeName(string $type_name) Return CcTracktypes objects filtered by the type_name column
* @method array findByDbDescription(string $description) Return CcTracktypes objects filtered by the description column * @method array findByDbDescription(string $description) Return CcTracktypes objects filtered by the description column
* @method array findByDbAnalyzeCuePoints(boolean $analyze_cue_points) Return CcTracktypes objects filtered by the analyze_cue_points column
* *
* @package propel.generator.airtime.om * @package propel.generator.airtime.om
*/ */
@ -146,7 +150,7 @@ abstract class BaseCcTracktypesQuery extends ModelCriteria
*/ */
protected function findPkSimple($key, $con) protected function findPkSimple($key, $con)
{ {
$sql = 'SELECT "id", "code", "visibility", "type_name", "description" FROM "cc_track_types" WHERE "id" = :p0'; $sql = 'SELECT "id", "code", "visibility", "type_name", "description", "analyze_cue_points" FROM "cc_track_types" WHERE "id" = :p0';
try { try {
$stmt = $con->prepare($sql); $stmt = $con->prepare($sql);
$stmt->bindValue(':p0', $key, PDO::PARAM_INT); $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
@ -391,6 +395,33 @@ abstract class BaseCcTracktypesQuery extends ModelCriteria
return $this->addUsingAlias(CcTracktypesPeer::DESCRIPTION, $dbDescription, $comparison); return $this->addUsingAlias(CcTracktypesPeer::DESCRIPTION, $dbDescription, $comparison);
} }
/**
* Filter the query on the analyze_cue_points column
*
* Example usage:
* <code>
* $query->filterByDbAnalyzeCuePoints(true); // WHERE analyze_cue_points = true
* $query->filterByDbAnalyzeCuePoints('yes'); // WHERE analyze_cue_points = true
* </code>
*
* @param boolean|string $dbAnalyzeCuePoints The value to use as filter.
* Non-boolean arguments are converted using the following rules:
* * 1, '1', 'true', 'on', and 'yes' are converted to boolean true
* * 0, '0', 'false', 'off', and 'no' are converted to boolean false
* Check on string values is case insensitive (so 'FaLsE' is seen as 'false').
* @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
*
* @return CcTracktypesQuery The current query, for fluid interface
*/
public function filterByDbAnalyzeCuePoints($dbAnalyzeCuePoints = null, $comparison = null)
{
if (is_string($dbAnalyzeCuePoints)) {
$dbAnalyzeCuePoints = in_array(strtolower($dbAnalyzeCuePoints), array('false', 'off', '-', 'no', 'n', '0', '')) ? false : true;
}
return $this->addUsingAlias(CcTracktypesPeer::ANALYZE_CUE_POINTS, $dbAnalyzeCuePoints, $comparison);
}
/** /**
* Filter the query by a related CcFiles object * Filter the query by a related CcFiles object
* *

View File

@ -13,31 +13,44 @@ class Application_Service_MediaService
/** Move (or copy) a file to the stor/organize directory and send it off to the /** Move (or copy) a file to the stor/organize directory and send it off to the
* analyzer to be processed. * analyzer to be processed.
* *
* @param $filePath string Path to the local file to import to the library * @param mixed $fileId
* @param $originalFilename string The original filename, if you want it to be preserved after import * @param mixed $fileOwnerId The ID of the user that will own the file inside Airtime
* @param $ownerId string The ID of the user that will own the file inside Airtime * @param mixed $fileTrackTypeId
* @param $copyFile bool True if you want to copy the file to the "organize" directory, false if you want to move it (default) * @param string $fileOriginalFilename The original filename, if you want it to be preserved after import
* @param mixed $fileId * @param string $filePath Path to the local file to import to the library
* @param bool $copyFile True if you want to copy the file to the "organize" directory, false if you want to move it (default)
* *
* @return Ambigous * @return Ambigous
* *
* @throws Exception * @throws Exception
*/ */
public static function importFileToLibrary($fileId, $filePath, $originalFilename, $ownerId, $copyFile) public static function importFileToLibrary(
{ $fileId,
$importedStorageDirectory = Config::getStoragePath() . '/imported/' . $ownerId; $fileOwnerId,
$fileTrackTypeId,
$fileOriginalFilename,
$filePath,
$copyFile
) {
$importedStorageDirectory = Config::getStoragePath() . '/imported/' . $fileOwnerId;
// Copy the temporary file over to the "organize" folder so that it's off our webserver // Copy the temporary file over to the "organize" folder so that it's off our webserver
// and accessible by libretime-analyzer which could be running on a different machine. // and accessible by libretime-analyzer which could be running on a different machine.
$newTempFilePath = Application_Model_StoredFile::moveFileToStor($filePath, $fileId, $originalFilename, $copyFile); $newTempFilePath = Application_Model_StoredFile::moveFileToStor(
$filePath,
$fileId,
$fileOriginalFilename,
$copyFile
);
// Dispatch a message to libretime-analyzer through RabbitMQ, // Dispatch a message to libretime-analyzer through RabbitMQ,
// notifying it that there's a new upload to process! // notifying it that there's a new upload to process!
Application_Model_RabbitMq::SendMessageToAnalyzer( Application_Model_RabbitMq::SendMessageToAnalyzer(
$newTempFilePath, $newTempFilePath,
$importedStorageDirectory, $importedStorageDirectory,
basename($originalFilename), basename($fileOriginalFilename),
$fileId $fileId,
$fileTrackTypeId
); );
return $newTempFilePath; return $newTempFilePath;

View File

@ -92,6 +92,7 @@
<column name="visibility" phpName="DbVisibility" type="BOOLEAN" required="true" defaultValue="true" /> <column name="visibility" phpName="DbVisibility" type="BOOLEAN" required="true" defaultValue="true" />
<column name="type_name" phpName="DbTypeName" type="VARCHAR" size="64" required="true" defaultValue="" /> <column name="type_name" phpName="DbTypeName" type="VARCHAR" size="64" required="true" defaultValue="" />
<column name="description" phpName="DbDescription" type="VARCHAR" size="255" required="true" defaultValue="" /> <column name="description" phpName="DbDescription" type="VARCHAR" size="255" required="true" defaultValue="" />
<column name="analyze_cue_points" phpName="DbAnalyzeCuePoints" type="BOOLEAN" required="true" defaultValue="true" />
<unique name="cc_track_types_id_idx"> <unique name="cc_track_types_id_idx">
<unique-column name="id" /> <unique-column name="id" />
</unique> </unique>

View File

@ -14,6 +14,8 @@ function populateForm(entries) {
} }
$("#visibility").val(visibility_value); $("#visibility").val(visibility_value);
$("#analyze_cue_points").prop("checked", entries.analyze_cue_points);
if (entries.id.length != 0) { if (entries.id.length != 0) {
$("#code").attr("readonly", "readonly"); $("#code").attr("readonly", "readonly");
} else { } else {