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
0dd327a6
Commit
0dd327a6
authored
Apr 16, 2020
by
Phạm Văn Đoan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
xử lý cập nhật thông tin nhạc sĩ cho các bài hát từ zing
parent
7d4b30ac
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
88 additions
and
5 deletions
+88
-5
UpdateTrackArtistCommand.php
app/Console/Commands/Update/UpdateTrackArtistCommand.php
+62
-3
Functions.php
app/Helpers/Functions.php
+26
-2
No files found.
app/Console/Commands/Update/UpdateTrackArtistCommand.php
View file @
0dd327a6
...
...
@@ -84,13 +84,13 @@ class UpdateTrackArtistCommand extends Command
}
}
// Xử lý cập nhật
if
(
count
(
$track_id_singer
)
>
0
)
{
/*
if (count($track_id_singer) > 0) {
$track_db = Track::select(['id', 'id_zing', 'id_nct', 'id_keeng', 'title'])
->whereIn('id_zing', $track_id)
->get();
$this->privateUpdateTrackSinger($src, $track_db, $track_id_singer);
}
}
*/
// Lấy bài mới xuất bản --------------------------------------------------------------------------------
$track_id
=
[];
...
...
@@ -111,13 +111,38 @@ class UpdateTrackArtistCommand extends Command
}
}
// Xử lý cập nhật
if
(
count
(
$track_id_singer
)
>
0
)
{
/*
if (count($track_id_singer) > 0) {
$track_db = Track::select(['id', 'id_zing', 'id_nct', 'id_keeng', 'title'])
->whereIn('id_zing', $track_id)
->get();
$this->privateUpdateTrackSinger($src, $track_db, $track_id_singer);
}*/
// Xử lý cập nhật nhạc sĩ ------------------------------------------------------------------------------
echo
"
\n
Bắt đầu cập nhật Nhạc sĩ cho bài hát."
;
$array_zing_track
=
Track
::
select
([
'id'
,
'id_zing'
,
'singer_list'
,
'composer_list'
])
->
whereNotNull
(
'id_zing'
)
->
where
(
'id_zing'
,
'<>'
,
''
)
->
whereNull
(
'composer_list'
)
->
take
(
50
)
->
get
();
if
(
$array_zing_track
)
{
$track_id_composer
=
[];
foreach
(
$array_zing_track
as
$key
=>
$track
)
{
$url
=
getZingSongInfoUrl
(
$track
->
id_zing
);
$composer_list
=
$this
->
privateGetZingSongInfo
(
$url
);
if
(
$composer_list
)
{
$track_id_composer
[
$track
->
id
]
=
$composer_list
;
}
}
if
(
count
(
$track_id_composer
)
>
0
)
{
$this
->
privateUpdateTrackSinger
(
$src
,
$array_zing_track
,
[],
$track_id_composer
);
}
}
echo
"
\n
Kết thúc cập nhật Nhạc sĩ cho bài hát."
;
break
;
case
'nct'
:
$track_id
=
[];
...
...
@@ -246,4 +271,38 @@ class UpdateTrackArtistCommand extends Command
}
}
}
/**
* Hàm gọi api thông tin bài hát để lấy tên nhạc sĩ
*
* @param $api_url
* @return null|string
*/
private
function
privateGetZingSongInfo
(
$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
;
echo
"
\n
- Đang xử lý lấy nhạc sĩ của bài hát: "
.
$data
->
title
;
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
;
}
}
app/Helpers/Functions.php
View file @
0dd327a6
...
...
@@ -76,7 +76,7 @@ if (!function_exists('getDom')) {
}
if
(
!
function_exists
(
'curlZingMp3'
))
{
function
curlZingMp3
(
$url
)
{
function
curlZingMp3
(
$url
,
$is_get_song_info
=
false
)
{
$ch
=
curl_init
();
curl_setopt
(
$ch
,
CURLOPT_URL
,
$url
);
...
...
@@ -86,7 +86,11 @@ if (!function_exists('curlZingMp3')) {
curl_setopt
(
$ch
,
CURLOPT_ENCODING
,
'gzip, deflate'
);
$headers
=
array
();
$headers
[]
=
'Authority: mp3.zing.vn'
;
if
(
$is_get_song_info
)
{
$headers
[]
=
'Authority: zingmp3.vn'
;
}
else
{
$headers
[]
=
'Authority: mp3.zing.vn'
;
}
$headers
[]
=
'Cache-Control: max-age=0'
;
$headers
[]
=
'Upgrade-Insecure-Requests: 1'
;
$headers
[]
=
'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36'
;
...
...
@@ -268,6 +272,26 @@ if (!function_exists('getKeengUrlNewRealease')) {
}
}
if
(
!
function_exists
(
'getZingSongInfoUrl'
))
{
/**
* Hàm tạo URL để lấy thông tin bài hát theo chủ đề Pop Việt
* https://zingmp3.vn/api/song/get-song-info?id=ZWBW97D6&ctime=1586874275&sig=2024353481721f1238d558a63f76ed0b87563b91890bdda94764a7f2201ef29c4bf06bd4907312558c7d68f66f1b9c96bc1532f2670c1439b0531170d1caf225&api_key=38e8643fb0dc04e8d65b99994d3dafff
*
* @param $zing_id
* @return string
*/
function
getZingSongInfoUrl
(
$zing_id
)
{
$curl
=
curl
(
'http://edupham.com/api/v1/zing/get-song-info-url?zing_id='
.
$zing_id
);
if
(
$curl
)
{
$response
=
json_decode
(
$curl
);
if
(
isset
(
$response
->
data
))
{
return
$response
->
data
;
}
}
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
...
...
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