Built motion from commit 445c00a.|0.0.50
[motion.git] / server / api / sound / sound.controller.js
1 var _0x6991=["\x75\x73\x65\x20\x73\x74\x72\x69\x63\x74","\x6C\x6F\x64\x61\x73\x68","\x53\x6F\x75\x6E\x64","\x2E\x2E\x2F\x2E\x2E\x2F\x6D\x6F\x64\x65\x6C\x73","\x75\x70\x6C\x6F\x61\x64\x2D\x66\x69\x6C\x65","\x73\x69\x6D\x70\x6C\x65\x2D\x72\x61\x6E\x64\x6F\x6D","\x73\x6F\x78","\x70\x61\x74\x68","\x2E\x2E\x2F\x2E\x2E\x2F\x63\x6F\x6E\x66\x69\x67\x2F\x65\x6E\x76\x69\x72\x6F\x6E\x6D\x65\x6E\x74","\x66\x73","\x73\x65\x71\x75\x65\x6C\x69\x7A\x65","\x66\x69\x6C\x65\x2D\x62\x61\x73\x65\x36\x34","\x62\x6C\x75\x65\x62\x69\x72\x64","\x69\x6E\x64\x65\x78","\x63\x61\x74\x63\x68","\x73\x65\x6E\x64","\x73\x74\x61\x74\x75\x73","\x74\x68\x65\x6E","\x66\x69\x6E\x64\x41\x6E\x64\x43\x6F\x75\x6E\x74\x41\x6C\x6C","\x73\x68\x6F\x77","\x73\x65\x6E\x64\x53\x74\x61\x74\x75\x73","\x69\x64","\x70\x61\x72\x61\x6D\x73","\x66\x69\x6E\x64\x42\x79\x49\x64","\x63\x72\x65\x61\x74\x65","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x53\x6F\x75\x6E\x64\x73","\x6A\x6F\x69\x6E","\x66\x69\x6C\x65\x6E\x61\x6D\x65","\x65\x78\x74\x6E\x61\x6D\x65","\x4D\x61\x78\x20\x6E\x75\x6D\x62\x65\x72\x20\x6F\x66\x20\x66\x69\x6C\x65\x73\x20\x75\x70\x6C\x6F\x61\x64\x20\x65\x78\x63\x65\x65\x64\x65\x64","\x4F\x6E\x6C\x79\x20\x77\x61\x76\x2C\x6D\x70\x33\x2C\x67\x73\x6D\x2C\x20\x61\x6E\x64\x20\x6F\x67\x67\x20\x66\x6F\x72\x6D\x61\x74\x20\x61\x63\x63\x65\x70\x74\x65\x64","\x54\x68\x65\x20\x6D\x61\x78\x69\x6D\x75\x6D\x20\x66\x69\x6C\x65\x20\x73\x69\x7A\x65\x20\x69\x73\x20\x31\x35\x20\x4D\x62","\x49\x6E\x76\x61\x6C\x69\x64\x20\x72\x65\x71\x75\x65\x73\x74","\x65\x6E\x64","\x66\x69\x6C\x65","\x64\x65\x73\x63\x72\x69\x70\x74\x69\x6F\x6E","","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x66\x6F\x72\x6D\x61\x74","\x73\x75\x62\x73\x74\x72\x69\x6E\x67","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x66\x6F\x72\x6D\x61\x74","\x77\x61\x76","\x6E\x61\x6D\x65","\x64\x69\x73\x70\x6C\x61\x79\x5F\x6E\x61\x6D\x65","\x62\x61\x73\x65\x6E\x61\x6D\x65","\x73\x61\x76\x65\x5F\x6E\x61\x6D\x65","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x53\x6F\x75\x6E\x64\x73","\x2E","\x30\x37\x37\x37","\x63\x68\x6D\x6F\x64\x53\x79\x6E\x63","\x69\x64\x65\x6E\x74\x69\x66\x79","\x74\x72\x61\x6E\x73\x63\x6F\x64\x65","\x65\x72\x72\x6F\x72","\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x20\x43\x6F\x6E\x76\x65\x72\x73\x69\x6F\x6E\x20\x45\x72\x72\x6F\x72\x3A\x20","\x75\x6E\x6C\x69\x6E\x6B","\x6F\x6E","\x70\x72\x6F\x67\x72\x65\x73\x73","\x73\x72\x63","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x64\x75\x72\x61\x74\x69\x6F\x6E","\x64\x75\x72\x61\x74\x69\x6F\x6E","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x73\x61\x6D\x70\x6C\x65\x43\x6F\x75\x6E\x74","\x73\x61\x6D\x70\x6C\x65\x43\x6F\x75\x6E\x74","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x63\x68\x61\x6E\x6E\x65\x6C\x43\x6F\x75\x6E\x74","\x63\x68\x61\x6E\x6E\x65\x6C\x43\x6F\x75\x6E\x74","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x62\x69\x74\x52\x61\x74\x65","\x62\x69\x74\x52\x61\x74\x65","\x6F\x72\x69\x67\x69\x6E\x61\x6C\x5F\x73\x61\x6D\x70\x6C\x65\x52\x61\x74\x65","\x73\x61\x6D\x70\x6C\x65\x52\x61\x74\x65","\x64\x65\x73\x74","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x64\x75\x72\x61\x74\x69\x6F\x6E","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x73\x61\x6D\x70\x6C\x65\x43\x6F\x75\x6E\x74","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x63\x68\x61\x6E\x6E\x65\x6C\x43\x6F\x75\x6E\x74","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x62\x69\x74\x52\x61\x74\x65","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64\x5F\x73\x61\x6D\x70\x6C\x65\x52\x61\x74\x65","\x43\x6F\x6E\x76\x65\x72\x73\x69\x6F\x6E\x20\x63\x6F\x6D\x70\x6C\x65\x74\x65\x64","\x6C\x6F\x67","\x73\x74\x61\x72\x74","\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x2A\x20\x55\x70\x6C\x6F\x61\x64\x20\x65\x72\x72\x6F\x72\x20\x3A","\x70\x61\x72\x73\x65","\x75\x70\x64\x61\x74\x65","\x62\x6F\x64\x79","\x6D\x65\x72\x67\x65","\x73\x61\x76\x65","\x64\x65\x73\x74\x72\x6F\x79","\x74\x72\x61\x6E\x73\x61\x63\x74\x69\x6F\x6E","\x64\x6F\x77\x6E\x6C\x6F\x61\x64","\x6F\x72\x69\x67\x69\x6E\x61\x6C","\x73\x74\x72\x65\x61\x6D","\x63\x6F\x6E\x76\x65\x72\x74\x65\x64","\x62\x61\x73\x65\x36\x34","\x62\x69\x6E\x61\x72\x79","\x72\x65\x61\x64\x46\x69\x6C\x65","\x70\x72\x6F\x6D\x69\x73\x69\x66\x79","\x53\x6F\x75\x6E\x64\x73","\x5F\x66\x6F\x72\x6D\x61\x74"];_0x6991[0];var _=require(_0x6991[1]);var Sound=require(_0x6991[3])[_0x6991[2]];var uploadFile=require(_0x6991[4]);var sr=require(_0x6991[5]);var sox=require(_0x6991[6]);var path=require(_0x6991[7]);var config=require(_0x6991[8]);var fs=require(_0x6991[9]);var sequelize=require(_0x6991[3])[_0x6991[10]];var base64=require(_0x6991[11]);var Promise=require(_0x6991[12]);exports[_0x6991[13]]=function(_0xbc6dxc,_0xbc6dxd){Sound[_0x6991[18]]()[_0x6991[17]](function(_0xbc6dxf){return _0xbc6dxd[_0x6991[16]](200)[_0x6991[15]](_0xbc6dxf)})[_0x6991[14]](function(_0xbc6dxe){return handleError(_0xbc6dxd,_0xbc6dxe)})};exports[_0x6991[19]]=function(_0xbc6dxc,_0xbc6dxd){Sound[_0x6991[23]](_0xbc6dxc[_0x6991[22]][_0x6991[21]])[_0x6991[17]](function(Sound){if(!Sound){return _0xbc6dxd[_0x6991[20]](404)};return _0xbc6dxd[_0x6991[15]](Sound)})[_0x6991[14]](function(_0xbc6dxe){return handleError(_0xbc6dxd,_0xbc6dxe)})};exports[_0x6991[24]]=function(_0xbc6dxc,_0xbc6dxd){var _0xbc6dx10= new uploadFile({dest:path[_0x6991[26]](config[_0x6991[25]]),maxFileSize:15*1000000,maxNumberOfFiles:10,minNumberOfFiles:0,acceptFileTypes:/(\.|\/)(wav|mp3|gsm|ogg)$/i,rename:function(_0xbc6dx11,_0xbc6dx12){return sr()+path[_0x6991[28]](_0xbc6dx12[_0x6991[27]])},messages:{maxNumberOfFiles:_0x6991[29],acceptFileTypes:_0x6991[30],maxFileSize:_0x6991[31],invalidRequest:_0x6991[32]}});_0xbc6dx10[_0x6991[54]](_0x6991[33],function(_0xbc6dx13,_0xbc6dx14){if(!_0xbc6dx14[_0x6991[34]][_0x6991[27]]){return _0xbc6dxd[_0x6991[16]](500)[_0x6991[15]](_0xbc6dx10)};var _0xbc6dx15={};var _0xbc6dx16=path[_0x6991[28]](_0xbc6dx14[_0x6991[34]][_0x6991[27]]);_0xbc6dx15[_0x6991[35]]=_0x6991[36];_0xbc6dx15[_0x6991[37]]=path[_0x6991[28]](_0xbc6dx14[_0x6991[34]][_0x6991[27]])[_0x6991[38]](1);_0xbc6dx15[_0x6991[39]]=_0x6991[40];_0xbc6dx15[_0x6991[41]]=_0xbc6dx15[_0x6991[42]]=path[_0x6991[43]](_0xbc6dx14[_0x6991[34]][_0x6991[7]],_0xbc6dx16);_0xbc6dx15[_0x6991[44]]=path[_0x6991[43]](_0xbc6dx14[_0x6991[34]][_0x6991[27]],_0xbc6dx16);var _0xbc6dx17=path[_0x6991[26]](config[_0x6991[25]],_0xbc6dx15[_0x6991[44]]+_0xbc6dx16);var _0xbc6dx18=path[_0x6991[26]](config[_0x6991[45]],_0xbc6dx15[_0x6991[44]]+_0x6991[46]+_0xbc6dx15[_0x6991[39]]);fs[_0x6991[48]](_0xbc6dx17,parseInt(_0x6991[47],8));sox[_0x6991[49]](_0xbc6dx17,function(_0xbc6dxe,_0xbc6dx19){});var _0xbc6dx1a=sox[_0x6991[50]](_0xbc6dx17,_0xbc6dx18,{sampleRate:8000,format:_0x6991[40],channelCount:1,bitRate:192*1024,compressionQuality:5});_0xbc6dx1a[_0x6991[54]](_0x6991[51],function(_0xbc6dxe){console[_0x6991[51]](_0x6991[52],_0xbc6dxe);fs[_0x6991[53]](_0xbc6dx17,function(_0xbc6dxe){if(_0xbc6dxe){return handleError(_0xbc6dxd,_0xbc6dxe)}});return handleError(_0xbc6dxd,_0xbc6dxe)});_0xbc6dx1a[_0x6991[54]](_0x6991[55],function(_0xbc6dx1b,_0xbc6dx1c){});_0xbc6dx1a[_0x6991[54]](_0x6991[56],function(_0xbc6dx1d){_0xbc6dx15[_0x6991[57]]=isNaN(_0xbc6dx1d[_0x6991[58]])?null:_0xbc6dx1d[_0x6991[58]]*1000;_0xbc6dx15[_0x6991[59]]=isNaN(_0xbc6dx1d[_0x6991[60]])?null:_0xbc6dx1d[_0x6991[60]];_0xbc6dx15[_0x6991[61]]=isNaN(_0xbc6dx1d[_0x6991[62]])?null:_0xbc6dx1d[_0x6991[62]];_0xbc6dx15[_0x6991[63]]=isNaN(_0xbc6dx1d[_0x6991[64]])?null:_0xbc6dx1d[_0x6991[64]];_0xbc6dx15[_0x6991[65]]=isNaN(_0xbc6dx1d[_0x6991[66]])?null:_0xbc6dx1d[_0x6991[66]]});_0xbc6dx1a[_0x6991[54]](_0x6991[67],function(_0xbc6dx1d){_0xbc6dx15[_0x6991[68]]=isNaN(_0xbc6dx1d[_0x6991[58]])?null:_0xbc6dx1d[_0x6991[58]]*1000;_0xbc6dx15[_0x6991[69]]=isNaN(_0xbc6dx1d[_0x6991[60]])?null:_0xbc6dx1d[_0x6991[60]];_0xbc6dx15[_0x6991[70]]=isNaN(_0xbc6dx1d[_0x6991[62]])?null:_0xbc6dx1d[_0x6991[62]];_0xbc6dx15[_0x6991[71]]=isNaN(_0xbc6dx1d[_0x6991[64]])?null:_0xbc6dx1d[_0x6991[64]];_0xbc6dx15[_0x6991[72]]=isNaN(_0xbc6dx1d[_0x6991[66]])?null:_0xbc6dx1d[_0x6991[66]]});_0xbc6dx1a[_0x6991[54]](_0x6991[33],function(){console[_0x6991[74]](_0x6991[73]);fs[_0x6991[48]](_0xbc6dx18,parseInt(_0x6991[47],8));Sound[_0x6991[24]](_0xbc6dx15)[_0x6991[17]](function(_0xbc6dx1e){return _0xbc6dxd[_0x6991[16]](201)[_0x6991[15]](_0xbc6dx1e)})[_0x6991[14]](function(_0xbc6dxe){console[_0x6991[74]](_0xbc6dxe);return handleError(_0xbc6dxd,_0xbc6dxe)})});_0xbc6dx1a[_0x6991[75]]()});_0xbc6dx10[_0x6991[54]](_0x6991[51],function(_0xbc6dxe){console[_0x6991[74]](_0x6991[76],_0xbc6dxe);return handleError(_0xbc6dxd,_0xbc6dxe)});_0xbc6dx10[_0x6991[77]](_0xbc6dxc)};exports[_0x6991[78]]=function(_0xbc6dxc,_0xbc6dxd){if(_0xbc6dxc[_0x6991[79]][_0x6991[21]]){delete _0xbc6dxc[_0x6991[79]][_0x6991[21]]};Sound[_0x6991[23]](_0xbc6dxc[_0x6991[22]][_0x6991[21]])[_0x6991[17]](function(_0xbc6dx1e){if(!_0xbc6dx1e){return _0xbc6dxd[_0x6991[20]](404)};var _0xbc6dx1f=_[_0x6991[80]](_0xbc6dx1e,_0xbc6dxc[_0x6991[79]]);_0xbc6dx1f[_0x6991[81]]()[_0x6991[17]](function(){return _0xbc6dxd[_0x6991[16]](200)[_0x6991[15]](_0xbc6dx1e)})[_0x6991[14]](function(_0xbc6dxe){return handleError(_0xbc6dxd,_0xbc6dxe)})})[_0x6991[14]](function(_0xbc6dxe){return handleError(_0xbc6dxd,_0xbc6dxe)})};exports[_0x6991[82]]=function(_0xbc6dxc,_0xbc6dxd){Sound[_0x6991[23]](_0xbc6dxc[_0x6991[22]][_0x6991[21]])[_0x6991[17]](function(_0xbc6dx1e){if(!_0xbc6dx1e){return _0xbc6dxd[_0x6991[16]](404)[_0x6991[15]](_0xbc6dx1e)};var _0xbc6dx20=path[_0x6991[26]](config[_0x6991[25]],_0xbc6dx1e[_0x6991[44]]+_0x6991[46]+_0xbc6dx1e[_0x6991[37]]);var _0xbc6dx21=path[_0x6991[26]](config[_0x6991[45]],_0xbc6dx1e[_0x6991[44]]+_0x6991[46]+_0xbc6dx1e[_0x6991[39]]);return sequelize[_0x6991[83]](function(_0xbc6dx22){return _0xbc6dx1e[_0x6991[82]]({transaction:_0xbc6dx22})[_0x6991[17]](function(){fs[_0x6991[53]](_0xbc6dx20,function(_0xbc6dxe){if(_0xbc6dxe){return handleError(_0xbc6dxd,_0xbc6dxe)}});fs[_0x6991[53]](_0xbc6dx21,function(_0xbc6dxe){if(_0xbc6dxe){return handleError(_0xbc6dxd,_0xbc6dxe)}});return _0xbc6dxd[_0x6991[16]](200)[_0x6991[15]](_0xbc6dx1e)})})[_0x6991[14]](function(_0xbc6dxe){return handleError(_0xbc6dxd,_0xbc6dxe)})})[_0x6991[14]](function(_0xbc6dxe){return handleError(_0xbc6dxd,_0xbc6dxe)})};exports[_0x6991[84]]=function(_0xbc6dxc,_0xbc6dxd){getStream(_0xbc6dxc,_0xbc6dxd,_0x6991[85])};exports[_0x6991[86]]=function(_0xbc6dxc,_0xbc6dxd){getStream(_0xbc6dxc,_0xbc6dxd,_0x6991[87])};function getStream(_0xbc6dxc,_0xbc6dxd,_0xbc6dx24){return Sound[_0x6991[23]](_0xbc6dxc[_0x6991[22]][_0x6991[21]])[_0x6991[17]](function(_0xbc6dx1e){var _0xbc6dx26=Promise[_0x6991[91]](fs[_0x6991[90]]);return _0xbc6dx26(path[_0x6991[26]](config[_0xbc6dx24+_0x6991[92]],_0xbc6dx1e[_0x6991[44]]+_0x6991[46]+_0xbc6dx1e[_0xbc6dx24+_0x6991[93]]))})[_0x6991[17]](function(_0xbc6dx19){var _0xbc6dx25= new Buffer(_0xbc6dx19,_0x6991[89]).toString(_0x6991[88]);return _0xbc6dx25})[_0x6991[17]](function(_0xbc6dx25){return _0xbc6dxd[_0x6991[16]](200)[_0x6991[15]]({downloadString:_0xbc6dx25})})[_0x6991[14]](function(_0xbc6dxe){console[_0x6991[74]](_0xbc6dxe);return handleError(_0xbc6dxd,_0xbc6dxe)})}function handleError(_0xbc6dxd,_0xbc6dxe){return _0xbc6dxd[_0x6991[16]](500)[_0x6991[15]](_0xbc6dxe)}