Gives the interface the ability to pull information from the YouTube page.

This will make filling in song data much easier.
This commit is contained in:
Markil3
2021-10-10 16:20:01 -06:00
parent a92d686ddb
commit 0de20568a7
18 changed files with 1012 additions and 246 deletions

View File

@@ -1,5 +0,0 @@
package edu.regis.universeplayer;
public class AutoGson
{
}

View File

@@ -4,11 +4,13 @@
package edu.regis.universeplayer.data;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;
import javax.swing.ImageIcon;
public class Album implements Comparable<Album>
public class Album implements Comparable<Album>, Serializable
{
public int id;
public String name;
@@ -18,7 +20,30 @@ public class Album implements Comparable<Album>
public String[] genres;
public int totalTracks;
public int totalDiscs;
@Override
public boolean equals(Object o)
{
if (this == o)
{
return true;
}
if (!(o instanceof Album album))
{
return false;
}
return year == album.year && totalTracks == album.totalTracks && totalDiscs == album.totalDiscs && name.equals(album.name) && Arrays.equals(artists, album.artists) && Arrays.equals(genres, album.genres);
}
@Override
public int hashCode()
{
int result = Objects.hash(name, year, totalTracks, totalDiscs);
result = 31 * result + Arrays.hashCode(artists);
result = 31 * result + Arrays.hashCode(genres);
return result;
}
@Override
public int compareTo(Album o)
{

View File

@@ -10,7 +10,11 @@ import org.slf4j.LoggerFactory;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Arrays;
import java.util.Objects;
/**
* An internet song is a specific type of song that is accessed from a webpage.
*/
public class InternetSong extends Song
{
private static final Logger logger = LoggerFactory
@@ -21,6 +25,30 @@ public class InternetSong extends Song
*/
public URL location;
@Override
public boolean equals(Object o)
{
if (this == o)
{
return true;
}
if (!(o instanceof InternetSong that))
{
return false;
}
if (!super.equals(o))
{
return false;
}
return Objects.equals(location, that.location);
}
@Override
public int hashCode()
{
return Objects.hash(super.hashCode(), location);
}
@Override
public int compareTo(Song o)
{

View File

@@ -6,6 +6,7 @@ package edu.regis.universeplayer.data;
import java.io.File;
import java.util.Arrays;
import java.util.Objects;
/**
* This song represents a song found on the local file system.
@@ -30,6 +31,30 @@ public class LocalSong extends Song
*/
public long lastMod;
@Override
public boolean equals(Object o)
{
if (this == o)
{
return true;
}
if (!(o instanceof LocalSong localSong))
{
return false;
}
if (!super.equals(o))
{
return false;
}
return file.equals(localSong.file);
}
@Override
public int hashCode()
{
return Objects.hash(super.hashCode(), file);
}
@Override
public int compareTo(Song o)
{

View File

@@ -6,6 +6,7 @@ package edu.regis.universeplayer.data;
import java.io.Serializable;
import java.util.Arrays;
import java.util.Objects;
/**
* Contains data for a song.
@@ -42,6 +43,28 @@ public class Song implements Comparable<Song>, Serializable
*/
public Album album;
@Override
public boolean equals(Object o)
{
if (this == o)
{
return true;
}
if (!(o instanceof Song song))
{
return false;
}
return trackNum == song.trackNum && disc == song.disc && title.equals(song.title) && Arrays.equals(artists, song.artists) && album.equals(song.album);
}
@Override
public int hashCode()
{
int result = Objects.hash(title, trackNum, disc, album);
result = 31 * result + Arrays.hashCode(artists);
return result;
}
@Override
public int compareTo(Song o)
{