Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
张艾宸
/
webScreen
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
张艾宸
2020-01-02 17:55:47 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
ca9dd20a19e7f17d7c578eccc3f28d8c8eccafa2
ca9dd20a
1 parent
246d2733
默认录制时长改为6个小时
添加接口recording,可选择录制的课堂
隐藏空白字符变更
内嵌
并排对比
正在显示
3 个修改的文件
包含
93 行增加
和
2 行删除
config/config.json
config/method.js
routes/index.js
config/config.json
查看文件 @
ca9dd20
...
...
@@ -18,7 +18,7 @@
"portalPort"
:
80
,
"channels"
:
2
,
"playRecord"
:
1
,
"d"
:
18
00000
,
"d"
:
216
00000
,
"s"
:
3000
,
"fa"
:
15
,
"k"
:
0
,
...
...
config/method.js
查看文件 @
ca9dd20
...
...
@@ -15,6 +15,15 @@ const methods = {
ymd
:
year
+
"-"
+
month
+
"-"
+
date
}
},
dayTimeYMD
()
{
let
dayTimeDate
=
new
Date
()
let
year
=
dayTimeDate
.
getFullYear
()
let
month
=
dayTimeDate
.
getMonth
()
+
1
let
date
=
dayTimeDate
.
getDate
()
return
{
ymd
:
year
+
"-"
+
month
+
"-"
+
date
}
},
async
getRequestClassIds
(
url
,
siteId
,
key
,
startTime
,
endTime
,
page
)
{
let
axiosUrl
=
`
$
{
url
}?
siteId
=
$
{
siteId
}
&
key
=
$
{
key
}
&
from
=
$
{
startTime
}
&
to
=
$
{
endTime
}
&
page
=
$
{
page
}
`
let
result
=
await
axios
.
get
(
axiosUrl
)
...
...
routes/index.js
查看文件 @
ca9dd20
...
...
@@ -7,7 +7,7 @@ const method = require("../config/method")
const
config
=
require
(
"../config/config"
)
// const { GETCLASSURL, GETCLASSURLPARAMETER, PROJECTCATALOG, PROJECTWINCATALOG, BACKMEDIACONFIG } = config
const
{
YesterdayTime
,
getRequestClassIds
}
=
method
const
{
YesterdayTime
,
getRequestClassIds
,
dayTimeYMD
}
=
method
const
{
startTime
,
endTime
,
ymd
}
=
YesterdayTime
()
let
siteIds
=
[]
...
...
@@ -101,6 +101,57 @@ class MediaCreat {
}
});
}
async
recordingCreat
(
id
,
siteId
)
{
let
fileConfig
=
await
new
MediaCreat
().
getConfigFileJson
()
if
(
!
fileConfig
)
return
false
const
{
BACKMEDIACONFIG
,
PROJECTWINCATALOG
,
PROJECTCATALOG
}
=
JSON
.
parse
(
fileConfig
)
let
mediaDir
=
PROJECTCATALOG
+
"/media/"
let
recordingDir
=
mediaDir
+
"recording/"
let
classDir
=
recordingDir
+
siteId
+
"/"
let
dateDir
=
classDir
+
dayTimeYMD
().
ymd
if
(
!
fs
.
existsSync
(
mediaDir
))
{
fs
.
mkdirSync
(
mediaDir
);
}
if
(
!
fs
.
existsSync
(
recordingDir
))
{
fs
.
mkdirSync
(
recordingDir
);
}
if
(
!
fs
.
existsSync
(
classDir
))
{
fs
.
mkdirSync
(
classDir
);
}
if
(
!
fs
.
existsSync
(
dateDir
))
{
fs
.
mkdirSync
(
dateDir
);
}
let
url
=
`
web_capture_c
-
o
=
..
/
media
/
recording
/
$
{
siteId
}
/${dayTimeYMD
()
.ymd}/
$
{
id
}.
mp4
-
u
=
"${BACKMEDIACONFIG.url}?classId=${id}&userId=${BACKMEDIACONFIG.userId}&userName=${BACKMEDIACONFIG.userName}&userRole=${BACKMEDIACONFIG.userRole}&portalIP=${BACKMEDIACONFIG.portalIP}&portalPort=${BACKMEDIACONFIG.portalPort}&channels=${BACKMEDIACONFIG.channels}&playRecord=${BACKMEDIACONFIG.playRecord}"
-
d
=
$
{
BACKMEDIACONFIG
.
d
}
-
s
=
$
{
BACKMEDIACONFIG
.
s
}
-
fa
=
$
{
BACKMEDIACONFIG
.
fa
}
-
k
=
$
{
BACKMEDIACONFIG
.
k
}
-
w
=
$
{
BACKMEDIACONFIG
.
w
}
-
h
=
$
{
BACKMEDIACONFIG
.
h
}
`
var
workerProcess
=
spawn
(
url
,
{
cwd
:
PROJECTWINCATALOG
,
shell
:
true
})
// workerProcess.stdout.on('data', async function (data) {
// });
workerProcess
.
on
(
'close'
,
async
function
(
code
)
{
let
files
=
fs
.
readdirSync
(
dateDir
);
if
(
files
.
indexOf
(
id
+
".mp4"
)
==
-
1
)
{
//当前课堂没有写入到文件夹,进入重录
new
MediaCreat
().
recordingCreat
(
id
,
siteId
)
return
false
}
else
{
if
(
parentData
[
siteId
].
indexOf
(
id
.
toString
())
!=
-
1
)
{
parentData
[
siteId
].
splice
(
parentData
[
siteId
].
indexOf
(
id
.
toString
()),
1
)
}
if
(
parentData
[
siteId
].
length
==
0
)
{
// //全部录制完毕
fs
.
writeFile
(
dateDir
+
"/download.json"
,
`
{
"code"
:
"0"
,
"success"
:
"ok"
}
`
,
function
(
err
)
{
if
(
err
)
{
console
.
log
(
err
);
}
});
}
if
(
classid
.
length
)
{
let
shiftData
=
classid
.
shift
()
new
MediaCreat
().
recordingCreat
(
shiftData
[
'classId'
],
shiftData
[
'siteId'
])
}
}
});
}
async
getConfigFileJson
(){
const
buffer
=
fs
.
readFileSync
(
process
.
cwd
()
+
"/config/config.json"
)
...
...
@@ -137,4 +188,35 @@ router.get('/', async function (req, res, next) {
}
});
/**
* {
* "classId":[{ classId: '389675110', siteId: 'kuaikuenglish' }]
* }
*/
router
.
post
(
'/recording'
,
async
function
(
req
,
res
,
next
)
{
let
fileConfig
=
await
new
MediaCreat
().
getConfigFileJson
()
if
(
!
fileConfig
)
return
false
const
{
classId
}
=
req
.
body
if
(
classId
&&
classId
.
length
){
classid
=
classId
const
{
PROJECTCATALOG
,
GETCLASSURLPARAMETER
}
=
JSON
.
parse
(
fileConfig
)
for
(
let
i
=
0
;
i
<
classId
.
length
;
i
++
){
if
(
!
Array
.
isArray
(
parentData
[
classId
[
i
].
siteId
])){
parentData
[
classId
[
i
].
siteId
]
=
[]
}
parentData
[
classId
[
i
].
siteId
].
push
(
classId
[
i
].
classId
)
}
for
(
let
i
=
0
;
i
<
GETCLASSURLPARAMETER
.
maxMedia
;
i
++
){
let
shiftData
=
classid
.
shift
()
if
(
shiftData
)
{
new
MediaCreat
().
recordingCreat
(
shiftData
[
'classId'
],
shiftData
[
'siteId'
])
}
else
{
return
false
}
}
}
res
.
send
({
code
:
"0"
});
})
module
.
exports
=
router
;
...
...
请
注册
或
登录
后发表评论