{"size": 1423, "ext": "js", "max_stars_repo_path": "src/core/utils/qobuzhelper.js", "max_stars_repo_name": "crackhub-dev/music-dl-bot", "max_stars_repo_stars_event_min_datetime": "2022-02-16T14:05:51.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T06:13:23.000Z", "max_issues_repo_path": "src/core/utils/qobuzhelper.js", "max_issues_repo_name": "crackhub-dev/music-dl-bot", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/core/utils/qobuzhelper.js", "max_forks_repo_name": "crackhub-dev/music-dl-bot", "max_forks_repo_forks_event_min_datetime": "2022-03-07T01:32:37.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-28T17:53:41.000Z"}
{"max_stars_count": 31, "max_issues_count": null, "max_forks_count": 4, "avg_line_length": 37.4473684211, "max_line_length": 93, "alphanum_fraction": 0.392832045}
const cheerio = require('cheerio');
const axios = require('axios');

module.exports = {
    async findq(link, callback) {
        axios.get(link).then(response => {
            const $ = cheerio.load(response.data);
            try {
                const title = $('.album-meta__title').text();
                const artist = $('.album-meta__artist').text();
                const res = axios.get(`https://www.qobuz.com/api.json/0.2/catalog/search`, {
                    headers: {
                        'X-App-Id': '', // qobuz X-App-Id Header
                        'X-User-Auth-Token': '', //qobuz X-User-Auth-Token Header
                    },
                    params: { query: `${title} ${artist}`, offset: '0', limit: '10' },
                }).then(res => {
                    let albums = res.data.albums.items;
                    albums.forEach(album => {
                        if (album.title == title && album.artist.name == artist) {
                            let album_id = album.id;
                            let url = `https://play.qobuz.com/album/${album_id}`
                            return callback(url);
                        } else {
                            return callback(link)
                        }
                    })
                })
            } catch (err) {
                return err;
            }

        })



    }
}