Commit d4050713 by Phạm Văn Đoan

tối ưu code lấy track từ NCT, xóa phần thừa

parent 904cf140
......@@ -61,7 +61,7 @@ class NctCrawlerTrackCommand extends Command
$tracks = $this->trackRepository->processNctGetTrackInfoFromTop100($url);
$tracks_playlist = $this->trackRepository->processNctGetTrackInfoFromTop100Playlist($url_playlist_top100);
print_r($tracks); return false;
if (count($tracks) == 0) return false;
$key_insert = 0;
......
......@@ -85,9 +85,9 @@ class Kernel extends ConsoleKernel
$schedule->command('crawler:get-listen zing --limit=-1')->dailyAt('22:50');
$schedule->command('calculate:daily-listen')->dailyAt('1:00');
//$schedule->command('calculate:daily-listen')->dailyAt('1:10');
$schedule->command('calculate:daily-listen')->dailyAt('1:10');
$schedule->command('calculate:report daily')->dailyAt('8:54');
$schedule->command('calculate:report daily')->dailyAt('8:05');
$schedule->command('calculate:report weekly')->sundays();
$schedule->command('calculate:report monthly')->monthlyOn(21, '6:10');
......
......@@ -87,32 +87,32 @@ class TrackRepository extends BaseRepository
/* Lấy tên bài hát ------------------------------------------------------------------------------------------ */
$element_track_title = 'div.box_info_field h3.h3 a';
foreach ($dom->find($element_track_title) as $data) {
$tracks['title'][] = str_replace(['<h2 class="card-header">', '</h2>'], ['', ''], $data->innertext);
$tracks['title'][] = str_replace([], [], $data->innertext);
}
/* Lấy đường dẫn ảnh của bài hát ---------------------------------------------------------------------------- */
$element_track_img = 'div.box_info_field a img';
foreach ($dom->find($element_track_img) as $data) {
$tracks['img'][] = str_replace(['<h2 class="card-header">', '</h2>'], ['', ''], $data->{"data-src"});
$tracks['img'][] = str_replace([], [], $data->{"data-src"});
}
/* Lấy link bài hát ----------------------------------------------------------------------------------------- */
$element_track_link = 'div.box_info_field h3.h3 a';
foreach ($dom->find($element_track_link) as $data) {
$link = str_replace(['<h2 class="card-header">', '</h2>'], ['', ''], $data->href);
$link = str_replace([], [], $data->href);
$tracks['link'][] = $link;
}
/* Lấy tên ca sĩ hát ---------------------------------------------------------------------------------------- */
$element_track_singer = 'div.box_info_field h4.list_name_singer a';
foreach ($dom->find($element_track_singer) as $data) {
$tracks['singer'][] = str_replace(['<h2 class="card-header">', '</h2>'], ['', ''], $data->innertext);
$tracks['singer'][] = str_replace([], [], $data->innertext);
}
/* Lấy url thông tin cá nhân ca sĩ -------------------------------------------------------------------------- */
$element_singer_profile = 'div.box_info_field h4.list_name_singer a';
foreach ($dom->find($element_singer_profile) as $data) {
$tracks['url_profile'][] = str_replace(['<h2 class="card-header">', '</h2>'], ['', ''], $data->href);
$tracks['url_profile'][] = str_replace([], [], $data->href);
}
/* Lấy ID dạng chuỗi của bài hát ---------------------------------------------------------------------------- */
......
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