Skip to content
This repository has been archived by the owner on Sep 8, 2022. It is now read-only.

Commit

Permalink
make it work
Browse files Browse the repository at this point in the history
  • Loading branch information
umjammer committed Feb 14, 2020
1 parent f7a1cd3 commit c64dce3
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 18 deletions.
30 changes: 19 additions & 11 deletions 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.8</version>
<version>0.3.9v</version>
<packaging>jar</packaging>
<name>${project.groupId}:${project.artifactId}</name>
<url>https://github.com/felixgail/gplaymusic</url>
Expand Down Expand Up @@ -67,31 +67,39 @@
</repository>
</distributionManagement>

<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>

<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>${gson.version}</version>
</dependency>
<dependency>
<groupId>com.github.bjoernpetersen</groupId>
<artifactId>gpsoauth</artifactId>
<version>0.3.2</version>
<groupId>com.github.svarzee</groupId>
<artifactId>gpsoauth-java</artifactId>
<version>v0.9.1</version>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>retrofit</artifactId>
<version>2.5.0</version>
<version>2.4.0</version>
<exclusions>
<exclusion>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>com.squareup.retrofit2</groupId>
<artifactId>converter-gson</artifactId>
<version>2.5.0</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.12.0</version>
<version>2.4.0</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,4 +60,9 @@ public String getAndroidID() {
public void setAndroidID(String androidID) {
this.androidID = androidID;
}

@Override
public String toString() {
return "Config [subscription=" + getSubscription() + ", map=" + map + ", locale=" + locale + ", androidID=" + androidID + "]";
}
}
22 changes: 19 additions & 3 deletions src/main/java/com/github/felixgail/gplaymusic/model/Track.java
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,9 @@ public Optional<String> getComment() {

@Override
public String getID() {
return getStoreId().orElseGet(
() -> getUuid().orElseThrow(
() -> new NullPointerException("Track contains neither StoreID nor UUID.")));
return getUuid().orElseGet(
() -> getStoreId().orElseThrow(
() -> new NullPointerException("Track contains neither UUID nor StoreID.")));
}

public Optional<String> getStoreId() {
Expand Down Expand Up @@ -358,6 +358,22 @@ public String string() {
return gsonPrettyPrinter.toJson(this);
}

@Override
public String toString() {
return "Track [title=" + title + ", artist=" + artist + ", composer=" + composer + ", album=" + album + ", albumArtist=" +
albumArtist + ", year=" + year + ", trackNumber=" + trackNumber + ", genre=" + genre + ", durationMillis=" +
durationMillis + ", albumArtRef=" + albumArtRef + ", artistArtRef=" + artistArtRef + ", discNumber=" + discNumber +
", estimatedSize=" + estimatedSize + ", trackType=" + trackType + ", storeId=" + storeId + ", albumId=" + albumId +
", artistId=" + artistId + ", nid=" + nid + ", trackAvailableForSubscription=" + trackAvailableForSubscription +
", trackAvailableForPurchase=" + trackAvailableForPurchase + ", albumAvailableForPurchase=" +
albumAvailableForPurchase + ", explicitType=" + explicitType + ", playCount=" + playCount + ", rating=" + rating +
", beatsPerMinute=" + beatsPerMinute + ", clientId=" + clientId + ", comment=" + comment + ", totalTrackCount=" +
totalTrackCount + ", totalDiscCount=" + totalDiscCount + ", lastRatingChangeTimestamp=" + lastRatingChangeTimestamp +
", lastModifiedTimestamp=" + lastModifiedTimestamp + ", contentType=" + contentType + ", creationTimestamp=" +
creationTimestamp + ", recentTimestamp=" + recentTimestamp + ", uuid=" + uuid + ", video=" + video +
", sessionToken=" + sessionToken + ", mainApi=" + mainApi + ", wentryID=" + wentryID + "]";
}

/**
* Downloads the song to the provided path. Existing files will be replaced.
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.github.felixgail.gplaymusic.util;

import java.io.IOException;
import okhttp3.OkHttpClient;
import svarzee.gps.gpsoauth.AuthToken;
import svarzee.gps.gpsoauth.Gpsoauth;

Expand All @@ -26,8 +25,7 @@ public static AuthToken provideToken(final String user, final String password,
final String androidID)
throws IOException, Gpsoauth.TokenRequestFailed {
lastTokenFetched = System.currentTimeMillis();
OkHttpClient client = new OkHttpClient();
Gpsoauth auth = new Gpsoauth(client);
Gpsoauth auth = new Gpsoauth();
// clientSig taken from https://github.com/simon-weber/gmusicapi/blob/develop/gmusicapi/session.py#L199
return auth.login(user, password, androidID, "sj", "com.google.android.music",
"AIzaSyARTC1h-_puqO0PHCHUoj1BTDjuAOxNVA8");
Expand All @@ -42,7 +40,7 @@ public static AuthToken provideToken(final String user, final String password,
* @return a new Token, recovered from the saved string.
*/
public static AuthToken provideToken(final String token) {
return new AuthToken(token);
return new AuthToken(token, -1);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static void loginToService(TestUtil.Property username, TestUtil.Property passwor
.setAuthToken(authToken)
.setDebug(false)
.setHttpClientBuilder(builder)
.setAndroidID(androidID.get())
.build();
} catch (InitializationException e) {
if (usingExistingToken) {
Expand Down

0 comments on commit c64dce3

Please sign in to comment.