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
a077d701
Commit
a077d701
authored
Jun 16, 2020
by
Phạm Văn Đoan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix lỗi lấy lượt nghe từ zing
parent
4be75d07
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
4 deletions
+29
-4
CrawlerNctTrackListenCommand.php
app/Console/Commands/CrawlerNctTrackListenCommand.php
+6
-3
CrawlerTrackListenCommand.php
app/Console/Commands/CrawlerTrackListenCommand.php
+23
-1
No files found.
app/Console/Commands/CrawlerNctTrackListenCommand.php
View file @
a077d701
...
...
@@ -46,10 +46,12 @@ class CrawlerNctTrackListenCommand extends Command
public
function
handle
()
{
$from_page
=
'nct'
;
$limit
=
5
0
;
$limit
=
10
0
;
//$crawlered = $this->trackRepository->getCrawlerListenInserted($from_page, false);
$crawlered
=
CrawlerListenNct
::
groupBy
(
'track_id'
)
->
pluck
(
'track_id'
)
->
all
();
$yesterday
=
Carbon
::
yesterday
()
->
format
(
'Y-m-d'
);
$crawlered
=
CrawlerListenNct
::
groupBy
(
'track_id'
)
->
where
(
'date_chart'
,
'='
,
$yesterday
)
->
pluck
(
'track_id'
)
->
all
();
echo
"
\n
Tổng số bài hát đã lấy lượt nghe hôm nay: "
.
count
(
$crawlered
);
...
...
@@ -59,6 +61,7 @@ class CrawlerNctTrackListenCommand extends Command
echo
"
\n
Tổng số bài hát cần lấy lượt nghe: "
.
$total
;
$listen
=
[];
foreach
(
$inserted
as
$key
=>
$track
)
{
$listen
[]
=
$this
->
privateGetListen
(
$from_page
,
$track
);
echo
"
\n
"
.
(
$key
+
1
)
.
"/"
.
$total
.
": Đã lấy lịch sử lượt nghe bài hát có ID= "
.
$track
[
'id'
];
...
...
app/Console/Commands/CrawlerTrackListenCommand.php
View file @
a077d701
...
...
@@ -139,7 +139,7 @@ class CrawlerTrackListenCommand extends Command
break
;
case
'nct'
:
$url
=
getNctUrlGetCounter
(
$track
[
'id_nct'
]);
/*
$url = getNctUrlGetCounter($track['id_nct']);
$curl = cURL($url);
$response = json_decode($curl);
...
...
@@ -147,6 +147,28 @@ class CrawlerTrackListenCommand extends Command
if (isset($response->data) && isset($response->data->songs) && $response->data->songs->{$track['id_nct']} > 0) {
$listen = $response->data->songs->{$track['id_nct']};
}
}*/
/* Tính lượt nghe lấy data từ biểu đồ lượt nghe */
$url
=
getNctUrlGetCounterForChart
(
$track
[
'id_nct'
]);
$curl
=
cURL
(
$url
);
$response
=
json_decode
(
$curl
);
if
(
isset
(
$response
->
status
)
&&
$response
->
status
==
'Success'
)
{
if
(
isset
(
$response
->
dailyChart
)
&&
isset
(
$response
->
dateChart
)
&&
isset
(
$response
->
cumuChart
)
&&
is_array
(
$response
->
dailyChart
)
&&
is_array
(
$response
->
dateChart
)
&&
is_array
(
$response
->
cumuChart
))
{
/*foreach ($response->dailyChart as $key => $val) {
$listen[$key]['track_id'] = $track['id'];
$listen[$key]['daily_chart'] = $val;
$listen[$key]['date_chart'] = date('Y-m-d', strtotime(str_replace('/', '-', $response->dateChart[$key])));
$listen[$key]['cumu_chart'] = $response->cumuChart[$key];
}*/
//echo "\n " . end($response->cumuChart) . " | " . end($response->dailyChart) . " : " . $track['id_nct'];
$listen
=
end
(
$response
->
cumuChart
)
+
end
(
$response
->
dailyChart
);
}
}
break
;
...
...
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