Merge branch 'dev' into camsoda
This commit is contained in:
commit
b24b2fe3fe
|
@ -1,3 +1,8 @@
|
||||||
|
1.6.2
|
||||||
|
========================
|
||||||
|
* Added detection of model name changes for MyFreeCams
|
||||||
|
|
||||||
|
|
||||||
1.6.1
|
1.6.1
|
||||||
========================
|
========================
|
||||||
* Fixed UI freeze, which occured for a high number of recorded models
|
* Fixed UI freeze, which occured for a high number of recorded models
|
||||||
|
|
|
@ -8,6 +8,8 @@ import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import com.iheartradio.m3u8.ParseException;
|
import com.iheartradio.m3u8.ParseException;
|
||||||
import com.iheartradio.m3u8.PlaylistException;
|
import com.iheartradio.m3u8.PlaylistException;
|
||||||
|
import com.squareup.moshi.JsonReader;
|
||||||
|
import com.squareup.moshi.JsonWriter;
|
||||||
|
|
||||||
import ctbrec.recorder.download.StreamSource;
|
import ctbrec.recorder.download.StreamSource;
|
||||||
|
|
||||||
|
@ -98,6 +100,16 @@ public abstract class AbstractModel implements Model {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readSiteSpecificData(JsonReader reader) throws IOException {
|
||||||
|
// noop default implementation, can be overriden by concrete models
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeSiteSpecificData(JsonWriter writer) throws IOException {
|
||||||
|
// noop default implementation, can be overriden by concrete models
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
|
|
|
@ -6,6 +6,8 @@ import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import com.iheartradio.m3u8.ParseException;
|
import com.iheartradio.m3u8.ParseException;
|
||||||
import com.iheartradio.m3u8.PlaylistException;
|
import com.iheartradio.m3u8.PlaylistException;
|
||||||
|
import com.squareup.moshi.JsonReader;
|
||||||
|
import com.squareup.moshi.JsonWriter;
|
||||||
|
|
||||||
import ctbrec.recorder.download.StreamSource;
|
import ctbrec.recorder.download.StreamSource;
|
||||||
import ctbrec.sites.Site;
|
import ctbrec.sites.Site;
|
||||||
|
@ -35,4 +37,6 @@ public interface Model {
|
||||||
public boolean unfollow() throws IOException;
|
public boolean unfollow() throws IOException;
|
||||||
public void setSite(Site site);
|
public void setSite(Site site);
|
||||||
public Site getSite();
|
public Site getSite();
|
||||||
|
public void writeSiteSpecificData(JsonWriter writer) throws IOException;
|
||||||
|
public void readSiteSpecificData(JsonReader reader) throws IOException;
|
||||||
}
|
}
|
|
@ -32,45 +32,51 @@ public class ModelJsonAdapter extends JsonAdapter<Model> {
|
||||||
String url = null;
|
String url = null;
|
||||||
String type = null;
|
String type = null;
|
||||||
int streamUrlIndex = -1;
|
int streamUrlIndex = -1;
|
||||||
|
|
||||||
|
Model model = null;
|
||||||
while(reader.hasNext()) {
|
while(reader.hasNext()) {
|
||||||
Token token = reader.peek();
|
try {
|
||||||
if(token == Token.NAME) {
|
Token token = reader.peek();
|
||||||
String key = reader.nextName();
|
if(token == Token.NAME) {
|
||||||
if(key.equals("name")) {
|
String key = reader.nextName();
|
||||||
name = reader.nextString();
|
if(key.equals("name")) {
|
||||||
} else if(key.equals("description")) {
|
name = reader.nextString();
|
||||||
description = reader.nextString();
|
model.setName(name);
|
||||||
} else if(key.equals("url")) {
|
} else if(key.equals("description")) {
|
||||||
url = reader.nextString();
|
description = reader.nextString();
|
||||||
} else if(key.equals("type")) {
|
model.setDescription(description);
|
||||||
type = reader.nextString();
|
} else if(key.equals("url")) {
|
||||||
} else if(key.equals("streamUrlIndex")) {
|
url = reader.nextString();
|
||||||
streamUrlIndex = reader.nextInt();
|
model.setUrl(url);
|
||||||
|
} else if(key.equals("type")) {
|
||||||
|
type = reader.nextString();
|
||||||
|
Class<?> modelClass = Class.forName(Optional.ofNullable(type).orElse(ChaturbateModel.class.getName()));
|
||||||
|
model = (Model) modelClass.newInstance();
|
||||||
|
} else if(key.equals("streamUrlIndex")) {
|
||||||
|
streamUrlIndex = reader.nextInt();
|
||||||
|
model.setStreamUrlIndex(streamUrlIndex);
|
||||||
|
} else if(key.equals("siteSpecific")) {
|
||||||
|
reader.beginObject();
|
||||||
|
model.readSiteSpecificData(reader);
|
||||||
|
reader.endObject();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
reader.skipValue();
|
||||||
}
|
}
|
||||||
} else {
|
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||||
reader.skipValue();
|
throw new IOException("Couldn't instantiate model class [" + type + "]", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reader.endObject();
|
reader.endObject();
|
||||||
|
|
||||||
try {
|
if(sites != null) {
|
||||||
Class<?> modelClass = Class.forName(Optional.ofNullable(type).orElse(ChaturbateModel.class.getName()));
|
for (Site site : sites) {
|
||||||
Model model = (Model) modelClass.newInstance();
|
if(site.isSiteForModel(model)) {
|
||||||
model.setName(name);
|
model.setSite(site);
|
||||||
model.setDescription(description);
|
|
||||||
model.setUrl(url);
|
|
||||||
model.setStreamUrlIndex(streamUrlIndex);
|
|
||||||
if(sites != null) {
|
|
||||||
for (Site site : sites) {
|
|
||||||
if(site.isSiteForModel(model)) {
|
|
||||||
model.setSite(site);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return model;
|
|
||||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
|
||||||
throw new IOException("Couldn't instantiate model class [" + type + "]", e);
|
|
||||||
}
|
}
|
||||||
|
return model;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -81,6 +87,10 @@ public class ModelJsonAdapter extends JsonAdapter<Model> {
|
||||||
writeValueIfSet(writer, "description", model.getDescription());
|
writeValueIfSet(writer, "description", model.getDescription());
|
||||||
writeValueIfSet(writer, "url", model.getUrl());
|
writeValueIfSet(writer, "url", model.getUrl());
|
||||||
writer.name("streamUrlIndex").value(model.getStreamUrlIndex());
|
writer.name("streamUrlIndex").value(model.getStreamUrlIndex());
|
||||||
|
writer.name("siteSpecific");
|
||||||
|
writer.beginObject();
|
||||||
|
model.writeSiteSpecificData(writer);
|
||||||
|
writer.endObject();
|
||||||
writer.endObject();
|
writer.endObject();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class MyFreeCams extends AbstractSite {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAffiliateLink() {
|
public String getAffiliateLink() {
|
||||||
return "";
|
return BASE_URI + "/?baf=8127165";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -93,7 +93,7 @@ public class MyFreeCams extends AbstractSite {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBuyTokensLink() {
|
public String getBuyTokensLink() {
|
||||||
return "https://www.myfreecams.com/php/purchase.php?request=tokens";
|
return BASE_URI + "/php/purchase.php?request=tokens";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -149,7 +149,7 @@ public class MyFreeCams extends AbstractSite {
|
||||||
layout.add(password, 1, 1);
|
layout.add(password, 1, 1);
|
||||||
|
|
||||||
Button createAccount = new Button("Create new Account");
|
Button createAccount = new Button("Create new Account");
|
||||||
createAccount.setOnAction((e) -> DesktopIntergation.open(BASE_URI + "/php/signup.php?request=register"));
|
createAccount.setOnAction((e) -> DesktopIntergation.open(getAffiliateLink()));
|
||||||
layout.add(createAccount, 1, 2);
|
layout.add(createAccount, 1, 2);
|
||||||
GridPane.setColumnSpan(createAccount, 2);
|
GridPane.setColumnSpan(createAccount, 2);
|
||||||
GridPane.setMargin(username, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN));
|
GridPane.setMargin(username, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN));
|
||||||
|
|
|
@ -495,7 +495,7 @@ public class MyFreeCamsClient {
|
||||||
lock.lock();
|
lock.lock();
|
||||||
try {
|
try {
|
||||||
for (SessionState state : sessionStates.values()) {
|
for (SessionState state : sessionStates.values()) {
|
||||||
if(Objects.equals(state.getNm(), model.getName())) {
|
if(Objects.equals(state.getNm(), model.getName()) || Objects.equals(model.getUid(), state.getUid())) {
|
||||||
model.update(state, getStreamUrl(state));
|
model.update(state, getStreamUrl(state));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,8 @@ import com.iheartradio.m3u8.PlaylistParser;
|
||||||
import com.iheartradio.m3u8.data.MasterPlaylist;
|
import com.iheartradio.m3u8.data.MasterPlaylist;
|
||||||
import com.iheartradio.m3u8.data.Playlist;
|
import com.iheartradio.m3u8.data.Playlist;
|
||||||
import com.iheartradio.m3u8.data.PlaylistData;
|
import com.iheartradio.m3u8.data.PlaylistData;
|
||||||
|
import com.squareup.moshi.JsonReader;
|
||||||
|
import com.squareup.moshi.JsonWriter;
|
||||||
|
|
||||||
import ctbrec.AbstractModel;
|
import ctbrec.AbstractModel;
|
||||||
import ctbrec.recorder.download.StreamSource;
|
import ctbrec.recorder.download.StreamSource;
|
||||||
|
@ -37,7 +39,7 @@ public class MyFreeCamsModel extends AbstractModel {
|
||||||
|
|
||||||
private static final transient Logger LOG = LoggerFactory.getLogger(MyFreeCamsModel.class);
|
private static final transient Logger LOG = LoggerFactory.getLogger(MyFreeCamsModel.class);
|
||||||
|
|
||||||
private int uid;
|
private int uid = -1; // undefined
|
||||||
private String hlsUrl;
|
private String hlsUrl;
|
||||||
private double camScore;
|
private double camScore;
|
||||||
private int viewerCount;
|
private int viewerCount;
|
||||||
|
@ -207,7 +209,17 @@ public class MyFreeCamsModel extends AbstractModel {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setName(String name) {
|
||||||
|
if(getName() != null && name != null && !getName().equals(name)) {
|
||||||
|
LOG.debug("Model name changed {} -> {}", getName(), name);
|
||||||
|
}
|
||||||
|
super.setName(name);
|
||||||
|
}
|
||||||
|
|
||||||
public void update(SessionState state, String streamUrl) {
|
public void update(SessionState state, String streamUrl) {
|
||||||
|
uid = Integer.parseInt(state.getUid().toString());
|
||||||
|
setName(state.getNm());
|
||||||
setCamScore(state.getM().getCamscore());
|
setCamScore(state.getM().getCamscore());
|
||||||
setState(State.of(state.getVs()));
|
setState(State.of(state.getVs()));
|
||||||
setStreamUrl(streamUrl);
|
setStreamUrl(streamUrl);
|
||||||
|
@ -308,4 +320,15 @@ public class MyFreeCamsModel extends AbstractModel {
|
||||||
public Site getSite() {
|
public Site getSite() {
|
||||||
return site;
|
return site;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readSiteSpecificData(JsonReader reader) throws IOException {
|
||||||
|
reader.nextName();
|
||||||
|
uid = reader.nextInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeSiteSpecificData(JsonWriter writer) throws IOException {
|
||||||
|
writer.name("uid").value(uid);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,8 @@ import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
import com.iheartradio.m3u8.ParseException;
|
import com.iheartradio.m3u8.ParseException;
|
||||||
import com.iheartradio.m3u8.PlaylistException;
|
import com.iheartradio.m3u8.PlaylistException;
|
||||||
|
import com.squareup.moshi.JsonReader;
|
||||||
|
import com.squareup.moshi.JsonWriter;
|
||||||
|
|
||||||
import ctbrec.AbstractModel;
|
import ctbrec.AbstractModel;
|
||||||
import ctbrec.Model;
|
import ctbrec.Model;
|
||||||
|
@ -145,4 +147,14 @@ public class JavaFxModel extends AbstractModel {
|
||||||
public Site getSite() {
|
public Site getSite() {
|
||||||
return delegate.getSite();
|
return delegate.getSite();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readSiteSpecificData(JsonReader reader) throws IOException {
|
||||||
|
delegate.readSiteSpecificData(reader);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeSiteSpecificData(JsonWriter writer) throws IOException {
|
||||||
|
delegate.writeSiteSpecificData(writer);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue