Skip to content

Commit

Permalink
clients/plex/libtizplex: allow passing music section during creation (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
juanrubio committed Nov 29, 2019
1 parent daeb786 commit d6e9e46
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 11 deletions.
14 changes: 9 additions & 5 deletions clients/plex/libtizplex/src/tizplex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,20 @@ namespace

void start_plex (boost::python::object &py_global,
boost::python::object &py_plex_proxy,
const std::string &base_url, const std::string &auth_token)
const std::string &base_url, const std::string &auth_token,
const std::string &music_section)
{
bp::object pyplexproxy = py_global["tizplexproxy"];
py_plex_proxy = pyplexproxy (base_url.c_str (), auth_token.c_str ());
py_plex_proxy = pyplexproxy (base_url.c_str (), auth_token.c_str (),
music_section.c_str ());
}
}

tizplex::tizplex (const std::string &base_url, const std::string &auth_token)
tizplex::tizplex (const std::string &base_url, const std::string &auth_token,
const std::string &music_section)
: base_url_ (base_url),
auth_token_ (auth_token),
music_section_ (music_section),
current_url_ (),
current_track_index_ (),
current_queue_length_ (),
Expand Down Expand Up @@ -166,8 +170,8 @@ int tizplex::init ()
int tizplex::start ()
{
int rc = 0;
try_catch_wrapper (
start_plex (py_global_, py_plex_proxy_, base_url_, auth_token_));
try_catch_wrapper (start_plex (py_global_, py_plex_proxy_, base_url_,
auth_token_, music_section_));
return rc;
}

Expand Down
4 changes: 3 additions & 1 deletion clients/plex/libtizplex/src/tizplex.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class tizplex
};

public:
tizplex (const std::string &base_url, const std::string &auth_token);
tizplex (const std::string &base_url, const std::string &auth_token,
const std::string &music_section);
~tizplex ();

int init ();
Expand Down Expand Up @@ -86,6 +87,7 @@ class tizplex
private:
std::string base_url_;
std::string auth_token_;
std::string music_section_;
std::string current_url_;
std::string current_track_index_;
std::string current_queue_length_;
Expand Down
11 changes: 7 additions & 4 deletions clients/plex/libtizplex/src/tizplex_c.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,14 @@ static void plex_free_data (tiz_plex_t *ap_plex)
}

static int plex_alloc_data (tiz_plex_t *ap_plex, const char *ap_base_url,
const char *ap_auth_token)
const char *ap_auth_token,
const char *ap_music_section)
{
int rc = 0;
assert (ap_plex);
try
{
ap_plex->p_proxy_ = new tizplex (ap_base_url, ap_auth_token);
ap_plex->p_proxy_ = new tizplex (ap_base_url, ap_auth_token, ap_music_section);
}
catch (...)
{
Expand All @@ -67,7 +68,8 @@ static int plex_alloc_data (tiz_plex_t *ap_plex, const char *ap_base_url,
}

extern "C" int tiz_plex_init (tiz_plex_ptr_t *app_plex, const char *ap_base_url,
const char *ap_auth_token)
const char *ap_auth_token,
const char *ap_music_section)
{
tiz_plex_t *p_plex = NULL;
int rc = 1;
Expand All @@ -76,7 +78,8 @@ extern "C" int tiz_plex_init (tiz_plex_ptr_t *app_plex, const char *ap_base_url,

if ((p_plex = (tiz_plex_t *)calloc (1, sizeof (tiz_plex_t))))
{
if (!plex_alloc_data (p_plex, ap_base_url, ap_auth_token))
if (!plex_alloc_data (p_plex, ap_base_url, ap_auth_token,
ap_music_section))
{
tizplex *p_px = p_plex->p_proxy_;
assert (p_px);
Expand Down
4 changes: 3 additions & 1 deletion clients/plex/libtizplex/src/tizplex_c.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,13 @@ typedef enum tiz_plex_playback_mode {
* initialised.
* @param ap_base_url The Plex server base url.
* @param ap_auth_token The Plex account auth token.
* @param ap_music_section The name of the music section in the Plex library.
*
* @return 0 on success.
*/
int tiz_plex_init (/*@null@ */ tiz_plex_ptr_t *app_plex,
const char *ap_base_url, const char *ap_auth_token);
const char *ap_base_url, const char *ap_auth_token,
const char *ap_music_section);

/**
* Clear the playback queue.
Expand Down

0 comments on commit d6e9e46

Please sign in to comment.