Sort by camsoda sort value
This commit is contained in:
parent
e940a81d41
commit
60494a09fd
|
@ -35,6 +35,7 @@ public class CamsodaModel extends AbstractModel {
|
||||||
private List<StreamSource> streamSources = null;
|
private List<StreamSource> streamSources = null;
|
||||||
private int[] resolution;
|
private int[] resolution;
|
||||||
private String status = "n/a";
|
private String status = "n/a";
|
||||||
|
private float sortOrder = 0;
|
||||||
|
|
||||||
public String getStreamUrl() throws IOException {
|
public String getStreamUrl() throws IOException {
|
||||||
if(streamUrl == null) {
|
if(streamUrl == null) {
|
||||||
|
@ -172,4 +173,11 @@ public class CamsodaModel extends AbstractModel {
|
||||||
this.streamUrl = streamUrl;
|
this.streamUrl = streamUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public float getSortOrder() {
|
||||||
|
return sortOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSortOrder(float sortOrder) {
|
||||||
|
this.sortOrder = sortOrder;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package ctbrec.sites.camsoda;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@ -37,9 +38,9 @@ public class CamsodaUpdateService extends PaginatedScheduledService {
|
||||||
return new Task<List<Model>>() {
|
return new Task<List<Model>>() {
|
||||||
@Override
|
@Override
|
||||||
public List<Model> call() throws IOException {
|
public List<Model> call() throws IOException {
|
||||||
List<Model> models = new ArrayList<>();
|
List<CamsodaModel> models = new ArrayList<>();
|
||||||
if(loginRequired && StringUtil.isBlank(ctbrec.Config.getInstance().getSettings().username)) {
|
if(loginRequired && StringUtil.isBlank(ctbrec.Config.getInstance().getSettings().username)) {
|
||||||
return models;
|
return Collections.emptyList();
|
||||||
} else {
|
} else {
|
||||||
String url = CamsodaUpdateService.this.url;
|
String url = CamsodaUpdateService.this.url;
|
||||||
LOG.debug("Fetching page {}", url);
|
LOG.debug("Fetching page {}", url);
|
||||||
|
@ -55,7 +56,6 @@ public class CamsodaUpdateService extends PaginatedScheduledService {
|
||||||
JSONArray tpl = result.getJSONArray("tpl");
|
JSONArray tpl = result.getJSONArray("tpl");
|
||||||
String name = tpl.getString(0);
|
String name = tpl.getString(0);
|
||||||
// int connections = tpl.getInt(2);
|
// int connections = tpl.getInt(2);
|
||||||
// float sortValue = tpl.getFloat(3);
|
|
||||||
String streamName = tpl.getString(5);
|
String streamName = tpl.getString(5);
|
||||||
String tsize = tpl.getString(6);
|
String tsize = tpl.getString(6);
|
||||||
String serverPrefix = tpl.getString(7);
|
String serverPrefix = tpl.getString(7);
|
||||||
|
@ -63,6 +63,7 @@ public class CamsodaUpdateService extends PaginatedScheduledService {
|
||||||
CamsodaModel model = (CamsodaModel) camsoda.createModel(name);
|
CamsodaModel model = (CamsodaModel) camsoda.createModel(name);
|
||||||
model.setDescription(tpl.getString(4));
|
model.setDescription(tpl.getString(4));
|
||||||
model.setStreamUrl("https://" + edgeServers.getString(0) + "/cam/mp4:" + streamName + "_h264_aac_480p/playlist.m3u8");
|
model.setStreamUrl("https://" + edgeServers.getString(0) + "/cam/mp4:" + streamName + "_h264_aac_480p/playlist.m3u8");
|
||||||
|
model.setSortOrder(tpl.getFloat(3));
|
||||||
long unixtime = System.currentTimeMillis() / 1000;
|
long unixtime = System.currentTimeMillis() / 1000;
|
||||||
String preview = "https://thumbs-orig.camsoda.com/thumbs/"
|
String preview = "https://thumbs-orig.camsoda.com/thumbs/"
|
||||||
+ streamName + '/' + serverPrefix + '/' + tsize + '/' + unixtime + '/' + name + ".jpg?cb=" + unixtime;
|
+ streamName + '/' + serverPrefix + '/' + tsize + '/' + unixtime + '/' + name + ".jpg?cb=" + unixtime;
|
||||||
|
@ -77,12 +78,13 @@ public class CamsodaUpdateService extends PaginatedScheduledService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return models.stream()
|
return models.stream()
|
||||||
|
.sorted((m1,m2) -> (int)(m2.getSortOrder() - m1.getSortOrder()))
|
||||||
.skip( (page-1) * modelsPerPage)
|
.skip( (page-1) * modelsPerPage)
|
||||||
.limit(modelsPerPage)
|
.limit(modelsPerPage)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
} else {
|
} else {
|
||||||
response.close();
|
response.close();
|
||||||
return models;
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
int code = response.code();
|
int code = response.code();
|
||||||
|
|
Loading…
Reference in New Issue