listen1

const listen1Api = require('../dist/listen1-api');
const express = require('express');

function search(song_name, platform) {

    let search = '/search?source=' + platform + '&keywords=' + song_name;
    let bootstrap_track = '/bootstrap_track?track_id=';
    let lyric = '/lyric?track_id=';

    listen1Api.apiGet(search).then((data) => {
        let song_id = [];
        data.result.forEach((value) => {
            song_id.push(value.id);
            console.log(data);
        });
        return song_id;
    }).then((song_id) => {
        song_id.forEach(value => {
            listen1Api.apiGet(bootstrap_track + value).then((data) => {
                console.log(data);
            });
        });
    });
}

search("Baby", "qq");
const listen1Api = require('../dist/listen1-api');
const express = require('express');

function search(song_name, platform) {

    let search = '/search?source=' + platform + '&keywords=' + song_name;
    let bootstrap_track = '/bootstrap_track?track_id=';
    let lyric = '/lyric?track_id=';

    listen1Api.apiGet(search)
        .then((data) => {
            let song = [];
            data.result.forEach((value) => {
                song.push(value);
            });
            return song;
        }).then((song) => {
            for (let i = 0; i < song.length; i++) {
                listen1Api.apiGet(bootstrap_track + song[i].id).then((data) => {
                    song[i].song_url = data.url;
                    return song[i];
                }).then((song) => {
                    console.log(song)
                    console.log("+++++++++++++++++++++++++++++++++++++++++++++++++++++++++")
                })


            }
        });
}


search("gaobaiqiqiu", "qq");

你可能感兴趣的:(算法,JavaScript)