View Javadoc

1   package com.es.skreemr;
2   
3   /***
4    * Holds song name, artist name, album name, duration of song, Year of
5    * song/album, SkreemR's Listed Genre, Bitrate of song, Frequency of Song, if
6    * the song plays in Variable Bitrate Mode, The date SkreemR scanned file, and
7    * Url of file
8    * 
9    * @author Keith Blackard
10   */
11  public class SkreemRSong {
12  	/***
13  	 * Holds song name, artist name, album name, duration of song, Year of
14  	 * song/album, SkreemR's Listed Genre, Bitrate of song, Frequency of Song,
15  	 * if the song plays in Variable Bitrate Mode, The date SkreemR scanned
16  	 * file, and Url of file
17  	 */
18  	private String song, artist, album, duration, year, genre, bitrate,
19  			frequency, vbr, date, url;
20  
21  	/***
22  	 * Create a new SkreemR Song Object to be dealt with later.
23  	 * 
24  	 * @param url
25  	 *            The url of the song from SkreemR
26  	 * @param tags
27  	 *            The tags of the file to be parsed from SkreemR
28  	 */
29  	public SkreemRSong(String url, String tags) {
30  		parseTags(tags);
31  		this.url = url;
32  	}
33  
34  	/***
35  	 * @param tags
36  	 *            parses the tags that were returned from SkreemR
37  	 */
38  	private void parseTags(String tags) {
39  		song = tags.substring(tags.indexOf("<b>Song") + 13, tags
40  				.indexOf("<br><b>Artist"));
41  		artist = tags.substring(tags.indexOf("<b>Artist") + 15, tags
42  				.indexOf("<br><b>Album"));
43  		album = tags.substring(tags.indexOf("<b>Album") + 14, tags
44  				.indexOf("<br><b>Duration"));
45  		duration = tags.substring(tags.indexOf("<b>Duration") + 17, tags
46  				.indexOf("<br><b>Year"));
47  		year = tags.substring(tags.indexOf("<b>Year") + 13, tags
48  				.indexOf("<br><b>Genre"));
49  		genre = tags.substring(tags.indexOf("<b>Genre") + 14, tags
50  				.indexOf("<br><b>Bitrate"));
51  		bitrate = tags.substring(tags.indexOf("<b>Bitrate") + 16, tags
52  				.indexOf("<br><b>Frequency"));
53  		frequency = tags.substring(tags.indexOf("<b>Frequency:</b> ") + 18,
54  				tags.indexOf("<br><b>VBR"));
55  		vbr = tags.substring(tags.indexOf("<b>VBR:</b> ") + 12, tags
56  				.indexOf("<br><b>Date crawled"));
57  		date = tags.substring(tags.indexOf("<b>Date crawled:</b>") + 21);
58  		// End of String Expected, else; badly formatted string/SkreemR has
59  		// changed layout
60  	}
61  
62  	@Override
63  	public String toString() {
64  		return "Song: " + song + "\nArtist: " + artist + "\nAlbum: " + album
65  				+ "\nDuration: " + duration + "\nYear: " + year + "\nGenre: "
66  				+ genre + "\nBitrate: " + bitrate + "\nFrequency: " + frequency
67  				+ "\nVBR: " + vbr + "\nDate Scanned: " + date + "\nURL: " + url;
68  	}
69  
70  	/***
71  	 * @return the song name
72  	 */
73  	public String getSong() {
74  		return song;
75  	}
76  
77  	/***
78  	 * @return the song artist
79  	 */
80  	public String getArtist() {
81  		return artist;
82  	}
83  
84  	/***
85  	 * @return the album name
86  	 */
87  	public String getAlbum() {
88  		return album;
89  	}
90  
91  	/***
92  	 * @return the duration of song
93  	 */
94  	public String getDuration() {
95  		return duration;
96  	}
97  
98  	/***
99  	 * @return the year made
100 	 */
101 	public String getYear() {
102 		return year;
103 	}
104 
105 	/***
106 	 * @return the genre listed from SkreemR
107 	 */
108 	public String getGenre() {
109 		return genre;
110 	}
111 
112 	/***
113 	 * @return the bitrate of file
114 	 */
115 	public String getBitrate() {
116 		return bitrate;
117 	}
118 
119 	/***
120 	 * @return the frequency of file
121 	 */
122 	public String getFrequency() {
123 		return frequency;
124 	}
125 
126 	/***
127 	 * @return true if song has variable bit rate
128 	 */
129 	public String getVbr() {
130 		return vbr;
131 	}
132 
133 	/***
134 	 * @return the date SkreemR last scanned file
135 	 */
136 	public String getDate() {
137 		return date;
138 	}
139 
140 	/***
141 	 * @return the url of the mp3 file
142 	 */
143 	public String getUrl() {
144 		return url;
145 	}
146 }