Skip to content

Commit f5e3b9c

Browse files
committed
2.0.0 Update
Changed complete System up to use the Genius API
1 parent eeb7d4b commit f5e3b9c

File tree

10 files changed

+553
-255
lines changed

10 files changed

+553
-255
lines changed

pom.xml

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
34
<modelVersion>4.0.0</modelVersion>
45

56
<groupId>com.github.connyscode.ctils</groupId>
67
<artifactId>jtrack</artifactId>
7-
<version>1.0.5.2-SNAPSHOT</version>
8+
<version>2.0.0-SNAPSHOT</version>
89
<name>${project.groupId}:${project.artifactId}</name>
9-
<description>yes.
10-
</description>
10+
<description>jTrack is a small and powerful library for collecting data of tracks.</description>
1111
<url>https://github.com/ConnysCode/jTrack</url>
1212

1313
<developers>
@@ -136,6 +136,23 @@
136136
<artifactId>jsoup</artifactId>
137137
<version>1.13.1</version>
138138
</dependency>
139+
140+
<!--CANARY-->
141+
<!-- https://mvnrepository.com/artifact/com.googlecode.json-simple/json-simple -->
142+
<dependency>
143+
<groupId>com.googlecode.json-simple</groupId>
144+
<artifactId>json-simple</artifactId>
145+
<version>1.1.1</version>
146+
</dependency>
147+
148+
<!-- https://mvnrepository.com/artifact/com.squareup.okhttp/okhttp -->
149+
<dependency>
150+
<groupId>com.squareup.okhttp</groupId>
151+
<artifactId>okhttp</artifactId>
152+
<version>2.7.5</version>
153+
</dependency>
154+
155+
139156
</dependencies>
140157

141158
</project>
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
package com.github.connyscode.ctils.jTrack;
2+
3+
import com.github.connyscode.ctils.jTrack.backend.GeniusAPI;
4+
import org.json.simple.JSONArray;
5+
import org.json.simple.JSONObject;
6+
7+
import java.lang.reflect.Array;
8+
import java.util.ArrayList;
9+
import java.util.List;
10+
11+
import static com.github.connyscode.ctils.jTrack.backend.Messaging.error;
12+
13+
public class Artist {
14+
15+
private String artistName = "", artistUrl = "https://genius.com/", artistHeaderImageUrl = "https://genius.com/", artistImageUrl = "https://genius.com/", artistDescription = "";
16+
private long artistID = 0, artistFollowers = 0;
17+
private List<String> alternateNames = new ArrayList<>();
18+
private boolean artistVerified = false;
19+
20+
/**
21+
* Create a Track
22+
*
23+
* @param trackObject song response from genius
24+
* @see Artist
25+
*/
26+
public Artist(JSONObject trackObject) {
27+
try {
28+
JSONObject artist = trackObject;
29+
30+
// Artist
31+
artistName = (String) artist.get("name");
32+
artistUrl = (String) artist.get("url");
33+
artistHeaderImageUrl = (String) artist.get("header_image_url");
34+
artistImageUrl = (String) artist.get("image_url");
35+
artistID = (long) artist.get("id");
36+
artistVerified = (boolean) artist.get("is_verified");
37+
if (artist.get("description") != null)
38+
artistDescription = (String) ((JSONObject) artist.get("description")).get("plain");
39+
artistFollowers = (long) artist.get("followers_count");
40+
41+
JSONArray alts = (JSONArray) artist.get("alternate_names");
42+
for(int i = 0; i < alts.size(); i++){
43+
alternateNames.add((String) alts.get(i));
44+
}
45+
} catch (Exception e) {
46+
e.printStackTrace();
47+
error("t01", "Could not read complete Track data!");
48+
}
49+
}
50+
51+
/**
52+
* @return The name of the Artist
53+
*/
54+
public String artistName() {
55+
return this.artistName;
56+
}
57+
58+
/**
59+
* @return The artist's Header as an URL<br>(Mostly same as Track.artistImageUrl())
60+
*/
61+
public String artistHeaderImageUrl() {
62+
return this.artistHeaderImageUrl;
63+
}
64+
65+
/**
66+
* @return The artist's Profile Picture as an URL
67+
*/
68+
public String artistImageUrl() {
69+
return this.artistImageUrl;
70+
}
71+
72+
/**
73+
* @return The artist's Genius URL
74+
*/
75+
public String artistUrl() {
76+
return this.artistUrl;
77+
}
78+
79+
/**
80+
* @return The artist's Description
81+
*/
82+
public String artistDescription() {
83+
return this.artistDescription;
84+
}
85+
86+
/**
87+
* @return The artist's follower count
88+
*/
89+
public long artistFollowers() {
90+
return this.artistFollowers;
91+
}
92+
93+
/**
94+
* @return The artist's alternate Names
95+
*/
96+
public List<String> alternateNames() {
97+
return this.alternateNames;
98+
}
99+
100+
/**
101+
* @return The artist's Genius URL
102+
*/
103+
public long artistGID() {
104+
return this.artistID;
105+
}
106+
107+
/**
108+
* @return Is Artist verified
109+
*/
110+
public boolean artistVerified() {
111+
return this.artistVerified;
112+
}
113+
///* MISC *///
114+
115+
}

0 commit comments

Comments
 (0)