forked from j62/ctbrec
Add a cookie to define the sorting for BongaCams
The cookie is set to sort by popularity
This commit is contained in:
parent
2a5c0ccd43
commit
a2f048fe0d
|
@ -89,7 +89,7 @@ public class CookieJarImpl implements CookieJar {
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Map<String, List<Cookie>> getCookies() {
|
public Map<String, List<Cookie>> getCookies() {
|
||||||
return cookieStore;
|
return cookieStore;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,10 @@ package ctbrec.sites.bonga;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.HttpCookie;
|
import java.net.HttpCookie;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
import java.util.concurrent.LinkedBlockingQueue;
|
import java.util.concurrent.LinkedBlockingQueue;
|
||||||
|
|
||||||
|
@ -28,6 +31,30 @@ public class BongaCamsHttpClient extends HttpClient {
|
||||||
|
|
||||||
public BongaCamsHttpClient() {
|
public BongaCamsHttpClient() {
|
||||||
super("bongacams");
|
super("bongacams");
|
||||||
|
addSortByPopularCookie();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a cookie, which defines the sort order for returned model lists
|
||||||
|
*/
|
||||||
|
private void addSortByPopularCookie() {
|
||||||
|
Cookie sortByCookie = new Cookie.Builder()
|
||||||
|
.domain("bongacams.com")
|
||||||
|
.name("bcmlsf9")
|
||||||
|
.value("%7B%22limit%22%3A20%2C%22c_limit%22%3A10%2C%22th_type%22%3A%22live%22%2C%22sorting%22%3A%22popular%22%2C%22display%22%3A%22auto%22%7D")
|
||||||
|
.build();
|
||||||
|
|
||||||
|
Map<String, List<Cookie>> cookies = cookieJar.getCookies();
|
||||||
|
for (Entry<String, List<Cookie>> entry : cookies.entrySet()) {
|
||||||
|
List<Cookie> cookieList = entry.getValue();
|
||||||
|
for (Iterator<Cookie> iterator = cookieList.iterator(); iterator.hasNext();) {
|
||||||
|
Cookie cookie = iterator.next();
|
||||||
|
if(cookie.name().equals("bcmlsf9")) {
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
entry.getValue().add(sortByCookie);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -175,7 +175,7 @@ public class BongaCamsModel extends AbstractModel {
|
||||||
StreamSource best = streamSources.get(streamSources.size()-1);
|
StreamSource best = streamSources.get(streamSources.size()-1);
|
||||||
resolution = new int[] {best.width, best.height};
|
resolution = new int[] {best.width, best.height};
|
||||||
} catch (ExecutionException | IOException | ParseException | PlaylistException e) {
|
} catch (ExecutionException | IOException | ParseException | PlaylistException e) {
|
||||||
LOG.error("Couldn't determine stream resolution", e);
|
LOG.error("Couldn't determine stream resolution for {}", getName(), e);
|
||||||
}
|
}
|
||||||
return resolution;
|
return resolution;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue