Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
media-resource
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
杨昕
media-resource
Commits
f91c4d5d
Commit
f91c4d5d
authored
Jul 27, 2020
by
杨昕
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加定时脚本处理
parent
1c5fd782
Pipeline
#10084
passed with stages
in 39 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
99 additions
and
0 deletions
+99
-0
MediaController.php
app/Http/Controllers/Api/Client/MediaController.php
+22
-0
MediaModel.php
app/Model/MediaModel.php
+74
-0
api.php
routes/api.php
+3
-0
No files found.
app/Http/Controllers/Api/Client/MediaController.php
View file @
f91c4d5d
...
@@ -188,5 +188,27 @@ class MediaController extends Controller
...
@@ -188,5 +188,27 @@ class MediaController extends Controller
}
}
/**
* @param Request $request
* @return \Illuminate\Http\JsonResponse
* @throws \App\Exceptions\ControllerException
*/
public
function
handleMediaUrl
(
Request
$request
){
$res
=
handler_drive
(
function
()
use
(
$request
){
SrsHookValidate
::
srsHookCallback
(
$request
,[
'media_name'
=>
''
,
'username'
=>
''
,
'page'
=>
'integer'
,
'media_id'
=>
''
,
'description'
=>
''
,
'sort'
=>
''
,
'page_size'
=>
'integer'
,
]);
return
MediaModel
::
handleMediaUrl
(
$request
);
});
return
success
(
$res
);
}
}
}
app/Model/MediaModel.php
View file @
f91c4d5d
...
@@ -21,6 +21,8 @@ class MediaModel extends Eloquent
...
@@ -21,6 +21,8 @@ class MediaModel extends Eloquent
protected
$fillable
=
[];
protected
$fillable
=
[];
public
$timestamps
=
false
;
public
function
media_category
()
public
function
media_category
()
...
@@ -388,4 +390,76 @@ class MediaModel extends Eloquent
...
@@ -388,4 +390,76 @@ class MediaModel extends Eloquent
return
$media
;
return
$media
;
}
}
public
static
function
handleMediaUrl
(
$request
){
try
{
$medias
=
MediaModel
::
query
()
->
raw
(
function
(
$collection
)
use
(
$request
){
$limit
=
(
isset
(
$request
->
page_size
)
?
(
int
)(
$request
->
page_size
)
:
Constant
::
PAGE_NUMBER
)
;
$page
=
$request
->
page
??
1
;
/**
* 默认降序
*/
$sort
=
-
1
;
if
(
$request
->
sort
==
'asc'
){
$sort
=
1
;
}
if
(
isset
(
$request
->
media_id
)
&&
!
empty
(
$request
->
media_id
)){
$aggregate
[][
'$match'
][
'_id'
]
=
$request
->
media_id
;
}
if
(
isset
(
$request
->
media_name
)
&&
!
empty
(
$request
->
media_name
)){
$aggregate
[][
'$match'
][
'media_url'
]
=
[
'$regex'
=>
'https://qcoenfz67.bkt.clouddn.com'
];
}
if
(
isset
(
$request
->
username
)
&&
!
empty
(
$request
->
username
)){
$aggregate
[][
'$match'
][
'username'
]
=
$request
->
username
;
}
$aggregate
[][
'$sort'
]
=
[
'start_time'
=>
$sort
];
$count
=
sizeof
(
$collection
->
aggregate
(
$aggregate
)
->
toArray
());
$skip
=
((
empty
(
$request
->
page
)
?
1
:
$request
->
page
)
-
1
)
*
$limit
;
$aggregate
[][
'$skip'
]
=
$skip
;
$aggregate
[][
'$limit'
]
=
$limit
;
return
new
LengthAwarePaginator
(
$collection
->
aggregate
(
$aggregate
)
->
toArray
(),
$count
,
$limit
,
$page
,[
'path'
=>
Paginator
::
resolveCurrentPath
(),
'pageName'
=>
'page'
,
]);
});
if
(
!
empty
(
$medias
)){
foreach
(
$medias
as
$media
){
$data
=
[
'media_url'
=>
"https://vod-mam.eoffcn.com/"
.
$media
->
_id
.
'/index.m3u8'
,
];
$flag
=
MediaModel
::
where
(
"_id"
,
$media
->
_id
)
->
update
(
$data
);
if
(
$flag
==
0
){
throw
new
\Exception
(
"更新失败"
);
}
}
}
}
catch
(
\Exception
$exception
){
throw
new
DatabaseException
(
$exception
->
getMessage
());
}
return
$medias
;
}
}
}
routes/api.php
View file @
f91c4d5d
...
@@ -43,5 +43,7 @@ Route::group(['namespace' => 'Api', 'prefix' => 'user'], function () {
...
@@ -43,5 +43,7 @@ Route::group(['namespace' => 'Api', 'prefix' => 'user'], function () {
Route
::
post
(
"media_list"
,
"MediaController@media_list"
);
Route
::
post
(
"media_list"
,
"MediaController@media_list"
);
Route
::
get
(
"play_url/
{
id
}
"
,
"MediaController@play_url"
);
Route
::
get
(
"play_url/
{
id
}
"
,
"MediaController@play_url"
);
Route
::
get
(
"media_url_change"
,
"Client\MediaController@handleMediaUrl"
);
});
});
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment