Skip to content

Commit

Permalink
fixed partial sync for Ampache and Plex
Browse files Browse the repository at this point in the history
  • Loading branch information
memen45 committed Oct 19, 2022
1 parent 520c2ae commit bd76a19
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
1 change: 1 addition & 0 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ Version [] -

Version [0.2.6] - 19-10-2022
- added workaround for Plex' missing metadata
- fixed partial sync for Ampache and Plex large playlists

Version [0.2.5] - 16-10-2022
- fixed Plex sync error with larger playlists
Expand Down
13 changes: 9 additions & 4 deletions source/Api/AmpacheProvider.mc
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ class AmpacheProvider {
// set range parameters
d_limit = MAX_LIMIT;
d_offset = OFFSET;
d_count = MAX_COUNT;

d_action = AMPACHE_ACTION_PLAYLISTS;
do_();
Expand Down Expand Up @@ -180,6 +181,7 @@ class AmpacheProvider {
// set range parameters
d_limit = MAX_LIMIT;
d_offset = OFFSET;
d_count = MAX_COUNT;

d_action = AMPACHE_ACTION_PLAYLIST_SONGS;
do_();
Expand Down Expand Up @@ -280,6 +282,7 @@ class AmpacheProvider {
// set range parameters
d_limit = 5; // use lower limit due to description
d_offset = OFFSET;
d_count = MAX_COUNT;

d_action = AMPACHE_ACTION_PODCASTS;
do_();
Expand Down Expand Up @@ -331,11 +334,13 @@ class AmpacheProvider {
if (d_limit == null) {
d_limit = MAX_LIMIT;
}

System.println("AmpacheProvider::checkDone()");
System.println(d_response.size());
System.println(response.size());
System.println(d_count);
System.println(d_limit);
System.println("Total received: " + d_response.size());
System.println("Last received: " + response.size());
System.println("Max total: " + d_count);
System.println("Max at once: " + d_limit);

if ((d_response.size() < d_count) // count not reached
&& (response.size() >= d_limit)) { // limit reached
// request required, since response was full and count not reached
Expand Down
17 changes: 11 additions & 6 deletions source/Api/PlexProvider.mc
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class PlexProvider {

enum { MAX_COUNT = 10000, MAX_LIMIT = 20, OFFSET = 0, }
private var d_limit = MAX_LIMIT; // defines the number of results in a single response
private var d_offset = OFFSET; // defines the offset for the request
private var d_count = MAX_COUNT; // count objects for ranged requests
private var d_offset = OFFSET; // defines the offset for the ranged request
private var d_count = MAX_COUNT; // defines the number of objects to be received in ranged requests

private var d_id; // required for getPlaylist, getPlaylistSongs, getRefId, getArtwork
private var d_encoding; // encoding parameter needed for stream
Expand Down Expand Up @@ -122,6 +122,7 @@ class PlexProvider {
// set range parameters
d_limit = MAX_LIMIT;
d_offset = OFFSET;
d_count = MAX_COUNT;

d_action = PLEX_PLAYLISTS;
do_();
Expand Down Expand Up @@ -161,6 +162,7 @@ class PlexProvider {
d_response.add(plex_to_playlist(response));

d_action = null;
d_count = MAX_COUNT;
d_callback.invoke(d_response);
}

Expand Down Expand Up @@ -194,6 +196,7 @@ class PlexProvider {
// set range parameters
d_limit = MAX_LIMIT;
d_offset = OFFSET;
d_count = MAX_COUNT;

d_action = PLEX_PLAYLIST_SONGS;
do_();
Expand Down Expand Up @@ -312,11 +315,13 @@ class PlexProvider {
if (d_limit == null) {
d_limit = MAX_LIMIT;
}

System.println("PlexProvider::checkDone()");
System.println(d_response.size());
System.println(response.size());
System.println(d_count);
System.println(d_limit);
System.println("Total received: " + d_response.size());
System.println("Last received: " + response.size());
System.println("Max total: " + d_count);
System.println("Max at once: " + d_limit);

if ((d_response.size() < d_count) // count not reached
&& (response.size() >= d_limit)) { // limit reached
// request required, since response was full and count not reached
Expand Down

0 comments on commit bd76a19

Please sign in to comment.