#ifndef MONSTERCAT_DL_H_ #define MONSTERCAT_DL_H_ #include #include #include #include "json.hpp" constexpr bool FORMAT_MP3 = true; constexpr bool FORMAT_FLAC = false; struct Track { public: int number; std::string artist; std::string title; std::string id; std::string extended_mix_file_id; std::string extended_mix_extension; }; struct Release { std::string type; std::string release_date; std::string artist; std::string title; std::vector tracks; std::string id; std::string catalog_id; }; class Monstercat_DL { private: std::ostream *m_log; std::string m_base_url; bool m_is_logged_in; std::string calc_proper_artist(const std::string& artist_raw); std::string calc_proper_title(const std::string& artist_raw, const std::string& title_raw, const std::string& version_raw); public: Monstercat_DL(); ~Monstercat_DL(); bool login(const std::string& user, const std::string& pass); bool logout(); nlohmann::json get_release_json(const std::string& catalog_id); nlohmann::json get_browse_json(const std::string& release_id); Release parse_release_json(const nlohmann::json& release_json); void add_extended_mixes(Release& release, const nlohmann::json& browse_json); std::string calc_release_folder(const Release& release, const std::string& main_folder); std::string calc_track_filename(const Release& release, int track_num); bool download_cover(const std::string& catalog_id, const std::string& path); bool download_track(const std::string& release_id, const std::string& track_id, const std::string& filepath, bool is_mp3); bool download_file(const std::string& file_id, const std::string& filepath); }; #endif // MONSTERCAT_DL_H_