Split up project into client, server, common and master
This commit is contained in:
parent
e87611fe3d
commit
cda330ddbd
|
@ -1,6 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ctbrec</name>
|
||||
<name>ctbrec-client</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
|
|
|
@ -3,9 +3,14 @@
|
|||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>ctbrec</groupId>
|
||||
<artifactId>client</artifactId>
|
||||
<version>1.9.0</version>
|
||||
|
||||
<parent>
|
||||
<groupId>ctbrec</groupId>
|
||||
<artifactId>master</artifactId>
|
||||
<version>1.9.0</version>
|
||||
<relativePath>../master</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
|
@ -60,76 +65,58 @@
|
|||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>ctbrec</groupId>
|
||||
<artifactId>common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>1.10.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>3.10.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.moshi</groupId>
|
||||
<artifactId>moshi</artifactId>
|
||||
<version>1.5.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20180130</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>1.7.25</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-classic</artifactId>
|
||||
<version>1.2.3</version>
|
||||
<scope>runtime</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-server</artifactId>
|
||||
<version>[9.3.24.v20180605,)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty</groupId>
|
||||
<artifactId>jetty-servlet</artifactId>
|
||||
<version>[9.3.24.v20180605,)</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.iheartradio.m3u8</groupId>
|
||||
<artifactId>open-m3u8</artifactId>
|
||||
<version>0.2.4</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jcodec</groupId>
|
||||
<artifactId>jcodec</artifactId>
|
||||
<version>0.2.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
<version>11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-web</artifactId>
|
||||
<version>11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
<version>17.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
|
|
@ -1,125 +0,0 @@
|
|||
package ctbrec.sites.cam4;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpCookie;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ctbrec.io.HttpClient;
|
||||
import javafx.application.Platform;
|
||||
import okhttp3.Cookie;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class Cam4HttpClient extends HttpClient {
|
||||
|
||||
private static final transient Logger LOG = LoggerFactory.getLogger(Cam4HttpClient.class);
|
||||
|
||||
public Cam4HttpClient() {
|
||||
super("cam4");
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean login() throws IOException {
|
||||
if(loggedIn) {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean cookiesWorked = checkLoginSuccess();
|
||||
if(cookiesWorked) {
|
||||
loggedIn = true;
|
||||
LOG.debug("Logged in with cookies");
|
||||
return true;
|
||||
}
|
||||
|
||||
BlockingQueue<Boolean> queue = new LinkedBlockingQueue<>();
|
||||
|
||||
Runnable showDialog = () -> {
|
||||
// login with javafx WebView
|
||||
Cam4LoginDialog loginDialog = new Cam4LoginDialog();
|
||||
|
||||
// transfer cookies from WebView to OkHttp cookie jar
|
||||
transferCookies(loginDialog);
|
||||
|
||||
try {
|
||||
queue.put(true);
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("Error while signaling termination", e);
|
||||
}
|
||||
};
|
||||
|
||||
if(Platform.isFxApplicationThread()) {
|
||||
showDialog.run();
|
||||
} else {
|
||||
Platform.runLater(showDialog);
|
||||
try {
|
||||
queue.take();
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("Error while waiting for login dialog to close", e);
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
loggedIn = checkLoginSuccess();
|
||||
return loggedIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* check, if the login worked by requesting unchecked mail
|
||||
* @throws IOException
|
||||
*/
|
||||
private boolean checkLoginSuccess() throws IOException {
|
||||
String mailUrl = Cam4.BASE_URI + "/mail/unreadThreads";
|
||||
Request req = new Request.Builder()
|
||||
.url(mailUrl)
|
||||
.addHeader("X-Requested-With", "XMLHttpRequest")
|
||||
.build();
|
||||
Response response = execute(req);
|
||||
if(response.isSuccessful() && response.body().contentLength() > 0) {
|
||||
JSONObject json = new JSONObject(response.body().string());
|
||||
return json.has("status") && Objects.equals("success", json.getString("status"));
|
||||
} else {
|
||||
response.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void transferCookies(Cam4LoginDialog loginDialog) {
|
||||
HttpUrl redirectedUrl = HttpUrl.parse(loginDialog.getUrl());
|
||||
List<Cookie> cookies = new ArrayList<>();
|
||||
for (HttpCookie webViewCookie : loginDialog.getCookies()) {
|
||||
if(webViewCookie.getDomain().contains("cam4")) {
|
||||
Cookie cookie = Cookie.parse(redirectedUrl, webViewCookie.toString());
|
||||
LOG.debug("{} {} {}", webViewCookie.getDomain(), webViewCookie.getName(), webViewCookie.getValue());
|
||||
cookies.add(cookie);
|
||||
}
|
||||
}
|
||||
cookieJar.saveFromResponse(redirectedUrl, cookies);
|
||||
|
||||
HttpUrl origUrl = HttpUrl.parse(Cam4LoginDialog.URL);
|
||||
cookies = new ArrayList<>();
|
||||
for (HttpCookie webViewCookie : loginDialog.getCookies()) {
|
||||
if(webViewCookie.getDomain().contains("cam4")) {
|
||||
Cookie cookie = Cookie.parse(origUrl, webViewCookie.toString());
|
||||
cookies.add(cookie);
|
||||
}
|
||||
}
|
||||
cookieJar.saveFromResponse(origUrl, cookies);
|
||||
}
|
||||
|
||||
protected int getTokenBalance() throws IOException {
|
||||
if(!loggedIn) {
|
||||
login();
|
||||
}
|
||||
|
||||
throw new RuntimeException("Not implemented, yet");
|
||||
}
|
||||
}
|
|
@ -126,6 +126,7 @@ public class JavaFxModel implements Model {
|
|||
|
||||
@Override
|
||||
public void receiveTip(int tokens) throws IOException {
|
||||
SiteUiFactory.getUi(getSite()).login();
|
||||
delegate.receiveTip(tokens);
|
||||
}
|
||||
|
||||
|
@ -136,11 +137,13 @@ public class JavaFxModel implements Model {
|
|||
|
||||
@Override
|
||||
public boolean follow() throws IOException {
|
||||
SiteUiFactory.getUi(getSite()).login();
|
||||
return delegate.follow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unfollow() throws IOException {
|
||||
SiteUiFactory.getUi(getSite()).login();
|
||||
return delegate.unfollow();
|
||||
}
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ public class SettingsTab extends Tab implements TabSelectionListener {
|
|||
rightSide.getChildren().add(credentialsAccordion);
|
||||
for (int i = 0; i < sites.size(); i++) {
|
||||
Site site = sites.get(i);
|
||||
ConfigUI siteConfig = site.getConfigurationGui();
|
||||
ConfigUI siteConfig = SiteUiFactory.getUi(site).getConfigUI();
|
||||
if(siteConfig != null) {
|
||||
TitledPane pane = new TitledPane(site.getName(), siteConfig.createConfigPanel());
|
||||
credentialsAccordion.getPanes().add(pane);
|
||||
|
|
|
@ -14,7 +14,8 @@ public class SiteTabPane extends TabPane {
|
|||
setSide(Side.LEFT);
|
||||
|
||||
// add all tabs
|
||||
for (Tab tab : site.getTabProvider().getTabs(scene)) {
|
||||
TabProvider tabProvider = SiteUiFactory.getUi(site).getTabProvider();
|
||||
for (Tab tab : tabProvider.getTabs(scene)) {
|
||||
getTabs().add(tab);
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,12 @@
|
|||
package ctbrec.ui;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ctbrec.sites.ConfigUI;
|
||||
|
||||
public interface SiteUI {
|
||||
|
||||
public TabProvider getTabProvider();
|
||||
public ConfigUI getConfigUI();
|
||||
public boolean login() throws IOException;
|
||||
}
|
|
@ -0,0 +1,53 @@
|
|||
package ctbrec.ui;
|
||||
|
||||
import ctbrec.sites.Site;
|
||||
import ctbrec.sites.bonga.BongaCams;
|
||||
import ctbrec.sites.cam4.Cam4;
|
||||
import ctbrec.sites.camsoda.Camsoda;
|
||||
import ctbrec.sites.chaturbate.Chaturbate;
|
||||
import ctbrec.sites.mfc.MyFreeCams;
|
||||
import ctbrec.ui.sites.bonga.BongaCamsSiteUi;
|
||||
import ctbrec.ui.sites.cam4.Cam4SiteUi;
|
||||
import ctbrec.ui.sites.camsoda.CamsodaSiteUi;
|
||||
import ctbrec.ui.sites.chaturbate.ChaturbateSiteUi;
|
||||
import ctbrec.ui.sites.myfreecams.MyFreeCamsSiteUi;
|
||||
|
||||
public class SiteUiFactory {
|
||||
|
||||
private static BongaCamsSiteUi bongaSiteUi;
|
||||
private static Cam4SiteUi cam4SiteUi;
|
||||
private static CamsodaSiteUi camsodaSiteUi;
|
||||
private static ChaturbateSiteUi ctbSiteUi;
|
||||
private static MyFreeCamsSiteUi mfcSiteUi;
|
||||
|
||||
public static SiteUI getUi(Site site) {
|
||||
if (site instanceof BongaCams) {
|
||||
if (bongaSiteUi == null) {
|
||||
bongaSiteUi = new BongaCamsSiteUi((BongaCams) site);
|
||||
}
|
||||
return bongaSiteUi;
|
||||
} else if (site instanceof Cam4) {
|
||||
if (cam4SiteUi == null) {
|
||||
cam4SiteUi = new Cam4SiteUi((Cam4) site);
|
||||
}
|
||||
return cam4SiteUi;
|
||||
} else if (site instanceof Camsoda) {
|
||||
if (camsodaSiteUi == null) {
|
||||
camsodaSiteUi = new CamsodaSiteUi((Camsoda) site);
|
||||
}
|
||||
return camsodaSiteUi;
|
||||
} else if (site instanceof Chaturbate) {
|
||||
if (ctbSiteUi == null) {
|
||||
ctbSiteUi = new ChaturbateSiteUi((Chaturbate) site);
|
||||
}
|
||||
return ctbSiteUi;
|
||||
} else if (site instanceof MyFreeCams) {
|
||||
if (mfcSiteUi == null) {
|
||||
mfcSiteUi = new MyFreeCamsSiteUi((MyFreeCams) site);
|
||||
}
|
||||
return mfcSiteUi;
|
||||
}
|
||||
throw new RuntimeException("Unknown site " + site.getName());
|
||||
}
|
||||
|
||||
}
|
|
@ -401,6 +401,7 @@ public class ThumbCell extends StackPane {
|
|||
return CompletableFuture.supplyAsync(() -> {
|
||||
try {
|
||||
if(follow) {
|
||||
SiteUiFactory.getUi(model.getSite()).login();
|
||||
boolean followed = model.follow();
|
||||
if(followed) {
|
||||
return true;
|
||||
|
@ -415,6 +416,7 @@ public class ThumbCell extends StackPane {
|
|||
return false;
|
||||
}
|
||||
} else {
|
||||
SiteUiFactory.getUi(model.getSite()).login();
|
||||
boolean unfollowed = model.unfollow();
|
||||
if(unfollowed) {
|
||||
Platform.runLater(() -> thumbCellList.remove(ThumbCell.this));
|
||||
|
|
|
@ -366,6 +366,7 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
|||
if(tipText.matches("[1-9]\\d*")) {
|
||||
int tokens = Integer.parseInt(tipText);
|
||||
try {
|
||||
SiteUiFactory.getUi(site).login();
|
||||
cell.getModel().receiveTip(tokens);
|
||||
Map<String, Object> event = new HashMap<>();
|
||||
event.put("event", "tokens.sent");
|
||||
|
@ -485,7 +486,8 @@ public class ThumbOverviewTab extends Tab implements TabSelectionListener {
|
|||
}
|
||||
|
||||
private double getFollowedTabYPosition() {
|
||||
Tab followedTab = site.getTabProvider().getFollowedTab();
|
||||
TabProvider tabProvider = SiteUiFactory.getUi(site).getTabProvider();
|
||||
Tab followedTab = tabProvider.getFollowedTab();
|
||||
TabPane tabPane = getTabPane();
|
||||
int idx = tabPane.getTabs().indexOf(followedTab);
|
||||
for (Node node : tabPane.getChildrenUnmodifiable()) {
|
||||
|
|
|
@ -35,6 +35,7 @@ public class TipDialog extends TextInputDialog {
|
|||
@Override
|
||||
protected Integer call() throws Exception {
|
||||
if (!Objects.equals(System.getenv("CTBREC_DEV"), "1")) {
|
||||
SiteUiFactory.getUi(site).login();
|
||||
return site.getTokenBalance();
|
||||
} else {
|
||||
return 1_000_000;
|
||||
|
|
|
@ -58,6 +58,7 @@ public class TokenLabel extends Label {
|
|||
@Override
|
||||
protected Integer call() throws Exception {
|
||||
if (!Objects.equals(System.getenv("CTBREC_DEV"), "1")) {
|
||||
SiteUiFactory.getUi(site).login();
|
||||
return site.getTokenBalance();
|
||||
} else {
|
||||
return 1_000_000;
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
package ctbrec.sites.bonga;
|
||||
package ctbrec.ui.sites.bonga;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.sites.bonga.BongaCams;
|
||||
import ctbrec.ui.DesktopIntegration;
|
||||
import ctbrec.ui.SettingsTab;
|
||||
import javafx.geometry.Insets;
|
|
@ -1,4 +1,4 @@
|
|||
package ctbrec.sites.bonga;
|
||||
package ctbrec.ui.sites.bonga;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
@ -15,6 +15,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.OS;
|
||||
import ctbrec.sites.bonga.BongaCams;
|
||||
import javafx.concurrent.Worker.State;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.ProgressIndicator;
|
|
@ -0,0 +1,112 @@
|
|||
package ctbrec.ui.sites.bonga;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpCookie;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.sites.bonga.BongaCams;
|
||||
import ctbrec.sites.bonga.BongaCamsHttpClient;
|
||||
import ctbrec.ui.SiteUI;
|
||||
import ctbrec.ui.TabProvider;
|
||||
import javafx.application.Platform;
|
||||
import okhttp3.Cookie;
|
||||
import okhttp3.CookieJar;
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
public class BongaCamsSiteUi implements SiteUI {
|
||||
|
||||
private static final transient Logger LOG = LoggerFactory.getLogger(BongaCamsSiteUi.class);
|
||||
private BongaCamsTabProvider tabProvider;
|
||||
private BongaCamsConfigUI configUi;
|
||||
private BongaCams bongaCams;
|
||||
|
||||
public BongaCamsSiteUi(BongaCams bongaCams) {
|
||||
this.bongaCams = bongaCams;
|
||||
tabProvider = new BongaCamsTabProvider(bongaCams);
|
||||
configUi = new BongaCamsConfigUI(bongaCams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabProvider getTabProvider() {
|
||||
return tabProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigUI getConfigUI() {
|
||||
return configUi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean login() throws IOException {
|
||||
boolean automaticLogin = bongaCams.login();
|
||||
if(automaticLogin) {
|
||||
return true;
|
||||
} else {
|
||||
BlockingQueue<Boolean> queue = new LinkedBlockingQueue<>();
|
||||
|
||||
Runnable showDialog = () -> {
|
||||
// login with javafx WebView
|
||||
BongaCamsLoginDialog loginDialog = new BongaCamsLoginDialog();
|
||||
|
||||
// transfer cookies from WebView to OkHttp cookie jar
|
||||
transferCookies(loginDialog);
|
||||
|
||||
try {
|
||||
queue.put(true);
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("Error while signaling termination", e);
|
||||
}
|
||||
};
|
||||
|
||||
if(Platform.isFxApplicationThread()) {
|
||||
showDialog.run();
|
||||
} else {
|
||||
Platform.runLater(showDialog);
|
||||
try {
|
||||
queue.take();
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("Error while waiting for login dialog to close", e);
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
BongaCamsHttpClient httpClient = (BongaCamsHttpClient)bongaCams.getHttpClient();
|
||||
boolean loggedIn = httpClient.checkLoginSuccess();
|
||||
if(loggedIn) {
|
||||
LOG.info("Logged in. User ID is {}", httpClient.getUserId());
|
||||
} else {
|
||||
LOG.info("Login failed");
|
||||
}
|
||||
return loggedIn;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void transferCookies(BongaCamsLoginDialog loginDialog) {
|
||||
BongaCamsHttpClient httpClient = (BongaCamsHttpClient)bongaCams.getHttpClient();
|
||||
CookieJar cookieJar = httpClient.getCookieJar();
|
||||
|
||||
HttpUrl redirectedUrl = HttpUrl.parse(loginDialog.getUrl());
|
||||
List<Cookie> cookies = new ArrayList<>();
|
||||
for (HttpCookie webViewCookie : loginDialog.getCookies()) {
|
||||
Cookie cookie = Cookie.parse(redirectedUrl, webViewCookie.toString());
|
||||
cookies.add(cookie);
|
||||
}
|
||||
cookieJar.saveFromResponse(redirectedUrl, cookies);
|
||||
|
||||
HttpUrl origUrl = HttpUrl.parse(BongaCamsLoginDialog.URL);
|
||||
cookies = new ArrayList<>();
|
||||
for (HttpCookie webViewCookie : loginDialog.getCookies()) {
|
||||
Cookie cookie = Cookie.parse(origUrl, webViewCookie.toString());
|
||||
cookies.add(cookie);
|
||||
}
|
||||
cookieJar.saveFromResponse(origUrl, cookies);
|
||||
}
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
package ctbrec.sites.bonga;
|
||||
package ctbrec.ui.sites.bonga;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ctbrec.recorder.Recorder;
|
||||
import ctbrec.sites.bonga.BongaCams;
|
||||
import ctbrec.ui.PaginatedScheduledService;
|
||||
import ctbrec.ui.TabProvider;
|
||||
import ctbrec.ui.ThumbOverviewTab;
|
||||
|
@ -16,9 +17,9 @@ public class BongaCamsTabProvider extends TabProvider {
|
|||
private Recorder recorder;
|
||||
private Tab friendsTab;
|
||||
|
||||
public BongaCamsTabProvider(Recorder recorder, BongaCams bongaCams) {
|
||||
this.recorder = recorder;
|
||||
public BongaCamsTabProvider(BongaCams bongaCams) {
|
||||
this.bongaCams = bongaCams;
|
||||
this.recorder = bongaCams.getRecorder();
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,4 +1,4 @@
|
|||
package ctbrec.sites.bonga;
|
||||
package ctbrec.ui.sites.bonga;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -11,6 +11,8 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Model;
|
||||
import ctbrec.sites.bonga.BongaCams;
|
||||
import ctbrec.sites.bonga.BongaCamsModel;
|
||||
import ctbrec.ui.PaginatedScheduledService;
|
||||
import javafx.concurrent.Task;
|
||||
import okhttp3.Request;
|
|
@ -1,7 +1,8 @@
|
|||
package ctbrec.sites.cam4;
|
||||
package ctbrec.ui.sites.cam4;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.sites.cam4.Cam4;
|
||||
import ctbrec.ui.DesktopIntegration;
|
||||
import ctbrec.ui.SettingsTab;
|
||||
import javafx.geometry.Insets;
|
|
@ -1,5 +1,6 @@
|
|||
package ctbrec.sites.cam4;
|
||||
package ctbrec.ui.sites.cam4;
|
||||
|
||||
import ctbrec.sites.cam4.Cam4;
|
||||
import ctbrec.ui.FollowedTab;
|
||||
import ctbrec.ui.ThumbOverviewTab;
|
||||
import javafx.concurrent.WorkerStateEvent;
|
|
@ -1,4 +1,4 @@
|
|||
package ctbrec.sites.cam4;
|
||||
package ctbrec.ui.sites.cam4;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -16,9 +16,12 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Model;
|
||||
import ctbrec.io.HtmlParser;
|
||||
import ctbrec.io.HttpException;
|
||||
import ctbrec.ui.HtmlParser;
|
||||
import ctbrec.sites.cam4.Cam4;
|
||||
import ctbrec.sites.cam4.Cam4Model;
|
||||
import ctbrec.ui.PaginatedScheduledService;
|
||||
import ctbrec.ui.SiteUiFactory;
|
||||
import javafx.concurrent.Task;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
@ -48,11 +51,13 @@ public class Cam4FollowedUpdateService extends PaginatedScheduledService {
|
|||
return new Task<List<Model>>() {
|
||||
@Override
|
||||
public List<Model> call() throws IOException {
|
||||
// login first
|
||||
SiteUiFactory.getUi(site).login();
|
||||
List<Model> models = new ArrayList<>();
|
||||
String username = Config.getInstance().getSettings().cam4Username;
|
||||
String url = site.getBaseUrl() + '/' + username + "/edit/friends_favorites";
|
||||
Request req = new Request.Builder().url(url).build();
|
||||
try(Response response = site.getHttpClient().execute(req, true)) {
|
||||
try(Response response = site.getHttpClient().execute(req)) {
|
||||
if(response.isSuccessful()) {
|
||||
String content = response.body().string();
|
||||
Elements cells = HtmlParser.getTags(content, "div#favorites div.ff_thumb");
|
|
@ -1,4 +1,4 @@
|
|||
package ctbrec.sites.cam4;
|
||||
package ctbrec.ui.sites.cam4;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
@ -15,6 +15,7 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.OS;
|
||||
import ctbrec.sites.cam4.Cam4;
|
||||
import javafx.concurrent.Worker.State;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.ProgressIndicator;
|
|
@ -0,0 +1,113 @@
|
|||
package ctbrec.ui.sites.cam4;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpCookie;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.sites.cam4.Cam4;
|
||||
import ctbrec.sites.cam4.Cam4HttpClient;
|
||||
import ctbrec.ui.SiteUI;
|
||||
import ctbrec.ui.TabProvider;
|
||||
import javafx.application.Platform;
|
||||
import okhttp3.Cookie;
|
||||
import okhttp3.CookieJar;
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
public class Cam4SiteUi implements SiteUI {
|
||||
private static final transient Logger LOG = LoggerFactory.getLogger(Cam4SiteUi.class);
|
||||
|
||||
private Cam4TabProvider tabProvider;
|
||||
private Cam4ConfigUI configUI;
|
||||
private Cam4 cam4;
|
||||
|
||||
public Cam4SiteUi(Cam4 cam4) {
|
||||
this.cam4 = cam4;
|
||||
tabProvider = new Cam4TabProvider(cam4);
|
||||
configUI = new Cam4ConfigUI();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabProvider getTabProvider() {
|
||||
return tabProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigUI getConfigUI() {
|
||||
return configUI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean login() throws IOException {
|
||||
boolean automaticLogin = cam4.login();
|
||||
if(automaticLogin) {
|
||||
return true;
|
||||
} else {
|
||||
|
||||
BlockingQueue<Boolean> queue = new LinkedBlockingQueue<>();
|
||||
|
||||
Runnable showDialog = () -> {
|
||||
// login with javafx WebView
|
||||
Cam4LoginDialog loginDialog = new Cam4LoginDialog();
|
||||
|
||||
// transfer cookies from WebView to OkHttp cookie jar
|
||||
transferCookies(loginDialog);
|
||||
|
||||
try {
|
||||
queue.put(true);
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("Error while signaling termination", e);
|
||||
}
|
||||
};
|
||||
|
||||
if(Platform.isFxApplicationThread()) {
|
||||
showDialog.run();
|
||||
} else {
|
||||
Platform.runLater(showDialog);
|
||||
try {
|
||||
queue.take();
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("Error while waiting for login dialog to close", e);
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
Cam4HttpClient httpClient = (Cam4HttpClient) cam4.getHttpClient();
|
||||
boolean loggedIn = httpClient.checkLoginSuccess();
|
||||
return loggedIn;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void transferCookies(Cam4LoginDialog loginDialog) {
|
||||
Cam4HttpClient httpClient = (Cam4HttpClient) cam4.getHttpClient();
|
||||
CookieJar cookieJar = httpClient.getCookieJar();
|
||||
|
||||
HttpUrl redirectedUrl = HttpUrl.parse(loginDialog.getUrl());
|
||||
List<Cookie> cookies = new ArrayList<>();
|
||||
for (HttpCookie webViewCookie : loginDialog.getCookies()) {
|
||||
if(webViewCookie.getDomain().contains("cam4")) {
|
||||
Cookie cookie = Cookie.parse(redirectedUrl, webViewCookie.toString());
|
||||
LOG.debug("{} {} {}", webViewCookie.getDomain(), webViewCookie.getName(), webViewCookie.getValue());
|
||||
cookies.add(cookie);
|
||||
}
|
||||
}
|
||||
cookieJar.saveFromResponse(redirectedUrl, cookies);
|
||||
|
||||
HttpUrl origUrl = HttpUrl.parse(Cam4LoginDialog.URL);
|
||||
cookies = new ArrayList<>();
|
||||
for (HttpCookie webViewCookie : loginDialog.getCookies()) {
|
||||
if(webViewCookie.getDomain().contains("cam4")) {
|
||||
Cookie cookie = Cookie.parse(origUrl, webViewCookie.toString());
|
||||
cookies.add(cookie);
|
||||
}
|
||||
}
|
||||
cookieJar.saveFromResponse(origUrl, cookies);
|
||||
}
|
||||
}
|
|
@ -1,9 +1,10 @@
|
|||
package ctbrec.sites.cam4;
|
||||
package ctbrec.ui.sites.cam4;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import ctbrec.recorder.Recorder;
|
||||
import ctbrec.sites.cam4.Cam4;
|
||||
import ctbrec.ui.TabProvider;
|
||||
import ctbrec.ui.ThumbOverviewTab;
|
||||
import javafx.scene.Scene;
|
||||
|
@ -15,9 +16,9 @@ public class Cam4TabProvider extends TabProvider {
|
|||
private Recorder recorder;
|
||||
private Cam4FollowedTab followed;
|
||||
|
||||
public Cam4TabProvider(Cam4 cam4, Recorder recorder) {
|
||||
public Cam4TabProvider(Cam4 cam4) {
|
||||
this.cam4 = cam4;
|
||||
this.recorder = recorder;
|
||||
this.recorder = cam4.getRecorder();
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,4 +1,4 @@
|
|||
package ctbrec.sites.cam4;
|
||||
package ctbrec.ui.sites.cam4;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -8,7 +8,6 @@ import java.util.concurrent.ExecutorService;
|
|||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.json.JSONObject;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
@ -17,9 +16,13 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Model;
|
||||
import ctbrec.StringUtil;
|
||||
import ctbrec.io.HtmlParser;
|
||||
import ctbrec.io.HttpException;
|
||||
import ctbrec.ui.HtmlParser;
|
||||
import ctbrec.sites.cam4.Cam4;
|
||||
import ctbrec.sites.cam4.Cam4Model;
|
||||
import ctbrec.ui.PaginatedScheduledService;
|
||||
import ctbrec.ui.SiteUiFactory;
|
||||
import javafx.concurrent.Task;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
@ -58,8 +61,11 @@ public class Cam4UpdateService extends PaginatedScheduledService {
|
|||
} else {
|
||||
String url = Cam4UpdateService.this.url + "&page=" + page;
|
||||
LOG.debug("Fetching page {}", url);
|
||||
if(loginRequired) {
|
||||
SiteUiFactory.getUi(site).login();
|
||||
}
|
||||
Request request = new Request.Builder().url(url).build();
|
||||
try (Response response = site.getHttpClient().execute(request, loginRequired)) {
|
||||
try (Response response = site.getHttpClient().execute(request)) {
|
||||
if (response.isSuccessful()) {
|
||||
JSONObject json = new JSONObject(response.body().string());
|
||||
String html = json.getString("html");
|
|
@ -1,7 +1,8 @@
|
|||
package ctbrec.sites.camsoda;
|
||||
package ctbrec.ui.sites.camsoda;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.sites.camsoda.Camsoda;
|
||||
import ctbrec.ui.DesktopIntegration;
|
||||
import ctbrec.ui.SettingsTab;
|
||||
import javafx.geometry.Insets;
|
|
@ -1,5 +1,6 @@
|
|||
package ctbrec.sites.camsoda;
|
||||
package ctbrec.ui.sites.camsoda;
|
||||
|
||||
import ctbrec.sites.camsoda.Camsoda;
|
||||
import ctbrec.ui.FollowedTab;
|
||||
import ctbrec.ui.ThumbOverviewTab;
|
||||
import javafx.concurrent.WorkerStateEvent;
|
|
@ -1,4 +1,4 @@
|
|||
package ctbrec.sites.camsoda;
|
||||
package ctbrec.ui.sites.camsoda;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -12,7 +12,10 @@ import org.json.JSONObject;
|
|||
|
||||
import ctbrec.Model;
|
||||
import ctbrec.io.HttpException;
|
||||
import ctbrec.sites.camsoda.Camsoda;
|
||||
import ctbrec.sites.camsoda.CamsodaModel;
|
||||
import ctbrec.ui.PaginatedScheduledService;
|
||||
import ctbrec.ui.SiteUiFactory;
|
||||
import javafx.concurrent.Task;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
@ -32,8 +35,9 @@ public class CamsodaFollowedUpdateService extends PaginatedScheduledService {
|
|||
public List<Model> call() throws IOException {
|
||||
List<Model> models = new ArrayList<>();
|
||||
String url = camsoda.getBaseUrl() + "/api/v1/user/current";
|
||||
SiteUiFactory.getUi(camsoda).login();
|
||||
Request request = new Request.Builder().url(url).build();
|
||||
try(Response response = camsoda.getHttpClient().execute(request, true)) {
|
||||
try(Response response = camsoda.getHttpClient().execute(request)) {
|
||||
if (response.isSuccessful()) {
|
||||
JSONObject json = new JSONObject(response.body().string());
|
||||
if(json.has("status") && json.getBoolean("status")) {
|
|
@ -1,4 +1,4 @@
|
|||
package ctbrec.sites.camsoda;
|
||||
package ctbrec.ui.sites.camsoda;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
|
@ -9,6 +9,7 @@ import java.util.Base64;
|
|||
import java.util.List;
|
||||
|
||||
import ctbrec.OS;
|
||||
import ctbrec.sites.camsoda.Camsoda;
|
||||
import javafx.concurrent.Worker.State;
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.ProgressIndicator;
|
|
@ -1,4 +1,4 @@
|
|||
package ctbrec.sites.camsoda;
|
||||
package ctbrec.ui.sites.camsoda;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.InvalidKeyException;
|
||||
|
@ -21,8 +21,10 @@ import org.slf4j.LoggerFactory;
|
|||
|
||||
import ctbrec.Model;
|
||||
import ctbrec.recorder.Recorder;
|
||||
import ctbrec.sites.camsoda.Camsoda;
|
||||
import ctbrec.ui.AutosizeAlert;
|
||||
import ctbrec.ui.DesktopIntegration;
|
||||
import ctbrec.ui.SiteUiFactory;
|
||||
import ctbrec.ui.TabSelectionListener;
|
||||
import javafx.application.Platform;
|
||||
import javafx.beans.value.ChangeListener;
|
||||
|
@ -203,6 +205,7 @@ public class CamsodaShowsTab extends Tab implements TabSelectionListener {
|
|||
setCursor(Cursor.WAIT);
|
||||
new Thread(() -> {
|
||||
try {
|
||||
SiteUiFactory.getUi(model.getSite()).login();
|
||||
model.follow();
|
||||
} catch (Exception e) {
|
||||
LOG.error("Couldn't follow model {}", model, e);
|
|
@ -0,0 +1,107 @@
|
|||
package ctbrec.ui.sites.camsoda;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpCookie;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.sites.camsoda.Camsoda;
|
||||
import ctbrec.sites.camsoda.CamsodaHttpClient;
|
||||
import ctbrec.ui.SiteUI;
|
||||
import ctbrec.ui.TabProvider;
|
||||
import ctbrec.ui.sites.cam4.Cam4LoginDialog;
|
||||
import javafx.application.Platform;
|
||||
import okhttp3.Cookie;
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
public class CamsodaSiteUi implements SiteUI {
|
||||
|
||||
private static final transient Logger LOG = LoggerFactory.getLogger(CamsodaSiteUi.class);
|
||||
|
||||
private CamsodaTabProvider tabProvider;
|
||||
private CamsodaConfigUI configUi;
|
||||
private Camsoda camsoda;
|
||||
|
||||
public CamsodaSiteUi(Camsoda camsoda) {
|
||||
this.camsoda = camsoda;
|
||||
tabProvider = new CamsodaTabProvider(camsoda);
|
||||
configUi = new CamsodaConfigUI(camsoda);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabProvider getTabProvider() {
|
||||
return tabProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigUI getConfigUI() {
|
||||
return configUi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean login() throws IOException {
|
||||
boolean automaticLogin = camsoda.login();
|
||||
return automaticLogin;
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private boolean loginWithDialog() throws IOException {
|
||||
BlockingQueue<Boolean> queue = new LinkedBlockingQueue<>();
|
||||
|
||||
Runnable showDialog = () -> {
|
||||
// login with javafx WebView
|
||||
CamsodaLoginDialog loginDialog = new CamsodaLoginDialog();
|
||||
|
||||
// transfer cookies from WebView to OkHttp cookie jar
|
||||
transferCookies(loginDialog);
|
||||
|
||||
try {
|
||||
queue.put(true);
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("Error while signaling termination", e);
|
||||
}
|
||||
};
|
||||
|
||||
if(Platform.isFxApplicationThread()) {
|
||||
showDialog.run();
|
||||
} else {
|
||||
Platform.runLater(showDialog);
|
||||
try {
|
||||
queue.take();
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("Error while waiting for login dialog to close", e);
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
CamsodaHttpClient httpClient = (CamsodaHttpClient)camsoda.getHttpClient();
|
||||
boolean loggedIn = httpClient.checkLoginSuccess();
|
||||
return loggedIn;
|
||||
}
|
||||
|
||||
private void transferCookies(CamsodaLoginDialog loginDialog) {
|
||||
HttpUrl redirectedUrl = HttpUrl.parse(loginDialog.getUrl());
|
||||
List<Cookie> cookies = new ArrayList<>();
|
||||
for (HttpCookie webViewCookie : loginDialog.getCookies()) {
|
||||
Cookie cookie = Cookie.parse(redirectedUrl, webViewCookie.toString());
|
||||
cookies.add(cookie);
|
||||
}
|
||||
camsoda.getHttpClient().getCookieJar().saveFromResponse(redirectedUrl, cookies);
|
||||
|
||||
HttpUrl origUrl = HttpUrl.parse(Cam4LoginDialog.URL);
|
||||
cookies = new ArrayList<>();
|
||||
for (HttpCookie webViewCookie : loginDialog.getCookies()) {
|
||||
Cookie cookie = Cookie.parse(origUrl, webViewCookie.toString());
|
||||
cookies.add(cookie);
|
||||
}
|
||||
camsoda.getHttpClient().getCookieJar().saveFromResponse(origUrl, cookies);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package ctbrec.sites.camsoda;
|
||||
package ctbrec.ui.sites.camsoda;
|
||||
|
||||
import static ctbrec.sites.camsoda.Camsoda.*;
|
||||
|
||||
|
@ -6,6 +6,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import ctbrec.recorder.Recorder;
|
||||
import ctbrec.sites.camsoda.Camsoda;
|
||||
import ctbrec.ui.TabProvider;
|
||||
import ctbrec.ui.ThumbOverviewTab;
|
||||
import javafx.scene.Scene;
|
||||
|
@ -17,9 +18,9 @@ public class CamsodaTabProvider extends TabProvider {
|
|||
private Recorder recorder;
|
||||
CamsodaFollowedTab followedTab;
|
||||
|
||||
public CamsodaTabProvider(Camsoda camsoda, Recorder recorder) {
|
||||
public CamsodaTabProvider(Camsoda camsoda) {
|
||||
this.camsoda = camsoda;
|
||||
this.recorder = recorder;
|
||||
this.recorder = camsoda.getRecorder();
|
||||
followedTab = new CamsodaFollowedTab("Followed", camsoda);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package ctbrec.sites.camsoda;
|
||||
package ctbrec.ui.sites.camsoda;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
@ -6,15 +6,18 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ctbrec.Model;
|
||||
import ctbrec.StringUtil;
|
||||
import ctbrec.io.HttpException;
|
||||
import ctbrec.sites.camsoda.Camsoda;
|
||||
import ctbrec.sites.camsoda.CamsodaModel;
|
||||
import ctbrec.ui.PaginatedScheduledService;
|
||||
import ctbrec.ui.SiteUiFactory;
|
||||
import javafx.concurrent.Task;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
@ -45,8 +48,11 @@ public class CamsodaUpdateService extends PaginatedScheduledService {
|
|||
} else {
|
||||
String url = CamsodaUpdateService.this.url;
|
||||
LOG.debug("Fetching page {}", url);
|
||||
if(loginRequired) {
|
||||
SiteUiFactory.getUi(camsoda).login();
|
||||
}
|
||||
Request request = new Request.Builder().url(url).build();
|
||||
try(Response response = camsoda.getHttpClient().execute(request, loginRequired)) {
|
||||
try(Response response = camsoda.getHttpClient().execute(request)) {
|
||||
if (response.isSuccessful()) {
|
||||
JSONObject json = new JSONObject(response.body().string());
|
||||
if(json.has("status") && json.getBoolean("status")) {
|
|
@ -1,7 +1,8 @@
|
|||
package ctbrec.sites.chaturbate;
|
||||
package ctbrec.ui.sites.chaturbate;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.sites.chaturbate.Chaturbate;
|
||||
import ctbrec.ui.DesktopIntegration;
|
||||
import ctbrec.ui.SettingsTab;
|
||||
import javafx.geometry.Insets;
|
|
@ -1,5 +1,6 @@
|
|||
package ctbrec.sites.chaturbate;
|
||||
package ctbrec.ui.sites.chaturbate;
|
||||
|
||||
import ctbrec.sites.chaturbate.Chaturbate;
|
||||
import ctbrec.ui.FollowedTab;
|
||||
import ctbrec.ui.ThumbOverviewTab;
|
||||
import javafx.concurrent.WorkerStateEvent;
|
|
@ -0,0 +1,37 @@
|
|||
package ctbrec.ui.sites.chaturbate;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.sites.chaturbate.Chaturbate;
|
||||
import ctbrec.ui.SiteUI;
|
||||
import ctbrec.ui.TabProvider;
|
||||
|
||||
public class ChaturbateSiteUi implements SiteUI {
|
||||
|
||||
private ChaturbateTabProvider tabProvider;
|
||||
private ChaturbateConfigUi configUi;
|
||||
private Chaturbate chaturbate;
|
||||
|
||||
public ChaturbateSiteUi(Chaturbate chaturbate) {
|
||||
this.chaturbate = chaturbate;
|
||||
tabProvider = new ChaturbateTabProvider(chaturbate);
|
||||
configUi = new ChaturbateConfigUi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabProvider getTabProvider() {
|
||||
return tabProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigUI getConfigUI() {
|
||||
return configUi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean login() throws IOException {
|
||||
return chaturbate.login();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package ctbrec.sites.chaturbate;
|
||||
package ctbrec.ui.sites.chaturbate;
|
||||
|
||||
import static ctbrec.sites.chaturbate.Chaturbate.*;
|
||||
|
||||
|
@ -6,6 +6,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import ctbrec.recorder.Recorder;
|
||||
import ctbrec.sites.chaturbate.Chaturbate;
|
||||
import ctbrec.ui.TabProvider;
|
||||
import ctbrec.ui.ThumbOverviewTab;
|
||||
import javafx.scene.Scene;
|
||||
|
@ -17,9 +18,9 @@ public class ChaturbateTabProvider extends TabProvider {
|
|||
private Recorder recorder;
|
||||
private ChaturbateFollowedTab followedTab;
|
||||
|
||||
public ChaturbateTabProvider(Chaturbate chaturbate, Recorder recorder) {
|
||||
public ChaturbateTabProvider(Chaturbate chaturbate) {
|
||||
this.chaturbate = chaturbate;
|
||||
this.recorder = recorder;
|
||||
this.recorder = chaturbate.getRecorder();
|
||||
this.followedTab = new ChaturbateFollowedTab("Followed", BASE_URI + "/followed-cams/", chaturbate);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package ctbrec.sites.chaturbate;
|
||||
package ctbrec.ui.sites.chaturbate;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collections;
|
||||
|
@ -7,12 +7,15 @@ import java.util.concurrent.ExecutorService;
|
|||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ThreadFactory;
|
||||
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ctbrec.Model;
|
||||
import ctbrec.StringUtil;
|
||||
import ctbrec.sites.chaturbate.Chaturbate;
|
||||
import ctbrec.sites.chaturbate.ChaturbateModelParser;
|
||||
import ctbrec.ui.PaginatedScheduledService;
|
||||
import ctbrec.ui.SiteUiFactory;
|
||||
import javafx.concurrent.Task;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
@ -51,8 +54,11 @@ public class ChaturbateUpdateService extends PaginatedScheduledService {
|
|||
} else {
|
||||
String url = ChaturbateUpdateService.this.url + "?page="+page+"&keywords=&_=" + System.currentTimeMillis();
|
||||
LOG.debug("Fetching page {}", url);
|
||||
if(loginRequired) {
|
||||
SiteUiFactory.getUi(chaturbate).login();
|
||||
}
|
||||
Request request = new Request.Builder().url(url).build();
|
||||
Response response = chaturbate.getHttpClient().execute(request, loginRequired);
|
||||
Response response = chaturbate.getHttpClient().execute(request);
|
||||
if (response.isSuccessful()) {
|
||||
List<Model> models = ChaturbateModelParser.parseModels(chaturbate, response.body().string());
|
||||
response.close();
|
|
@ -1,4 +1,4 @@
|
|||
package ctbrec.sites.mfc;
|
||||
package ctbrec.ui.sites.myfreecams;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -7,13 +7,19 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.eclipse.jetty.util.StringUtil;
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ctbrec.Model;
|
||||
import ctbrec.StringUtil;
|
||||
import ctbrec.sites.mfc.MyFreeCams;
|
||||
import ctbrec.sites.mfc.MyFreeCamsClient;
|
||||
import ctbrec.sites.mfc.MyFreeCamsModel;
|
||||
import ctbrec.sites.mfc.SessionState;
|
||||
import ctbrec.sites.mfc.User;
|
||||
import ctbrec.ui.PaginatedScheduledService;
|
||||
import ctbrec.ui.SiteUiFactory;
|
||||
import javafx.concurrent.Task;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
@ -42,12 +48,13 @@ public class FriendsUpdateService extends PaginatedScheduledService {
|
|||
return Collections.emptyList();
|
||||
} else {
|
||||
List<MyFreeCamsModel> models = new ArrayList<>();
|
||||
SiteUiFactory.getUi(myFreeCams).login();
|
||||
String url = myFreeCams.getBaseUrl() + "/php/manage_lists2.php?passcode=&list_type=friends&data_mode=online&get_user_list=1";
|
||||
Request req = new Request.Builder()
|
||||
.url(url)
|
||||
.header("Referer", myFreeCams.getBaseUrl())
|
||||
.build();
|
||||
try(Response resp = myFreeCams.getHttpClient().execute(req, true)) {
|
||||
try(Response resp = myFreeCams.getHttpClient().execute(req)) {
|
||||
if(resp.isSuccessful()) {
|
||||
String body = resp.body().string().substring(4);
|
||||
try {
|
|
@ -1,4 +1,4 @@
|
|||
package ctbrec.sites.mfc;
|
||||
package ctbrec.ui.sites.myfreecams;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import ctbrec.Model;
|
||||
import ctbrec.sites.mfc.MyFreeCamsClient;
|
||||
import ctbrec.ui.PaginatedScheduledService;
|
||||
import javafx.concurrent.Task;
|
||||
|
|
@ -1,7 +1,8 @@
|
|||
package ctbrec.sites.mfc;
|
||||
package ctbrec.ui.sites.myfreecams;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.sites.mfc.MyFreeCams;
|
||||
import ctbrec.ui.DesktopIntegration;
|
||||
import ctbrec.ui.SettingsTab;
|
||||
import javafx.geometry.Insets;
|
|
@ -1,8 +1,9 @@
|
|||
package ctbrec.sites.mfc;
|
||||
import static ctbrec.sites.mfc.FriendsUpdateService.Mode.*;
|
||||
package ctbrec.ui.sites.myfreecams;
|
||||
import static ctbrec.ui.sites.myfreecams.FriendsUpdateService.Mode.*;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import ctbrec.sites.mfc.MyFreeCams;
|
||||
import ctbrec.ui.FollowedTab;
|
||||
import ctbrec.ui.ThumbOverviewTab;
|
||||
import javafx.geometry.Insets;
|
|
@ -0,0 +1,37 @@
|
|||
package ctbrec.ui.sites.myfreecams;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.sites.mfc.MyFreeCams;
|
||||
import ctbrec.ui.SiteUI;
|
||||
import ctbrec.ui.TabProvider;
|
||||
|
||||
public class MyFreeCamsSiteUi implements SiteUI {
|
||||
|
||||
private MyFreeCamsTabProvider tabProvider;
|
||||
private MyFreeCamsConfigUI configUi;
|
||||
private MyFreeCams myFreeCams;
|
||||
|
||||
public MyFreeCamsSiteUi(MyFreeCams myFreeCams) {
|
||||
this.myFreeCams = myFreeCams;
|
||||
tabProvider = new MyFreeCamsTabProvider(myFreeCams);
|
||||
configUi = new MyFreeCamsConfigUI(myFreeCams);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabProvider getTabProvider() {
|
||||
return tabProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigUI getConfigUI() {
|
||||
return configUi;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean login() throws IOException {
|
||||
return myFreeCams.login();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,11 @@
|
|||
package ctbrec.sites.mfc;
|
||||
package ctbrec.ui.sites.myfreecams;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import ctbrec.recorder.Recorder;
|
||||
import ctbrec.sites.mfc.MyFreeCams;
|
||||
import ctbrec.ui.PaginatedScheduledService;
|
||||
import ctbrec.ui.TabProvider;
|
||||
import ctbrec.ui.ThumbOverviewTab;
|
||||
|
@ -17,9 +18,9 @@ public class MyFreeCamsTabProvider extends TabProvider {
|
|||
private MyFreeCams myFreeCams;
|
||||
private MyFreeCamsFriendsTab friends;
|
||||
|
||||
public MyFreeCamsTabProvider(MyFreeCamsClient client, Recorder recorder, MyFreeCams myFreeCams) {
|
||||
this.recorder = recorder;
|
||||
public MyFreeCamsTabProvider(MyFreeCams myFreeCams) {
|
||||
this.myFreeCams = myFreeCams;
|
||||
this.recorder = myFreeCams.getRecorder();
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,4 +1,4 @@
|
|||
package ctbrec.sites.mfc;
|
||||
package ctbrec.ui.sites.myfreecams;
|
||||
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -6,6 +6,7 @@ import java.util.List;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
import ctbrec.Model;
|
||||
import ctbrec.sites.mfc.MyFreeCamsClient;
|
||||
import ctbrec.ui.PaginatedScheduledService;
|
||||
import javafx.concurrent.Task;
|
||||
|
|
@ -1,10 +1,11 @@
|
|||
package ctbrec.sites.mfc;
|
||||
package ctbrec.ui.sites.myfreecams;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import ctbrec.Model;
|
||||
import ctbrec.sites.mfc.MyFreeCamsClient;
|
||||
import ctbrec.ui.PaginatedScheduledService;
|
||||
import javafx.concurrent.Task;
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
|
@ -0,0 +1,2 @@
|
|||
/bin/
|
||||
/target/
|
|
@ -0,0 +1,23 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>ctbrec-common</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
|
@ -0,0 +1,2 @@
|
|||
eclipse.preferences.version=1
|
||||
encoding/<project>=UTF-8
|
|
@ -0,0 +1,13 @@
|
|||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=1.8
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.release=disabled
|
||||
org.eclipse.jdt.core.compiler.source=1.8
|
|
@ -0,0 +1,4 @@
|
|||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
|
@ -0,0 +1,65 @@
|
|||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>common</artifactId>
|
||||
|
||||
<parent>
|
||||
<groupId>ctbrec</groupId>
|
||||
<artifactId>master</artifactId>
|
||||
<version>1.9.0</version>
|
||||
<relativePath>../master</relativePath>
|
||||
</parent>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>1.8</maven.compiler.source>
|
||||
<maven.compiler.target>1.8</maven.compiler.target>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.okhttp3</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.squareup.moshi</groupId>
|
||||
<artifactId>moshi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.iheartradio.m3u8</groupId>
|
||||
<artifactId>open-m3u8</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jcodec</groupId>
|
||||
<artifactId>jcodec</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.guava</groupId>
|
||||
<artifactId>guava</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-controls</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openjfx</groupId>
|
||||
<artifactId>javafx-web</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,11 @@
|
|||
package ctbrec;
|
||||
|
||||
public class StringUtil {
|
||||
public static boolean isBlank(String s) {
|
||||
return s == null || s.trim().isEmpty();
|
||||
}
|
||||
|
||||
public static boolean isNotBlank(String s) {
|
||||
return !isBlank(s);
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package ctbrec.ui;
|
||||
package ctbrec.io;
|
||||
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
|
@ -23,6 +23,7 @@ import ctbrec.Config;
|
|||
import ctbrec.Settings.ProxyType;
|
||||
import okhttp3.ConnectionPool;
|
||||
import okhttp3.Cookie;
|
||||
import okhttp3.CookieJar;
|
||||
import okhttp3.Credentials;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.OkHttpClient.Builder;
|
||||
|
@ -91,18 +92,19 @@ public abstract class HttpClient {
|
|||
}
|
||||
}
|
||||
|
||||
public Response execute(Request request) throws IOException {
|
||||
Response resp = execute(request, false);
|
||||
return resp;
|
||||
}
|
||||
// public Response execute(Request request) throws IOException {
|
||||
// Response resp = execute(request, false);
|
||||
// return resp;
|
||||
// }
|
||||
|
||||
public Response execute(Request req, boolean requiresLogin) throws IOException {
|
||||
if(requiresLogin && !loggedIn) {
|
||||
loggedIn = login();
|
||||
if(!loggedIn) {
|
||||
throw new IOException("403 Unauthorized");
|
||||
}
|
||||
}
|
||||
// public Response execute(Request req, boolean requiresLogin) throws IOException {
|
||||
public Response execute(Request req) throws IOException {
|
||||
// if(requiresLogin && !loggedIn) {
|
||||
// loggedIn = login();
|
||||
// if(!loggedIn) {
|
||||
// throw new IOException("403 Unauthorized");
|
||||
// }
|
||||
// }
|
||||
Response resp = client.newCall(req).execute();
|
||||
return resp;
|
||||
}
|
||||
|
@ -209,4 +211,8 @@ public abstract class HttpClient {
|
|||
return auth;
|
||||
}
|
||||
}
|
||||
|
||||
public CookieJar getCookieJar() {
|
||||
return cookieJar;
|
||||
}
|
||||
}
|
|
@ -36,13 +36,13 @@ import ctbrec.Model;
|
|||
import ctbrec.OS;
|
||||
import ctbrec.Recording;
|
||||
import ctbrec.Recording.STATUS;
|
||||
import ctbrec.io.HttpClient;
|
||||
import ctbrec.io.HttpException;
|
||||
import ctbrec.io.StreamRedirectThread;
|
||||
import ctbrec.recorder.PlaylistGenerator.InvalidPlaylistException;
|
||||
import ctbrec.recorder.download.Download;
|
||||
import ctbrec.recorder.download.HlsDownload;
|
||||
import ctbrec.recorder.download.MergedHlsDownload;
|
||||
import ctbrec.recorder.server.RecorderHttpClient;
|
||||
|
||||
public class LocalRecorder implements Recorder {
|
||||
|
||||
|
@ -722,4 +722,9 @@ public class LocalRecorder implements Recorder {
|
|||
lock.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpClient getHttpClient() {
|
||||
return client;
|
||||
}
|
||||
}
|
|
@ -7,6 +7,7 @@ import java.util.List;
|
|||
|
||||
import ctbrec.Model;
|
||||
import ctbrec.Recording;
|
||||
import ctbrec.io.HttpClient;
|
||||
|
||||
public interface Recorder {
|
||||
public void startRecording(Model model) throws IOException, InvalidKeyException, NoSuchAlgorithmException, IllegalStateException;
|
||||
|
@ -39,4 +40,6 @@ public interface Recorder {
|
|||
* @return
|
||||
*/
|
||||
public List<Model> getOnlineModels();
|
||||
|
||||
public HttpClient getHttpClient();
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
package ctbrec.recorder.server;
|
||||
package ctbrec.recorder;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
@ -357,4 +357,9 @@ public class RemoteRecorder implements Recorder {
|
|||
public List<Model> getOnlineModels() {
|
||||
return onlineModels;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpClient getHttpClient() {
|
||||
return client;
|
||||
}
|
||||
}
|
|
@ -1,8 +1,11 @@
|
|||
package ctbrec.sites;
|
||||
|
||||
import ctbrec.recorder.Recorder;
|
||||
|
||||
public abstract class AbstractSite implements Site {
|
||||
|
||||
private boolean enabled;
|
||||
private Recorder recorder;
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
|
@ -13,4 +16,14 @@ public abstract class AbstractSite implements Site {
|
|||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecorder(Recorder recorder) {
|
||||
this.recorder = recorder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Recorder getRecorder() {
|
||||
return recorder;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
package ctbrec.sites;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
public class NeedsManualLoginException extends IOException {
|
||||
|
||||
}
|
|
@ -5,25 +5,23 @@ import java.io.IOException;
|
|||
import ctbrec.Model;
|
||||
import ctbrec.io.HttpClient;
|
||||
import ctbrec.recorder.Recorder;
|
||||
import ctbrec.ui.TabProvider;
|
||||
|
||||
public interface Site {
|
||||
public String getName();
|
||||
public String getBaseUrl();
|
||||
public String getAffiliateLink();
|
||||
public void setRecorder(Recorder recorder);
|
||||
public TabProvider getTabProvider();
|
||||
public Recorder getRecorder();
|
||||
public Model createModel(String name);
|
||||
public Integer getTokenBalance() throws IOException;
|
||||
public String getBuyTokensLink();
|
||||
public void login() throws IOException;
|
||||
public boolean login() throws IOException;
|
||||
public HttpClient getHttpClient();
|
||||
public void init() throws IOException;
|
||||
public void shutdown();
|
||||
public boolean supportsTips();
|
||||
public boolean supportsFollow();
|
||||
public boolean isSiteForModel(Model m);
|
||||
public ConfigUI getConfigurationGui();
|
||||
public boolean credentialsAvailable();
|
||||
public void setEnabled(boolean enabled);
|
||||
public boolean isEnabled();
|
|
@ -8,10 +8,7 @@ import ctbrec.Config;
|
|||
import ctbrec.Model;
|
||||
import ctbrec.io.HttpClient;
|
||||
import ctbrec.io.HttpException;
|
||||
import ctbrec.recorder.Recorder;
|
||||
import ctbrec.sites.AbstractSite;
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.ui.TabProvider;
|
||||
import okhttp3.FormBody;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
|
@ -22,8 +19,6 @@ public class BongaCams extends AbstractSite {
|
|||
public static final String BASE_URL = "https://bongacams.com";
|
||||
|
||||
private BongaCamsHttpClient httpClient;
|
||||
private Recorder recorder;
|
||||
private BongaCamsTabProvider tabProvider;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -40,19 +35,6 @@ public class BongaCams extends AbstractSite {
|
|||
return "http://bongacams2.com/track?c=610249";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecorder(Recorder recorder) {
|
||||
this.recorder = recorder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabProvider getTabProvider() {
|
||||
if(tabProvider == null) {
|
||||
tabProvider = new BongaCamsTabProvider(recorder, this);
|
||||
}
|
||||
return tabProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model createModel(String name) {
|
||||
BongaCamsModel model = new BongaCamsModel();
|
||||
|
@ -80,7 +62,7 @@ public class BongaCams extends AbstractSite {
|
|||
.addHeader("X-Requested-With", "XMLHttpRequest")
|
||||
.post(body)
|
||||
.build();
|
||||
try(Response response = getHttpClient().execute(request, true)) {
|
||||
try(Response response = getHttpClient().execute(request)) {
|
||||
if(response.isSuccessful()) {
|
||||
JSONObject json = new JSONObject(response.body().string());
|
||||
if(json.optString("status").equals("online")) {
|
||||
|
@ -101,8 +83,8 @@ public class BongaCams extends AbstractSite {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void login() throws IOException {
|
||||
getHttpClient().login();
|
||||
public boolean login() throws IOException {
|
||||
return credentialsAvailable() && getHttpClient().login();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -139,11 +121,6 @@ public class BongaCams extends AbstractSite {
|
|||
return m instanceof BongaCamsModel;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigUI getConfigurationGui() {
|
||||
return new BongaCamsConfigUI(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean credentialsAvailable() {
|
||||
String username = Config.getInstance().getSettings().bongaUsername;
|
|
@ -1,14 +1,10 @@
|
|||
package ctbrec.sites.bonga;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpCookie;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import org.json.JSONArray;
|
||||
import org.json.JSONObject;
|
||||
|
@ -18,10 +14,8 @@ import org.slf4j.LoggerFactory;
|
|||
import ctbrec.Config;
|
||||
import ctbrec.io.HttpClient;
|
||||
import ctbrec.io.HttpException;
|
||||
import javafx.application.Platform;
|
||||
import okhttp3.Cookie;
|
||||
import okhttp3.FormBody;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
import okhttp3.Response;
|
||||
|
@ -72,48 +66,14 @@ public class BongaCamsHttpClient extends HttpClient {
|
|||
return true;
|
||||
}
|
||||
|
||||
BlockingQueue<Boolean> queue = new LinkedBlockingQueue<>();
|
||||
|
||||
Runnable showDialog = () -> {
|
||||
// login with javafx WebView
|
||||
BongaCamsLoginDialog loginDialog = new BongaCamsLoginDialog();
|
||||
|
||||
// transfer cookies from WebView to OkHttp cookie jar
|
||||
transferCookies(loginDialog);
|
||||
|
||||
try {
|
||||
queue.put(true);
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("Error while signaling termination", e);
|
||||
}
|
||||
};
|
||||
|
||||
if(Platform.isFxApplicationThread()) {
|
||||
showDialog.run();
|
||||
} else {
|
||||
Platform.runLater(showDialog);
|
||||
try {
|
||||
queue.take();
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("Error while waiting for login dialog to close", e);
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
loggedIn = checkLoginSuccess();
|
||||
if(loggedIn) {
|
||||
LOG.info("Logged in. User ID is {}", userId);
|
||||
} else {
|
||||
LOG.info("Login failed");
|
||||
}
|
||||
return loggedIn;
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check, if the login worked by requesting roomdata and looking
|
||||
* @throws IOException
|
||||
*/
|
||||
private boolean checkLoginSuccess() throws IOException {
|
||||
public boolean checkLoginSuccess() throws IOException {
|
||||
String modelName = getAnyModelName();
|
||||
// we request the roomData of a random model, because it contains
|
||||
// user data, if the user is logged in, which we can use to verify, that the login worked
|
||||
|
@ -180,24 +140,6 @@ public class BongaCamsHttpClient extends HttpClient {
|
|||
}
|
||||
}
|
||||
|
||||
private void transferCookies(BongaCamsLoginDialog loginDialog) {
|
||||
HttpUrl redirectedUrl = HttpUrl.parse(loginDialog.getUrl());
|
||||
List<Cookie> cookies = new ArrayList<>();
|
||||
for (HttpCookie webViewCookie : loginDialog.getCookies()) {
|
||||
Cookie cookie = Cookie.parse(redirectedUrl, webViewCookie.toString());
|
||||
cookies.add(cookie);
|
||||
}
|
||||
cookieJar.saveFromResponse(redirectedUrl, cookies);
|
||||
|
||||
HttpUrl origUrl = HttpUrl.parse(BongaCamsLoginDialog.URL);
|
||||
cookies = new ArrayList<>();
|
||||
for (HttpCookie webViewCookie : loginDialog.getCookies()) {
|
||||
Cookie cookie = Cookie.parse(origUrl, webViewCookie.toString());
|
||||
cookies.add(cookie);
|
||||
}
|
||||
cookieJar.saveFromResponse(origUrl, cookies);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean login() throws IOException {
|
||||
// String url = BongaCams.BASE_URL + "/login";
|
|
@ -165,7 +165,7 @@ public class BongaCamsModel extends AbstractModel {
|
|||
.addHeader("X-Requested-With", "XMLHttpRequest")
|
||||
.post(body)
|
||||
.build();
|
||||
try(Response response = site.getHttpClient().execute(request, true)) {
|
||||
try(Response response = site.getHttpClient().execute(request)) {
|
||||
if(response.isSuccessful()) {
|
||||
JSONObject json = new JSONObject(response.body().string());
|
||||
if(!json.optString("status").equals("success")) {
|
|
@ -2,15 +2,10 @@ package ctbrec.sites.cam4;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Model;
|
||||
import ctbrec.io.HttpClient;
|
||||
import ctbrec.recorder.Recorder;
|
||||
import ctbrec.sites.AbstractSite;
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.ui.TabProvider;
|
||||
|
||||
public class Cam4 extends AbstractSite {
|
||||
|
||||
|
@ -19,8 +14,6 @@ public class Cam4 extends AbstractSite {
|
|||
public static final String AFFILIATE_LINK = BASE_URI + "/?referrerId=1514a80d87b5effb456cca02f6743aa1";
|
||||
|
||||
private HttpClient httpClient;
|
||||
private Recorder recorder;
|
||||
private Cam4TabProvider tabProvider;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -37,19 +30,6 @@ public class Cam4 extends AbstractSite {
|
|||
return AFFILIATE_LINK;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecorder(Recorder recorder) {
|
||||
this.recorder = recorder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabProvider getTabProvider() {
|
||||
if(tabProvider == null) {
|
||||
tabProvider = new Cam4TabProvider(this, recorder);
|
||||
}
|
||||
return tabProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model createModel(String name) {
|
||||
Cam4Model m = new Cam4Model();
|
||||
|
@ -73,11 +53,8 @@ public class Cam4 extends AbstractSite {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void login() throws IOException {
|
||||
if (credentialsAvailable()) {
|
||||
boolean success = getHttpClient().login();
|
||||
LoggerFactory.getLogger(getClass()).debug("Login success: {}", success);
|
||||
}
|
||||
public boolean login() throws IOException {
|
||||
return credentialsAvailable() && getHttpClient().login();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -117,9 +94,4 @@ public class Cam4 extends AbstractSite {
|
|||
String username = Config.getInstance().getSettings().cam4Username;
|
||||
return username != null && !username.trim().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigUI getConfigurationGui() {
|
||||
return new Cam4ConfigUI();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,65 @@
|
|||
package ctbrec.sites.cam4;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ctbrec.io.HttpClient;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class Cam4HttpClient extends HttpClient {
|
||||
|
||||
private static final transient Logger LOG = LoggerFactory.getLogger(Cam4HttpClient.class);
|
||||
|
||||
public Cam4HttpClient() {
|
||||
super("cam4");
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized boolean login() throws IOException {
|
||||
if(loggedIn) {
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean cookiesWorked = checkLoginSuccess();
|
||||
if(cookiesWorked) {
|
||||
loggedIn = true;
|
||||
LOG.debug("Logged in with cookies");
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* check, if the login worked by requesting unchecked mail
|
||||
* @throws IOException
|
||||
*/
|
||||
public boolean checkLoginSuccess() throws IOException {
|
||||
String mailUrl = Cam4.BASE_URI + "/mail/unreadThreads";
|
||||
Request req = new Request.Builder()
|
||||
.url(mailUrl)
|
||||
.addHeader("X-Requested-With", "XMLHttpRequest")
|
||||
.build();
|
||||
Response response = execute(req);
|
||||
if(response.isSuccessful() && response.body().contentLength() > 0) {
|
||||
JSONObject json = new JSONObject(response.body().string());
|
||||
return json.has("status") && Objects.equals("success", json.getString("status"));
|
||||
} else {
|
||||
response.close();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
protected int getTokenBalance() throws IOException {
|
||||
if(!loggedIn) {
|
||||
login();
|
||||
}
|
||||
|
||||
throw new RuntimeException("Not implemented, yet");
|
||||
}
|
||||
}
|
|
@ -24,11 +24,10 @@ import com.iheartradio.m3u8.data.PlaylistData;
|
|||
|
||||
import ctbrec.AbstractModel;
|
||||
import ctbrec.Config;
|
||||
import ctbrec.io.HtmlParser;
|
||||
import ctbrec.io.HttpException;
|
||||
import ctbrec.recorder.download.StreamSource;
|
||||
import ctbrec.sites.Site;
|
||||
import ctbrec.ui.CamrecApplication;
|
||||
import ctbrec.ui.HtmlParser;
|
||||
import okhttp3.FormBody;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
|
@ -168,7 +167,7 @@ public class Cam4Model extends AbstractModel {
|
|||
.url(url)
|
||||
.addHeader("X-Requested-With", "XMLHttpRequest")
|
||||
.build();
|
||||
Response response = site.getHttpClient().execute(req, true);
|
||||
Response response = site.getHttpClient().execute(req);
|
||||
boolean success = response.isSuccessful();
|
||||
response.close();
|
||||
return success;
|
||||
|
@ -185,7 +184,7 @@ public class Cam4Model extends AbstractModel {
|
|||
|
||||
// we have to use a client without any cam4 cookies here, otherwise
|
||||
// this request is redirected to the login page. no idea why
|
||||
try(Response response = CamrecApplication.httpClient.execute(req)) {
|
||||
try(Response response = site.getRecorder().getHttpClient().execute(req)) {
|
||||
String broadCasterId = null;
|
||||
if(response.isSuccessful()) {
|
||||
String content = response.body().string();
|
||||
|
@ -209,7 +208,7 @@ public class Cam4Model extends AbstractModel {
|
|||
.post(body)
|
||||
.addHeader("X-Requested-With", "XMLHttpRequest")
|
||||
.build();
|
||||
Response resp = site.getHttpClient().execute(req, true);
|
||||
Response resp = site.getHttpClient().execute(req);
|
||||
if(resp.isSuccessful()) {
|
||||
return Objects.equals(resp.body().string(), "Ok");
|
||||
} else {
|
|
@ -8,19 +8,14 @@ import ctbrec.Config;
|
|||
import ctbrec.Model;
|
||||
import ctbrec.io.HttpClient;
|
||||
import ctbrec.io.HttpException;
|
||||
import ctbrec.recorder.Recorder;
|
||||
import ctbrec.sites.AbstractSite;
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.ui.TabProvider;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
public class Camsoda extends AbstractSite {
|
||||
|
||||
public static final String BASE_URI = "https://www.camsoda.com";
|
||||
private Recorder recorder;
|
||||
private HttpClient httpClient;
|
||||
private CamsodaTabProvider tabProvider;
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
|
@ -42,19 +37,6 @@ public class Camsoda extends AbstractSite {
|
|||
return BASE_URI;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecorder(Recorder recorder) {
|
||||
this.recorder = recorder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabProvider getTabProvider() {
|
||||
if(tabProvider == null) {
|
||||
tabProvider = new CamsodaTabProvider(this, recorder);
|
||||
}
|
||||
return tabProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model createModel(String name) {
|
||||
CamsodaModel model = new CamsodaModel();
|
||||
|
@ -73,7 +55,7 @@ public class Camsoda extends AbstractSite {
|
|||
String username = Config.getInstance().getSettings().camsodaUsername;
|
||||
String url = BASE_URI + "/api/v1/user/" + username;
|
||||
Request request = new Request.Builder().url(url).build();
|
||||
try(Response response = getHttpClient().execute(request, true)) {
|
||||
try(Response response = getHttpClient().execute(request)) {
|
||||
if(response.isSuccessful()) {
|
||||
JSONObject json = new JSONObject(response.body().string());
|
||||
if(json.has("user")) {
|
||||
|
@ -90,10 +72,8 @@ public class Camsoda extends AbstractSite {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void login() throws IOException {
|
||||
if(credentialsAvailable()) {
|
||||
getHttpClient().login();
|
||||
}
|
||||
public boolean login() throws IOException {
|
||||
return credentialsAvailable() && getHttpClient().login();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -135,9 +115,4 @@ public class Camsoda extends AbstractSite {
|
|||
String username = Config.getInstance().getSettings().camsodaUsername;
|
||||
return username != null && !username.trim().isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigUI getConfigurationGui() {
|
||||
return new CamsodaConfigUI(this);
|
||||
}
|
||||
}
|
|
@ -1,12 +1,7 @@
|
|||
package ctbrec.sites.camsoda;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.HttpCookie;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import org.json.JSONObject;
|
||||
import org.jsoup.nodes.Element;
|
||||
|
@ -14,14 +9,10 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.io.HtmlParser;
|
||||
import ctbrec.io.HttpClient;
|
||||
import ctbrec.io.HttpException;
|
||||
import ctbrec.sites.cam4.Cam4LoginDialog;
|
||||
import ctbrec.ui.HtmlParser;
|
||||
import javafx.application.Platform;
|
||||
import okhttp3.Cookie;
|
||||
import okhttp3.FormBody;
|
||||
import okhttp3.HttpUrl;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.Response;
|
||||
|
||||
|
@ -76,45 +67,11 @@ public class CamsodaHttpClient extends HttpClient {
|
|||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private boolean loginWithDialog() throws IOException {
|
||||
BlockingQueue<Boolean> queue = new LinkedBlockingQueue<>();
|
||||
|
||||
Runnable showDialog = () -> {
|
||||
// login with javafx WebView
|
||||
CamsodaLoginDialog loginDialog = new CamsodaLoginDialog();
|
||||
|
||||
// transfer cookies from WebView to OkHttp cookie jar
|
||||
transferCookies(loginDialog);
|
||||
|
||||
try {
|
||||
queue.put(true);
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("Error while signaling termination", e);
|
||||
}
|
||||
};
|
||||
|
||||
if(Platform.isFxApplicationThread()) {
|
||||
showDialog.run();
|
||||
} else {
|
||||
Platform.runLater(showDialog);
|
||||
try {
|
||||
queue.take();
|
||||
} catch (InterruptedException e) {
|
||||
LOG.error("Error while waiting for login dialog to close", e);
|
||||
throw new IOException(e);
|
||||
}
|
||||
}
|
||||
|
||||
loggedIn = checkLoginSuccess();
|
||||
return loggedIn;
|
||||
}
|
||||
|
||||
/**
|
||||
* check, if the login worked
|
||||
* @throws IOException
|
||||
*/
|
||||
private boolean checkLoginSuccess() throws IOException {
|
||||
public boolean checkLoginSuccess() throws IOException {
|
||||
String url = Camsoda.BASE_URI + "/api/v1/user/current";
|
||||
Request request = new Request.Builder().url(url).build();
|
||||
try(Response response = execute(request)) {
|
||||
|
@ -127,29 +84,11 @@ public class CamsodaHttpClient extends HttpClient {
|
|||
}
|
||||
}
|
||||
|
||||
private void transferCookies(CamsodaLoginDialog loginDialog) {
|
||||
HttpUrl redirectedUrl = HttpUrl.parse(loginDialog.getUrl());
|
||||
List<Cookie> cookies = new ArrayList<>();
|
||||
for (HttpCookie webViewCookie : loginDialog.getCookies()) {
|
||||
Cookie cookie = Cookie.parse(redirectedUrl, webViewCookie.toString());
|
||||
cookies.add(cookie);
|
||||
}
|
||||
cookieJar.saveFromResponse(redirectedUrl, cookies);
|
||||
|
||||
HttpUrl origUrl = HttpUrl.parse(Cam4LoginDialog.URL);
|
||||
cookies = new ArrayList<>();
|
||||
for (HttpCookie webViewCookie : loginDialog.getCookies()) {
|
||||
Cookie cookie = Cookie.parse(origUrl, webViewCookie.toString());
|
||||
cookies.add(cookie);
|
||||
}
|
||||
cookieJar.saveFromResponse(origUrl, cookies);
|
||||
}
|
||||
|
||||
protected String getCsrfToken() throws IOException {
|
||||
if(csrfToken == null) {
|
||||
String url = Camsoda.BASE_URI;
|
||||
Request request = new Request.Builder().url(url).build();
|
||||
try(Response response = execute(request, true)) {
|
||||
try(Response response = execute(request)) {
|
||||
if(response.isSuccessful()) {
|
||||
Element meta = HtmlParser.getTag(response.body().string(), "meta[name=\"_token\"]");
|
||||
csrfToken = meta.attr("content");
|
|
@ -188,7 +188,7 @@ public class CamsodaModel extends AbstractModel {
|
|||
.addHeader("Accept-Language", "en")
|
||||
.addHeader("X-CSRF-Token", csrfToken)
|
||||
.build();
|
||||
try(Response response = site.getHttpClient().execute(request, true)) {
|
||||
try(Response response = site.getHttpClient().execute(request)) {
|
||||
if(!response.isSuccessful()) {
|
||||
throw new HttpException(response.code(), response.message());
|
||||
}
|
||||
|
@ -210,7 +210,7 @@ public class CamsodaModel extends AbstractModel {
|
|||
.addHeader("Accept-Language", "en")
|
||||
.addHeader("X-CSRF-Token", csrfToken)
|
||||
.build();
|
||||
try(Response response = site.getHttpClient().execute(request, true)) {
|
||||
try(Response response = site.getHttpClient().execute(request)) {
|
||||
if (response.isSuccessful()) {
|
||||
return true;
|
||||
} else {
|
||||
|
@ -233,7 +233,7 @@ public class CamsodaModel extends AbstractModel {
|
|||
.addHeader("Accept-Language", "en")
|
||||
.addHeader("X-CSRF-Token", csrfToken)
|
||||
.build();
|
||||
try (Response response = site.getHttpClient().execute(request, true)) {
|
||||
try (Response response = site.getHttpClient().execute(request)) {
|
||||
if (response.isSuccessful()) {
|
||||
return true;
|
||||
} else {
|
|
@ -26,13 +26,10 @@ import com.squareup.moshi.Moshi;
|
|||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.Model;
|
||||
import ctbrec.io.HtmlParser;
|
||||
import ctbrec.io.HttpClient;
|
||||
import ctbrec.io.HttpException;
|
||||
import ctbrec.recorder.Recorder;
|
||||
import ctbrec.sites.AbstractSite;
|
||||
import ctbrec.sites.ConfigUI;
|
||||
import ctbrec.ui.HtmlParser;
|
||||
import ctbrec.ui.TabProvider;
|
||||
import okhttp3.FormBody;
|
||||
import okhttp3.Request;
|
||||
import okhttp3.RequestBody;
|
||||
|
@ -44,9 +41,7 @@ public class Chaturbate extends AbstractSite {
|
|||
public static final String BASE_URI = "https://chaturbate.com";
|
||||
public static final String AFFILIATE_LINK = BASE_URI + "/in/?track=default&tour=grq0&campaign=55vTi";
|
||||
public static final String REGISTRATION_LINK = BASE_URI + "/in/?track=default&tour=g4pe&campaign=55vTi";
|
||||
private Recorder recorder;
|
||||
private ChaturbateHttpClient httpClient;
|
||||
private ChaturbateTabProvider tabProvider;
|
||||
|
||||
@Override
|
||||
public void init() throws IOException {
|
||||
|
@ -68,19 +63,6 @@ public class Chaturbate extends AbstractSite {
|
|||
return getBaseUrl() + "/in/?track=default&tour=LQps&campaign=55vTi&room=0xb00bface";
|
||||
}
|
||||
|
||||
@Override
|
||||
public TabProvider getTabProvider() {
|
||||
if(tabProvider == null) {
|
||||
tabProvider = new ChaturbateTabProvider(this, recorder);
|
||||
}
|
||||
return tabProvider;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRecorder(Recorder recorder) {
|
||||
this.recorder = recorder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Model createModel(String name) {
|
||||
ChaturbateModel m = new ChaturbateModel(this);
|
||||
|
@ -98,7 +80,7 @@ public class Chaturbate extends AbstractSite {
|
|||
|
||||
String url = "https://chaturbate.com/p/" + username + "/";
|
||||
Request req = new Request.Builder().url(url).build();
|
||||
Response resp = getHttpClient().execute(req, true);
|
||||
Response resp = getHttpClient().execute(req);
|
||||
if (resp.isSuccessful()) {
|
||||
String profilePage = resp.body().string();
|
||||
String tokenText = HtmlParser.getText(profilePage, "span.tokencount");
|
||||
|
@ -115,19 +97,8 @@ public class Chaturbate extends AbstractSite {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void login() {
|
||||
if (credentialsAvailable()) {
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
getHttpClient().login();
|
||||
} catch (IOException e1) {
|
||||
LOG.warn("Initial login failed", e1);
|
||||
}
|
||||
};
|
||||
}.start();
|
||||
}
|
||||
public boolean login() throws IOException {
|
||||
return credentialsAvailable() && getHttpClient().login();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -196,7 +167,7 @@ public class Chaturbate extends AbstractSite {
|
|||
.addHeader("Referer", "https://chaturbate.com/"+name+"/")
|
||||
.addHeader("X-Requested-With", "XMLHttpRequest")
|
||||
.build();
|
||||
try(Response response = getHttpClient().execute(req, true)) {
|
||||
try(Response response = getHttpClient().execute(req)) {
|
||||
if(!response.isSuccessful()) {
|
||||
throw new IOException(response.code() + " " + response.message());
|
||||
}
|
||||
|
@ -312,11 +283,6 @@ public class Chaturbate extends AbstractSite {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ConfigUI getConfigurationGui() {
|
||||
return new ChaturbateConfigUi();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean credentialsAvailable() {
|
||||
String username = Config.getInstance().getSettings().username;
|
|
@ -7,8 +7,8 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import ctbrec.Config;
|
||||
import ctbrec.io.HtmlParser;
|
||||
import ctbrec.io.HttpClient;
|
||||
import ctbrec.ui.HtmlParser;
|
||||
import okhttp3.Cookie;
|
||||
import okhttp3.FormBody;
|
||||
import okhttp3.Request;
|
||||
|
@ -115,8 +115,8 @@ public class ChaturbateHttpClient extends HttpClient {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Response execute(Request req, boolean requiresLogin) throws IOException {
|
||||
Response resp = super.execute(req, requiresLogin);
|
||||
public Response execute(Request req) throws IOException {
|
||||
Response resp = super.execute(req);
|
||||
extractCsrfToken(req);
|
||||
return resp;
|
||||
}
|
|
@ -152,7 +152,7 @@ public class ChaturbateModel extends AbstractModel {
|
|||
.header("X-CSRFToken", ((ChaturbateHttpClient)site.getHttpClient()).getToken())
|
||||
.header("X-Requested-With", "XMLHttpRequest")
|
||||
.build();
|
||||
resp = site.getHttpClient().execute(req, true);
|
||||
resp = site.getHttpClient().execute(req);
|
||||
if(resp.isSuccessful()) {
|
||||
String msg = resp.body().string();
|
||||
if(!msg.equalsIgnoreCase("ok")) {
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue