Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
TimBL
dr_py
提交
03985505
dr_py
项目概览
TimBL
/
dr_py
与 Fork 源项目一致
Fork自
晚风拂柳颜 / dr_py
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
dr_py
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
03985505
编写于
11月 22, 2022
作者:
H
hjdhnx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
播放链接增加url编码
上级
57d40776
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
10 addition
and
4 deletion
+10
-4
js/version.txt
js/version.txt
+1
-1
libs/alist.js
libs/alist.js
+8
-2
libs/alist.min.js
libs/alist.min.js
+1
-1
未找到文件。
js/version.txt
浏览文件 @
03985505
3.9.23beta4
\ No newline at end of file
3.9.23beta5
\ No newline at end of file
libs/alist.js
浏览文件 @
03985505
...
...
@@ -133,7 +133,10 @@ function init(ext) {
return
this
.
settings
.
v3
?
res
.
data
.
content
:
res
.
data
.
files
},
getFile
(
path
)
{
return
{
raw_url
:
this
.
server
+
'
/d
'
+
path
};
let
raw_url
=
this
.
server
+
'
/d
'
+
path
;
raw_url
=
encodeURI
(
raw_url
);
// print('raw_url:'+raw_url);
return
{
raw_url
:
raw_url
};
// const res = http.post(this.server + this.api.file, { data: this.getParams(path) }).json();
// const data = this.settings.v3 ? res.data : res.data.files[0];
...
...
@@ -415,7 +418,10 @@ function search(wd, quick) {
}
print
(
'
搜索链接:
'
+
surl
);
let
html
=
http
.
get
(
surl
).
text
();
let
lists
=
pdfa
(
html
,
'
div&&ul&&a
'
);
let
lists
=
[];
try
{
lists
=
pdfa
(
html
,
'
div&&ul&&a
'
);
}
catch
(
e
)
{}
print
(
`搜索结果数:
${
lists
.
length
}
,搜索结果显示数量限制:
${
limit_search_show
}
`
);
let
vods
=
[];
let
excludeReg
=
/
\.(
pdf|epub|mobi|txt|doc|lrc
)
$/
;
// 过滤后缀文件
...
...
libs/alist.min.js
浏览文件 @
03985505
import
{
distance
}
from
"
https://unpkg.com/fastest-levenshtein@1.0.16/esm/mod.js
"
;
import
{
getFirstLetterList
}
from
"
https://gitcode.net/qq_32394351/dr_py/-/raw/master/libs/pinyin_getFirstLetterList.js
"
;
String
.
prototype
.
rstrip
=
function
(
chars
){
let
regex
=
new
RegExp
(
chars
+
"
$
"
);
return
this
.
replace
(
regex
,
""
)};
var
showMode
=
"
single
"
;
var
searchDriver
=
""
;
var
limit_search_show
=
200
;
var
search_type
=
""
;
function
print
(
any
){
any
=
any
||
""
;
if
(
typeof
any
==
"
object
"
&&
Object
.
keys
(
any
).
length
>
0
){
try
{
any
=
JSON
.
stringify
(
any
);
console
.
log
(
any
)}
catch
(
e
){
console
.
log
(
typeof
any
+
"
:
"
+
any
.
length
)}}
else
if
(
typeof
any
==
"
object
"
&&
Object
.
keys
(
any
).
length
<
1
){
console
.
log
(
"
null object
"
)}
else
{
console
.
log
(
any
)}}
const
http
=
function
(
url
,
options
=
{}){
if
(
options
.
method
===
"
POST
"
&&
options
.
data
){
options
.
body
=
JSON
.
stringify
(
options
.
data
);
options
.
headers
=
Object
.
assign
({
"
content-type
"
:
"
application/json
"
},
options
.
headers
)}
const
res
=
req
(
url
,
options
);
res
.
json
=
()
=>
res
.
content
?
JSON
.
parse
(
res
.
content
):
null
;
res
.
text
=
()
=>
res
.
content
;
return
res
};[
"
get
"
,
"
post
"
].
forEach
(
method
=>
{
http
[
method
]
=
function
(
url
,
options
=
{}){
return
http
(
url
,
Object
.
assign
(
options
,{
method
:
method
.
toUpperCase
()}))}});
const
__drives
=
{};
function
isMedia
(
file
){
return
/
\.(
wmv|mpeg|mov|ram|swf|mp4|mp3|wma|avi|rm|rmvb|flv|mpg|mkv|m3u8
)
$/
.
test
(
file
)}
function
get_drives_path
(
tid
){
const
index
=
tid
.
indexOf
(
"
$
"
);
const
name
=
tid
.
substring
(
0
,
index
);
const
path
=
tid
.
substring
(
index
+
1
);
return
{
drives
:
get_drives
(
name
),
path
:
path
}}
function
get_drives
(
name
){
const
{
settings
,
api
,
server
}
=
__drives
[
name
];
if
(
settings
.
v3
==
null
){
settings
.
v3
=
false
;
const
data
=
http
.
get
(
server
+
"
/api/public/settings
"
).
json
().
data
;
if
(
Array
.
isArray
(
data
)){
settings
.
title
=
data
.
find
(
x
=>
x
.
key
===
"
title
"
)?.
value
;
settings
.
v3
=
false
;
settings
.
version
=
data
.
find
(
x
=>
x
.
key
===
"
version
"
)?.
value
;
settings
.
enableSearch
=
data
.
find
(
x
=>
x
.
key
===
"
enable search
"
)?.
value
===
"
true
"
}
else
{
settings
.
title
=
data
.
title
;
settings
.
v3
=
true
;
settings
.
version
=
data
.
version
;
settings
.
enableSearch
=
false
}
api
.
path
=
settings
.
v3
?
"
/api/fs/list
"
:
"
/api/public/path
"
;
api
.
file
=
settings
.
v3
?
"
/api/fs/get
"
:
"
/api/public/path
"
;
api
.
search
=
settings
.
v3
?
"
/api/public/search
"
:
"
/api/public/search
"
}
return
__drives
[
name
]}
function
init
(
ext
){
let
alist_data
=
ext
.
split
(
"
;
"
);
let
alist_data_url
=
alist_data
[
0
];
limit_search_show
=
alist_data
.
length
>
1
?
Number
(
alist_data
[
1
])
||
limit_search_show
:
limit_search_show
;
search_type
=
alist_data
.
length
>
2
?
alist_data
[
2
]:
search_type
;
const
data
=
http
.
get
(
alist_data_url
).
json
();
searchDriver
=
(
data
.
find
(
x
=>
x
.
search
)
||
{}).
name
||
""
;
data
.
forEach
(
item
=>
{
let
_path_param
=
[];
if
(
item
.
params
){
_path_param
=
Object
.
keys
(
item
.
params
);
_path_param
.
sort
((
a
,
b
)
=>
a
.
length
-
b
.
length
)}
__drives
[
item
.
name
]
=
{
name
:
item
.
name
,
server
:
item
.
server
.
endsWith
(
"
/
"
)?
item
.
server
.
rstrip
(
"
/
"
):
item
.
server
,
startPage
:
item
.
startPage
||
"
/
"
,
showAll
:
item
.
showAll
===
true
,
search
:
!!
item
.
search
,
params
:
item
.
params
||
{},
_path_param
:
_path_param
,
settings
:{},
api
:{},
getParams
(
path
){
const
key
=
this
.
_path_param
.
find
(
x
=>
path
.
startsWith
(
x
));
return
Object
.
assign
({},
this
.
params
[
key
],{
path
:
path
})},
getPath
(
path
){
const
res
=
http
.
post
(
this
.
server
+
this
.
api
.
path
,{
data
:
this
.
getParams
(
path
)}).
json
();
return
this
.
settings
.
v3
?
res
.
data
.
content
:
res
.
data
.
files
},
getFile
(
path
){
return
{
raw_url
:
this
.
server
+
"
/d
"
+
path
}},
isFolder
(
data
){
return
data
.
type
===
1
},
isVideo
(
data
){
return
this
.
settings
.
v3
?
data
.
type
===
2
:
data
.
type
===
3
},
is_subt
(
data
){
if
(
data
.
type
===
1
){
return
false
}
const
ext
=
/
\.(
srt|ass|scc|stl|ttml
)
$/
;
return
ext
.
test
(
data
.
name
)},
getPic
(
data
){
let
pic
=
this
.
settings
.
v3
?
data
.
thumb
:
data
.
thumbnail
;
return
pic
||
(
this
.
isFolder
(
data
)?
"
http://img1.3png.com/281e284a670865a71d91515866552b5f172b.png
"
:
""
)},
getTime
(
data
,
isStandard
){
isStandard
=
isStandard
||
false
;
try
{
let
tTime
=
data
.
updated_at
||
data
.
time_str
||
data
.
modified
||
""
;
let
date
=
""
;
if
(
tTime
){
tTime
=
tTime
.
split
(
"
T
"
);
date
=
tTime
[
0
];
if
(
isStandard
){
date
=
date
.
replace
(
/-/g
,
"
/
"
)}
tTime
=
tTime
[
1
].
split
(
/Z|
\.
/
);
date
+=
"
"
+
tTime
[
0
]}
return
date
}
catch
(
e
){
return
""
}}}});
print
(
"
init执行完毕
"
)}
function
home
(
filter
){
let
classes
=
Object
.
keys
(
__drives
).
map
(
key
=>
({
type_id
:
`
${
key
}
$
${
__drives
[
key
].
startPage
}
`
,
type_name
:
key
,
type_flag
:
"
1
"
}));
let
filter_dict
=
{};
let
filters
=
[{
key
:
"
order
"
,
name
:
"
排序
"
,
value
:[{
n
:
"
名称⬆️
"
,
v
:
"
vod_name_asc
"
},{
n
:
"
名称⬇️
"
,
v
:
"
vod_name_desc
"
},{
n
:
"
时间⬆️
"
,
v
:
"
vod_time_asc
"
},{
n
:
"
时间⬇️
"
,
v
:
"
vod_time_desc
"
},{
n
:
"
大小⬆️
"
,
v
:
"
vod_size_asc
"
},{
n
:
"
大小⬇️
"
,
v
:
"
vod_size_desc
"
}]},{
key
:
"
show
"
,
name
:
"
播放展示
"
,
value
:[{
n
:
"
单集
"
,
v
:
"
single
"
},{
n
:
"
全集
"
,
v
:
"
all
"
}]}];
classes
.
forEach
(
it
=>
{
filter_dict
[
it
.
type_id
]
=
filters
});
print
(
"
----home----
"
);
print
(
classes
);
return
JSON
.
stringify
({
class
:
classes
,
filters
:
filter_dict
})}
function
homeVod
(
params
){
return
JSON
.
stringify
({
list
:[]})}
function
category
(
tid
,
pg
,
filter
,
extend
){
let
{
drives
,
path
}
=
get_drives_path
(
tid
);
const
id
=
tid
.
endsWith
(
"
/
"
)?
tid
:
tid
+
"
/
"
;
const
list
=
drives
.
getPath
(
path
);
let
subList
=
[];
let
vodFiles
=
[];
let
allList
=
[];
list
.
forEach
(
item
=>
{
if
(
drives
.
is_subt
(
item
)){
subList
.
push
(
item
.
name
)}
if
(
!
drives
.
showAll
&&!
drives
.
isFolder
(
item
)
&&!
drives
.
isVideo
(
item
)){
return
}
let
vod_time
=
drives
.
getTime
(
item
);
let
vod_size
=
get_size
(
item
.
size
);
let
remark
=
vod_time
.
split
(
"
"
)[
0
].
substr
(
3
)
+
"
\t
"
+
vod_size
;
const
vod
=
{
vod_id
:
id
+
item
.
name
+
(
drives
.
isFolder
(
item
)?
"
/
"
:
""
),
vod_name
:
item
.
name
.
replaceAll
(
"
$
"
,
""
).
replaceAll
(
"
#
"
,
""
),
vod_pic
:
drives
.
getPic
(
item
),
vod_time
:
vod_time
,
vod_size
:
item
.
size
,
vod_tag
:
drives
.
isFolder
(
item
)?
"
folder
"
:
"
file
"
,
vod_remarks
:
drives
.
isFolder
(
item
)?
remark
+
"
文件夹
"
:
remark
};
if
(
drives
.
isVideo
(
item
)){
vodFiles
.
push
(
vod
)}
allList
.
push
(
vod
)});
if
(
vodFiles
.
length
===
1
&&
subList
.
length
>
0
){
let
sub
;
if
(
subList
.
length
===
1
){
sub
=
subList
[
0
]}
else
{
let
subs
=
JSON
.
parse
(
JSON
.
stringify
(
subList
));
subs
.
sort
((
a
,
b
)
=>
{
let
a_similar
=
(
a
.
includes
(
"
chs
"
)?
100
:
0
)
+
levenshteinDistance
(
a
,
vodFiles
[
0
].
vod_name
);
let
b_similar
=
(
b
.
includes
(
"
chs
"
)?
100
:
0
)
+
levenshteinDistance
(
b
,
vodFiles
[
0
].
vod_name
);
if
(
a_similar
>
b_similar
){
return
1
}
else
{
return
-
1
}});
sub
=
subs
.
slice
(
-
1
)[
0
]}
vodFiles
[
0
].
vod_id
+=
"
@@@
"
+
sub
;
vodFiles
[
0
].
vod_remarks
+=
"
🏷️
"
}
else
{
vodFiles
.
forEach
(
item
=>
{
const
lh
=
0
;
let
sub
;
subList
.
forEach
(
s
=>
{
const
l
=
levenshteinDistance
(
s
,
item
.
vod_name
);
if
(
l
>
60
&&
l
>
lh
){
sub
=
s
}});
if
(
sub
){
item
.
vod_id
+=
"
@@@
"
+
sub
;
item
.
vod_remarks
+=
"
🏷️
"
}})}
print
(
"
----category----,tid:
"
+
tid
);
let
fl
=
filter
?
extend
:{};
if
(
fl
.
order
){
let
key
=
fl
.
order
.
split
(
"
_
"
).
slice
(
0
,
-
1
).
join
(
"
_
"
);
let
order
=
fl
.
order
.
split
(
"
_
"
).
slice
(
-
1
)[
0
];
print
(
`排序key:
${
key
}
,排序order:
${
order
}
`
);
if
(
key
.
includes
(
"
name
"
)){
allList
=
sortListByName
(
allList
,
key
,
order
)}
else
if
(
key
.
includes
(
"
time
"
)){
allList
=
sortListByTime
(
allList
,
key
,
order
)}
else
if
(
key
.
includes
(
"
size
"
)){
allList
=
sortListBySize
(
allList
,
key
,
order
)}}
else
{
allList
=
sortListByName
(
allList
,
"
vod_name
"
,
"
asc
"
)}
if
(
fl
.
show
){
showMode
=
fl
.
show
}
return
JSON
.
stringify
({
page
:
1
,
pagecount
:
1
,
limit
:
allList
.
length
,
total
:
allList
.
length
,
list
:
allList
})}
function
getAll
(
otid
,
tid
,
drives
,
path
){
try
{
const
content
=
category
(
tid
,
null
,
false
,
null
);
const
{
list
}
=
JSON
.
parse
(
content
);
let
vod_play_url
=
[];
list
.
forEach
(
x
=>
{
if
(
x
.
vod_tag
===
"
file
"
){
vod_play_url
.
push
(
`
${
x
.
vod_name
}
$
${
x
.
vod_id
.
substring
(
x
.
vod_id
.
indexOf
(
"
$
"
)
+
1
)}
`
)}});
const
pl
=
path
.
split
(
"
/
"
);
const
vod_name
=
pl
[
pl
.
length
-
2
]
||
drives
.
name
;
let
vod
=
{
vod_id
:
otid
,
vod_name
:
vod_name
,
type_name
:
"
文件夹
"
,
vod_pic
:
"
https://avatars.githubusercontent.com/u/97389433?s=120&v=4
"
,
vod_content
:
tid
,
vod_tag
:
"
folder
"
,
vod_play_from
:
drives
.
name
,
vod_play_url
:
vod_play_url
.
join
(
"
#
"
),
vod_remarks
:
drives
.
settings
.
title
};
print
(
"
----detail1----
"
);
print
(
vod
);
return
JSON
.
stringify
({
list
:[
vod
]})}
catch
(
e
){
print
(
e
.
message
);
return
JSON
.
stringify
({
list
:[{}]})}}
function
detail
(
tid
){
let
isSearch
=
tid
.
endsWith
(
"
#search#
"
);
let
otid
=
tid
;
tid
=
tid
.
replace
(
"
#search#
"
,
""
);
let
isFile
=
isMedia
(
tid
);
let
{
drives
,
path
}
=
get_drives_path
(
tid
);
if
(
path
.
endsWith
(
"
/
"
)){
return
getAll
(
otid
,
tid
,
drives
,
path
)}
else
{
if
(
isSearch
&&!
isFile
){
return
getAll
(
otid
,
tid
,
drives
,
path
)}
else
if
(
showMode
===
"
all
"
){
let
new_tid
=
tid
.
split
(
"
/
"
).
slice
(
0
,
-
1
).
join
(
"
/
"
)
+
"
/
"
;
print
(
`全集模式 tid:
${
tid
}
=>tid:
${
new_tid
}
`
);
let
{
drives
,
path
}
=
get_drives_path
(
new_tid
);
return
getAll
(
otid
,
new_tid
,
drives
,
path
)}
else
{
let
paths
=
path
.
split
(
"
@@@
"
);
let
vod_name
=
paths
[
0
].
substring
(
paths
[
0
].
lastIndexOf
(
"
/
"
)
+
1
);
let
vod
=
{
vod_id
:
otid
,
vod_name
:
vod_name
,
type_name
:
"
文件
"
,
vod_pic
:
"
https://avatars.githubusercontent.com/u/97389433?s=120&v=4
"
,
vod_content
:
tid
,
vod_play_from
:
drives
.
name
,
vod_play_url
:
vod_name
+
"
$
"
+
path
,
vod_remarks
:
drives
.
settings
.
title
};
print
(
"
----detail2----
"
);
print
(
vod
);
return
JSON
.
stringify
({
list
:[
vod
]})}}}
function
play
(
flag
,
id
,
flags
){
const
drives
=
get_drives
(
flag
);
const
urls
=
id
.
split
(
"
@@@
"
);
let
vod
=
{
parse
:
0
,
playUrl
:
""
,
url
:
drives
.
getFile
(
urls
[
0
]).
raw_url
};
if
(
urls
.
length
>=
2
){
const
path
=
urls
[
0
].
substring
(
0
,
urls
[
0
].
lastIndexOf
(
"
/
"
)
+
1
);
vod
.
subt
=
drives
.
getFile
(
path
+
urls
[
1
]).
raw_url
}
print
(
"
----play----
"
);
print
(
vod
);
return
JSON
.
stringify
(
vod
)}
function
search
(
wd
,
quick
){
print
(
__drives
);
print
(
"
可搜索的alist驱动:
"
+
searchDriver
);
if
(
!
searchDriver
){
return
JSON
.
stringify
({
list
:[]})}
else
{
let
driver
=
__drives
[
searchDriver
];
print
(
driver
);
let
surl
=
driver
.
server
+
"
/search?box=
"
+
wd
+
"
&url=
"
;
if
(
search_type
){
surl
+=
"
&type=
"
+
search_type
}
print
(
"
搜索链接:
"
+
surl
);
let
html
=
http
.
get
(
surl
).
text
();
let
lists
=
pdfa
(
html
,
"
div&&ul&&a
"
);
print
(
`搜索结果数:
${
lists
.
length
}
,搜索结果显示数量限制:
${
limit_search_show
}
`
);
let
vods
=
[];
let
excludeReg
=
/
\.(
pdf|epub|mobi|txt|doc|lrc
)
$/
;
lists
.
forEach
(
it
=>
{
let
vhref
=
pdfh
(
it
,
"
a&&href
"
);
if
(
vhref
){
vhref
=
unescape
(
vhref
)}
if
(
excludeReg
.
test
(
vhref
)){
return
}
let
vid
=
searchDriver
+
"
$
"
+
vhref
+
"
#search#
"
;
vods
.
push
({
vod_name
:
pdfh
(
it
,
"
a&&Text
"
),
vod_id
:
vid
,
vod_pic
:
"
http://img1.3png.com/281e284a670865a71d91515866552b5f172b.png
"
,
vod_remarks
:
searchDriver
})});
vods
=
vods
.
slice
(
0
,
limit_search_show
);
print
(
vods
);
return
JSON
.
stringify
({
list
:
vods
})}}
function
get_size
(
sz
){
if
(
sz
<=
0
){
return
""
}
let
filesize
=
""
;
if
(
sz
>
1024
*
1024
*
1024
*
1024
){
sz
/=
1024
*
1024
*
1024
*
1024
;
filesize
=
"
TB
"
}
else
if
(
sz
>
1024
*
1024
*
1024
){
sz
/=
1024
*
1024
*
1024
;
filesize
=
"
GB
"
}
else
if
(
sz
>
1024
*
1024
){
sz
/=
1024
*
1024
;
filesize
=
"
MB
"
}
else
if
(
sz
>
1024
){
sz
/=
1024
;
filesize
=
"
KB
"
}
else
{
filesize
=
"
B
"
}
let
sizeStr
=
sz
.
toFixed
(
2
)
+
filesize
,
index
=
sizeStr
.
indexOf
(
"
.
"
),
dou
=
sizeStr
.
substr
(
index
+
1
,
2
);
if
(
dou
===
"
00
"
){
return
sizeStr
.
substring
(
0
,
index
)
+
sizeStr
.
substr
(
index
+
3
,
2
)}
else
{
return
sizeStr
}}
function
levenshteinDistance
(
str1
,
str2
){
return
100
-
100
*
distance
(
str1
,
str2
)
/
Math
.
max
(
str1
.
length
,
str2
.
length
)}
const
sortListByFirst
=
(
vodList
,
key
)
=>
{
key
=
key
||
"
vod_name
"
;
const
symbol_list
=
[];
const
cn_list
=
[];
const
en_list
=
[];
const
num_list
=
[];
vodList
.
forEach
(
vod
=>
{
const
{
vod_name
}
=
vod
;
if
(
/
[\u
4e00-
\u
9fa5
]
/
.
test
(
vod_name
[
0
])){
cn_list
.
push
(
vod
)}
else
if
(
/
[
a-zA-Z
]
/
.
test
(
vod_name
[
0
])){
en_list
.
push
(
vod
)}
else
if
(
/
[\d]
/
.
test
(
vod_name
[
0
])){
num_list
.
push
(
vod
)}
else
{
symbol_list
.
push
(
vod
)}});
const
newList
=
[...
cn_list
.
sort
((
a
,
b
)
=>
a
.
vod_name
[
0
]?.
localeCompare
(
b
.
vod_name
[
0
])),...
en_list
.
sort
((
a
,
b
)
=>
a
.
vod_name
[
0
].
localeCompare
(
b
.
vod_name
[
0
])),...
num_list
.
sort
((
a
,
b
)
=>
a
.
vod_name
[
0
]
-
b
.
vod_name
[
0
]),...
symbol_list
.
sort
((
a
,
b
)
=>
a
.
vod_name
[
0
]
-
b
.
vod_name
[
0
])];
return
newList
};
function
isAllChinese
(
str
){
return
/^
[\u
4E00-
\u
9FA5
]
+$/
.
test
(
str
)}
function
isChinese
(
char
){
return
/^
[\u
4E00-
\u
9FA5
]
$/
.
test
(
char
)}
const
sortListByName
=
(
vodList
,
key
,
order
)
=>
{
if
(
!
key
){
return
vodList
}
order
=
order
||
"
asc
"
;
let
ASCarr
=
vodList
.
sort
((
a
,
b
)
=>
{
a
=
a
[
key
];
b
=
b
[
key
];
if
(
typeof
a
===
"
number
"
&&
typeof
b
===
"
string
"
){
return
-
1
}
if
(
typeof
a
===
"
string
"
&&
typeof
b
===
"
number
"
){
return
1
}
if
(
isNaN
(
a
)
||
isNaN
(
b
)){
if
(
isAllChinese
(
a
)
&&!
isAllChinese
(
b
)){
return
1
}
if
(
!
isAllChinese
(
a
)
&&
isAllChinese
(
b
)){
return
-
1
}
a
=
a
.
toString
();
b
=
b
.
toString
();
let
result
=
0
;
for
(
let
index
=
0
;
index
<
(
a
.
length
-
b
.
length
?
b
.
length
:
a
.
length
);
index
++
){
if
(
!
isChinese
(
a
[
index
])
&&
isChinese
(
b
[
index
])){
result
=-
1
}
if
(
isChinese
(
a
[
index
])
&&!
isChinese
(
b
[
index
])){
result
=
1
}
if
(
isChinese
(
a
[
index
])
&&
isChinese
(
b
[
index
])){
let
pinyinA
=
getFirstLetterList
(
a
[
index
]).
toString
();
let
pinyinB
=
getFirstLetterList
(
b
[
index
]).
toString
();
result
=
pinyinA
.
localeCompare
(
pinyinB
,
"
zh-Hans-CN
"
,{
sensitivity
:
"
accent
"
})}
if
(
result
!==
0
){
break
}}
return
result
||
a
.
toString
().
localeCompare
(
b
.
toString
(),
"
zh-Hans-CN
"
,{
sensitivity
:
"
accent
"
})}
else
{
return
Number
(
a
)
-
Number
(
b
)}});
if
(
order
===
"
desc
"
){
ASCarr
.
reverse
()}
return
ASCarr
};
const
getTimeInt
=
timeStr
=>
{
return
new
Date
(
timeStr
).
getTime
()};
const
sortListByTime
=
(
vodList
,
key
,
order
)
=>
{
if
(
!
key
){
return
vodList
}
let
ASCarr
=
vodList
.
sort
((
a
,
b
)
=>
{
a
=
a
[
key
];
b
=
b
[
key
];
return
getTimeInt
(
a
)
-
getTimeInt
(
b
)});
if
(
order
===
"
desc
"
){
ASCarr
.
reverse
()}
return
ASCarr
};
const
sortListBySize
=
(
vodList
,
key
,
order
)
=>
{
if
(
!
key
){
return
vodList
}
let
ASCarr
=
vodList
.
sort
((
a
,
b
)
=>
{
a
=
a
[
key
];
b
=
b
[
key
];
return
(
Number
(
a
)
||
0
)
-
(
Number
(
b
)
||
0
)});
if
(
order
===
"
desc
"
){
ASCarr
.
reverse
()}
return
ASCarr
};
export
default
{
init
:
init
,
home
:
home
,
homeVod
:
homeVod
,
category
:
category
,
detail
:
detail
,
play
:
play
,
search
:
search
};
\ No newline at end of file
import
{
distance
}
from
"
https://unpkg.com/fastest-levenshtein@1.0.16/esm/mod.js
"
;
import
{
getFirstLetterList
}
from
"
https://gitcode.net/qq_32394351/dr_py/-/raw/master/libs/pinyin_getFirstLetterList.js
"
;
String
.
prototype
.
rstrip
=
function
(
chars
){
let
regex
=
new
RegExp
(
chars
+
"
$
"
);
return
this
.
replace
(
regex
,
""
)};
var
showMode
=
"
single
"
;
var
searchDriver
=
""
;
var
limit_search_show
=
200
;
var
search_type
=
""
;
function
print
(
any
){
any
=
any
||
""
;
if
(
typeof
any
==
"
object
"
&&
Object
.
keys
(
any
).
length
>
0
){
try
{
any
=
JSON
.
stringify
(
any
);
console
.
log
(
any
)}
catch
(
e
){
console
.
log
(
typeof
any
+
"
:
"
+
any
.
length
)}}
else
if
(
typeof
any
==
"
object
"
&&
Object
.
keys
(
any
).
length
<
1
){
console
.
log
(
"
null object
"
)}
else
{
console
.
log
(
any
)}}
const
http
=
function
(
url
,
options
=
{}){
if
(
options
.
method
===
"
POST
"
&&
options
.
data
){
options
.
body
=
JSON
.
stringify
(
options
.
data
);
options
.
headers
=
Object
.
assign
({
"
content-type
"
:
"
application/json
"
},
options
.
headers
)}
const
res
=
req
(
url
,
options
);
res
.
json
=
()
=>
res
.
content
?
JSON
.
parse
(
res
.
content
):
null
;
res
.
text
=
()
=>
res
.
content
;
return
res
};[
"
get
"
,
"
post
"
].
forEach
(
method
=>
{
http
[
method
]
=
function
(
url
,
options
=
{}){
return
http
(
url
,
Object
.
assign
(
options
,{
method
:
method
.
toUpperCase
()}))}});
const
__drives
=
{};
function
isMedia
(
file
){
return
/
\.(
wmv|mpeg|mov|ram|swf|mp4|mp3|wma|avi|rm|rmvb|flv|mpg|mkv|m3u8
)
$/
.
test
(
file
)}
function
get_drives_path
(
tid
){
const
index
=
tid
.
indexOf
(
"
$
"
);
const
name
=
tid
.
substring
(
0
,
index
);
const
path
=
tid
.
substring
(
index
+
1
);
return
{
drives
:
get_drives
(
name
),
path
:
path
}}
function
get_drives
(
name
){
const
{
settings
,
api
,
server
}
=
__drives
[
name
];
if
(
settings
.
v3
==
null
){
settings
.
v3
=
false
;
const
data
=
http
.
get
(
server
+
"
/api/public/settings
"
).
json
().
data
;
if
(
Array
.
isArray
(
data
)){
settings
.
title
=
data
.
find
(
x
=>
x
.
key
===
"
title
"
)?.
value
;
settings
.
v3
=
false
;
settings
.
version
=
data
.
find
(
x
=>
x
.
key
===
"
version
"
)?.
value
;
settings
.
enableSearch
=
data
.
find
(
x
=>
x
.
key
===
"
enable search
"
)?.
value
===
"
true
"
}
else
{
settings
.
title
=
data
.
title
;
settings
.
v3
=
true
;
settings
.
version
=
data
.
version
;
settings
.
enableSearch
=
false
}
api
.
path
=
settings
.
v3
?
"
/api/fs/list
"
:
"
/api/public/path
"
;
api
.
file
=
settings
.
v3
?
"
/api/fs/get
"
:
"
/api/public/path
"
;
api
.
search
=
settings
.
v3
?
"
/api/public/search
"
:
"
/api/public/search
"
}
return
__drives
[
name
]}
function
init
(
ext
){
let
alist_data
=
ext
.
split
(
"
;
"
);
let
alist_data_url
=
alist_data
[
0
];
limit_search_show
=
alist_data
.
length
>
1
?
Number
(
alist_data
[
1
])
||
limit_search_show
:
limit_search_show
;
search_type
=
alist_data
.
length
>
2
?
alist_data
[
2
]:
search_type
;
const
data
=
http
.
get
(
alist_data_url
).
json
();
searchDriver
=
(
data
.
find
(
x
=>
x
.
search
)
||
{}).
name
||
""
;
data
.
forEach
(
item
=>
{
let
_path_param
=
[];
if
(
item
.
params
){
_path_param
=
Object
.
keys
(
item
.
params
);
_path_param
.
sort
((
a
,
b
)
=>
a
.
length
-
b
.
length
)}
__drives
[
item
.
name
]
=
{
name
:
item
.
name
,
server
:
item
.
server
.
endsWith
(
"
/
"
)?
item
.
server
.
rstrip
(
"
/
"
):
item
.
server
,
startPage
:
item
.
startPage
||
"
/
"
,
showAll
:
item
.
showAll
===
true
,
search
:
!!
item
.
search
,
params
:
item
.
params
||
{},
_path_param
:
_path_param
,
settings
:{},
api
:{},
getParams
(
path
){
const
key
=
this
.
_path_param
.
find
(
x
=>
path
.
startsWith
(
x
));
return
Object
.
assign
({},
this
.
params
[
key
],{
path
:
path
})},
getPath
(
path
){
const
res
=
http
.
post
(
this
.
server
+
this
.
api
.
path
,{
data
:
this
.
getParams
(
path
)}).
json
();
return
this
.
settings
.
v3
?
res
.
data
.
content
:
res
.
data
.
files
},
getFile
(
path
){
let
raw_url
=
this
.
server
+
"
/d
"
+
path
;
raw_url
=
encodeURI
(
raw_url
);
return
{
raw_url
:
raw_url
}},
isFolder
(
data
){
return
data
.
type
===
1
},
isVideo
(
data
){
return
this
.
settings
.
v3
?
data
.
type
===
2
:
data
.
type
===
3
},
is_subt
(
data
){
if
(
data
.
type
===
1
){
return
false
}
const
ext
=
/
\.(
srt|ass|scc|stl|ttml
)
$/
;
return
ext
.
test
(
data
.
name
)},
getPic
(
data
){
let
pic
=
this
.
settings
.
v3
?
data
.
thumb
:
data
.
thumbnail
;
return
pic
||
(
this
.
isFolder
(
data
)?
"
http://img1.3png.com/281e284a670865a71d91515866552b5f172b.png
"
:
""
)},
getTime
(
data
,
isStandard
){
isStandard
=
isStandard
||
false
;
try
{
let
tTime
=
data
.
updated_at
||
data
.
time_str
||
data
.
modified
||
""
;
let
date
=
""
;
if
(
tTime
){
tTime
=
tTime
.
split
(
"
T
"
);
date
=
tTime
[
0
];
if
(
isStandard
){
date
=
date
.
replace
(
/-/g
,
"
/
"
)}
tTime
=
tTime
[
1
].
split
(
/Z|
\.
/
);
date
+=
"
"
+
tTime
[
0
]}
return
date
}
catch
(
e
){
return
""
}}}});
print
(
"
init执行完毕
"
)}
function
home
(
filter
){
let
classes
=
Object
.
keys
(
__drives
).
map
(
key
=>
({
type_id
:
`
${
key
}
$
${
__drives
[
key
].
startPage
}
`
,
type_name
:
key
,
type_flag
:
"
1
"
}));
let
filter_dict
=
{};
let
filters
=
[{
key
:
"
order
"
,
name
:
"
排序
"
,
value
:[{
n
:
"
名称⬆️
"
,
v
:
"
vod_name_asc
"
},{
n
:
"
名称⬇️
"
,
v
:
"
vod_name_desc
"
},{
n
:
"
时间⬆️
"
,
v
:
"
vod_time_asc
"
},{
n
:
"
时间⬇️
"
,
v
:
"
vod_time_desc
"
},{
n
:
"
大小⬆️
"
,
v
:
"
vod_size_asc
"
},{
n
:
"
大小⬇️
"
,
v
:
"
vod_size_desc
"
}]},{
key
:
"
show
"
,
name
:
"
播放展示
"
,
value
:[{
n
:
"
单集
"
,
v
:
"
single
"
},{
n
:
"
全集
"
,
v
:
"
all
"
}]}];
classes
.
forEach
(
it
=>
{
filter_dict
[
it
.
type_id
]
=
filters
});
print
(
"
----home----
"
);
print
(
classes
);
return
JSON
.
stringify
({
class
:
classes
,
filters
:
filter_dict
})}
function
homeVod
(
params
){
return
JSON
.
stringify
({
list
:[]})}
function
category
(
tid
,
pg
,
filter
,
extend
){
let
{
drives
,
path
}
=
get_drives_path
(
tid
);
const
id
=
tid
.
endsWith
(
"
/
"
)?
tid
:
tid
+
"
/
"
;
const
list
=
drives
.
getPath
(
path
);
let
subList
=
[];
let
vodFiles
=
[];
let
allList
=
[];
list
.
forEach
(
item
=>
{
if
(
drives
.
is_subt
(
item
)){
subList
.
push
(
item
.
name
)}
if
(
!
drives
.
showAll
&&!
drives
.
isFolder
(
item
)
&&!
drives
.
isVideo
(
item
)){
return
}
let
vod_time
=
drives
.
getTime
(
item
);
let
vod_size
=
get_size
(
item
.
size
);
let
remark
=
vod_time
.
split
(
"
"
)[
0
].
substr
(
3
)
+
"
\t
"
+
vod_size
;
const
vod
=
{
vod_id
:
id
+
item
.
name
+
(
drives
.
isFolder
(
item
)?
"
/
"
:
""
),
vod_name
:
item
.
name
.
replaceAll
(
"
$
"
,
""
).
replaceAll
(
"
#
"
,
""
),
vod_pic
:
drives
.
getPic
(
item
),
vod_time
:
vod_time
,
vod_size
:
item
.
size
,
vod_tag
:
drives
.
isFolder
(
item
)?
"
folder
"
:
"
file
"
,
vod_remarks
:
drives
.
isFolder
(
item
)?
remark
+
"
文件夹
"
:
remark
};
if
(
drives
.
isVideo
(
item
)){
vodFiles
.
push
(
vod
)}
allList
.
push
(
vod
)});
if
(
vodFiles
.
length
===
1
&&
subList
.
length
>
0
){
let
sub
;
if
(
subList
.
length
===
1
){
sub
=
subList
[
0
]}
else
{
let
subs
=
JSON
.
parse
(
JSON
.
stringify
(
subList
));
subs
.
sort
((
a
,
b
)
=>
{
let
a_similar
=
(
a
.
includes
(
"
chs
"
)?
100
:
0
)
+
levenshteinDistance
(
a
,
vodFiles
[
0
].
vod_name
);
let
b_similar
=
(
b
.
includes
(
"
chs
"
)?
100
:
0
)
+
levenshteinDistance
(
b
,
vodFiles
[
0
].
vod_name
);
if
(
a_similar
>
b_similar
){
return
1
}
else
{
return
-
1
}});
sub
=
subs
.
slice
(
-
1
)[
0
]}
vodFiles
[
0
].
vod_id
+=
"
@@@
"
+
sub
;
vodFiles
[
0
].
vod_remarks
+=
"
🏷️
"
}
else
{
vodFiles
.
forEach
(
item
=>
{
const
lh
=
0
;
let
sub
;
subList
.
forEach
(
s
=>
{
const
l
=
levenshteinDistance
(
s
,
item
.
vod_name
);
if
(
l
>
60
&&
l
>
lh
){
sub
=
s
}});
if
(
sub
){
item
.
vod_id
+=
"
@@@
"
+
sub
;
item
.
vod_remarks
+=
"
🏷️
"
}})}
print
(
"
----category----,tid:
"
+
tid
);
let
fl
=
filter
?
extend
:{};
if
(
fl
.
order
){
let
key
=
fl
.
order
.
split
(
"
_
"
).
slice
(
0
,
-
1
).
join
(
"
_
"
);
let
order
=
fl
.
order
.
split
(
"
_
"
).
slice
(
-
1
)[
0
];
print
(
`排序key:
${
key
}
,排序order:
${
order
}
`
);
if
(
key
.
includes
(
"
name
"
)){
allList
=
sortListByName
(
allList
,
key
,
order
)}
else
if
(
key
.
includes
(
"
time
"
)){
allList
=
sortListByTime
(
allList
,
key
,
order
)}
else
if
(
key
.
includes
(
"
size
"
)){
allList
=
sortListBySize
(
allList
,
key
,
order
)}}
else
{
allList
=
sortListByName
(
allList
,
"
vod_name
"
,
"
asc
"
)}
if
(
fl
.
show
){
showMode
=
fl
.
show
}
return
JSON
.
stringify
({
page
:
1
,
pagecount
:
1
,
limit
:
allList
.
length
,
total
:
allList
.
length
,
list
:
allList
})}
function
getAll
(
otid
,
tid
,
drives
,
path
){
try
{
const
content
=
category
(
tid
,
null
,
false
,
null
);
const
{
list
}
=
JSON
.
parse
(
content
);
let
vod_play_url
=
[];
list
.
forEach
(
x
=>
{
if
(
x
.
vod_tag
===
"
file
"
){
vod_play_url
.
push
(
`
${
x
.
vod_name
}
$
${
x
.
vod_id
.
substring
(
x
.
vod_id
.
indexOf
(
"
$
"
)
+
1
)}
`
)}});
const
pl
=
path
.
split
(
"
/
"
);
const
vod_name
=
pl
[
pl
.
length
-
2
]
||
drives
.
name
;
let
vod
=
{
vod_id
:
otid
,
vod_name
:
vod_name
,
type_name
:
"
文件夹
"
,
vod_pic
:
"
https://avatars.githubusercontent.com/u/97389433?s=120&v=4
"
,
vod_content
:
tid
,
vod_tag
:
"
folder
"
,
vod_play_from
:
drives
.
name
,
vod_play_url
:
vod_play_url
.
join
(
"
#
"
),
vod_remarks
:
drives
.
settings
.
title
};
print
(
"
----detail1----
"
);
print
(
vod
);
return
JSON
.
stringify
({
list
:[
vod
]})}
catch
(
e
){
print
(
e
.
message
);
return
JSON
.
stringify
({
list
:[{}]})}}
function
detail
(
tid
){
let
isSearch
=
tid
.
endsWith
(
"
#search#
"
);
let
otid
=
tid
;
tid
=
tid
.
replace
(
"
#search#
"
,
""
);
let
isFile
=
isMedia
(
tid
);
let
{
drives
,
path
}
=
get_drives_path
(
tid
);
if
(
path
.
endsWith
(
"
/
"
)){
return
getAll
(
otid
,
tid
,
drives
,
path
)}
else
{
if
(
isSearch
&&!
isFile
){
return
getAll
(
otid
,
tid
,
drives
,
path
)}
else
if
(
showMode
===
"
all
"
){
let
new_tid
=
tid
.
split
(
"
/
"
).
slice
(
0
,
-
1
).
join
(
"
/
"
)
+
"
/
"
;
print
(
`全集模式 tid:
${
tid
}
=>tid:
${
new_tid
}
`
);
let
{
drives
,
path
}
=
get_drives_path
(
new_tid
);
return
getAll
(
otid
,
new_tid
,
drives
,
path
)}
else
{
let
paths
=
path
.
split
(
"
@@@
"
);
let
vod_name
=
paths
[
0
].
substring
(
paths
[
0
].
lastIndexOf
(
"
/
"
)
+
1
);
let
vod
=
{
vod_id
:
otid
,
vod_name
:
vod_name
,
type_name
:
"
文件
"
,
vod_pic
:
"
https://avatars.githubusercontent.com/u/97389433?s=120&v=4
"
,
vod_content
:
tid
,
vod_play_from
:
drives
.
name
,
vod_play_url
:
vod_name
+
"
$
"
+
path
,
vod_remarks
:
drives
.
settings
.
title
};
print
(
"
----detail2----
"
);
print
(
vod
);
return
JSON
.
stringify
({
list
:[
vod
]})}}}
function
play
(
flag
,
id
,
flags
){
const
drives
=
get_drives
(
flag
);
const
urls
=
id
.
split
(
"
@@@
"
);
let
vod
=
{
parse
:
0
,
playUrl
:
""
,
url
:
drives
.
getFile
(
urls
[
0
]).
raw_url
};
if
(
urls
.
length
>=
2
){
const
path
=
urls
[
0
].
substring
(
0
,
urls
[
0
].
lastIndexOf
(
"
/
"
)
+
1
);
vod
.
subt
=
drives
.
getFile
(
path
+
urls
[
1
]).
raw_url
}
print
(
"
----play----
"
);
print
(
vod
);
return
JSON
.
stringify
(
vod
)}
function
search
(
wd
,
quick
){
print
(
__drives
);
print
(
"
可搜索的alist驱动:
"
+
searchDriver
);
if
(
!
searchDriver
){
return
JSON
.
stringify
({
list
:[]})}
else
{
let
driver
=
__drives
[
searchDriver
];
print
(
driver
);
let
surl
=
driver
.
server
+
"
/search?box=
"
+
wd
+
"
&url=
"
;
if
(
search_type
){
surl
+=
"
&type=
"
+
search_type
}
print
(
"
搜索链接:
"
+
surl
);
let
html
=
http
.
get
(
surl
).
text
();
let
lists
=
[];
try
{
lists
=
pdfa
(
html
,
"
div&&ul&&a
"
)}
catch
(
e
){}
print
(
`搜索结果数:
${
lists
.
length
}
,搜索结果显示数量限制:
${
limit_search_show
}
`
);
let
vods
=
[];
let
excludeReg
=
/
\.(
pdf|epub|mobi|txt|doc|lrc
)
$/
;
lists
.
forEach
(
it
=>
{
let
vhref
=
pdfh
(
it
,
"
a&&href
"
);
if
(
vhref
){
vhref
=
unescape
(
vhref
)}
if
(
excludeReg
.
test
(
vhref
)){
return
}
let
vid
=
searchDriver
+
"
$
"
+
vhref
+
"
#search#
"
;
vods
.
push
({
vod_name
:
pdfh
(
it
,
"
a&&Text
"
),
vod_id
:
vid
,
vod_pic
:
"
http://img1.3png.com/281e284a670865a71d91515866552b5f172b.png
"
,
vod_remarks
:
searchDriver
})});
vods
=
vods
.
slice
(
0
,
limit_search_show
);
print
(
vods
);
return
JSON
.
stringify
({
list
:
vods
})}}
function
get_size
(
sz
){
if
(
sz
<=
0
){
return
""
}
let
filesize
=
""
;
if
(
sz
>
1024
*
1024
*
1024
*
1024
){
sz
/=
1024
*
1024
*
1024
*
1024
;
filesize
=
"
TB
"
}
else
if
(
sz
>
1024
*
1024
*
1024
){
sz
/=
1024
*
1024
*
1024
;
filesize
=
"
GB
"
}
else
if
(
sz
>
1024
*
1024
){
sz
/=
1024
*
1024
;
filesize
=
"
MB
"
}
else
if
(
sz
>
1024
){
sz
/=
1024
;
filesize
=
"
KB
"
}
else
{
filesize
=
"
B
"
}
let
sizeStr
=
sz
.
toFixed
(
2
)
+
filesize
,
index
=
sizeStr
.
indexOf
(
"
.
"
),
dou
=
sizeStr
.
substr
(
index
+
1
,
2
);
if
(
dou
===
"
00
"
){
return
sizeStr
.
substring
(
0
,
index
)
+
sizeStr
.
substr
(
index
+
3
,
2
)}
else
{
return
sizeStr
}}
function
levenshteinDistance
(
str1
,
str2
){
return
100
-
100
*
distance
(
str1
,
str2
)
/
Math
.
max
(
str1
.
length
,
str2
.
length
)}
const
sortListByFirst
=
(
vodList
,
key
)
=>
{
key
=
key
||
"
vod_name
"
;
const
symbol_list
=
[];
const
cn_list
=
[];
const
en_list
=
[];
const
num_list
=
[];
vodList
.
forEach
(
vod
=>
{
const
{
vod_name
}
=
vod
;
if
(
/
[\u
4e00-
\u
9fa5
]
/
.
test
(
vod_name
[
0
])){
cn_list
.
push
(
vod
)}
else
if
(
/
[
a-zA-Z
]
/
.
test
(
vod_name
[
0
])){
en_list
.
push
(
vod
)}
else
if
(
/
[\d]
/
.
test
(
vod_name
[
0
])){
num_list
.
push
(
vod
)}
else
{
symbol_list
.
push
(
vod
)}});
const
newList
=
[...
cn_list
.
sort
((
a
,
b
)
=>
a
.
vod_name
[
0
]?.
localeCompare
(
b
.
vod_name
[
0
])),...
en_list
.
sort
((
a
,
b
)
=>
a
.
vod_name
[
0
].
localeCompare
(
b
.
vod_name
[
0
])),...
num_list
.
sort
((
a
,
b
)
=>
a
.
vod_name
[
0
]
-
b
.
vod_name
[
0
]),...
symbol_list
.
sort
((
a
,
b
)
=>
a
.
vod_name
[
0
]
-
b
.
vod_name
[
0
])];
return
newList
};
function
isAllChinese
(
str
){
return
/^
[\u
4E00-
\u
9FA5
]
+$/
.
test
(
str
)}
function
isChinese
(
char
){
return
/^
[\u
4E00-
\u
9FA5
]
$/
.
test
(
char
)}
const
sortListByName
=
(
vodList
,
key
,
order
)
=>
{
if
(
!
key
){
return
vodList
}
order
=
order
||
"
asc
"
;
let
ASCarr
=
vodList
.
sort
((
a
,
b
)
=>
{
a
=
a
[
key
];
b
=
b
[
key
];
if
(
typeof
a
===
"
number
"
&&
typeof
b
===
"
string
"
){
return
-
1
}
if
(
typeof
a
===
"
string
"
&&
typeof
b
===
"
number
"
){
return
1
}
if
(
isNaN
(
a
)
||
isNaN
(
b
)){
if
(
isAllChinese
(
a
)
&&!
isAllChinese
(
b
)){
return
1
}
if
(
!
isAllChinese
(
a
)
&&
isAllChinese
(
b
)){
return
-
1
}
a
=
a
.
toString
();
b
=
b
.
toString
();
let
result
=
0
;
for
(
let
index
=
0
;
index
<
(
a
.
length
-
b
.
length
?
b
.
length
:
a
.
length
);
index
++
){
if
(
!
isChinese
(
a
[
index
])
&&
isChinese
(
b
[
index
])){
result
=-
1
}
if
(
isChinese
(
a
[
index
])
&&!
isChinese
(
b
[
index
])){
result
=
1
}
if
(
isChinese
(
a
[
index
])
&&
isChinese
(
b
[
index
])){
let
pinyinA
=
getFirstLetterList
(
a
[
index
]).
toString
();
let
pinyinB
=
getFirstLetterList
(
b
[
index
]).
toString
();
result
=
pinyinA
.
localeCompare
(
pinyinB
,
"
zh-Hans-CN
"
,{
sensitivity
:
"
accent
"
})}
if
(
result
!==
0
){
break
}}
return
result
||
a
.
toString
().
localeCompare
(
b
.
toString
(),
"
zh-Hans-CN
"
,{
sensitivity
:
"
accent
"
})}
else
{
return
Number
(
a
)
-
Number
(
b
)}});
if
(
order
===
"
desc
"
){
ASCarr
.
reverse
()}
return
ASCarr
};
const
getTimeInt
=
timeStr
=>
{
return
new
Date
(
timeStr
).
getTime
()};
const
sortListByTime
=
(
vodList
,
key
,
order
)
=>
{
if
(
!
key
){
return
vodList
}
let
ASCarr
=
vodList
.
sort
((
a
,
b
)
=>
{
a
=
a
[
key
];
b
=
b
[
key
];
return
getTimeInt
(
a
)
-
getTimeInt
(
b
)});
if
(
order
===
"
desc
"
){
ASCarr
.
reverse
()}
return
ASCarr
};
const
sortListBySize
=
(
vodList
,
key
,
order
)
=>
{
if
(
!
key
){
return
vodList
}
let
ASCarr
=
vodList
.
sort
((
a
,
b
)
=>
{
a
=
a
[
key
];
b
=
b
[
key
];
return
(
Number
(
a
)
||
0
)
-
(
Number
(
b
)
||
0
)});
if
(
order
===
"
desc
"
){
ASCarr
.
reverse
()}
return
ASCarr
};
export
default
{
init
:
init
,
home
:
home
,
homeVod
:
homeVod
,
category
:
category
,
detail
:
detail
,
play
:
play
,
search
:
search
};
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录