initial commit

This commit is contained in:
aj 2018-03-24 14:28:07 -07:00
commit 19e1d283f8
11 changed files with 253 additions and 0 deletions

74
.gitignore vendored Normal file
View File

@ -0,0 +1,74 @@
fmframework/src/sarsoo/fmframework/net/Key.java
# Directories #
/build/
/bin/
target/
# OS Files #
.DS_Store
*.class
# Package Files #
*.jar
*.war
*.ear
*.db
######################
# Windows
######################
# Windows image file caches
Thumbs.db
# Folder config file
Desktop.ini
######################
# OSX
######################
.DS_Store
.svn
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
######################
# Eclipse
######################
*.pydevproject
.project
.metadata
bin/**
tmp/**
tmp/**/*
*.tmp
*.bak
*.swp
*~.nib
local.properties
.classpath
.settings/
.loadpath
/src/main/resources/rebel.xml
# External tool builders
.externalToolBuilders/
# Locally stored "Eclipse launch configurations"
*.launch
# CDT-specific
.cproject
# PDT-specific
.buildpath

1
fmframework/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/.project

View File

@ -0,0 +1,14 @@
package sarsoo.fmframework.music;
import java.util.ArrayList;
public class Album extends FMObj{
protected int id;
protected String date;
protected Artist artist;
protected int listeners;
protected int playCount;
protected ArrayList<Tag> tagList;
protected ArrayList<Track> trackList;
}

View File

@ -0,0 +1,14 @@
package sarsoo.fmframework.music;
import java.util.ArrayList;
public class Artist extends FMObj{
protected int listeners;
protected int plays;
protected boolean streamable;
protected ArrayList<Album> albums;
protected ArrayList<Track> tracks;
protected ArrayList<Artist> similarArtists;
protected ArrayList<Tag> tagList;
protected Wiki wiki;
}

View File

@ -0,0 +1,5 @@
package sarsoo.fmframework.music;
public class Bio {
public String date;
}

View File

@ -0,0 +1,21 @@
package sarsoo.fmframework.music;
public class FMObj {
protected String name;
protected String url;
protected String mbid;
public String getName() {
return name;
}
public String getUrl() {
return url;
}
public String getMbid() {
return mbid;
}
}

View File

@ -0,0 +1,11 @@
package sarsoo.fmframework.music;
public class Tag {
protected String name;
protected String url;
protected int reach;
protected int taggings;
protected Boolean streamable;
protected String summary;
protected String content;
}

View File

@ -0,0 +1,17 @@
package sarsoo.fmframework.music;
import java.util.ArrayList;
public class Track extends FMObj{
protected Album album;
protected Artist artist;
protected int trackNumber;
protected int id;
protected int duration;
protected int playcount;
protected boolean streamable;
protected ArrayList<Tag> tagList;
protected Wiki wiki;
}

View File

@ -0,0 +1,7 @@
package sarsoo.fmframework.music;
public class Wiki {
protected String date;
protected String summary;
protected String content;
}

View File

@ -0,0 +1,45 @@
package sarsoo.fmframework.net;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
public class Network {
public static void apiAlbumInfoCall(String artist, String album, String username) {
try {
String urlString = String.format("http://ws.audioscrobbler.com/2.0/?method=album.getInfo&artist=%s&album=%s&autocorrect=1&username=%s&format=json&api_key=%s",
artist, album, username, Key.getKey());
URL url = new URL(urlString);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/json");
if (conn.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
String output;
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
System.out.println(output);
}
conn.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}

View File

@ -0,0 +1,44 @@
package sarsoo.fmframework.net;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
public class TestCall {
public static void main(String [] args) {
try {
URL url = new URL("http://ws.audioscrobbler.com/2.0/?method=artist.getInfo&artist=Mastodon&format=json&api_key=" + Key.getKey());
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setRequestProperty("Accept", "application/json");
if (conn.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : " + conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader((conn.getInputStream())));
String output;
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
System.out.println(output);
}
conn.disconnect();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}