added some error handling for parsing, added get artist
This commit is contained in:
parent
2134e358c1
commit
8014a1e3a6
@ -6,7 +6,7 @@ import sarsoo.fmframework.util.Reference;
|
|||||||
public class Driver {
|
public class Driver {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
Reference.setUserName("Sarsoo");
|
Reference.setUserName("sarsoo");
|
||||||
|
|
||||||
MainMenu main = new MainMenu();
|
MainMenu main = new MainMenu();
|
||||||
main.setVisible(true);
|
main.setVisible(true);
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package sarsoo.fmframework.error;
|
package sarsoo.fmframework.error;
|
||||||
|
|
||||||
|
import sarsoo.fmframework.util.Reference;
|
||||||
|
|
||||||
public class ApiCallException extends Exception {
|
public class ApiCallException extends Exception {
|
||||||
|
|
||||||
private int failureCode;
|
private int failureCode;
|
||||||
@ -42,6 +44,8 @@ public class ApiCallException extends Exception {
|
|||||||
return "Suspended API key - Access for your account has been suspended, please contact Last.fm";
|
return "Suspended API key - Access for your account has been suspended, please contact Last.fm";
|
||||||
case 29:
|
case 29:
|
||||||
return "Rate limit exceeded - Your IP has made too many requests in a short period";
|
return "Rate limit exceeded - Your IP has made too many requests in a short period";
|
||||||
|
case 400:
|
||||||
|
return "Bad Request";
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package sarsoo.fmframework.gui;
|
package sarsoo.fmframework.gui;
|
||||||
|
|
||||||
|
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
@ -16,15 +15,16 @@ import javax.swing.JPanel;
|
|||||||
import sarsoo.fmframework.music.Album;
|
import sarsoo.fmframework.music.Album;
|
||||||
import sarsoo.fmframework.net.Network;
|
import sarsoo.fmframework.net.Network;
|
||||||
|
|
||||||
public class AlbumView extends JFrame{
|
public class AlbumView extends JFrame {
|
||||||
JPanel info = new JPanel();
|
|
||||||
JPanel buttons = new JPanel();
|
JPanel buttons = new JPanel();
|
||||||
JPanel buttons2 = new JPanel();
|
JPanel buttons2 = new JPanel();
|
||||||
|
|
||||||
JLabel name = new JLabel();
|
JLabel name = new JLabel();
|
||||||
JLabel artist = new JLabel();
|
JLabel artist = new JLabel();
|
||||||
JLabel listeners = new JLabel();
|
JLabel listeners = new JLabel();
|
||||||
JLabel playCount = new JLabel();
|
JLabel playCount = new JLabel();
|
||||||
JLabel userPlayCount = new JLabel();
|
JLabel userPlayCount = new JLabel();
|
||||||
|
|
||||||
JButton open = new JButton("View Online");
|
JButton open = new JButton("View Online");
|
||||||
JButton viewArtist = new JButton("View Artist");
|
JButton viewArtist = new JButton("View Artist");
|
||||||
JButton musicBrainz = new JButton("Open MusicBrainz");
|
JButton musicBrainz = new JButton("Open MusicBrainz");
|
||||||
@ -36,22 +36,21 @@ public class AlbumView extends JFrame{
|
|||||||
setLayout(new GridLayout(7,0));
|
setLayout(new GridLayout(7,0));
|
||||||
setSize(300, 300);
|
setSize(300, 300);
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
info.setLayout(new GridLayout());
|
|
||||||
|
|
||||||
buttons.setLayout(new FlowLayout());
|
buttons.setLayout(new FlowLayout());
|
||||||
buttons2.setLayout(new FlowLayout());
|
buttons2.setLayout(new FlowLayout());
|
||||||
// info.add(name);
|
|
||||||
// info.add(listeners);
|
|
||||||
// info.add(playCount);
|
|
||||||
// info.add(userPlayCount);
|
|
||||||
buttons.add(open);
|
buttons.add(open);
|
||||||
buttons.add(viewArtist);
|
buttons.add(viewArtist);
|
||||||
buttons2.add(musicBrainz);
|
if(album.getMbid() != null)
|
||||||
|
buttons2.add(musicBrainz);
|
||||||
buttons2.add(rym);
|
buttons2.add(rym);
|
||||||
|
|
||||||
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
||||||
|
|
||||||
name.setText(album.getName());
|
name.setText(album.getName());
|
||||||
name.setHorizontalTextPosition(JLabel.CENTER);
|
|
||||||
artist.setText(album.getArtist().getName());
|
artist.setText(album.getArtist().getName());
|
||||||
listeners.setText(numberFormat.format(album.getListeners()) + " Listeners");
|
listeners.setText(numberFormat.format(album.getListeners()) + " Listeners");
|
||||||
playCount.setText(numberFormat.format(album.getPlayCount()) + " Scrobbles");
|
playCount.setText(numberFormat.format(album.getPlayCount()) + " Scrobbles");
|
||||||
@ -78,12 +77,13 @@ public class AlbumView extends JFrame{
|
|||||||
Network.openURL(album.getRymURL());;
|
Network.openURL(album.getRymURL());;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
add(name);
|
add(name);
|
||||||
add(artist);
|
add(artist);
|
||||||
add(listeners);
|
add(listeners);
|
||||||
add(playCount);
|
add(playCount);
|
||||||
add(userPlayCount);
|
add(userPlayCount);
|
||||||
// add(info);
|
|
||||||
add(buttons);
|
add(buttons);
|
||||||
add(buttons2);
|
add(buttons2);
|
||||||
}
|
}
|
||||||
|
@ -16,12 +16,13 @@ import sarsoo.fmframework.music.FMObj;
|
|||||||
import sarsoo.fmframework.net.Network;
|
import sarsoo.fmframework.net.Network;
|
||||||
|
|
||||||
public class FMObjView extends JFrame{
|
public class FMObjView extends JFrame{
|
||||||
JPanel info = new JPanel();
|
|
||||||
JPanel buttons = new JPanel();
|
JPanel buttons = new JPanel();
|
||||||
|
|
||||||
JLabel name = new JLabel();
|
JLabel name = new JLabel();
|
||||||
JLabel listeners = new JLabel();
|
JLabel listeners = new JLabel();
|
||||||
JLabel playCount = new JLabel();
|
JLabel playCount = new JLabel();
|
||||||
JLabel userPlayCount = new JLabel();
|
JLabel userPlayCount = new JLabel();
|
||||||
|
|
||||||
JButton open = new JButton("View Online");
|
JButton open = new JButton("View Online");
|
||||||
JButton musicBrainz = new JButton("Open MusicBrainz");
|
JButton musicBrainz = new JButton("Open MusicBrainz");
|
||||||
|
|
||||||
@ -31,14 +32,12 @@ public class FMObjView extends JFrame{
|
|||||||
setLayout(new GridLayout(5,0));
|
setLayout(new GridLayout(5,0));
|
||||||
setSize(300, 300);
|
setSize(300, 300);
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
info.setLayout(new GridLayout());
|
|
||||||
buttons.setLayout(new FlowLayout());
|
buttons.setLayout(new FlowLayout());
|
||||||
// info.add(name);
|
|
||||||
// info.add(listeners);
|
|
||||||
// info.add(playCount);
|
|
||||||
// info.add(userPlayCount);
|
|
||||||
buttons.add(open);
|
buttons.add(open);
|
||||||
buttons.add(musicBrainz);
|
if(obj.getMbid() != null)
|
||||||
|
buttons.add(musicBrainz);
|
||||||
|
|
||||||
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
||||||
|
|
||||||
|
@ -11,9 +11,12 @@ import java.util.Locale;
|
|||||||
import javax.swing.JButton;
|
import javax.swing.JButton;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
|
|
||||||
import sarsoo.fmframework.music.Album;
|
import sarsoo.fmframework.music.Album;
|
||||||
|
import sarsoo.fmframework.music.Artist;
|
||||||
|
import sarsoo.fmframework.music.Track;
|
||||||
import sarsoo.fmframework.net.Network;
|
import sarsoo.fmframework.net.Network;
|
||||||
import sarsoo.fmframework.util.GetObject;
|
import sarsoo.fmframework.util.GetObject;
|
||||||
import sarsoo.fmframework.util.Reference;
|
import sarsoo.fmframework.util.Reference;
|
||||||
@ -21,6 +24,7 @@ import sarsoo.fmframework.util.Reference;
|
|||||||
public class MainMenu extends JFrame{
|
public class MainMenu extends JFrame{
|
||||||
|
|
||||||
JButton getAlbum = new JButton("Get Album");
|
JButton getAlbum = new JButton("Get Album");
|
||||||
|
JButton getArtist = new JButton("Get Artist");
|
||||||
JButton viewTDE = new JButton("View TDE");
|
JButton viewTDE = new JButton("View TDE");
|
||||||
JButton viewBPHQ = new JButton("View BPHQ");
|
JButton viewBPHQ = new JButton("View BPHQ");
|
||||||
JButton viewLastTrack = new JButton("View Last Track");
|
JButton viewLastTrack = new JButton("View Last Track");
|
||||||
@ -28,13 +32,28 @@ public class MainMenu extends JFrame{
|
|||||||
public MainMenu() {
|
public MainMenu() {
|
||||||
super("fmframework");
|
super("fmframework");
|
||||||
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
setLayout(new GridLayout(2,2));
|
setLayout(new GridLayout(3,2));
|
||||||
setSize(300, 300);
|
setSize(300, 300);
|
||||||
setResizable(false);
|
setResizable(false);
|
||||||
|
|
||||||
getAlbum.addActionListener(new ActionListener() {
|
getAlbum.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
GetObject.getAlbum().view();;
|
Album album = GetObject.getAlbum();
|
||||||
|
if(album != null) {
|
||||||
|
album.view();
|
||||||
|
}else {
|
||||||
|
JOptionPane.showMessageDialog(null, "No Album Found", "Album Error", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
getArtist.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
Artist artist = GetObject.getArtist();
|
||||||
|
if(artist != null) {
|
||||||
|
artist.view();
|
||||||
|
}else {
|
||||||
|
JOptionPane.showMessageDialog(null, "No Artist Found", "Artist Error", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
viewTDE.addActionListener(new ActionListener() {
|
viewTDE.addActionListener(new ActionListener() {
|
||||||
@ -49,12 +68,18 @@ public class MainMenu extends JFrame{
|
|||||||
});
|
});
|
||||||
viewLastTrack.addActionListener(new ActionListener() {
|
viewLastTrack.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
GetObject.getLastTrack().view();
|
Track track = GetObject.getLastTrack();
|
||||||
|
if(track != null) {
|
||||||
|
track.view();
|
||||||
|
}else {
|
||||||
|
JOptionPane.showMessageDialog(null, "No Track Found", "Track Error", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
add(viewLastTrack);
|
add(viewLastTrack);
|
||||||
add(getAlbum);
|
add(getAlbum);
|
||||||
|
add(getArtist);
|
||||||
add(viewTDE);
|
add(viewTDE);
|
||||||
add(viewBPHQ);
|
add(viewBPHQ);
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package sarsoo.fmframework.gui;
|
package sarsoo.fmframework.gui;
|
||||||
|
|
||||||
|
|
||||||
import java.awt.FlowLayout;
|
import java.awt.FlowLayout;
|
||||||
import java.awt.GridLayout;
|
import java.awt.GridLayout;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
@ -17,35 +16,41 @@ import sarsoo.fmframework.music.Album;
|
|||||||
import sarsoo.fmframework.music.Track;
|
import sarsoo.fmframework.music.Track;
|
||||||
import sarsoo.fmframework.net.Network;
|
import sarsoo.fmframework.net.Network;
|
||||||
|
|
||||||
public class TrackView extends JFrame{
|
public class TrackView extends JFrame {
|
||||||
JPanel info = new JPanel();
|
|
||||||
JPanel buttons = new JPanel();
|
JPanel buttons = new JPanel();
|
||||||
JPanel buttons2 = new JPanel();
|
JPanel buttons2 = new JPanel();
|
||||||
|
|
||||||
JLabel name = new JLabel();
|
JLabel name = new JLabel();
|
||||||
JLabel album = new JLabel();
|
JLabel album = new JLabel();
|
||||||
JLabel artist = new JLabel();
|
JLabel artist = new JLabel();
|
||||||
JLabel listeners = new JLabel();
|
JLabel listeners = new JLabel();
|
||||||
JLabel playCount = new JLabel();
|
JLabel playCount = new JLabel();
|
||||||
JLabel userPlayCount = new JLabel();
|
JLabel userPlayCount = new JLabel();
|
||||||
|
|
||||||
JButton open = new JButton("View Online");
|
JButton open = new JButton("View Online");
|
||||||
JButton viewArtist = new JButton("View Artist");
|
JButton viewArtist = new JButton("View Artist");
|
||||||
JButton viewAlbum = new JButton("View Album");
|
JButton viewAlbum = new JButton("View Album");
|
||||||
JButton musicBrainz = new JButton("Open MusicBrainz");
|
JButton musicBrainz = new JButton("Open MusicBrainz");
|
||||||
|
JButton genius = new JButton("Open Genius");
|
||||||
|
|
||||||
public TrackView(Track track) {
|
public TrackView(Track track) {
|
||||||
super(track.getName());
|
super(track.getName());
|
||||||
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
|
||||||
setLayout(new GridLayout(8,0));
|
setLayout(new GridLayout(8, 1));
|
||||||
setSize(300, 300);
|
// setSize(300, 300);
|
||||||
setResizable(false);
|
// setResizable(false);
|
||||||
info.setLayout(new GridLayout());
|
|
||||||
buttons.setLayout(new FlowLayout());
|
buttons.setLayout(new FlowLayout());
|
||||||
buttons2.setLayout(new FlowLayout());
|
buttons2.setLayout(new FlowLayout());
|
||||||
|
|
||||||
buttons.add(open);
|
buttons.add(open);
|
||||||
buttons.add(musicBrainz);
|
if (track.getMbid() != null)
|
||||||
|
buttons.add(musicBrainz);
|
||||||
buttons2.add(viewArtist);
|
buttons2.add(viewArtist);
|
||||||
buttons2.add(viewAlbum);
|
if (track.getAlbum() != null)
|
||||||
|
buttons2.add(viewAlbum);
|
||||||
|
if (track.getArtist() != null)
|
||||||
|
buttons2.add(genius);
|
||||||
|
|
||||||
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
NumberFormat numberFormat = NumberFormat.getNumberInstance(Locale.US);
|
||||||
|
|
||||||
@ -56,7 +61,6 @@ public class TrackView extends JFrame{
|
|||||||
playCount.setText(numberFormat.format(track.getPlayCount()) + " Scrobbles");
|
playCount.setText(numberFormat.format(track.getPlayCount()) + " Scrobbles");
|
||||||
userPlayCount.setText(numberFormat.format(track.getUserPlayCount()) + " Your Scrobbles");
|
userPlayCount.setText(numberFormat.format(track.getUserPlayCount()) + " Your Scrobbles");
|
||||||
|
|
||||||
|
|
||||||
open.addActionListener(new ActionListener() {
|
open.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
Network.openURL(track.getUrl());
|
Network.openURL(track.getUrl());
|
||||||
@ -69,7 +73,7 @@ public class TrackView extends JFrame{
|
|||||||
});
|
});
|
||||||
musicBrainz.addActionListener(new ActionListener() {
|
musicBrainz.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
Network.openURL(track.getMusicBrainzURL());;
|
Network.openURL(track.getMusicBrainzURL());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
viewAlbum.addActionListener(new ActionListener() {
|
viewAlbum.addActionListener(new ActionListener() {
|
||||||
@ -77,6 +81,12 @@ public class TrackView extends JFrame{
|
|||||||
track.getAlbum().view();
|
track.getAlbum().view();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
genius.addActionListener(new ActionListener() {
|
||||||
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
|
Network.openURL(track.getLyricsURL());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
add(name);
|
add(name);
|
||||||
add(album);
|
add(album);
|
||||||
add(artist);
|
add(artist);
|
||||||
@ -85,5 +95,6 @@ public class TrackView extends JFrame{
|
|||||||
add(userPlayCount);
|
add(userPlayCount);
|
||||||
add(buttons);
|
add(buttons);
|
||||||
add(buttons2);
|
add(buttons2);
|
||||||
|
pack();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,6 @@ public class Album extends FMObj{
|
|||||||
this.artist = artist;
|
this.artist = artist;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return name + " - " + artist.getName();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Artist getArtist() {
|
public Artist getArtist() {
|
||||||
return artist;
|
return artist;
|
||||||
}
|
}
|
||||||
@ -40,18 +35,34 @@ public class Album extends FMObj{
|
|||||||
return album;
|
return album;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<Track> getTrackList(){
|
|
||||||
return trackList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Track getTrack(int track) {
|
public Track getTrack(int track) {
|
||||||
return trackList.get(track);
|
return trackList.get(track);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<Track> getTrackList(){
|
||||||
|
return trackList;
|
||||||
|
}
|
||||||
|
|
||||||
public ArrayList<Tag> getTags(){
|
public ArrayList<Tag> getTags(){
|
||||||
return tagList;
|
return tagList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getRymURL() {
|
||||||
|
return "https://rateyourmusic.com/release/album/" + getArtist().getName().replaceAll(" ", "_").toLowerCase() + "/" + getName().replaceAll(" ", "_").toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMusicBrainzURL() {
|
||||||
|
return "https://musicbrainz.org/release/" + mbid;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void view() {
|
||||||
|
AlbumView view = new AlbumView(this);
|
||||||
|
view.setVisible(true);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if(obj.getClass() != this.getClass()) return false;
|
if(obj.getClass() != this.getClass()) return false;
|
||||||
@ -64,19 +75,8 @@ public class Album extends FMObj{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRymURL() {
|
public String toString() {
|
||||||
return "https://rateyourmusic.com/release/album/" + getArtist().getName().replaceAll(" ", "_").toLowerCase() + "/" + getName().replaceAll(" ", "_").toLowerCase();
|
return name + " - " + artist.getName();
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void view() {
|
|
||||||
AlbumView view = new AlbumView(this);
|
|
||||||
view.setVisible(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMusicBrainzURL() {
|
|
||||||
return "https://musicbrainz.org/release/" + mbid;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,10 +22,6 @@ public class Artist extends FMObj{
|
|||||||
super(name, url, mbid, listeners, playCount, userPlayCount, wiki);
|
super(name, url, mbid, listeners, playCount, userPlayCount, wiki);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Artist getArtist(String name, String username) {
|
public static Artist getArtist(String name, String username) {
|
||||||
String url = Network.getArtistInfoUrl(name, username);
|
String url = Network.getArtistInfoUrl(name, username);
|
||||||
Document response = Network.getResponse(url);
|
Document response = Network.getResponse(url);
|
||||||
@ -52,6 +48,15 @@ public class Artist extends FMObj{
|
|||||||
return tagList;
|
return tagList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMusicBrainzURL() {
|
||||||
|
return "https://musicbrainz.org/artist/" + mbid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getRymURL() {
|
||||||
|
return "https://rateyourmusic.com/artist/" + getName().replaceAll(" ", "_").toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if(obj.getClass() != this.getClass()) return false;
|
if(obj.getClass() != this.getClass()) return false;
|
||||||
@ -63,14 +68,8 @@ public class Artist extends FMObj{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public String toString() {
|
||||||
public String getMusicBrainzURL() {
|
return name;
|
||||||
return "https://musicbrainz.org/artist/" + mbid;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getRymURL() {
|
|
||||||
return "https://rateyourmusic.com/artist/" + getName().replaceAll(" ", "_").toLowerCase();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package sarsoo.fmframework.music;
|
package sarsoo.fmframework.music;
|
||||||
|
|
||||||
import java.awt.Component;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
import sarsoo.fmframework.gui.FMObjView;
|
|
||||||
import sarsoo.fmframework.gui.TrackView;
|
import sarsoo.fmframework.gui.TrackView;
|
||||||
import sarsoo.fmframework.net.Network;
|
import sarsoo.fmframework.net.Network;
|
||||||
import sarsoo.fmframework.parser.Parser;
|
import sarsoo.fmframework.parser.Parser;
|
||||||
@ -48,6 +46,19 @@ public class Track extends FMObj{
|
|||||||
this.album = album;
|
this.album = album;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMusicBrainzURL() {
|
||||||
|
return "https://musicbrainz.org/artist/" + mbid;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getLyricsURL() {
|
||||||
|
return Network.getLyricsUrl(name, artist.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Album getAlbum() {
|
||||||
|
return album;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if(obj.getClass() != this.getClass()) return false;
|
if(obj.getClass() != this.getClass()) return false;
|
||||||
@ -60,18 +71,14 @@ public class Track extends FMObj{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMusicBrainzURL() {
|
|
||||||
return "https://musicbrainz.org/artist/" + mbid;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void view() {
|
public void view() {
|
||||||
TrackView view = new TrackView(this);
|
TrackView view = new TrackView(this);
|
||||||
view.setVisible(true);
|
view.setVisible(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Album getAlbum() {
|
public String toString() {
|
||||||
return album;
|
return name + " - " + artist.getName();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,20 +51,12 @@ public class Network {
|
|||||||
} catch (ParserConfigurationException e) {
|
} catch (ParserConfigurationException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
} catch (
|
|
||||||
|
|
||||||
MalformedURLException e) {
|
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
} catch (ApiCallException e) {
|
} catch (ApiCallException e) {
|
||||||
System.out.println(e.getFailureCode() + " " + e.getError());
|
System.err.println(e.getFailureCode() + " " + e.getError());
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
@ -72,7 +64,7 @@ public class Network {
|
|||||||
|
|
||||||
public static String getArtistInfoUrl(String artist, String username) {
|
public static String getArtistInfoUrl(String artist, String username) {
|
||||||
String urlString = String.format(
|
String urlString = String.format(
|
||||||
"http://ws.audioscrobbler.com/2.0/?method=artist.getInfo&artist=%s&autocorrect=1&username=%s&api_key=%s",
|
"http://ws.audioscrobbler.com/2.0/?method=artist.getInfo&artist=%s&autocorrect=0&username=%s&api_key=%s",
|
||||||
artist, username, Key.getKey());
|
artist, username, Key.getKey());
|
||||||
return urlString;
|
return urlString;
|
||||||
|
|
||||||
@ -80,7 +72,7 @@ public class Network {
|
|||||||
|
|
||||||
public static String getArtistInfoMbidUrl(String mbid, String username) {
|
public static String getArtistInfoMbidUrl(String mbid, String username) {
|
||||||
String urlString = String.format(
|
String urlString = String.format(
|
||||||
"http://ws.audioscrobbler.com/2.0/?method=artist.getInfo&mbid=%s&autocorrect=1&username=%s&api_key=%s",
|
"http://ws.audioscrobbler.com/2.0/?method=artist.getInfo&mbid=%s&autocorrect=0&username=%s&api_key=%s",
|
||||||
mbid, username, Key.getKey());
|
mbid, username, Key.getKey());
|
||||||
return urlString;
|
return urlString;
|
||||||
|
|
||||||
@ -88,22 +80,31 @@ public class Network {
|
|||||||
|
|
||||||
public static String getAlbumInfoUrl(String album, String artist, String username) {
|
public static String getAlbumInfoUrl(String album, String artist, String username) {
|
||||||
String urlString = String.format(
|
String urlString = String.format(
|
||||||
"http://ws.audioscrobbler.com/2.0/?method=album.getInfo&album=%s&artist=%s&autocorrect=1&username=%s&api_key=%s",
|
"http://ws.audioscrobbler.com/2.0/?method=album.getInfo&album=%s&artist=%s&autocorrect=0&username=%s&api_key=%s",
|
||||||
album, artist, username, Key.getKey());
|
album, artist, username, Key.getKey());
|
||||||
return urlString;
|
return urlString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getTrackInfoUrl(String name, String artist, String username) {
|
public static String getTrackInfoUrl(String name, String artist, String username) {
|
||||||
String urlString = String.format(
|
String urlString = String.format(
|
||||||
"http://ws.audioscrobbler.com/2.0/?method=track.getInfo&track=%s&artist=%s&autocorrect=1&username=%s&api_key=%s",
|
"http://ws.audioscrobbler.com/2.0/?method=track.getInfo&track=%s&artist=%s&autocorrect=0&username=%s&api_key=%s",
|
||||||
name, artist, username, Key.getKey());
|
name, artist, username, Key.getKey());
|
||||||
return urlString;
|
return urlString;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getLastTrackUrl(String username) {
|
public static String getLastTrackUrl(String username) {
|
||||||
String urlString = String.format(
|
String urlString = String.format(
|
||||||
"http://ws.audioscrobbler.com/2.0/?method=user.getRecentTracks&limit=1&user=%s&api_key=%s",
|
"http://ws.audioscrobbler.com/2.0/?method=user.getRecentTracks&limit=1&user=%s&api_key=%s", username,
|
||||||
username, Key.getKey());
|
Key.getKey());
|
||||||
|
return urlString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getLyricsUrl(String trackName, String artistName) {
|
||||||
|
String track = trackName.replaceAll(" ", "-");
|
||||||
|
// track = track.replaceAll("[^a-zA-Z ]", "").toLowerCase();
|
||||||
|
String artist = artistName.replaceAll(" ", "-");
|
||||||
|
// artist = artist.replaceAll("[^a-zA-Z ]", "").toLowerCase();
|
||||||
|
String urlString = String.format("http://genius.com/%s-%s-lyrics", artist, track);
|
||||||
return urlString;
|
return urlString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,106 +24,157 @@ import sarsoo.fmframework.util.Reference;
|
|||||||
public class Parser {
|
public class Parser {
|
||||||
|
|
||||||
public static Album parseAlbum(Document doc) {
|
public static Album parseAlbum(Document doc) {
|
||||||
|
try {
|
||||||
|
String name = doc.getElementsByTagName("name").item(0).getTextContent();
|
||||||
|
String artist = doc.getElementsByTagName("artist").item(0).getTextContent();
|
||||||
|
String mbid = null;
|
||||||
|
try {
|
||||||
|
mbid = doc.getElementsByTagName("mbid").item(0).getTextContent();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
System.err.println("Null Mbid for " + name);
|
||||||
|
}
|
||||||
|
String url = doc.getElementsByTagName("url").item(0).getTextContent();
|
||||||
|
int listeners = Integer.parseInt(doc.getElementsByTagName("listeners").item(0).getTextContent());
|
||||||
|
int playCount = Integer.parseInt(doc.getElementsByTagName("playcount").item(0).getTextContent());
|
||||||
|
|
||||||
String name = doc.getElementsByTagName("name").item(0).getTextContent();
|
int userPlayCount = 0;
|
||||||
String artist = doc.getElementsByTagName("artist").item(0).getTextContent();
|
try {
|
||||||
String mbid = doc.getElementsByTagName("mbid").item(0).getTextContent();
|
userPlayCount = Integer.parseInt(doc.getElementsByTagName("userplaycount").item(0).getTextContent());
|
||||||
String url = doc.getElementsByTagName("url").item(0).getTextContent();
|
} catch (Exception e) {
|
||||||
int listeners = Integer.parseInt(doc.getElementsByTagName("listeners").item(0).getTextContent());
|
System.err.println("Couldn't parse userPlayCount, possibly unscrobbled");
|
||||||
int playCount = Integer.parseInt(doc.getElementsByTagName("playcount").item(0).getTextContent());
|
}
|
||||||
int userPlayCount = Integer.parseInt(doc.getElementsByTagName("userplaycount").item(0).getTextContent());
|
|
||||||
|
|
||||||
// Node trackListNode = doc.getElementsByTagName("tracks").item(0);
|
// Node trackListNode = doc.getElementsByTagName("tracks").item(0);
|
||||||
// NodeList trackNodeList = trackListNode.getChildNodes();
|
// NodeList trackNodeList = trackListNode.getChildNodes();
|
||||||
// if (trackListNode != null) {
|
// if (trackListNode != null) {
|
||||||
// int counter = 0;
|
// int counter = 0;
|
||||||
// while (trackNodeList.item(counter) != null) {
|
// while (trackNodeList.item(counter) != null) {
|
||||||
// Node track = trackNodeList.item(counter);
|
// Node track = trackNodeList.item(counter);
|
||||||
// //System.out.println(track.getTextContent());
|
// //System.out.println(track.getTextContent());
|
||||||
// String trackName = track.getFirstChild().getTextContent();
|
// String trackName = track.getFirstChild().getTextContent();
|
||||||
// String trackUrl =
|
// String trackUrl =
|
||||||
// track.getFirstChild().getNextSibling().getNextSibling().getTextContent();
|
// track.getFirstChild().getNextSibling().getNextSibling().getTextContent();
|
||||||
// //String trackDuration =
|
// //String trackDuration =
|
||||||
// track.getFirstChild().getNextSibling().getNextSibling().getNextSibling().getNextSibling().getTextContent();
|
// track.getFirstChild().getNextSibling().getNextSibling().getNextSibling().getNextSibling().getTextContent();
|
||||||
// int trackNumber =
|
// int trackNumber =
|
||||||
// Integer.parseInt(track.getAttributes().getNamedItem("rank").getNodeValue());
|
// Integer.parseInt(track.getAttributes().getNamedItem("rank").getNodeValue());
|
||||||
// // String trackName =
|
// // String trackName =
|
||||||
// // trackListNode.getFirstChild().getFirstChild().getTextContent();
|
// // trackListNode.getFirstChild().getFirstChild().getTextContent();
|
||||||
// // String trackUrl = trackListNode.getNextSibling().getTextContent();
|
// // String trackUrl = trackListNode.getNextSibling().getTextContent();
|
||||||
// System.out.println(trackUrl);
|
// System.out.println(trackUrl);
|
||||||
// counter++;
|
// counter++;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// Node wikiNode = doc.getElementsByTagName("wiki").item(0);
|
// Node wikiNode = doc.getElementsByTagName("wiki").item(0);
|
||||||
// String published = wikiNode.getFirstChild().getTextContent();
|
// String published = wikiNode.getFirstChild().getTextContent();
|
||||||
// String summary = wikiNode.getFirstChild().getNextSibling().getTextContent();
|
// String summary = wikiNode.getFirstChild().getNextSibling().getTextContent();
|
||||||
// String content =
|
// String content =
|
||||||
// wikiNode.getFirstChild().getNextSibling().getNextSibling().getTextContent();
|
// wikiNode.getFirstChild().getNextSibling().getNextSibling().getTextContent();
|
||||||
|
|
||||||
// System.out.println(published);
|
// System.out.println(published);
|
||||||
// System.out.println(summary);
|
// System.out.println(summary);
|
||||||
// System.out.println(content);
|
// System.out.println(content);
|
||||||
|
|
||||||
Artist artistObj = Artist.getArtist(artist, Reference.getUserName());
|
Artist artistObj = Artist.getArtist(artist, Reference.getUserName());
|
||||||
Wiki wiki = new Wiki();
|
Wiki wiki = new Wiki();
|
||||||
|
|
||||||
Album album = new Album(name, url, mbid, artistObj, listeners, playCount, userPlayCount, wiki);
|
Album album = new Album(name, url, mbid, artistObj, listeners, playCount, userPlayCount, wiki);
|
||||||
return album;
|
return album;
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
System.err.println("Could Not Parse Album");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Artist parseArtist(Document doc) {
|
public static Artist parseArtist(Document doc) {
|
||||||
|
try {
|
||||||
|
String name = doc.getElementsByTagName("name").item(0).getTextContent();
|
||||||
|
String mbid = null;
|
||||||
|
try {
|
||||||
|
mbid = doc.getElementsByTagName("mbid").item(0).getTextContent();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
System.err.println("Null Mbid for " + name);
|
||||||
|
}
|
||||||
|
String url = doc.getElementsByTagName("url").item(0).getTextContent();
|
||||||
|
// String streamable =
|
||||||
|
// doc.getElementsByTagName("streamable").item(0).getTextContent();
|
||||||
|
int listeners = Integer.parseInt(doc.getElementsByTagName("listeners").item(0).getTextContent());
|
||||||
|
int playCount = Integer.parseInt(doc.getElementsByTagName("playcount").item(0).getTextContent());
|
||||||
|
|
||||||
String name = doc.getElementsByTagName("name").item(0).getTextContent();
|
int userPlayCount = 0;
|
||||||
String mbid = doc.getElementsByTagName("mbid").item(0).getTextContent();
|
try {
|
||||||
String url = doc.getElementsByTagName("url").item(0).getTextContent();
|
userPlayCount = Integer.parseInt(doc.getElementsByTagName("userplaycount").item(0).getTextContent());
|
||||||
// String streamable =
|
} catch (Exception e) {
|
||||||
// doc.getElementsByTagName("streamable").item(0).getTextContent();
|
System.err.println("Couldn't parse userPlayCount, possibly unscrobbled");
|
||||||
int listeners = Integer.parseInt(doc.getElementsByTagName("listeners").item(0).getTextContent());
|
}
|
||||||
int playCount = Integer.parseInt(doc.getElementsByTagName("playcount").item(0).getTextContent());
|
// System.out.println(listeners);
|
||||||
int userPlayCount = Integer.parseInt(doc.getElementsByTagName("userplaycount").item(0).getTextContent());
|
|
||||||
|
|
||||||
// System.out.println(listeners);
|
Artist artist = new Artist(name, url, mbid, listeners, playCount, userPlayCount, false, false, null);
|
||||||
|
return artist;
|
||||||
Artist artist = new Artist(name, url, mbid, listeners, playCount, userPlayCount, false, false, null);
|
} catch (NullPointerException e) {
|
||||||
return artist;
|
System.err.println("Could Not Parse Artist");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Track parseTrack(Document doc) {
|
public static Track parseTrack(Document doc) {
|
||||||
|
|
||||||
String name = doc.getElementsByTagName("name").item(0).getTextContent();
|
try {
|
||||||
String artistName = doc.getElementsByTagName("artist").item(0).getFirstChild().getTextContent();
|
String name = doc.getElementsByTagName("name").item(0).getTextContent();
|
||||||
String mbid = doc.getElementsByTagName("mbid").item(0).getTextContent();
|
String artistName = doc.getElementsByTagName("artist").item(0).getFirstChild().getTextContent();
|
||||||
String url = doc.getElementsByTagName("url").item(0).getTextContent();
|
String mbid = null;
|
||||||
int listeners = Integer.parseInt(doc.getElementsByTagName("listeners").item(0).getTextContent());
|
try {
|
||||||
int playCount = Integer.parseInt(doc.getElementsByTagName("playcount").item(0).getTextContent());
|
mbid = doc.getElementsByTagName("mbid").item(0).getTextContent();
|
||||||
int userPlayCount = Integer.parseInt(doc.getElementsByTagName("userplaycount").item(0).getTextContent());
|
} catch (NullPointerException e) {
|
||||||
|
System.err.println("Null Mbid for " + name + " - " + artistName);
|
||||||
|
}
|
||||||
|
String url = doc.getElementsByTagName("url").item(0).getTextContent();
|
||||||
|
int listeners = Integer.parseInt(doc.getElementsByTagName("listeners").item(0).getTextContent());
|
||||||
|
int playCount = Integer.parseInt(doc.getElementsByTagName("playcount").item(0).getTextContent());
|
||||||
|
|
||||||
Artist artistObj = Artist.getArtist(artistName, Reference.getUserName());
|
int userPlayCount = 0;
|
||||||
|
try {
|
||||||
|
userPlayCount = Integer.parseInt(doc.getElementsByTagName("userplaycount").item(0).getTextContent());
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.err.println("Couldn't parse userPlayCount, possibly unscrobbled");
|
||||||
|
}
|
||||||
|
|
||||||
// System.out.println(userPlayCount);
|
// String albumName =
|
||||||
|
// doc.getElementsByTagName("album").item(0).getTextContent();
|
||||||
|
// System.out.println(albumName);
|
||||||
|
Artist artistObj = Artist.getArtist(artistName, Reference.getUserName());
|
||||||
|
|
||||||
Track track = new Track(name, url, mbid, artistObj, listeners, playCount, userPlayCount, null);
|
// System.out.println(userPlayCount);
|
||||||
return track;
|
|
||||||
|
|
||||||
|
Track track = new Track(name, url, mbid, artistObj, listeners, playCount, userPlayCount, null);
|
||||||
|
return track;
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
System.err.println("Could Not Parse Track");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Track parseLastTrack(Document doc) {
|
public static Track parseLastTrack(Document doc) {
|
||||||
|
try {
|
||||||
|
String name = doc.getElementsByTagName("name").item(0).getTextContent();
|
||||||
|
|
||||||
String name = doc.getElementsByTagName("name").item(0).getTextContent();
|
String artistName = doc.getElementsByTagName("artist").item(0).getTextContent();
|
||||||
|
|
||||||
String artistName = doc.getElementsByTagName("artist").item(0).getTextContent();
|
String albumName = doc.getElementsByTagName("album").item(0).getTextContent();
|
||||||
|
|
||||||
String albumName = doc.getElementsByTagName("album").item(0).getTextContent();
|
Track track = Track.getTrack(name, artistName, Reference.getUserName());
|
||||||
|
|
||||||
Track track = Track.getTrack(name, artistName, Reference.getUserName());
|
Album album = Album.getAlbum(albumName, artistName, Reference.getUserName());
|
||||||
|
|
||||||
Album album = Album.getAlbum(albumName, artistName, Reference.getUserName());
|
track.setAlbum(album);
|
||||||
|
|
||||||
track.setAlbum(album);
|
return track;
|
||||||
|
} catch (NullPointerException e) {
|
||||||
return track;
|
System.err.println("Could Not Parse Track");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package sarsoo.fmframework.test;
|
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.*;
|
|
||||||
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
import org.w3c.dom.Document;
|
|
||||||
|
|
||||||
import sarsoo.fmframework.music.Album;
|
|
||||||
import sarsoo.fmframework.net.Network;
|
|
||||||
import sarsoo.fmframework.parser.AlbumParser;
|
|
||||||
|
|
||||||
class AlbumParserTest {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
void test() {
|
|
||||||
//Document doc = Network.apiAlbumInfoCall("Pink Floyd", "The Wall", "sarsoo");
|
|
||||||
//Album album = AlbumParser.parseAlbum(doc);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -20,4 +20,11 @@ class AlbumTest {
|
|||||||
assertEquals(album.getArtist().getName(), "Eminem");
|
assertEquals(album.getArtist().getName(), "Eminem");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
void testListeners() {
|
||||||
|
Album album = Album.getAlbum("Recovery", "Eminem", "sarsoo");
|
||||||
|
assertNotNull(album.getListeners());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import sarsoo.fmframework.gui.ArtistListView;
|
|||||||
import sarsoo.fmframework.music.Artist;
|
import sarsoo.fmframework.music.Artist;
|
||||||
|
|
||||||
public class ArtistList extends ArrayList<Artist> {
|
public class ArtistList extends ArrayList<Artist> {
|
||||||
|
|
||||||
private String groupName = null;
|
private String groupName = null;
|
||||||
|
|
||||||
public ArtistList() {
|
public ArtistList() {
|
||||||
|
@ -5,6 +5,7 @@ import javax.swing.JOptionPane;
|
|||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
|
||||||
import sarsoo.fmframework.music.Album;
|
import sarsoo.fmframework.music.Album;
|
||||||
|
import sarsoo.fmframework.music.Artist;
|
||||||
import sarsoo.fmframework.music.Track;
|
import sarsoo.fmframework.music.Track;
|
||||||
import sarsoo.fmframework.net.Network;
|
import sarsoo.fmframework.net.Network;
|
||||||
import sarsoo.fmframework.parser.Parser;
|
import sarsoo.fmframework.parser.Parser;
|
||||||
@ -12,8 +13,21 @@ import sarsoo.fmframework.parser.Parser;
|
|||||||
public class GetObject {
|
public class GetObject {
|
||||||
public static Album getAlbum() {
|
public static Album getAlbum() {
|
||||||
String artistName = JOptionPane.showInputDialog(null, "Enter Artist Name");
|
String artistName = JOptionPane.showInputDialog(null, "Enter Artist Name");
|
||||||
String albumName = JOptionPane.showInputDialog(null, "Enter Album Name");
|
if (artistName != null) {
|
||||||
return Album.getAlbum(albumName, artistName, "sarsoo");
|
String albumName = JOptionPane.showInputDialog(null, "Enter Album Name");
|
||||||
|
if (albumName != null) {
|
||||||
|
return Album.getAlbum(albumName, artistName, Reference.getUserName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Artist getArtist() {
|
||||||
|
String artistName = JOptionPane.showInputDialog(null, "Enter Artist Name");
|
||||||
|
if (artistName != null) {
|
||||||
|
return Artist.getArtist(artistName, Reference.getUserName());
|
||||||
|
}
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Track getLastTrack() {
|
public static Track getLastTrack() {
|
||||||
|
@ -4,6 +4,7 @@ import sarsoo.fmframework.music.Artist;
|
|||||||
|
|
||||||
public class Reference {
|
public class Reference {
|
||||||
private static String userName;
|
private static String userName;
|
||||||
|
private static boolean isHeadless = true;
|
||||||
|
|
||||||
public static String getUserName() {
|
public static String getUserName() {
|
||||||
return userName;
|
return userName;
|
||||||
@ -13,6 +14,14 @@ public class Reference {
|
|||||||
userName = userNameIn;
|
userName = userNameIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean getIsHeadless() {
|
||||||
|
return isHeadless;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void setIsHeadless(boolean headlessIn) {
|
||||||
|
isHeadless = headlessIn;
|
||||||
|
}
|
||||||
|
|
||||||
public static ArtistList getTDE() {
|
public static ArtistList getTDE() {
|
||||||
ArtistList tde = new ArtistList("TDE");
|
ArtistList tde = new ArtistList("TDE");
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user