Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calculate explicit percentage #46

Open
raad1masum opened this issue Nov 1, 2021 · 1 comment
Open

Calculate explicit percentage #46

raad1masum opened this issue Nov 1, 2021 · 1 comment
Assignees

Comments

@raad1masum
Copy link
Owner

No description provided.

@raad1masum
Copy link
Owner Author

public double getExplicitPercent(JSONObject obj) {
    JSONArray tracks = obj.getJSONObject("tracks").getJSONArray("items");

    double count = 0;
    double total = tracks.length();

    for (int i = 0; i < tracks.length(); i++) {
        if (tracks.getJSONObject(i).getJSONObject("track").getBoolean("explicit"))
           ++count;
    }

    double percent = count / total * 100;

    return Math.round(percent * 100.0) / 100.0;
}

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants