forked from j62/ctbrec
Add UI part for MVLive
At the moment only the thumbnail overview is working. More stuff to come...
This commit is contained in:
parent
e59de2f70b
commit
00692f991e
|
@ -47,6 +47,7 @@ import ctbrec.sites.chaturbate.Chaturbate;
|
||||||
import ctbrec.sites.fc2live.Fc2Live;
|
import ctbrec.sites.fc2live.Fc2Live;
|
||||||
import ctbrec.sites.flirt4free.Flirt4Free;
|
import ctbrec.sites.flirt4free.Flirt4Free;
|
||||||
import ctbrec.sites.jasmin.LiveJasmin;
|
import ctbrec.sites.jasmin.LiveJasmin;
|
||||||
|
import ctbrec.sites.manyvids.MVLive;
|
||||||
import ctbrec.sites.mfc.MyFreeCams;
|
import ctbrec.sites.mfc.MyFreeCams;
|
||||||
import ctbrec.sites.showup.Showup;
|
import ctbrec.sites.showup.Showup;
|
||||||
import ctbrec.sites.streamate.Streamate;
|
import ctbrec.sites.streamate.Streamate;
|
||||||
|
@ -114,6 +115,7 @@ public class CamrecApplication extends Application {
|
||||||
sites.add(new Fc2Live());
|
sites.add(new Fc2Live());
|
||||||
sites.add(new Flirt4Free());
|
sites.add(new Flirt4Free());
|
||||||
sites.add(new LiveJasmin());
|
sites.add(new LiveJasmin());
|
||||||
|
sites.add(new MVLive());
|
||||||
sites.add(new MyFreeCams());
|
sites.add(new MyFreeCams());
|
||||||
sites.add(new Showup());
|
sites.add(new Showup());
|
||||||
sites.add(new Streamate());
|
sites.add(new Streamate());
|
||||||
|
|
|
@ -71,6 +71,11 @@ public class SiteUiFactory {
|
||||||
flirt4FreeSiteUi = new Flirt4FreeSiteUi((Flirt4Free) site);
|
flirt4FreeSiteUi = new Flirt4FreeSiteUi((Flirt4Free) site);
|
||||||
}
|
}
|
||||||
return flirt4FreeSiteUi;
|
return flirt4FreeSiteUi;
|
||||||
|
} else if (site instanceof MVLive) {
|
||||||
|
if (mvLiveSiteUi == null) {
|
||||||
|
mvLiveSiteUi = new MVLiveSiteUi((MVLive) site);
|
||||||
|
}
|
||||||
|
return mvLiveSiteUi;
|
||||||
} else if (site instanceof MyFreeCams) {
|
} else if (site instanceof MyFreeCams) {
|
||||||
if (mfcSiteUi == null) {
|
if (mfcSiteUi == null) {
|
||||||
mfcSiteUi = new MyFreeCamsSiteUi((MyFreeCams) site);
|
mfcSiteUi = new MyFreeCamsSiteUi((MyFreeCams) site);
|
||||||
|
|
|
@ -0,0 +1,35 @@
|
||||||
|
package ctbrec.ui.sites.manyvids;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import ctbrec.sites.ConfigUI;
|
||||||
|
import ctbrec.sites.manyvids.MVLive;
|
||||||
|
import ctbrec.ui.TabProvider;
|
||||||
|
import ctbrec.ui.sites.AbstractSiteUi;
|
||||||
|
|
||||||
|
public class MVLiveSiteUi extends AbstractSiteUi {
|
||||||
|
|
||||||
|
private MVLiveTabProvider tabProvider;
|
||||||
|
private MVLive mvlive;
|
||||||
|
|
||||||
|
public MVLiveSiteUi(MVLive mvlive) {
|
||||||
|
this.mvlive = mvlive;
|
||||||
|
tabProvider = new MVLiveTabProvider(mvlive);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TabProvider getTabProvider() {
|
||||||
|
return tabProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ConfigUI getConfigUI() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean login() throws IOException {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,40 @@
|
||||||
|
package ctbrec.ui.sites.manyvids;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import ctbrec.sites.manyvids.MVLive;
|
||||||
|
import ctbrec.ui.TabProvider;
|
||||||
|
import ctbrec.ui.ThumbOverviewTab;
|
||||||
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.control.Tab;
|
||||||
|
|
||||||
|
public class MVLiveTabProvider extends TabProvider {
|
||||||
|
|
||||||
|
private MVLive mvlive;
|
||||||
|
|
||||||
|
public MVLiveTabProvider(MVLive mvlive) {
|
||||||
|
this.mvlive = mvlive;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Tab> getTabs(Scene scene) {
|
||||||
|
List<Tab> tabs = new ArrayList<>();
|
||||||
|
tabs.add(createTab("Online", mvlive.getBaseUrl() + "/MVLive/"));
|
||||||
|
return tabs;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Tab createTab(String title, String url) {
|
||||||
|
MVLiveUpdateService updateService = new MVLiveUpdateService(url, mvlive);
|
||||||
|
ThumbOverviewTab tab = new ThumbOverviewTab(title, updateService, mvlive);
|
||||||
|
tab.setRecorder(mvlive.getRecorder());
|
||||||
|
return tab;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Tab getFollowedTab() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,84 @@
|
||||||
|
package ctbrec.ui.sites.manyvids;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.jsoup.nodes.Element;
|
||||||
|
import org.jsoup.select.Elements;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
import ctbrec.Config;
|
||||||
|
import ctbrec.Model;
|
||||||
|
import ctbrec.io.HtmlParser;
|
||||||
|
import ctbrec.io.HttpException;
|
||||||
|
import ctbrec.sites.manyvids.MVLive;
|
||||||
|
import ctbrec.sites.manyvids.MVLiveModel;
|
||||||
|
import ctbrec.ui.PaginatedScheduledService;
|
||||||
|
import javafx.concurrent.Task;
|
||||||
|
import okhttp3.Request;
|
||||||
|
import okhttp3.Response;
|
||||||
|
|
||||||
|
public class MVLiveUpdateService extends PaginatedScheduledService {
|
||||||
|
|
||||||
|
private static final transient Logger LOG = LoggerFactory.getLogger(MVLiveUpdateService.class);
|
||||||
|
private String url;
|
||||||
|
private MVLive mvlive;
|
||||||
|
|
||||||
|
public MVLiveUpdateService(String url, MVLive mvlive) {
|
||||||
|
this.url = url;
|
||||||
|
this.mvlive = mvlive;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Task<List<Model>> createTask() {
|
||||||
|
return new Task<List<Model>>() {
|
||||||
|
@Override
|
||||||
|
public List<Model> call() throws IOException {
|
||||||
|
LOG.debug("Fetching page {}", url);
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(url)
|
||||||
|
.header("User-Agent", Config.getInstance().getSettings().httpUserAgent)
|
||||||
|
.header("Referer", MVLive.BASE_URL)
|
||||||
|
.build();
|
||||||
|
try (Response response = mvlive.getHttpClient().execute(request)) {
|
||||||
|
if (response.isSuccessful()) {
|
||||||
|
List<Model> models = new ArrayList<>();
|
||||||
|
String content = response.body().string();
|
||||||
|
Elements cards = HtmlParser.getTags(content, "div.live-room");
|
||||||
|
for (Element card : cards) {
|
||||||
|
try {
|
||||||
|
String cardHtml = card.html();
|
||||||
|
Element link = HtmlParser.getTag(cardHtml, "h5 a");
|
||||||
|
MVLiveModel model = (MVLiveModel) mvlive.createModel(link.text().trim());
|
||||||
|
model.setUrl(mvlive.getBaseUrl() + link.attr("href"));
|
||||||
|
Element thumb = HtmlParser.getTag(cardHtml, "a img");
|
||||||
|
model.setPreview(thumb.attr("src"));
|
||||||
|
Element status = HtmlParser.getTag(cardHtml, "div[class~=model-status]");
|
||||||
|
String cssClass = status.attr("class");
|
||||||
|
if(cssClass.contains("live")) {
|
||||||
|
model.setOnlineState(Model.State.ONLINE);
|
||||||
|
} else if(cssClass.contains("private")) {
|
||||||
|
model.setOnlineState(Model.State.PRIVATE);
|
||||||
|
} else {
|
||||||
|
model.setOnlineState(Model.State.UNKNOWN);
|
||||||
|
}
|
||||||
|
models.add(model);
|
||||||
|
} catch(RuntimeException e) {
|
||||||
|
if(e.getMessage().contains("No element selected by")) {
|
||||||
|
// ignore
|
||||||
|
} else {
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return models;
|
||||||
|
} else {
|
||||||
|
throw new HttpException(response.code(), response.message());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
|
@ -10,7 +10,7 @@ public class MVLive extends AbstractSite {
|
||||||
|
|
||||||
public static final String BASE_URL = "https://www.manyvids.com";
|
public static final String BASE_URL = "https://www.manyvids.com";
|
||||||
|
|
||||||
private MVLiveHttpClient httpClient = new MVLiveHttpClient();
|
private MVLiveHttpClient httpClient;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
|
@ -53,6 +53,9 @@ public class MVLive extends AbstractSite {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HttpClient getHttpClient() {
|
public HttpClient getHttpClient() {
|
||||||
|
if(httpClient == null) {
|
||||||
|
httpClient = new MVLiveHttpClient();
|
||||||
|
}
|
||||||
return httpClient;
|
return httpClient;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,54 +4,51 @@ import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import com.iheartradio.m3u8.ParseException;
|
import com.iheartradio.m3u8.ParseException;
|
||||||
import com.iheartradio.m3u8.PlaylistException;
|
import com.iheartradio.m3u8.PlaylistException;
|
||||||
|
|
||||||
import ctbrec.AbstractModel;
|
import ctbrec.AbstractModel;
|
||||||
|
import ctbrec.Model;
|
||||||
import ctbrec.recorder.download.StreamSource;
|
import ctbrec.recorder.download.StreamSource;
|
||||||
|
|
||||||
public class MVLiveModel extends AbstractModel {
|
public class MVLiveModel extends AbstractModel {
|
||||||
|
|
||||||
|
private static final transient Logger LOG = LoggerFactory.getLogger(MVLiveModel.class);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isOnline(boolean ignoreCache) throws IOException, ExecutionException, InterruptedException {
|
public boolean isOnline(boolean ignoreCache) throws IOException, ExecutionException, InterruptedException {
|
||||||
// TODO Auto-generated method stub
|
return getOnlineState(true) == Model.State.ONLINE;
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<StreamSource> getStreamSources() throws IOException, ExecutionException, ParseException, PlaylistException {
|
public List<StreamSource> getStreamSources() throws IOException, ExecutionException, ParseException, PlaylistException {
|
||||||
// TODO Auto-generated method stub
|
LOG.debug("Loading {}", getUrl());
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invalidateCacheEntries() {
|
public void invalidateCacheEntries() {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void receiveTip(Double tokens) throws IOException {
|
public void receiveTip(Double tokens) throws IOException {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getStreamResolution(boolean failFast) throws ExecutionException {
|
public int[] getStreamResolution(boolean failFast) throws ExecutionException {
|
||||||
// TODO Auto-generated method stub
|
return new int[2];
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean follow() throws IOException {
|
public boolean follow() throws IOException {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean unfollow() throws IOException {
|
public boolean unfollow() throws IOException {
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue