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
|
||||
========================
|
||||
* 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.PlaylistException;
|
||||
import com.squareup.moshi.JsonReader;
|
||||
import com.squareup.moshi.JsonWriter;
|
||||
|
||||
import ctbrec.recorder.download.StreamSource;
|
||||
|
||||
|
@ -98,6 +100,16 @@ public abstract class AbstractModel implements Model {
|
|||
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
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
|
|
|
@ -6,6 +6,8 @@ import java.util.concurrent.ExecutionException;
|
|||
|
||||
import com.iheartradio.m3u8.ParseException;
|
||||
import com.iheartradio.m3u8.PlaylistException;
|
||||
import com.squareup.moshi.JsonReader;
|
||||
import com.squareup.moshi.JsonWriter;
|
||||
|
||||
import ctbrec.recorder.download.StreamSource;
|
||||
import ctbrec.sites.Site;
|
||||
|
@ -35,4 +37,6 @@ public interface Model {
|
|||
public boolean unfollow() throws IOException;
|
||||
public void setSite(Site site);
|
||||
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 type = null;
|
||||
int streamUrlIndex = -1;
|
||||
|
||||
Model model = null;
|
||||
while(reader.hasNext()) {
|
||||
Token token = reader.peek();
|
||||
if(token == Token.NAME) {
|
||||
String key = reader.nextName();
|
||||
if(key.equals("name")) {
|
||||
name = reader.nextString();
|
||||
} else if(key.equals("description")) {
|
||||
description = reader.nextString();
|
||||
} else if(key.equals("url")) {
|
||||
url = reader.nextString();
|
||||
} else if(key.equals("type")) {
|
||||
type = reader.nextString();
|
||||
} else if(key.equals("streamUrlIndex")) {
|
||||
streamUrlIndex = reader.nextInt();
|
||||
try {
|
||||
Token token = reader.peek();
|
||||
if(token == Token.NAME) {
|
||||
String key = reader.nextName();
|
||||
if(key.equals("name")) {
|
||||
name = reader.nextString();
|
||||
model.setName(name);
|
||||
} else if(key.equals("description")) {
|
||||
description = reader.nextString();
|
||||
model.setDescription(description);
|
||||
} else if(key.equals("url")) {
|
||||
url = reader.nextString();
|
||||
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 {
|
||||
reader.skipValue();
|
||||
} catch (ClassNotFoundException | InstantiationException | IllegalAccessException e) {
|
||||
throw new IOException("Couldn't instantiate model class [" + type + "]", e);
|
||||
}
|
||||
}
|
||||
reader.endObject();
|
||||
|
||||
try {
|
||||
Class<?> modelClass = Class.forName(Optional.ofNullable(type).orElse(ChaturbateModel.class.getName()));
|
||||
Model model = (Model) modelClass.newInstance();
|
||||
model.setName(name);
|
||||
model.setDescription(description);
|
||||
model.setUrl(url);
|
||||
model.setStreamUrlIndex(streamUrlIndex);
|
||||
if(sites != null) {
|
||||
for (Site site : sites) {
|
||||
if(site.isSiteForModel(model)) {
|
||||
model.setSite(site);
|
||||
}
|
||||
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
|
||||
|
@ -81,6 +87,10 @@ public class ModelJsonAdapter extends JsonAdapter<Model> {
|
|||
writeValueIfSet(writer, "description", model.getDescription());
|
||||
writeValueIfSet(writer, "url", model.getUrl());
|
||||
writer.name("streamUrlIndex").value(model.getStreamUrlIndex());
|
||||
writer.name("siteSpecific");
|
||||
writer.beginObject();
|
||||
model.writeSiteSpecificData(writer);
|
||||
writer.endObject();
|
||||
writer.endObject();
|
||||
}
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ public class MyFreeCams extends AbstractSite {
|
|||
|
||||
@Override
|
||||
public String getAffiliateLink() {
|
||||
return "";
|
||||
return BASE_URI + "/?baf=8127165";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -93,7 +93,7 @@ public class MyFreeCams extends AbstractSite {
|
|||
|
||||
@Override
|
||||
public String getBuyTokensLink() {
|
||||
return "https://www.myfreecams.com/php/purchase.php?request=tokens";
|
||||
return BASE_URI + "/php/purchase.php?request=tokens";
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -149,7 +149,7 @@ public class MyFreeCams extends AbstractSite {
|
|||
layout.add(password, 1, 1);
|
||||
|
||||
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);
|
||||
GridPane.setColumnSpan(createAccount, 2);
|
||||
GridPane.setMargin(username, new Insets(0, 0, 0, SettingsTab.CHECKBOX_MARGIN));
|
||||
|
|
|
@ -495,7 +495,7 @@ public class MyFreeCamsClient {
|
|||
lock.lock();
|
||||
try {
|
||||
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));
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -23,6 +23,8 @@ import com.iheartradio.m3u8.PlaylistParser;
|
|||
import com.iheartradio.m3u8.data.MasterPlaylist;
|
||||
import com.iheartradio.m3u8.data.Playlist;
|
||||
import com.iheartradio.m3u8.data.PlaylistData;
|
||||
import com.squareup.moshi.JsonReader;
|
||||
import com.squareup.moshi.JsonWriter;
|
||||
|
||||
import ctbrec.AbstractModel;
|
||||
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 int uid;
|
||||
private int uid = -1; // undefined
|
||||
private String hlsUrl;
|
||||
private double camScore;
|
||||
private int viewerCount;
|
||||
|
@ -207,7 +209,17 @@ public class MyFreeCamsModel extends AbstractModel {
|
|||
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) {
|
||||
uid = Integer.parseInt(state.getUid().toString());
|
||||
setName(state.getNm());
|
||||
setCamScore(state.getM().getCamscore());
|
||||
setState(State.of(state.getVs()));
|
||||
setStreamUrl(streamUrl);
|
||||
|
@ -308,4 +320,15 @@ public class MyFreeCamsModel extends AbstractModel {
|
|||
public Site getSite() {
|
||||
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.PlaylistException;
|
||||
import com.squareup.moshi.JsonReader;
|
||||
import com.squareup.moshi.JsonWriter;
|
||||
|
||||
import ctbrec.AbstractModel;
|
||||
import ctbrec.Model;
|
||||
|
@ -145,4 +147,14 @@ public class JavaFxModel extends AbstractModel {
|
|||
public Site 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