Skip to content

Commit 05070a9

Browse files
committed
Merge branch 'master' into api-development
2 parents 469d7a3 + 8a248fa commit 05070a9

14 files changed

Lines changed: 273 additions & 69 deletions

File tree

.maven.xml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<settings xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/SETTINGS/1.0.0"
2+
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
3+
<servers>
4+
<server>
5+
<!-- Maven Central Deployment -->
6+
<id>ossrh</id>
7+
<username>${env.SONATYPE_USERNAME}</username>
8+
<password>${env.SONATYPE_PASSWORD}</password>
9+
</server>
10+
</servers>
11+
12+
<profiles>
13+
<profile>
14+
<id>ossrh</id>
15+
<activation>
16+
<activeByDefault>true</activeByDefault>
17+
</activation>
18+
<properties>
19+
<gpg.executable>${env.GPG_EXECUTABLE}</gpg.executable>
20+
<gpg.passphrase>${env.GPG_PASSPHRASE}</gpg.passphrase>
21+
</properties>
22+
</profile>
23+
</profiles>
24+
</settings>

.travis.yml

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,41 @@
1-
language: java
1+
language: java
2+
3+
before_install:
4+
- echo $GPG_SECRET_KEYS | base64 --decode | $GPG_EXECUTABLE --import
5+
- echo $GPG_OWNERTRUST | base64 --decode | $GPG_EXECUTABLE --import-ownertrust
6+
7+
install:
8+
- mvn -f mdnsjava install -B -V
9+
- mvn --settings .maven.xml install -DskipTests=true -Dgpg.skip -Dmaven.javadoc.skip=true -B -V
10+
11+
script:
12+
mvn clean deploy --settings .maven.xml -B -U -Prelease
13+
14+
before_deploy:
15+
- mvn help:evaluate -N -Dexpression=project.version|grep -v '\['
16+
- export project_version=$(mvn help:evaluate -N -Dexpression=project.version|grep -v '\[')
17+
18+
deploy:
19+
provider: releases
20+
skip_cleanup: true
21+
name: $project_version
22+
draft: true
23+
api_key:
24+
secure: qD8WixE5dpxKyiDEEPdrWVchBxMw7NKLrSNeUEJIb+p9Wq/yJ4cf3DScXYJToFJ/SB5JPCjjyj7rudOJ2wUMydJ01UGVJ+vbR/dTIXjtQxRJ7bDuqq4AGeUjZvDeBhigrA6hxWsqkzbRZzPEMcsWPa77Bs5drwiSJVixS2kLWgH3cKzLHZaqRQnlOeX20MHcPLFr/K0buFBg+qKUazx/z56qJuT0hh6+DYbXhdB9qK3bcGgUPE7rEaq6qfK0o3bZibCxtxFpMQR9qNXHnxfV5hUnq/k/YHQUNwFVo8kA3mSniYd9LxycLQ5nlwcbA2EgjKoJmQ3GYg1VLNsXVbWbw4aAl54h/7k7JzlCfpmM4DDrN62hGYzcoU+dD1WkAQob7a20pmmUmZI5LYUOJPIrpS98/DjDQdnkGeU/waCswSmjIYCqWhX2n0F1yYmC8X9nD2tRUCSyAAT3jFotLyRCsbjy1zg5xBFDw/Lgvd2ixgsnlVVKJrAo4q396WWstcL/2oGR/+J5K/Otlh0BBjJ+ND6tlKqOMFVLm6sE8WL0490Y9C2kumf9kDXV3QqganPnGS7/2MqqJBHrqhDXUbSZhkcExYfZwFjMqHA+Fi6yAFUvtNBC5W6nydWi2Nh1k5QiHtxCnukVnGU7iN0o+tT/H5d3UEklT+xIE0tILWcrXII=
25+
file:
26+
- core/target/librespot-java-core-jar-with-dependencies.jar
27+
- core/target/librespot-java-core-javadoc.jar
28+
- core/target/librespot-java-core-sources.jar
29+
- api/target/librespot-java-api-jar-with-dependencies.jar
30+
- api/target/librespot-java-api-javadoc.jar
31+
- api/target/librespot-java-api-sources.jar
32+
- api-client/target/librespot-java-api-client-jar-with-dependencies.jar
33+
- api-client/target/librespot-java-api-client-javadoc.jar
34+
- api-client/target/librespot-java-api-client-sources.jar
35+
on:
36+
repo: librespot-org/librespot-java
37+
tags: true
38+
39+
cache:
40+
directories:
41+
- ~/.m2/repository

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# librespot-java
22
[![Build Status](https://travis-ci.org/librespot-org/librespot-java.svg?branch=master)](https://travis-ci.org/librespot-org/librespot-java)
3+
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/xyz.gianlu.librespot/librespot-java/badge.svg)](https://maven-badges.herokuapp.com/maven-central/xyz.gianlu.librespot/librespot-java)
34

45
`librespot-java` is a port of [librespot](https://github.com/librespot-org/librespot), originally written in Rust. Additionally, this implementation provides an useful API to request metadata or control the player, more [here](https://github.com/librespot-org/librespot-java/blob/master/api).
56

api-client/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,4 @@
11
# librespot-api-client
2+
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/xyz.gianlu.librespot/librespot-api-client/badge.svg)](https://maven-badges.herokuapp.com/maven-central/xyz.gianlu.librespot/librespot-api-client)
3+
24
A GUI client for the [librespot-api](https://github.com/librespot-org/librespot-java/tree/master/api) made with JavaFX.

api/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# librespot-api
2+
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/xyz.gianlu.librespot/librespot-api/badge.svg)](https://maven-badges.herokuapp.com/maven-central/xyz.gianlu.librespot/librespot-api)
3+
24
This module depends on `librespot-core` and provides an API to interact with the Spotify client.
35

46
## How it works

conf.properties

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1-
# Configuration!
1+
## Device name
22
deviceName=librespot-java
3-
deviceType=Computer
3+
## Device type (Computer, Tablet, Smartphone, Speaker, TV, AVR, STB, AudioDongle, Unknown)
4+
deviceType=Computer
5+
# Authentication
6+
## Strategy (userPass, zeroconf, blob, facebook)
7+
auth.strategy=zeroconf
8+
## Spotify username (blob, userPass)
9+
auth.username=
10+
## Spotify password (userPass)
11+
auth.password=
12+
## Spotify authentication blob (blob)
13+
auth.blob=

core/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575

7676
<!-- mDNS -->
7777
<dependency>
78-
<groupId>net.posick</groupId>
78+
<groupId>xyz.gianlu.mdnsjava</groupId>
7979
<artifactId>mdnsjava</artifactId>
8080
<version>2.2.0</version>
8181
</dependency>

core/src/main/java/xyz/gianlu/librespot/AbsConfiguration.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
package xyz.gianlu.librespot;
22

33
import org.jetbrains.annotations.Nullable;
4+
import xyz.gianlu.librespot.core.AuthConfiguration;
45
import xyz.gianlu.librespot.core.Session;
56
import xyz.gianlu.librespot.player.CacheManager;
67
import xyz.gianlu.librespot.player.Player;
78

89
/**
910
* @author Gianlu
1011
*/
11-
public abstract class AbsConfiguration implements Player.PlayerConfiguration, CacheManager.CacheConfiguration {
12+
public abstract class AbsConfiguration implements Player.PlayerConfiguration, CacheManager.CacheConfiguration, AuthConfiguration {
1213

1314
@Nullable
1415
public abstract String deviceName();

core/src/main/java/xyz/gianlu/librespot/DefaultConfiguration.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package xyz.gianlu.librespot;
22

33
import org.jetbrains.annotations.NotNull;
4+
import org.jetbrains.annotations.Nullable;
45
import xyz.gianlu.librespot.core.Session;
56
import xyz.gianlu.librespot.player.TrackHandler;
67

@@ -61,4 +62,25 @@ public String deviceName() {
6162
public Session.DeviceType deviceType() {
6263
return Session.DeviceType.Computer;
6364
}
65+
66+
@Override
67+
public @Nullable String username() {
68+
return null;
69+
}
70+
71+
@Override
72+
public @Nullable String password() {
73+
return null;
74+
}
75+
76+
@Override
77+
public @Nullable String blob() {
78+
return null;
79+
}
80+
81+
@NotNull
82+
@Override
83+
public Strategy strategy() {
84+
return Strategy.ZEROCONF;
85+
}
6486
}

core/src/main/java/xyz/gianlu/librespot/FileConfiguration.java

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package xyz.gianlu.librespot;
22

3+
import org.jetbrains.annotations.Contract;
34
import org.jetbrains.annotations.NotNull;
45
import org.jetbrains.annotations.Nullable;
56
import xyz.gianlu.librespot.core.Session;
@@ -39,6 +40,18 @@ private float getFloat(@NotNull String key, float fallback) {
3940
}
4041
}
4142

43+
@Contract("_, _, !null -> !null")
44+
private <E extends Enum<E>> E getEnum(@NotNull Class<E> clazz, @NotNull String key, @Nullable E fallback) {
45+
String val = properties.getProperty(key, null);
46+
if (val == null) return fallback;
47+
48+
try {
49+
return Enum.valueOf(clazz, val);
50+
} catch (RuntimeException ex) {
51+
return fallback;
52+
}
53+
}
54+
4255
@Override
4356
public boolean cacheEnabled() {
4457
return getBoolean("cache.enabled", defaults.cacheEnabled());
@@ -76,8 +89,27 @@ public float normalisationPregain() {
7689

7790
@Override
7891
public @Nullable Session.DeviceType deviceType() {
79-
String val = properties.getProperty("deviceType", null);
80-
if (val == null) return null;
81-
return Session.DeviceType.valueOf(val);
92+
return getEnum(Session.DeviceType.class, "deviceType", null);
93+
}
94+
95+
@Override
96+
public @Nullable String username() {
97+
return properties.getProperty("auth.username", null);
98+
}
99+
100+
@Override
101+
public @Nullable String password() {
102+
return properties.getProperty("auth.password", null);
103+
}
104+
105+
@Override
106+
public @Nullable String blob() {
107+
return properties.getProperty("auth.blob", null);
108+
}
109+
110+
@NotNull
111+
@Override
112+
public Strategy strategy() {
113+
return getEnum(Strategy.class, "auth.strategy", defaults.strategy());
82114
}
83115
}

0 commit comments

Comments
 (0)