Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
crawler.vmusicchart.vn
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
Phạm Văn Đoan
crawler.vmusicchart.vn
Commits
91b7bcc2
Commit
91b7bcc2
authored
Apr 16, 2020
by
Phạm Văn Đoan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tạo api lấy thông tin nhạc sĩ top 100 ở zing
parent
d30690e2
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
78 additions
and
0 deletions
+78
-0
Functions.php
app/Helpers/Functions.php
+29
-0
NctController.php
app/Http/Controllers/Api/NctController.php
+48
-0
api.php
routes/api.php
+1
-0
No files found.
app/Helpers/Functions.php
View file @
91b7bcc2
...
...
@@ -292,6 +292,35 @@ if (!function_exists('getZingSongInfoUrl')) {
}
}
if
(
!
function_exists
(
'getZingSongInfo'
))
{
function
getZingSongInfo
(
$api_url
)
{
$composer_name
=
[];
if
(
$api_url
)
{
$curl
=
curlZingMp3
(
$api_url
);
if
(
$curl
)
{
$response
=
json_decode
(
$curl
);
if
(
isset
(
$response
->
err
)
&&
$response
->
err
==
0
)
{
$data
=
$response
->
data
;
if
(
isset
(
$data
->
composers
))
{
$composers
=
$data
->
composers
;
foreach
(
$composers
as
$key
=>
$composer
)
{
$composer_name
[]
=
$composer
->
name
;
}
}
}
}
}
if
(
count
(
$composer_name
)
>
0
)
{
return
implode
(
', '
,
$composer_name
);
}
return
null
;
}
}
if
(
!
function_exists
(
'convertViews'
))
{
/**
* Hàm tính toán quy đổi lượt nghe thành điểm từ các hệ thống nhạc: zing/nc/nhacvn/keeng
...
...
app/Http/Controllers/Api/NctController.php
View file @
91b7bcc2
...
...
@@ -66,6 +66,54 @@ class NctController extends Controller
]);
}
/**
* API: http://localhost:8000/api/get-zing-top100
* Deploy: https://vmusicchart.vn/crawler/api/get-zing-top100
*
* @param Request $request
* @return \Illuminate\Http\JsonResponse
*/
public
function
getZingTop100
(
Request
$request
)
{
$url
=
config
(
'api.zing.playlist'
);
$curl
=
curlZingMp3
(
$url
);
$response
=
json_decode
(
$curl
);
//
$array_tracks
=
[];
if
(
isset
(
$response
->
data
)
&&
isset
(
$response
->
data
->
song
)
&&
isset
(
$response
->
data
->
song
->
items
))
{
$tracks
=
$response
->
data
->
song
->
items
;
if
(
$tracks
)
{
$index
=
0
;
foreach
(
$tracks
as
$key
=>
$track
)
{
if
(
$key
>=
50
)
{
$index
=
1
;
}
$array_tracks
[
$index
][]
=
$track
;
//$zing_id = $track->id;
//$api_url = getZingSongInfoUrl($zing_id);
//$array_composer[] = getZingSongInfo($api_url);
}
}
}
//
$array_composer
=
[];
if
(
count
(
$array_tracks
)
>
0
)
{
foreach
(
$array_tracks
as
$index
=>
$tracks
)
{
foreach
(
$tracks
as
$key
=>
$track
)
{
$zing_id
=
$track
->
id
;
$api_url
=
getZingSongInfoUrl
(
$zing_id
);
$array_composer
[]
=
getZingSongInfo
(
$api_url
);
}
}
}
return
response
()
->
json
([
'code'
=>
200
,
'message'
=>
'Lấy thông tin top 100 bài hát Zing thành công.'
,
'data'
=>
$array_composer
]);
}
private
function
privateGeTrackLink
(
$tracks_playlist
,
$track_id
)
{
if
(
is_array
(
$tracks_playlist
)
&&
count
(
$tracks_playlist
)
>
0
)
{
...
...
routes/api.php
View file @
91b7bcc2
...
...
@@ -18,3 +18,4 @@ Route::middleware('auth:api')->get('/user', function (Request $request) {
});
Route
::
get
(
'/get-nct-top100'
,
'Api\NctController@getNctTop100'
);
Route
::
get
(
'/get-zing-top100'
,
'Api\NctController@getZingTop100'
);
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