Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
liyaoting
/
update-video
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
Commit 0a3540e0
authored
2023-06-10 00:19:52 +0800
by
liyaoting
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
整理&优化
1 parent
44d9b2be
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
32 deletions
src/main/java/cn/bxe/updatevideo/UpdateVideoApplication.java
src/main/java/cn/bxe/updatevideo/util/VersionUtil.java
src/main/java/cn/bxe/updatevideo/UpdateVideoApplication.java
View file @
0a3540e
...
...
@@ -16,6 +16,7 @@ import cn.bxe.updatevideo.util.JsonUtil;
import
cn.zhxu.okhttps.HTTP
;
import
cn.zhxu.okhttps.HttpResult
;
import
cn.zhxu.okhttps.gson.GsonMsgConvertor
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper
;
...
...
@@ -35,10 +36,8 @@ import ws.schild.jave.MultimediaInfo;
import
javax.imageio.ImageIO
;
import
java.awt.image.BufferedImage
;
import
java.io.ByteArrayInputStream
;
import
java.io.File
;
import
java.io.IOException
;
import
java.net.URL
;
import
java.util.*
;
import
java.util.concurrent.*
;
import
java.util.concurrent.atomic.AtomicInteger
;
...
...
@@ -46,6 +45,15 @@ import java.util.stream.Collectors;
import
static
cn
.
bxe
.
updatevideo
.
util
.
VersionUtil
.*;
/**
* @deprecated 用于更新知识点精讲视频(其实是新增 一般不修改旧的)
* 1.一般来说操作流程是: 获取新书籍->获取新章节->获取新模块->获取新视频->下载视频封面->更新数据库视频封面链接
* 2.如果只是某本版本更新了内容,并没有新增书籍,也可以单独更新章节/模块/视频
* 3.他们存储有几个域名,其中有一个oss.5rs.com得域名,这个域名下的视频封面不可以直接访问的,所以需要特殊处理来下载
* 更新完视频后检查下有无此域名的,如果有需要使用功能6单独下载
* 4.视频可能没有时长,使用功能8单独获取
*
*/
@SpringBootApplication
@MapperScan
(
"cn.bxe.updatevideo.mapper"
)
public
class
UpdateVideoApplication
{
...
...
@@ -84,10 +92,10 @@ public class UpdateVideoApplication {
System
.
out
.
println
(
"3: 更新模块"
);
System
.
out
.
println
(
"4: 更新视频"
);
System
.
out
.
println
(
"5: 下载封面"
);
System
.
out
.
println
(
"6:
更新数据库视频封面链接
"
);
System
.
out
.
println
(
"7:
补充视频时长
"
);
System
.
out
.
println
(
"8:
计算数量
"
);
System
.
out
.
println
(
"9:
下载oss5rsme视频封面
"
);
System
.
out
.
println
(
"6:
下载oss.5rs.me视频封面
"
);
System
.
out
.
println
(
"7:
更新数据库视频封面链接
"
);
System
.
out
.
println
(
"8:
补充视频时长
"
);
System
.
out
.
println
(
"9:
计算数量
"
);
System
.
out
.
println
(
"0: 退出"
);
Scanner
scanner
=
new
Scanner
(
System
.
in
);
System
.
out
.
print
(
"请输入功能代码: "
);
...
...
@@ -115,21 +123,21 @@ public class UpdateVideoApplication {
downloadCoverPic
();
break
;
case
"6"
:
System
.
out
.
println
(
"下载oss5rsme视频封面"
);
getOss5rsmeCover
();
break
;
case
"7"
:
System
.
out
.
println
(
"更新数据库视频封面链接咯"
);
updateDbVideoCoverUrl
();
break
;
case
"
7
"
:
case
"
8
"
:
System
.
out
.
println
(
"补充视频时长咯"
);
updateVideoDuration
();
break
;
case
"
8
"
:
case
"
9
"
:
System
.
out
.
println
(
"计算"
);
countSubjectVideo
();
break
;
case
"9"
:
System
.
out
.
println
(
"下载oss5rsme视频封面"
);
getOss5rsmeCover
();
break
;
case
"0"
:
System
.
out
.
println
(
"退出咯"
);
System
.
exit
(
0
);
...
...
@@ -144,8 +152,7 @@ public class UpdateVideoApplication {
private
static
void
updateTextbook
()
{
String
url
=
"https://api.bendiclass.com/external/api/textbook/v1/getTextbookListByLabel"
;
HttpResult
.
Body
body
=
http
.
sync
(
url
)
HttpResult
.
Body
body
=
http
.
sync
(
url
)
.
addHeader
(
"authorize"
,
"banxiaoer"
)
.
setBodyPara
(
new
Object
())
.
post
()
...
...
@@ -154,34 +161,33 @@ public class UpdateVideoApplication {
boolean
hasData
=
jsonObject
.
containsKey
(
"data"
);
if
(
hasData
)
{
String
data
=
jsonObject
.
get
Object
(
"data"
,
String
.
class
);
List
<
Textbook
>
textbooks
=
J
sonUtil
.
tranJsonStrTo
Array
(
data
,
Textbook
.
class
);
String
data
=
jsonObject
.
get
String
(
"data"
);
List
<
Textbook
>
textbooks
=
J
SONArray
.
parse
Array
(
data
,
Textbook
.
class
);
List
<
TbxXrBook
>
tbxXrBookList
=
new
ArrayList
<>();
for
(
Textbook
original
:
textbooks
)
{
if
(
original
.
getGradeName
().
contains
(
"修"
))
{
//过滤掉选修啥的 目前大概不需要
continue
;
}
TbxXrBook
pojo
=
new
TbxXrBook
();
pojo
.
setBookName
(
original
.
getSubjectName
()
+
original
.
getTextbookVersionName
()
+
original
.
getGradeName
()
+
original
.
getSchoolYearName
());
pojo
.
setTextbookId
(
(
int
)
original
.
getId
(
));
pojo
.
setTextbookId
(
Math
.
toIntExact
(
original
.
getId
()
));
pojo
.
setSubject
(
SUBJECT_MAP
.
get
(
original
.
getSubject
()));
pojo
.
setGradeCode
(
GRADE_MAP
.
get
(
original
.
getGrade
()));
pojo
.
setTerm
(
SCHOOL_YEAR_MAP
.
get
(
original
.
getSchoolYear
()));
pojo
.
setStatus
(
10
);
pojo
.
setTextbookVersion
(
VERSION_MAP
.
get
(
original
.
getTextbookVersion
()));
String
textBookVersion
=
VERSION_MAP
.
get
(
original
.
getTextbookVersion
());
if
(
textBookVersion
==
null
)
{
logger
.
warn
(
"版本未登记: {} {}"
,
original
.
getTextbookVersion
(),
pojo
.
getBookName
());
logger
.
warn
(
JsonUtil
.
tranObjectToJsonStr
(
original
));
}
pojo
.
setTextbookVersion
(
textBookVersion
);
pojo
.
setCreateTime
(
System
.
currentTimeMillis
());
tbxXrBookList
.
add
(
pojo
);
}
if
(
tbxXrBookList
.
size
()
>
0
)
{
//查询已存在的book
LambdaQueryWrapper
<
TbxXrBook
>
qw
=
new
LambdaQueryWrapper
<>();
qw
.
select
(
TbxXrBook:
:
getTextbookId
);
List
<
TbxXrBook
>
list
=
bookService
.
list
(
qw
);
//根据textbookId过滤已存在的
Set
<
Integer
>
textBookSet
=
list
.
stream
().
map
(
TbxXrBook:
:
getTextbookId
).
collect
(
Collectors
.
toSet
());
if
(!
tbxXrBookList
.
isEmpty
())
{
// 查询已存在的book
Set
<
Integer
>
textBookSet
=
bookService
.
lambdaQuery
().
select
(
TbxXrBook:
:
getTextbookId
).
list
()
.
stream
().
map
(
TbxXrBook:
:
getTextbookId
).
collect
(
Collectors
.
toSet
());
// 根据textbookId过滤已存在的
tbxXrBookList
=
tbxXrBookList
.
stream
().
filter
(
o
->
!
textBookSet
.
contains
(
o
.
getTextbookId
())).
collect
(
Collectors
.
toList
());
//保存新增的
//
保存新增的
bookService
.
saveBatch
(
tbxXrBookList
);
}
}
...
...
@@ -577,7 +583,7 @@ public class UpdateVideoApplication {
private
static
void
updateVideoDuration
()
throws
InterruptedException
{
LambdaQueryWrapper
<
TbxXrVideo
>
qw
=
new
LambdaQueryWrapper
<>();
qw
.
select
(
TbxXrVideo:
:
getId
,
TbxXrVideo:
:
getUrl
);
qw
.
eq
(
TbxXrVideo:
:
getTimeDuration
,
"
"
);
qw
.
in
(
TbxXrVideo:
:
getTimeDuration
,
""
,
"--
"
);
qw
.
eq
(
TbxXrVideo:
:
getStatus
,
10
);
List
<
TbxXrVideo
>
list
=
videoService
.
list
(
qw
);
int
size
=
list
.
size
();
...
...
@@ -620,7 +626,7 @@ public class UpdateVideoApplication {
LambdaQueryWrapper
<
TbxXrVideo
>
qw
=
new
LambdaQueryWrapper
<>();
qw
.
select
(
TbxXrVideo:
:
getVideoId
,
TbxXrVideo:
:
getId
);
qw
.
eq
(
TbxXrVideo:
:
getStatus
,
10
);
qw
.
notLike
(
TbxXrVideo:
:
getUrl
,
"https://oss.5rs.me"
);
//
qw.notLike(TbxXrVideo::getUrl, "https://oss.5rs.me");
qw
.
isNull
(
TbxXrVideo:
:
getCoverUrl
);
List
<
TbxXrVideo
>
list
=
videoService
.
list
(
qw
);
int
size
=
list
.
size
();
...
...
@@ -666,6 +672,7 @@ public class UpdateVideoApplication {
private
static
void
getOss5rsmeCover
()
throws
IOException
,
InterruptedException
{
LambdaQueryWrapper
<
TbxXrVideo
>
qw
=
new
LambdaQueryWrapper
<>();
qw
.
like
(
TbxXrVideo:
:
getUrl
,
"https://oss.5rs.me"
);
qw
.
isNull
(
TbxXrVideo:
:
getCoverUrl
);
List
<
TbxXrVideo
>
list
=
videoService
.
list
(
qw
);
for
(
TbxXrVideo
tbxXrVideo
:
list
)
{
//如果已存在则跳过
...
...
src/main/java/cn/bxe/updatevideo/util/VersionUtil.java
View file @
0a3540e
...
...
@@ -56,6 +56,9 @@ public class VersionUtil {
VERSION_MAP
.
put
(
"XIANG_SHAO"
,
"xiangshao"
);
VERSION_MAP
.
put
(
"RENJIAOJINGTONG"
,
"renjiaojingtong"
);
VERSION_MAP
.
put
(
"WAI_YAN_TOGETHER"
,
"waiyanyiqi"
);
VERSION_MAP
.
put
(
"POPULARIZE_SCIENCE"
,
"kepu"
);
VERSION_MAP
.
put
(
"PEP_A"
,
"pep_a"
);
VERSION_MAP
.
put
(
"PEP_B"
,
"pep_b"
);
//学年
SCHOOL_YEAR_MAP
.
put
(
"ALL_BOOKS"
,
5
);
...
...
Write
Preview
Styling with
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment