Handle new configuration options #5

Closed
bok opened this Issue Mar 30, 2011 · 4 comments

Comments

Projects
None yet
3 participants
Contributor

bok commented Mar 30, 2011

Spotify API 7 introduces 3 new session configuration options:

in sp_session_config:

+  /**
+   * Compress local copy of playlists, reduces disk space usage
+   */
+  bool compress_playlists;
+
+  /**
+   * Don't save metadata for local copies of playlists
+   * Reduces disk space usage at the expence of needing
+   * to request metadata from Spotify backend when loading list
+   */
+  bool dont_save_metadata_for_playlists;
+
+  /**
+   * Avoid loading playlists into RAM on startup. 
+   * See sp_playlist_is_in_ram() for more details.
+   */
+  bool initially_unload_playlists;

It would be nice if they were accessible through pyspotify.

Owner

adamcik commented Jun 5, 2013

Changes in #101 should make adding more config options quite a bit less painful. It would also be simple to extend the helper's I've written with config_bool(PyObject *settings, const char* attr, bool* target) so we can just do config_bool(settings, "dont_save_metadata_for_playlists", &config.dont_save_metadata_for_playlists) etc :-)

Owner

jodal commented Jun 6, 2013

All of these are already included in the pyspotify2 branch.

Owner

adamcik commented Jun 8, 2013

+static void
+config_bool(PyObject *settings, const char *attr, bool *target) {
+    PyObject *value = PyObject_GetAttrString(settings, attr);
+    if (value == NULL) {
+        PyErr_Format(SpotifyError, "%s not set", attr);
+        return;
+    }
+    if (value == Py_True)
+        *target = 1;
+    else if (value == Py_False)
+        *target = 0;
+    else if (value != Py_None)
+        PyErr_Format(SpotifyError, "%s must be True, False or None", attr);
+    Py_DECREF(value);
+}
Owner

jodal commented Apr 24, 2014

pyspotify 2 has now reached beta level and is fully usable. These configs will probably never be added to pyspotify 1.

@jodal jodal closed this Apr 24, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment