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
daebf8fa
Commit
daebf8fa
authored
May 14, 2020
by
Phạm Văn Đoan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cập nhật tải ảnh bài hát vào thư mục tháng hiện tại
nếu chưa có thư mục thì tạo
parent
c5ebd33b
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
3 deletions
+11
-3
CrawlerTrackImageCommand.php
app/Console/Commands/CrawlerTrackImageCommand.php
+11
-3
No files found.
app/Console/Commands/CrawlerTrackImageCommand.php
View file @
daebf8fa
...
@@ -42,6 +42,7 @@ class CrawlerTrackImageCommand extends Command
...
@@ -42,6 +42,7 @@ class CrawlerTrackImageCommand extends Command
/**
/**
* Execute the console command.
* Execute the console command.
* Cập nhật lưu vào thư mục của năm/tháng hiện tại - 14/05/2020
*
*
* @return mixed
* @return mixed
*/
*/
...
@@ -52,24 +53,31 @@ class CrawlerTrackImageCommand extends Command
...
@@ -52,24 +53,31 @@ class CrawlerTrackImageCommand extends Command
echo
"
\n
Tổng số bài hát cần lấy ảnh về: "
.
count
(
$tracks
);
echo
"
\n
Tổng số bài hát cần lấy ảnh về: "
.
count
(
$tracks
);
if
(
is_array
(
$tracks
)
&&
count
(
$tracks
)
>
0
)
{
if
(
is_array
(
$tracks
)
&&
count
(
$tracks
)
>
0
)
{
/* Kiểm tra đường dẫn tháng hiện tại, chưa có thì tạo mới */
$current_month
=
date
(
'Y/m'
);
$save_path
=
Constants
::
VMUSICCHART_IMG_TRACKS
.
$current_month
;
if
(
!
file_exists
(
$save_path
))
{
mkdir
(
$save_path
,
0755
,
true
);
}
/* Duyệt bài còn thiếu ảnh để tải về thư mục tháng hiện tại */
foreach
(
$tracks
as
$key
=>
$track
)
{
foreach
(
$tracks
as
$key
=>
$track
)
{
if
(
$track
[
'src_thumbnail_medium'
])
{
if
(
$track
[
'src_thumbnail_medium'
])
{
$file_name
=
md5
(
$track
[
'id'
])
.
'.png'
;
$file_name
=
md5
(
$track
[
'id'
])
.
'.png'
;
$file_path
=
Constants
::
VMUSICCHART_IMG_TRACKS
.
$file_name
;
$file_path
=
$save_path
.
'/'
.
$file_name
;
@
copy
(
Constants
::
VMUSICCHART_IMG_EMPTY_PNG
,
$file_path
);
@
copy
(
Constants
::
VMUSICCHART_IMG_EMPTY_PNG
,
$file_path
);
@
file_put_contents
(
$file_path
,
@
file_get_contents
(
$track
[
'src_thumbnail_medium'
]));
@
file_put_contents
(
$file_path
,
@
file_get_contents
(
$track
[
'src_thumbnail_medium'
]));
$track
=
Track
::
find
(
$track
[
'id'
]);
$track
=
Track
::
find
(
$track
[
'id'
]);
if
(
$track
)
{
if
(
$track
)
{
$track
->
art
=
Constants
::
VMUSICCHART_IMG_TRACKS_DB
.
$file_name
;
$track
->
art
=
Constants
::
VMUSICCHART_IMG_TRACKS_DB
.
$
current_month
.
'/'
.
$
file_name
;
$track
->
save
();
$track
->
save
();
}
}
}
}
}
}
}
}
echo
"
\n
Tải ảnh kết thúc."
;
echo
"
\n
Tải ảnh kết thúc.
\n
"
;
// Ghi log
// Ghi log
Crontjob
::
create
([
'message'
=>
'CrawlerTrackImageCommand is called at '
.
Carbon
::
now
()]);
Crontjob
::
create
([
'message'
=>
'CrawlerTrackImageCommand is called at '
.
Carbon
::
now
()]);
...
...
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