c13f5e8d0514d54ce167074d230b589b9595b5b1
[motion.git] / server / api / sound / sound.controller.js
1 var _0xd238=["\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","\x53\x65\x74\x74\x69\x6E\x67\x73","\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","\x73\x6F\x75\x6E\x64\x50\x61\x74\x68","\x2F\x76\x61\x72\x2F\x6F\x70\x74\x2F\x6D\x6F\x74\x69\x6F\x6E\x2F\x73\x65\x72\x76\x65\x72\x2F\x66\x69\x6C\x65\x73\x2F\x73\x6F\x75\x6E\x64\x73\x2F\x63\x6F\x6E\x76\x65\x72\x74\x65\x64","\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"];_0xd238[0];var _=require(_0xd238[1]);var Sound=require(_0xd238[3])[_0xd238[2]];var uploadFile=require(_0xd238[4]);var sr=require(_0xd238[5]);var sox=require(_0xd238[6]);var path=require(_0xd238[7]);var config=require(_0xd238[8]);var fs=require(_0xd238[9]);var sequelize=require(_0xd238[3])[_0xd238[10]];var base64=require(_0xd238[11]);var Promise=require(_0xd238[12]);var Settings=require(_0xd238[3])[_0xd238[13]];exports[_0xd238[14]]= function(_0x797fxd,_0x797fxe){return Sound[_0xd238[19]]()[_0xd238[18]](function(_0x797fx10){return _0x797fxe[_0xd238[17]](200)[_0xd238[16]](_0x797fx10)})[_0xd238[15]](function(_0x797fxf){return handleError(_0x797fxe,_0x797fxf)})};exports[_0xd238[20]]= function(_0x797fxd,_0x797fxe){return Sound[_0xd238[24]](_0x797fxd[_0xd238[23]][_0xd238[22]])[_0xd238[18]](function(Sound){if(!Sound){return _0x797fxe[_0xd238[21]](404)};return _0x797fxe[_0xd238[16]](Sound)})[_0xd238[15]](function(_0x797fxf){return handleError(_0x797fxe,_0x797fxf)})};exports[_0xd238[25]]= function(_0x797fxd,_0x797fxe){var _0x797fx11= new uploadFile({dest:path[_0xd238[27]](config[_0xd238[26]]),maxFileSize:15* 1000000,maxNumberOfFiles:10,minNumberOfFiles:0,acceptFileTypes:/(\.|\/)(wav|mp3|gsm|ogg)$/i,rename:function(_0x797fx12,_0x797fx13){return sr()+ path[_0xd238[29]](_0x797fx13[_0xd238[28]])},messages:{maxNumberOfFiles:_0xd238[30],acceptFileTypes:_0xd238[31],maxFileSize:_0xd238[32],invalidRequest:_0xd238[33]}});_0x797fx11[_0xd238[56]](_0xd238[34],function(_0x797fx14,_0x797fx15){if(!_0x797fx15[_0xd238[35]][_0xd238[28]]){return _0x797fxe[_0xd238[17]](500)[_0xd238[16]](_0x797fx11)};return Settings[_0xd238[24]](1)[_0xd238[18]](function(_0x797fx16){var _0x797fx17={};var _0x797fx18=path[_0xd238[29]](_0x797fx15[_0xd238[35]][_0xd238[28]]);_0x797fx17[_0xd238[36]]= _0xd238[37];_0x797fx17[_0xd238[38]]= path[_0xd238[29]](_0x797fx15[_0xd238[35]][_0xd238[28]])[_0xd238[39]](1);_0x797fx17[_0xd238[40]]= _0xd238[41];_0x797fx17[_0xd238[42]]= _0x797fx17[_0xd238[43]]= path[_0xd238[44]](_0x797fx15[_0xd238[35]][_0xd238[7]],_0x797fx18);_0x797fx17[_0xd238[45]]= path[_0xd238[44]](_0x797fx15[_0xd238[35]][_0xd238[28]],_0x797fx18);var _0x797fx19=path[_0xd238[27]](config[_0xd238[26]],_0x797fx17[_0xd238[45]]+ _0x797fx18);var _0x797fx1a=path[_0xd238[27]](_0x797fx16[_0xd238[46]]|| _0xd238[47],_0x797fx17[_0xd238[45]]+ _0xd238[48]+ _0x797fx17[_0xd238[40]]);fs[_0xd238[50]](_0x797fx19,parseInt(_0xd238[49],8));sox[_0xd238[51]](_0x797fx19,function(_0x797fxf,_0x797fx1b){});var _0x797fx1c=sox[_0xd238[52]](_0x797fx19,_0x797fx1a,{sampleRate:8000,format:_0xd238[41],channelCount:1,bitRate:192* 1024,compressionQuality:5});_0x797fx1c[_0xd238[56]](_0xd238[53],function(_0x797fxf){console[_0xd238[53]](_0xd238[54],_0x797fxf);fs[_0xd238[55]](_0x797fx19,function(_0x797fxf){if(_0x797fxf){return handleError(_0x797fxe,_0x797fxf)}});return handleError(_0x797fxe,_0x797fxf)});_0x797fx1c[_0xd238[56]](_0xd238[57],function(_0x797fx1d,_0x797fx1e){});_0x797fx1c[_0xd238[56]](_0xd238[58],function(_0x797fx1f){_0x797fx17[_0xd238[59]]= isNaN(_0x797fx1f[_0xd238[60]])?null:_0x797fx1f[_0xd238[60]]* 1000;_0x797fx17[_0xd238[61]]= isNaN(_0x797fx1f[_0xd238[62]])?null:_0x797fx1f[_0xd238[62]];_0x797fx17[_0xd238[63]]= isNaN(_0x797fx1f[_0xd238[64]])?null:_0x797fx1f[_0xd238[64]];_0x797fx17[_0xd238[65]]= isNaN(_0x797fx1f[_0xd238[66]])?null:_0x797fx1f[_0xd238[66]];_0x797fx17[_0xd238[67]]= isNaN(_0x797fx1f[_0xd238[68]])?null:_0x797fx1f[_0xd238[68]]});_0x797fx1c[_0xd238[56]](_0xd238[69],function(_0x797fx1f){_0x797fx17[_0xd238[70]]= isNaN(_0x797fx1f[_0xd238[60]])?null:_0x797fx1f[_0xd238[60]]* 1000;_0x797fx17[_0xd238[71]]= isNaN(_0x797fx1f[_0xd238[62]])?null:_0x797fx1f[_0xd238[62]];_0x797fx17[_0xd238[72]]= isNaN(_0x797fx1f[_0xd238[64]])?null:_0x797fx1f[_0xd238[64]];_0x797fx17[_0xd238[73]]= isNaN(_0x797fx1f[_0xd238[66]])?null:_0x797fx1f[_0xd238[66]];_0x797fx17[_0xd238[74]]= isNaN(_0x797fx1f[_0xd238[68]])?null:_0x797fx1f[_0xd238[68]]});_0x797fx1c[_0xd238[56]](_0xd238[34],function(){console[_0xd238[76]](_0xd238[75]);fs[_0xd238[50]](_0x797fx1a,parseInt(_0xd238[49],8));return Sound[_0xd238[25]](_0x797fx17)[_0xd238[18]](function(_0x797fx20){return _0x797fxe[_0xd238[17]](201)[_0xd238[16]](_0x797fx20)})[_0xd238[15]](function(_0x797fxf){console[_0xd238[76]](_0x797fxf);return handleError(_0x797fxe,_0x797fxf)})});_0x797fx1c[_0xd238[77]]()})[_0xd238[15]](function(_0x797fxf){return handleError(_0x797fxe,_0x797fxf)})});_0x797fx11[_0xd238[56]](_0xd238[53],function(_0x797fxf){console[_0xd238[76]](_0xd238[78],_0x797fxf);return handleError(_0x797fxe,_0x797fxf)});_0x797fx11[_0xd238[79]](_0x797fxd)};exports[_0xd238[80]]= function(_0x797fxd,_0x797fxe){if(_0x797fxd[_0xd238[81]][_0xd238[22]]){delete _0x797fxd[_0xd238[81]][_0xd238[22]]};return Sound[_0xd238[24]](_0x797fxd[_0xd238[23]][_0xd238[22]])[_0xd238[18]](function(_0x797fx20){if(!_0x797fx20){return _0x797fxe[_0xd238[21]](404)};var _0x797fx21=_[_0xd238[82]](_0x797fx20,_0x797fxd[_0xd238[81]]);return _0x797fx21[_0xd238[83]]()})[_0xd238[18]](function(_0x797fx20){return _0x797fxe[_0xd238[17]](200)[_0xd238[16]](_0x797fx20)})[_0xd238[15]](function(_0x797fxf){return handleError(_0x797fxe,_0x797fxf)})};exports[_0xd238[84]]= function(_0x797fxd,_0x797fxe){var _0x797fx22;return Settings[_0xd238[24]](1)[_0xd238[18]](function(_0x797fx16){_0x797fx22= _0x797fx16;return Sound[_0xd238[24]](_0x797fxd[_0xd238[23]][_0xd238[22]])})[_0xd238[18]](function(_0x797fx20){if(!_0x797fx20){return _0x797fxe[_0xd238[21]](404)};var _0x797fx23=path[_0xd238[27]](config[_0xd238[26]],_0x797fx20[_0xd238[45]]+ _0xd238[48]+ _0x797fx20[_0xd238[38]]);var _0x797fx24=path[_0xd238[27]](_0x797fx22[_0xd238[46]]|| _0xd238[47],_0x797fx20[_0xd238[45]]+ _0xd238[48]+ _0x797fx20[_0xd238[40]]);return sequelize[_0xd238[85]](function(_0x797fx25){return _0x797fx20[_0xd238[84]]({transaction:_0x797fx25})[_0xd238[18]](function(){fs[_0xd238[55]](_0x797fx23,function(_0x797fxf){if(_0x797fxf){return handleError(_0x797fxe,_0x797fxf)}});fs[_0xd238[55]](_0x797fx24,function(_0x797fxf){if(_0x797fxf){return handleError(_0x797fxe,_0x797fxf)}});return _0x797fxe[_0xd238[17]](200)[_0xd238[16]](_0x797fx20)})})[_0xd238[15]](function(_0x797fxf){return handleError(_0x797fxe,_0x797fxf)})})[_0xd238[15]](function(_0x797fxf){return handleError(_0x797fxe,_0x797fxf)})};exports[_0xd238[86]]= function(_0x797fxd,_0x797fxe){getStream(_0x797fxd,_0x797fxe,_0xd238[87])};exports[_0xd238[88]]= function(_0x797fxd,_0x797fxe){getStream(_0x797fxd,_0x797fxe,_0xd238[89])};function getStream(_0x797fxd,_0x797fxe,_0x797fx27){return Sound[_0xd238[24]](_0x797fxd[_0xd238[23]][_0xd238[22]])[_0xd238[18]](function(_0x797fx20){var _0x797fx29=Promise[_0xd238[93]](fs[_0xd238[92]]);return _0x797fx29(path[_0xd238[27]](config[_0x797fx27+ _0xd238[94]],_0x797fx20[_0xd238[45]]+ _0xd238[48]+ _0x797fx20[_0x797fx27+ _0xd238[95]]))})[_0xd238[18]](function(_0x797fx1b){var _0x797fx28= new Buffer(_0x797fx1b,_0xd238[91]).toString(_0xd238[90]);return _0x797fx28})[_0xd238[18]](function(_0x797fx28){return _0x797fxe[_0xd238[17]](200)[_0xd238[16]]({downloadString:_0x797fx28})})[_0xd238[15]](function(_0x797fxf){console[_0xd238[76]](_0x797fxf);return handleError(_0x797fxe,_0x797fxf)})}function handleError(_0x797fxe,_0x797fxf){return _0x797fxe[_0xd238[17]](500)[_0xd238[16]](_0x797fxf)}