Browse Source

更新数据库

Yu.ding 4 years ago
parent
commit
2bce547b22

BIN
.DS_Store


BIN
usr/.DS_Store


BIN
usr/local/.DS_Store


BIN
usr/local/defaults/.DS_Store


BIN
usr/local/defaults/etc/.DS_Store


BIN
usr/local/defaults/etc/asterisk/.DS_Store


BIN
usr/local/defaults/etc/asterisk/sysconf/.DS_Store


+ 10 - 10
usr/local/defaults/etc/asterisk/sysconf/database/coopaging_db.sql

@@ -670,24 +670,23 @@ DROP TABLE IF EXISTS `t_paging_tasks`;
 /*!40101 SET character_set_client = utf8 */;
 CREATE TABLE `t_paging_tasks` (
   `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
-  `enable` tinyint(1) NOT NULL DEFAULT 1,
-  `name` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL,
-  `mode` varchar(16) NOT NULL,
-  `start_date` date DEFAULT NULL,
-  `end_date` date DEFAULT NULL,
-  `week_days` varchar(32) DEFAULT NULL,
+  `enable` tinyint(1) NOT NULL DEFAULT '1',
+  `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NOT NULL,
+  `start_date` datetime DEFAULT NULL,
+  `end_date` datetime DEFAULT NULL,
+  `week_days` varchar(128) DEFAULT NULL,
   `start_time` time DEFAULT NULL,
   `end_time` time DEFAULT NULL,
   `type` varchar(32) DEFAULT NULL,
   `sound_type` varchar(32) DEFAULT NULL,
-  `play_mode` varchar(32) DEFAULT NULL,
   `content` varchar(128) DEFAULT NULL,
-  `group_ids` JSON NOT NULL,
+  `sourceId` varchar(128) NOT NULL DEFAULT '',
+  `extensions` json NOT NULL,
   `createdAt` datetime DEFAULT NULL,
   `updatedAt` datetime DEFAULT NULL,
   PRIMARY KEY (`id`),
   UNIQUE KEY `name` (`name`)
-) ENGINE=InnoDB;
+) ENGINE=InnoDB DEFAULT CHARSET=utf8;
 /*!40101 SET character_set_client = @saved_cs_client */;
 
 --
@@ -706,7 +705,8 @@ CREATE TABLE `t_paging_users` (
   `createdAt` datetime NOT NULL,
   `updatedAt` datetime NOT NULL,
   PRIMARY KEY (`id`),
-  UNIQUE KEY `id` (`id`)
+  UNIQUE KEY `id` (`id`),
+  UNIQUE KEY `username` (`username`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='用户列表';
 /*!40101 SET character_set_client = @saved_cs_client */;
 

+ 117 - 0
usr/local/defaults/etc/asterisk/sysconf/database/python内存

@@ -0,0 +1,117 @@
+Line #    Mem usage    Increment   Line Contents
+================================================
+    38   22.059 MiB   22.059 MiB   @profile
+    39                             def play_init(group_id,sourceInfoId):
+    40   22.059 MiB    0.000 MiB       silent = "/PA-System/pa-api/media/silent.mp3"
+    41   22.059 MiB    0.000 MiB       i = 0
+    42   22.059 MiB    0.000 MiB       popen = 0
+    43   22.059 MiB    0.000 MiB       castInfo = {}
+    44
+    45   22.059 MiB    0.000 MiB       s = shout.Shout()
+    46   22.059 MiB    0.000 MiB       print("Using libshout version %s" % shout.version())
+    47   22.059 MiB    0.000 MiB       s.host = gl.config['host']
+    48   22.059 MiB    0.000 MiB       s.port = int(gl.config['port'])
+    49   22.059 MiB    0.000 MiB       s.user = 'admin'
+    50   22.059 MiB    0.000 MiB       s.password = gl.config['secret']
+    51   22.059 MiB    0.000 MiB       s.mount = group_id
+    52   22.059 MiB    0.000 MiB       s.format = 'mp3'
+    53   22.059 MiB    0.000 MiB       s.protocol = 'http'
+    54   22.059 MiB    0.000 MiB       s.public = 0
+    55                                 # s.format = 'vorbis' | 'mp3'
+    56                                 # s.protocol = 'http' | 'xaudiocast' | 'icy'
+    57   22.059 MiB    0.000 MiB       s.name = ''
+    58   22.059 MiB    0.000 MiB       s.genre = ''
+    59   22.059 MiB    0.000 MiB       s.url = ''
+    60   22.059 MiB    0.000 MiB       s.SHOUT_AI_CHANNELS = gl.config['channels']
+    61   22.059 MiB    0.000 MiB       s.SHOUT_AI_BITRATE = gl.config['bitrate']
+    62   22.059 MiB    0.000 MiB       s.SHOUT_AI_SAMPLERATE = gl.config['samplerate']
+    63                                 # s.public = 0 | 1
+    64                                 # s.audio_info = { 'key': 'val', ... }
+    65                                 #  (keys are shout.SHOUT_AI_BITRATE, shout.SHOUT_AI_SAMPLERATE,
+    66                                 #   shout.SHOUT_AI_CHANNELS, shout.SHOUT_AI_QUALITY)
+    67   22.059 MiB    0.000 MiB       try:
+    68   22.059 MiB    0.000 MiB           s.open()
+    69                                 except:
+    70                                     print("open shout failed!")
+    71                                     redisdb.delete(sourceInfoId)
+    72                                     return False
+    73   22.059 MiB    0.000 MiB       while True:
+    74  301.402 MiB    0.000 MiB           if gl.groupstatus[group_id]['stop']:
+    75                                         break
+    76  301.402 MiB    0.254 MiB           sourceInfo = getPlayInfo(sourceInfoId)
+    77  301.402 MiB    0.000 MiB           if(sourceInfo == None):
+    78                                         break
+    79  301.402 MiB    0.000 MiB           playlist = sourceInfo["musicLibraries"]
+    80  301.402 MiB    0.000 MiB           listLen = len(playlist)
+    81  301.402 MiB    0.000 MiB           if(listLen == 0):
+    82                                         break
+    83  301.402 MiB    0.000 MiB           if(gl.groupstatus[group_id]['select']):
+    84  249.539 MiB    0.000 MiB               i = gl.groupstatus[group_id]['playid']
+    85                                     else:
+    86  301.402 MiB    0.000 MiB               if(sourceInfo["model"] == "once"):
+    87                                             i = once
+    88  301.402 MiB    0.000 MiB               elif(sourceInfo["model"] == "random"):
+    89  301.402 MiB    0.000 MiB                   i = random.randint(0, listLen - 1)
+    90  301.402 MiB    0.000 MiB           if (i >= listLen or i < 0):
+    91                                         i = 0
+    92  301.402 MiB    0.000 MiB           once = i
+    93  301.402 MiB    0.000 MiB           playMusic = playlist[i]
+    94  301.402 MiB    0.000 MiB           name = playMusic['name']
+    95  301.402 MiB    0.000 MiB           fa = playMusic['path']
+    96  301.402 MiB    0.000 MiB           print("play music name: %s,music id: %d" % (name,i))
+    97  301.402 MiB    0.000 MiB           sourceInfo['musicId'] = i
+    98  301.402 MiB    0.250 MiB           updatePlayInfo(sourceInfoId,sourceInfo)
+    99  301.402 MiB    0.000 MiB           castInfo['action'] = "update"
+   100  301.402 MiB    0.000 MiB           castInfo['sourceId'] = sourceInfoId
+   101  301.402 MiB    0.000 MiB           sendCastInfo(castInfo)
+   102                                     #fa = filelist[i]
+   103  301.402 MiB    0.000 MiB           try:
+   104  301.402 MiB    0.000 MiB               f = open(fa, 'rb')
+   105  301.402 MiB    0.000 MiB               gl.groupstatus[group_id] = {"stop":0,"next":0,"previous":0,"pause":0,"select":0,"playid":None}
+   106  301.402 MiB    0.000 MiB               print("opening file %s" % fa)
+   107                                     except:
+   108                                         i += 1
+   109                                         time.sleep(2)
+   110                                         continue
+   111
+   112  301.402 MiB    0.000 MiB           s.set_metadata({'song': name})
+   113  301.402 MiB    0.000 MiB           status = "start"
+   114                                     #nbuf = f.read(4096)
+   115  301.402 MiB    0.000 MiB           while True:
+   116  301.898 MiB    0.246 MiB               buf = f.read(4096)
+   117                                         #buf = nbuf
+   118  301.898 MiB    0.250 MiB               if len(buf) == 0 or gl.groupstatus[group_id]['stop'] or gl.groupstatus[group_id]['next'] or gl.groupstatus[group_id]['previous'] or gl.groupstatus[group_id]['select']:
+   119  301.402 MiB    0.000 MiB                   break
+   120  301.898 MiB    0.004 MiB               if gl.groupstatus[group_id]['pause']:
+   121                                             if (popen == 0):
+   122                                                 sourceInfo['pause'] = 1
+   123                                                 updatePlayInfo(sourceInfoId,sourceInfo)
+   124                                                 print("opening file %s" % silent)
+   125                                                 p = open(silent, 'rb')
+   126                                                 popen = 1
+   127                                             pbuf = p.read(4096)
+   128                                             s.send(pbuf)
+   129                                             s.sync()
+   130                                             continue
+   131  301.898 MiB    0.004 MiB               if popen:
+   132                                             sourceInfo['pause'] = 0
+   133                                             updatePlayInfo(sourceInfoId,sourceInfo)
+   134                                             p.close()
+   135                                             popen = 0
+   136  301.898 MiB    0.250 MiB               s.send(buf)
+   137  301.898 MiB    0.281 MiB               s.sync()
+   138  301.402 MiB    0.000 MiB           f.close()
+   139  301.402 MiB    0.000 MiB           if gl.groupstatus[group_id]['stop']:
+   140                                         break
+   141  301.402 MiB    0.000 MiB           if gl.groupstatus[group_id]['select']:
+   142  249.539 MiB    0.000 MiB               continue
+   143  301.402 MiB    0.000 MiB           if gl.groupstatus[group_id]['previous']:
+   144                                         if (i == 0):
+   145                                             i = 0
+   146                                         else:
+   147                                             i -= 1
+   148                                         continue
+   149                                     else:
+   150  301.402 MiB    0.000 MiB               i += 1
+   151                                 s.close()
+   152                                 redisdb.delete(sourceInfoId)