Skip to content
This repository has been archived by the owner on Jan 13, 2021. It is now read-only.

Fixes #52. Removed tracks filtering while fetching #53

Merged
merged 12 commits into from
May 10, 2019
4 changes: 2 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ project, you can discuss idea by creating an
[issue](https://github.com/FelixGail/gplaymusic/issues/new).

Please note that we have a
[code of conduct](https://github.com/FelixGail/gplaymusic/master/blob/CODE_OF_CONDUCT.md), please
[code of conduct](https://github.com/FelixGail/gplaymusic/blob/master/CODE_OF_CONDUCT.md), please
follow it in all your interactions with the project.

## Contributing Code
Expand All @@ -24,4 +24,4 @@ section of the _pom.xml_.

### Attribution
This contributing guide is based on a template by
[PurpleBooth](https://gist.github.com/PurpleBooth/b24679402957c63ec426).
[PurpleBooth](https://gist.github.com/PurpleBooth/b24679402957c63ec426).
6 changes: 5 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.github.felixgail</groupId>
<artifactId>gplaymusic</artifactId>
<version>0.3.6</version>
<version>0.3.7</version>
<packaging>jar</packaging>
<name>${project.groupId}:${project.artifactId}</name>
<url>https://github.com/felixgail/gplaymusic</url>
Expand Down Expand Up @@ -45,6 +45,10 @@
<name>vadimshilov</name>
<url>https://github.com/vadimshilov</url>
</contributor>
<contributor>
<name>Eugene Terekhov</name>
<url>https://github.com/nergal-perm</url>
</contributor>
</contributors>
<scm>
<connection>scm:git:https://github.com/FelixGail/gplaymusic.git</connection>
Expand Down
14 changes: 13 additions & 1 deletion src/main/java/com/github/felixgail/gplaymusic/api/TrackApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.github.felixgail.gplaymusic.model.requests.SearchTypes;
import java.io.IOException;
import java.util.List;
import java.util.stream.Collectors;

public class TrackApi implements SubApi {

Expand All @@ -29,7 +30,7 @@ public List<Track> search(String query, int maxResults) throws IOException {
}

public Track getTrack(String trackID) throws IOException {
Track track = null;
Track track;
if (trackID.startsWith("T")) {
track = mainApi.getService().fetchTrack(trackID).execute().body();
} else {
Expand All @@ -46,6 +47,17 @@ public List<Track> getLibraryTracks() throws IOException {
return libraryTrackCache.getAll();
}

/**
* Filters cache and returns tracks with 'Thumbs up' mark
* @return List of tracks liked by user
* @throws IOException if GMusic request fails
*/
public List<Track> getThumbsUpTracks() throws IOException {
return libraryTrackCache.getAll().stream()
.filter(t -> t.getRating().isPresent() && Integer.valueOf(t.getRating().get()) > 1)
.collect(Collectors.toList());
}

/**
* Library tracks can only be fetched as whole. To shorten wait times, collected songs are cached.
* Please consider updating the cache (asynchronously) when using the library over a long period
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,6 @@ public ListResult<Track> getChunk(String nextPageToken) throws IOException {
return mainApi.getService()
.listTracks(new PagingRequest(nextPageToken, -1)).execute().body();
}

@Override
public List<Track> next() throws IOException {
return super.next().stream()
.filter(t -> !t.getStoreId().isPresent() && t.getUuid().isPresent())
.collect(Collectors.toList());
}
};
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public Optional<List<Thumbnail>> getThumbnails() {
}

/**
* Score can be >1 (Probably between 0-100). Might score the trust in the result.
* Score can be greater than 1 (Probably between 0-100). Might score the trust in the result.
*/
public double getScore() {
return score;
Expand Down