Commit 560f1295 by Phạm Văn Đoan

test api NCT

parent f9de4f5d
......@@ -66,6 +66,53 @@ class NctController extends Controller
]);
}
public function getNctTop100AsComma(Request $request)
{
$url = config('api.nct.top100');
$url_playlist_top100 = config('api.nct.playlist_top100');
$tracks = $this->trackRepository->processNctGetTrackInfoFromTop100($url);
$tracks_playlist = $this->trackRepository->processNctGetTrackInfoFromTop100Playlist($url_playlist_top100);
$tracks_nct = Track::select(['id', 'id_nct', 'composer_list'])
->whereNotNull('id_nct')
->where('id_nct', '<>', '')
->get();
$array_tracks_nct = [];
foreach ($tracks_nct as $track) {
$array_tracks_nct[$track['id_nct']] = $track['composer_list'];
}
$response = null;
foreach ($tracks as $key => $track) {
$link = null;
$duration = 0;
$check = $this->privateGeTrackLink($tracks_playlist, $track['id_nct']);
if ($check) {
$link = $check['link'];
$duration = $check['duration'];
}
$response[] = $track;
$response[$key]['link'] = $link;
$response[$key]['duration'] = $duration;
$response[$key]['str_duration'] = gmdate('i:s', $duration);
if (array_key_exists($track['id_nct'], $array_tracks_nct)) {
$response[$key]['composer'] = $array_tracks_nct[$track['id_nct']];
} else {
$response[$key]['composer'] = '?';
}
echo $track['title'] . "," . $track['id_nct'] . "," . $track['id_nct_str'] . "," . $track['singer'] . '<br>';
}
die();
/*return response()->json([
'code' => 200,
'message' => 'Lấy thông tin top 100 bài hát NCT thành công.',
'data' => $response
]);*/
}
/**
* API: http://localhost:8000/api/get-zing-top100
* Deploy: https://vmusicchart.vn/crawler/api/get-zing-top100
......
......@@ -21,3 +21,4 @@ Route::get('/get-nct-top100', 'Api\NctController@getNctTop100');
Route::get('/get-zing-top100', 'Api\NctController@getZingTop100');
Route::get('/get-listen-history-by-date', 'Api\ListenHistoryController@getListenHistoryByDate');
Route::get('/get-track-list', 'Api\TrackController@getTrackList');
Route::get('/get-nct-top100-as-comma', 'Api\TrackController@getNctTop100AsComma');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment