Discman
Loading...
Searching...
No Matches
spotify.h
Go to the documentation of this file.
1
6
7#ifndef SPOTIFY_H
8#define SPOTIFY_H
9
10#include <string>
11#include <vector>
12#include <iomanip>
13
14#include <glibmm.h>
15#include <giomm/memoryinputstream.h>
16#include <gdkmm/pixbuf.h>
17#include <curlpp/Easy.hpp>
18#include <curlpp/Options.hpp>
19#include <curlpp/Infos.hpp>
20#include <curlpp/cURLpp.hpp>
21#include <json/value.h>
22#include <json/reader.h>
23#include <json/writer.h>
24#include <openssl/bio.h>
25#include <openssl/evp.h>
26#include <openssl/buffer.h>
27
28#include "album_art_provider.h"
29
31class Spotify : public AlbumArtProvider {
32 public:
33
38
40 static constexpr const char* BASE_URL = "https://api.spotify.com/v1/";
41
43 Spotify();
44
46 // and uses them to retrieve an API key.
47 void init() override;
48
55 std::vector<AlbumArt> album_art(const std::string& artist, const std::string& title, const int width, const int height) override;
56
57 private:
59 static std::string _accessToken;
60
64 static std::string method_name(const Method method);
65
69 static std::string base64_encode(const std::string& input);
70
75 static std::string url(const Method method, const std::map<std::string, std::string>& params);
76};
77
78#endif // SPOTIFY_H
AlbumArtProvider()
AlbumArtProvider constructor.
static std::string base64_encode(const std::string &input)
Encodes a string into base64. Used to encode an HTTP authorization header.
Definition spotify.cc:127
static std::string url(const Method method, const std::map< std::string, std::string > &params)
Calls url_with_params() with the Spotify API method URL.
Definition spotify.cc:155
void init() override
Retrieves the Spotify client ID and secret as environment variables.
Definition spotify.cc:17
Method
Spotify API methods.
Definition spotify.h:35
@ SearchForItem
Definition spotify.h:36
std::vector< AlbumArt > album_art(const std::string &artist, const std::string &title, const int width, const int height) override
Retrieves all album art matching the artist and title.
Definition spotify.cc:46
static constexpr const char * BASE_URL
The Spotify API base URL.
Definition spotify.h:40
static std::string method_name(const Method method)
Conversion method to convert a Spotify::Method to a string.
Definition spotify.cc:147
static std::string _accessToken
The Spotify API key retrieved.
Definition spotify.h:59
Spotify()
Spotify constructor.
Definition spotify.cc:11