public class MusicbrainzRestRequester extends RestRequester
discid, isrc, iswc
Modifier and Type | Field and Description |
---|---|
protected static String |
CLASSNAME |
protected String |
coverartImageUrl_
The URL for the CoverArt for any MRID looked up release.
|
protected static boolean |
debugOut_ |
protected static String |
DEFAULT_COVERARTARCHIVE_IP
DEFAULT CoverArt Archive server used by MUSICBRAINZ .
|
protected static String |
DEFAULT_COVERARTARCHIVE_REST_URL_PATHSTR
DEFAULT CoverArt Archive rest URL to start the URL path: /rest .
|
protected static String |
DEFAULT_COVERARTARCHIVE_TEST_IMAGE_ID |
protected static String |
DEFAULT_MUSICBRAINZ_IP
DEFAULT MUSICBRAINZ IP address to use: 10.0.0.207 .
|
protected static String |
DEFAULT_MUSICBRAINZ_PASSWORD
DEFAULT MUSICBRAINZ password to use: admin .
|
protected static String |
DEFAULT_MUSICBRAINZ_REST_URL_PATHSTR
DEFAULT MUSICBRAINZ rest URL to start the URL path: /rest .
|
protected static String |
DEFAULT_MUSICBRAINZ_TEST_ARTIST_MRID |
protected static String |
DEFAULT_MUSICBRAINZ_TEST_RELEASE_MRID
A default Release MRID to use for testing.
|
protected static String |
DEFAULT_MUSICBRAINZ_USERNAME
DEFAULT MUSICBRAINZ username to use: admin .
|
protected static boolean |
doWrites_ |
protected static StringBuilder |
helpMsg_ |
static String |
LOG_TAG |
protected String |
metaDataDirFilename_ |
protected String |
metaDataFilename_ |
protected String |
restUrlPath_
The start path to use in therest URL.
|
(package private) Builder |
xmlBuilder_ |
acceptJSON_, authenticating_, baseUrl_, password_, SYSTEM_FILE_SEPERATOR, SYSTEM_LINE_SEPERATOR, USER_AGENT, username_
Constructor and Description |
---|
MusicbrainzRestRequester()
Default constructor .
|
MusicbrainzRestRequester(String server,
String user,
String pass)
Constructor to customize all connection settings.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canConnect()
Check connectivity to the MusicBrainz URL specified by the class parms.
|
StringBuilder |
getConfig()
returns config.
|
String |
getCoverArtImageUrlStrByMbid(String mrid) |
String |
getCoverArtImageUrlStrByRelease(String artName,
String albName) |
protected static StringBuilder |
getHelpMsg()
initializes and gets the helpMsg_
class var.
|
protected static String |
getHelpMsgStr()
gets the help as a String.
|
StringBuilder |
getQuery()
queries all the nodes.
|
String |
getRestUrlPath()
Get Method for class field 'restUrlPath_'.
|
StringBuilder |
getStatus()
returns the status for all the nodes.
|
protected StringBuilder |
lookupArtist(String mrid) |
StringBuilder |
lookupArtist(String mrid,
String[] incs)
commandLine command executor method for the test Command.
|
protected StringBuilder |
lookupRelease(String mrid) |
StringBuilder |
lookupRelease(String mrid,
String[] incs)
commandLine command executor method for the test Command.
|
static void |
main(String[] args)
Class main commandLine entry method that has a test command and some convienience commands, as well as a pure rest command.
|
void |
parseArtistDir(String artistDirPath)
Parses the tunes dir and reads in all the artists.
|
Date |
parseFirstReleaseDate(Document respDoc) |
Element |
parseFirstReleaseEventElem(Document respDoc) |
Element |
parseFirstReleaseListElem(Document respDoc)
parses through a returned responseResult doc and looks for the 1st "release" element.
|
int |
parseFirstReleaseYear(Document respDoc) |
Date |
parseReleaseDate(Document respDoc,
int releaseIndex) |
Element |
parseReleaseEventElem(Document respDoc,
int releaseIndex) |
Elements |
parseReleaseEventElems(Document respDoc) |
Element |
parseReleaseListElem(Document respDoc,
int releaseIndex)
parses through a returned responseResult doc and looks for the releaseIndex "release" element.
|
Elements |
parseReleaseListElems(Document respDoc) |
int |
parseReleaseYear(Document respDoc,
int releaseIndex) |
Element |
parseSearchResultsForFirstReleaseElem(Document respDoc)
loops through a returned responseResult doc and looks for the 1st result.
|
String |
parseSearchResultsForFirstReleaseStatus(Document respDoc)
Parses through the Release search results doc, gets the 1st release
and looks for the status subElement.
|
String |
parseSearchResultsForFirstReleaseSubElement(Document respDoc,
String elementName)
Parses through the Release search results doc, gets the 1st release element
and looks for the subElement named elemntName passed into this method.
|
String |
parseSearchResultsForMRID(Document respDoc,
int releaseIndex)
Parses through the Release search results doc, gets the 'releaseIndex' release element
and looks for its MRID.
|
Element |
parseSearchResultsForReleaseElem(Document respDoc,
int releaseIndex)
loops through a returned responseResult doc and looks for the 'releaseIndex' result.
|
String |
parseSearchResultsForReleaseStatus(Document respDoc,
int releaseIndex)
Parses through the Release search results doc, gets the 'releaseIndex' release element
and looks for the status subElement.
|
String |
parseSearchResultsForReleaseSubElement(Document respDoc,
int releaseIndex,
String elementName)
Parses through the search results doc, gets the releaseIndex specified release
and looks for the subElement named elemntName passed into this method.
|
int |
parseSearchResultsForReleaseYear(Document respDoc) |
void |
parseTunesDir(String tunesDirPath)
Parses the tunes dir and reads in all the artists.
|
Document |
parseXMLResponse(String respXmlStr) |
static String |
prettyJson(String jsonStr)
Makes the JSON string pretty with indenting.
|
protected void |
restCMD(String[] args)
commandLine command executor method for the default rest Command.
|
String |
right(String value,
int length) |
StringBuilder |
searchArtist(String artist) |
StringBuilder |
searchArtist(String artist,
int limit)
Wraps the MusicBrainz search, specifically for an Artist ; example: https://musicbrainz.org/ws/2/release/?
|
StringBuilder |
searchRelease(String artist,
String release) |
StringBuilder |
searchRelease(String artist,
String release,
int limit)
Wraps the MusicBrainz search, specifically for a release ; example: https://musicbrainz.org/ws/2/release/?
|
void |
setRestUrlPath(String restUrlPath)
Set Method for class field 'restUrlPath_'.
|
protected void |
templateCMD(String[] args)
Template method for future commandLine command executor methods.
|
protected void |
testCMD(String[] args)
commandLine command executor method for the test Command.
|
callService, callService, getAcceptJSON, getBaseUrl, getPassword, getServiceUrl, getUsername, isInit, responseIndenter, serviceGet, servicePost, setAcceptJSON, setBaseUrl, setPassword, setUsername
protected static final String CLASSNAME
public static final String LOG_TAG
protected static final String DEFAULT_MUSICBRAINZ_IP
protected static final String DEFAULT_COVERARTARCHIVE_IP
protected static final String DEFAULT_MUSICBRAINZ_USERNAME
protected static final String DEFAULT_MUSICBRAINZ_PASSWORD
protected static final String DEFAULT_MUSICBRAINZ_REST_URL_PATHSTR
protected static final String DEFAULT_COVERARTARCHIVE_REST_URL_PATHSTR
protected static final String DEFAULT_MUSICBRAINZ_TEST_RELEASE_MRID
protected static final String DEFAULT_COVERARTARCHIVE_TEST_IMAGE_ID
protected static final String DEFAULT_MUSICBRAINZ_TEST_ARTIST_MRID
protected static StringBuilder helpMsg_
protected static boolean debugOut_
protected static boolean doWrites_
protected String metaDataDirFilename_
protected String metaDataFilename_
protected String restUrlPath_
protected String coverartImageUrl_
Builder xmlBuilder_
public MusicbrainzRestRequester()
public MusicbrainzRestRequester(String server, String user, String pass)
public void setRestUrlPath(String restUrlPath)
restUrlPath
- is the value to set this class field to.public String getRestUrlPath()
public String getCoverArtImageUrlStrByRelease(String artName, String albName)
public String getCoverArtImageUrlStrByMbid(String mrid)
public boolean canConnect()
public StringBuilder getStatus()
public StringBuilder getQuery()
public StringBuilder getConfig()
public static void main(String[] args)
public void parseArtistDir(String artistDirPath)
public void parseTunesDir(String tunesDirPath)
protected void testCMD(String[] args)
args
- the array of commandLine args that got passed inprotected StringBuilder lookupRelease(String mrid)
public StringBuilder lookupRelease(String mrid, String[] incs)
mrid
- the MusicBrainz Release ID to lookupincs
- the optional array of associated includes to add to the lookup, null to not add any extra includespublic StringBuilder searchRelease(String artist, String release)
public StringBuilder searchRelease(String artist, String release, int limit)
artist
- the artistName of teh releaserelease
- the name of the releaselimit
- the maximum number of returned resultspublic StringBuilder searchArtist(String artist)
public StringBuilder searchArtist(String artist, int limit)
artist
- the artistName of teh releaselimit
- the maximum number of returned resultsprotected StringBuilder lookupArtist(String mrid)
public StringBuilder lookupArtist(String mrid, String[] incs)
mrid
- the MusicBrainz Release ID to lookupincs
- the optional array of associated includes to add to the lookup, null to not add any extra includespublic Document parseXMLResponse(String respXmlStr)
public Date parseFirstReleaseDate(Document respDoc)
public Date parseReleaseDate(Document respDoc, int releaseIndex)
public int parseFirstReleaseYear(Document respDoc)
public int parseReleaseYear(Document respDoc, int releaseIndex)
public Elements parseReleaseEventElems(Document respDoc)
public Elements parseReleaseListElems(Document respDoc)
public Element parseFirstReleaseEventElem(Document respDoc)
public Element parseReleaseEventElem(Document respDoc, int releaseIndex)
public Element parseFirstReleaseListElem(Document respDoc)
respDoc
- is the MB responseResult XML document from a release query requestpublic Element parseReleaseListElem(Document respDoc, int releaseIndex)
respDoc
- is the MB responseResult XML document from a release query requestreleaseIndex
- is the zero based release element to returnpublic int parseSearchResultsForReleaseYear(Document respDoc)
public Element parseSearchResultsForFirstReleaseElem(Document respDoc)
public Element parseSearchResultsForReleaseElem(Document respDoc, int releaseIndex)
respDoc
- is the MB responseResult XML document from a release query requestreleaseIndex
- is the zero based release element to returnpublic String parseSearchResultsForFirstReleaseStatus(Document respDoc)
public String parseSearchResultsForReleaseStatus(Document respDoc, int releaseIndex)
respDoc
- is the MB responseResult XML document from a release query requestreleaseIndex
- is the zero based release element' status sub-element to returnpublic String parseSearchResultsForMRID(Document respDoc, int releaseIndex)
respDoc
- is the MB responseResult XML document from a release query requestreleaseIndex
- is the zero based release to returnpublic String parseSearchResultsForFirstReleaseSubElement(Document respDoc, String elementName)
public String parseSearchResultsForReleaseSubElement(Document respDoc, int releaseIndex, String elementName)
respDoc
- is the MB responseResult XML document from a release query requestreleaseIndex
- is the zero based release to returnelementName
- the sub-element name to look forprotected void restCMD(String[] args)
args
- the array of commandLine args that got passed inprotected void templateCMD(String[] args)
args
- the array of commandLine args that got passed inprotected static String getHelpMsgStr()
public static String prettyJson(String jsonStr)
protected static StringBuilder getHelpMsg()
WebARTS Library Licensed Under the GNU - General Public License. Other Libraries licensed under their respective Open Source Licenses