Skip to content

Commit

Permalink
Fix bug 'We are sorry, this song is removed"
Browse files Browse the repository at this point in the history
  • Loading branch information
thang-d committed Oct 22, 2018
1 parent 032a5cd commit d6cac1b
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions server/routes/api/media/song.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ module.exports = function getSong(req, res, next) {

co(function* () {
const html = yield request(`https://mp3.zing.vn/bai-hat/${name}/${id}.html`);
const regex = /media\/get-source\?type=audio&key=.{33}/; // get the resouce url
const regex = /key=.{33}/; // get the resouce url
const match = html.match(regex);

if (!match) throw new Error("can't find the resource URL");

const [matchUrl] = match;
const resource = yield request(`https://mp3.zing.vn/xhr/${matchUrl}`);
const resource = yield request(`https://mp3.zing.vn/xhr/media/get-source?type=audio&${matchUrl}`);
const data = JSON.parse(resource).data;
// data.lyric now is a url
if (!data.lyric.trim()) {
Expand Down

0 comments on commit d6cac1b

Please sign in to comment.