forked from j62/ctbrec
126 lines
3.1 KiB
Java
126 lines
3.1 KiB
Java
package ctbrec;
|
|
|
|
import java.text.ParseException;
|
|
import java.text.SimpleDateFormat;
|
|
import java.time.Instant;
|
|
import java.util.Date;
|
|
|
|
public class Recording {
|
|
private String modelName;
|
|
private Instant startDate;
|
|
private String path;
|
|
private boolean hasPlaylist;
|
|
private STATUS status;
|
|
private int progress = -1;
|
|
private long sizeInByte;
|
|
|
|
public static enum STATUS {
|
|
RECORDING,
|
|
GENERATING_PLAYLIST,
|
|
FINISHED,
|
|
DOWNLOADING,
|
|
MERGING
|
|
}
|
|
|
|
public Recording() {}
|
|
|
|
public Recording(String path) throws ParseException {
|
|
this.path = path;
|
|
this.modelName = path.substring(0, path.indexOf("/"));
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd_HH-mm");
|
|
Date date = sdf.parse(path.substring(path.indexOf('/')+1));
|
|
startDate = Instant.ofEpochMilli(date.getTime());
|
|
}
|
|
|
|
public String getModelName() {
|
|
return modelName;
|
|
}
|
|
|
|
public void setModelName(String modelName) {
|
|
this.modelName = modelName;
|
|
}
|
|
|
|
public Instant getStartDate() {
|
|
return startDate;
|
|
}
|
|
|
|
public void setStartDate(Instant startDate) {
|
|
this.startDate = startDate;
|
|
}
|
|
|
|
public STATUS getStatus() {
|
|
return status;
|
|
}
|
|
|
|
public void setStatus(STATUS status) {
|
|
this.status = status;
|
|
}
|
|
|
|
public int getProgress() {
|
|
return this.progress;
|
|
}
|
|
|
|
public void setProgress(int progress) {
|
|
this.progress = progress;
|
|
}
|
|
|
|
public String getPath() {
|
|
return path;
|
|
}
|
|
|
|
public void setPath(String path) {
|
|
this.path = path;
|
|
}
|
|
|
|
public boolean hasPlaylist() {
|
|
return hasPlaylist;
|
|
}
|
|
|
|
public void setHasPlaylist(boolean hasPlaylist) {
|
|
this.hasPlaylist = hasPlaylist;
|
|
}
|
|
|
|
public long getSizeInByte() {
|
|
return sizeInByte;
|
|
}
|
|
|
|
public void setSizeInByte(long sizeInByte) {
|
|
this.sizeInByte = sizeInByte;
|
|
}
|
|
|
|
@Override
|
|
public int hashCode() {
|
|
final int prime = 31;
|
|
int result = 1;
|
|
result = prime * result + ((modelName == null) ? 0 : modelName.hashCode());
|
|
result = prime * result + ((path == null) ? 0 : path.hashCode());
|
|
result = prime * result + ((startDate == null) ? 0 : startDate.hashCode());
|
|
return result;
|
|
}
|
|
|
|
@Override
|
|
public boolean equals(Object obj) {
|
|
if (this == obj)
|
|
return true;
|
|
if (obj == null)
|
|
return false;
|
|
Recording other = (Recording) obj;
|
|
if (modelName == null) {
|
|
if (other.getModelName() != null)
|
|
return false;
|
|
} else if (!modelName.equals(other.getModelName()))
|
|
return false;
|
|
if (path == null) {
|
|
if (other.getPath() != null)
|
|
return false;
|
|
} else if (!path.equals(other.getPath()))
|
|
return false;
|
|
if (startDate == null) {
|
|
if (other.getStartDate() != null)
|
|
return false;
|
|
} else if (!startDate.equals(other.getStartDate()))
|
|
return false;
|
|
return true;
|
|
}
|
|
}
|