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
e0c7e6a2
Commit
e0c7e6a2
authored
Apr 06, 2020
by
Phạm Văn Đoan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cập nhật lấy thông tin nghệ sĩ từ keeng
parent
14804614
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
20 deletions
+62
-20
UpdateTrackArtistCommand.php
app/Console/Commands/Update/UpdateTrackArtistCommand.php
+61
-19
Constants.php
app/Helpers/Constants.php
+1
-1
No files found.
app/Console/Commands/Update/UpdateTrackArtistCommand.php
View file @
e0c7e6a2
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
App\Console\Commands\Update
;
namespace
App\Console\Commands\Update
;
use
App\Models\Track
;
use
App\Models\Track
;
use
App\Models\TrackArtist
;
use
App\Models\TrackUser
;
use
App\Models\TrackUser
;
use
App\Repositories\TrackRepository
;
use
App\Repositories\TrackRepository
;
use
App\User
;
use
App\User
;
...
@@ -64,7 +65,7 @@ class UpdateTrackArtistCommand extends Command
...
@@ -64,7 +65,7 @@ class UpdateTrackArtistCommand extends Command
switch
(
$src
)
{
switch
(
$src
)
{
case
'zing'
:
case
'zing'
:
$track_id
=
[];
$track_id
=
[];
$track_id_
fullname
=
[];
$track_id_
singer
=
[];
// Lấy playlist ----------------------------------------------------------------------------------------
// Lấy playlist ----------------------------------------------------------------------------------------
$url
=
config
(
'api.zing.chart_realtime'
);
$url
=
config
(
'api.zing.chart_realtime'
);
$curl
=
curlZingMp3
(
$url
);
$curl
=
curlZingMp3
(
$url
);
...
@@ -74,22 +75,22 @@ class UpdateTrackArtistCommand extends Command
...
@@ -74,22 +75,22 @@ class UpdateTrackArtistCommand extends Command
foreach
(
$tracks
as
$key
=>
$track
)
{
foreach
(
$tracks
as
$key
=>
$track
)
{
if
(
isset
(
$track
->
title
)
&&
isset
(
$track
->
artists_names
)
&&
!
empty
(
$track
->
artists_names
))
{
if
(
isset
(
$track
->
title
)
&&
isset
(
$track
->
artists_names
)
&&
!
empty
(
$track
->
artists_names
))
{
$track_id
[]
=
$track
->
id
;
$track_id
[]
=
$track
->
id
;
$track_id_
fullname
[
$track
->
id
]
=
$track
->
artists_names
;
$track_id_
singer
[
$track
->
id
]
=
$track
->
artists_names
;
}
}
}
}
}
}
// Xử lý cập nhật
// Xử lý cập nhật
if
(
count
(
$track_id_
fullname
)
>
0
)
{
if
(
count
(
$track_id_
singer
)
>
0
)
{
$track_db
=
Track
::
select
([
'id'
,
'id_zing'
,
'title'
])
$track_db
=
Track
::
select
([
'id'
,
'id_zing'
,
'
id_nct'
,
'id_keeng'
,
'
title'
])
->
whereIn
(
'id_zing'
,
$track_id
)
->
whereIn
(
'id_zing'
,
$track_id
)
->
get
();
->
get
();
$this
->
privateUpdateTrackSinger
(
$src
,
$track_db
,
$track_id_
fullname
);
$this
->
privateUpdateTrackSinger
(
$src
,
$track_db
,
$track_id_
singer
);
}
}
// Lấy bài mới xuất bản --------------------------------------------------------------------------------
// Lấy bài mới xuất bản --------------------------------------------------------------------------------
$track_id
=
[];
$track_id
=
[];
$track_id_
fullname
=
[];
$track_id_
singer
=
[];
$url_new_release
=
config
(
'api.zing.new_release'
);
$url_new_release
=
config
(
'api.zing.new_release'
);
$curl_new_release
=
curlZingMp3
(
$url_new_release
);
$curl_new_release
=
curlZingMp3
(
$url_new_release
);
...
@@ -100,23 +101,23 @@ class UpdateTrackArtistCommand extends Command
...
@@ -100,23 +101,23 @@ class UpdateTrackArtistCommand extends Command
foreach
(
$tracks_new_release
as
$key
=>
$track
)
{
foreach
(
$tracks_new_release
as
$key
=>
$track
)
{
if
(
isset
(
$track
->
title
)
&&
isset
(
$track
->
artists_names
)
&&
!
empty
(
$track
->
artists_names
))
{
if
(
isset
(
$track
->
title
)
&&
isset
(
$track
->
artists_names
)
&&
!
empty
(
$track
->
artists_names
))
{
$track_id
[]
=
$track
->
id
;
$track_id
[]
=
$track
->
id
;
$track_id_
fullname
[
$track
->
id
]
=
$track
->
artists_names
;
$track_id_
singer
[
$track
->
id
]
=
$track
->
artists_names
;
}
}
}
}
}
}
// Xử lý cập nhật
// Xử lý cập nhật
if
(
count
(
$track_id_
fullname
)
>
0
)
{
if
(
count
(
$track_id_
singer
)
>
0
)
{
$track_db
=
Track
::
select
([
'id'
,
'id_zing'
,
'title'
])
$track_db
=
Track
::
select
([
'id'
,
'id_zing'
,
'
id_nct'
,
'id_keeng'
,
'
title'
])
->
whereIn
(
'id_zing'
,
$track_id
)
->
whereIn
(
'id_zing'
,
$track_id
)
->
get
();
->
get
();
$this
->
privateUpdateTrackSinger
(
$src
,
$track_db
,
$track_id_
fullname
);
$this
->
privateUpdateTrackSinger
(
$src
,
$track_db
,
$track_id_
singer
);
}
}
break
;
break
;
case
'nct'
:
case
'nct'
:
$track_id
=
[];
$track_id
=
[];
$track_id_
fullname
=
[];
$track_id_
singer
=
[];
// Lấy top 100 -----------------------------------------------------------------------------------------
// Lấy top 100 -----------------------------------------------------------------------------------------
$url
=
config
(
'api.nct.top100'
);
$url
=
config
(
'api.nct.top100'
);
$url_playlist_top100
=
config
(
'api.nct.playlist_top100'
);
$url_playlist_top100
=
config
(
'api.nct.playlist_top100'
);
...
@@ -125,21 +126,48 @@ class UpdateTrackArtistCommand extends Command
...
@@ -125,21 +126,48 @@ class UpdateTrackArtistCommand extends Command
foreach
(
$tracks
as
$key
=>
$track
)
{
foreach
(
$tracks
as
$key
=>
$track
)
{
if
(
isset
(
$track
[
'title'
])
&&
isset
(
$track
[
'singer'
]))
{
if
(
isset
(
$track
[
'title'
])
&&
isset
(
$track
[
'singer'
]))
{
$track_id
[]
=
$track
[
'id_nct'
];
$track_id
[]
=
$track
[
'id_nct'
];
$track_id_
fullname
[
$track
[
'id_nct'
]]
=
$track
[
'singer'
];
$track_id_
singer
[
$track
[
'id_nct'
]]
=
$track
[
'singer'
];
}
}
}
}
}
}
if
(
count
(
$track_id_
fullname
)
>
0
)
{
if
(
count
(
$track_id_
singer
)
>
0
)
{
$track_db
=
Track
::
select
([
'id'
,
'id_zing'
,
'id_nct'
,
'id_keeng'
,
'title'
])
$track_db
=
Track
::
select
([
'id'
,
'id_zing'
,
'id_nct'
,
'id_keeng'
,
'title'
])
->
whereIn
(
'id_nct'
,
$track_id
)
->
whereIn
(
'id_nct'
,
$track_id
)
->
get
();
->
get
();
$this
->
privateUpdateTrackSinger
(
$src
,
$track_db
,
$track_id_
fullname
);
$this
->
privateUpdateTrackSinger
(
$src
,
$track_db
,
$track_id_
singer
);
}
}
break
;
break
;
case
'keeng'
:
case
'keeng'
:
$track_id
=
[];
$track_id_singer
=
[];
$track_id_composer
=
[];
//
$url
=
getKeengUrlNewRealease
(
1
,
500
);
$curl
=
cURL
(
$url
);
$data
=
json_decode
(
$curl
);
$tracks
=
$data
->
data
;
if
(
$tracks
)
{
foreach
(
$tracks
as
$key
=>
$track
)
{
if
(
isset
(
$track
->
identify
)
&&
isset
(
$track
->
singer
)
&&
!
empty
(
$track
->
singer
))
{
$track_id
[]
=
$track
->
identify
;
$track_id_singer
[
$track
->
identify
]
=
$track
->
singer
;
$composer
=
(
isset
(
$track
->
info_extra
)
&&
isset
(
$track
->
info_extra
->
author_name
))
?
$track
->
info_extra
->
author_name
:
'?'
;
$track_id_composer
[
$track
->
identify
]
=
$composer
;
}
}
}
// Xử lý cập nhật
if
(
count
(
$track_id_singer
)
>
0
)
{
$track_db
=
Track
::
select
([
'id'
,
'id_zing'
,
'id_nct'
,
'id_keeng'
,
'title'
])
->
whereIn
(
'id_keeng'
,
$track_id
)
->
get
();
$this
->
privateUpdateTrackSinger
(
$src
,
$track_db
,
$track_id_singer
,
$track_id_composer
);
}
//print_r($track_id_composer); die();
break
;
break
;
case
'all'
:
case
'all'
:
...
@@ -147,12 +175,10 @@ class UpdateTrackArtistCommand extends Command
...
@@ -147,12 +175,10 @@ class UpdateTrackArtistCommand extends Command
default
:
default
:
}
}
//print_r($track_id_fullname); die();
echo
"
\n
Kết thúc cập nhật ca sĩ cho bài hát.
\n
"
;
echo
"
\n
Kết thúc cập nhật ca sĩ cho bài hát.
\n
"
;
}
}
private
function
privateUpdateTrackSinger
(
$src
,
$track_db
,
$track_id_
fullname
)
private
function
privateUpdateTrackSinger
(
$src
,
$track_db
,
$track_id_
singer
,
$track_id_composer
=
null
)
{
{
echo
"
\n
Cập nhật cho tổng số bài: "
.
$track_db
->
count
();
echo
"
\n
Cập nhật cho tổng số bài: "
.
$track_db
->
count
();
...
@@ -164,7 +190,7 @@ class UpdateTrackArtistCommand extends Command
...
@@ -164,7 +190,7 @@ class UpdateTrackArtistCommand extends Command
default
:
return
false
;
default
:
return
false
;
}
}
$user
=
User
::
updateOrCreate
(
$user
=
User
::
updateOrCreate
(
[
'full_name'
=>
$track_id_
fullname
[
$src_track_id
]],
[
'full_name'
=>
$track_id_
singer
[
$src_track_id
]],
[
'user_type'
=>
2
,
'updated_at'
=>
Carbon
::
now
()]
[
'user_type'
=>
2
,
'updated_at'
=>
Carbon
::
now
()]
);
);
...
@@ -173,9 +199,25 @@ class UpdateTrackArtistCommand extends Command
...
@@ -173,9 +199,25 @@ class UpdateTrackArtistCommand extends Command
'track_id'
=>
$track
->
id
,
'track_id'
=>
$track
->
id
,
'user_id'
=>
$user
->
id
'user_id'
=>
$user
->
id
],
],
[
'name'
=>
$track_id_
fullname
[
$src_track_id
]]
[
'name'
=>
$track_id_
singer
[
$src_track_id
]]
);
);
// Cập nhật sáng tác
switch
(
$src
)
{
case
'zing'
:
break
;
case
'nct'
:
break
;
case
'keeng'
:
TrackArtist
::
updateOrCreate
(
[
'track_id'
=>
$track
->
id
,
'user_id'
=>
$user
->
id
],
[
'name'
=>
$track_id_composer
[
$src_track_id
]]
);
break
;
default
:
}
echo
"
\n
- Cập nhật xong Ca sĩ (ID:
$user->id
) cho bài hát (ID:
$track->id
)"
;
echo
"
\n
- Cập nhật xong Ca sĩ (ID:
$user->id
) cho bài hát (ID:
$track->id
)"
;
}
}
}
}
...
...
app/Helpers/Constants.php
View file @
e0c7e6a2
...
@@ -32,7 +32,7 @@ class Constants
...
@@ -32,7 +32,7 @@ class Constants
const
TABLE_ROLE_USER
=
'role_user'
;
const
TABLE_ROLE_USER
=
'role_user'
;
const
TABLE_ROLES
=
'roles'
;
const
TABLE_ROLES
=
'roles'
;
const
TABLE_TRACK_ARTIST
=
'track_artist'
;
const
TABLE_TRACK_ARTIST
=
'track_artist
s
'
;
const
TABLE_TRACK_USER
=
'track_user'
;
const
TABLE_TRACK_USER
=
'track_user'
;
const
TABLE_TRACKS
=
'tracks'
;
const
TABLE_TRACKS
=
'tracks'
;
...
...
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