Skip to content

Commit

Permalink
README
Browse files Browse the repository at this point in the history
  • Loading branch information
SharkHunter committed Jun 1, 2011
1 parent f54f96e commit 6ae7cd8
Show file tree
Hide file tree
Showing 13 changed files with 279 additions and 88 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -5,7 +5,7 @@ various online wb tv channels. It allows you to save the content while viewing i

# Installation <a name="Install"></a>

* download the [Channels jar file](https://github.com/downloads/SharkHunter/Channel/tv_plug_116.jar) and place it in the PMS `plugins` directory
* download the [Channels jar file](https://github.com/downloads/SharkHunter/Channel/tv_plug_117.jar) and place it in the PMS `plugins` directory
* download the [Channels files](https://github.com/SharkHunter/Channel/tree/master/channels) you need and place them in a new directory.
* you must also download [PMSEncoder scripts](https://github.com/SharkHunter/Channel/tree/master/scripts).
* shut down PMS; open `PMS.conf` in a text editor; and add Channel specific configuration see below.
Expand All @@ -15,7 +15,7 @@ various online wb tv channels. It allows you to save the content while viewing i

## Upgrading <a name="Upgrade"></a>

To upgrade to a new version of the plugin, simply replace the old jar file in the `plugins` directory with the [new version](https://github.com/downloads/SharkHunter/Channel/tv_plug_116.jar) and restart PMS.
To upgrade to a new version of the plugin, simply replace the old jar file in the `plugins` directory with the [new version](https://github.com/downloads/SharkHunter/Channel/tv_plug_117.jar) and restart PMS.

## Uninstalling <a name="Uninstall"></a>

Expand Down
117 changes: 57 additions & 60 deletions channels/zattoo.ch
@@ -1,70 +1,67 @@
version=0.21

proxydef p1 {
addr=82.195.239.19
port=80
}
version=0.23

#http://tserver.zattoo.com/join?uuid=${uuid}&ticket_id=${ticketid}&f=${fvar}&channel=${channel}
scriptdef zattooScript {
channel=s_url
regex='=(.*)
match s_cookie
s_url='http://zattoo.com/view
uuid=v1
regex='getTime\(\) \- ([0-9]+)
scrape
f=v1
regex='ticket_id = "([^"]+)"
match htmRaw
ticket=v1
regex='setStaticAssets[^"]+"([^"]+)"
match htmRaw
swfVfy='http://zattoo.com
concat swfVfy v1
url='http://tserver.zattoo.com/join?uuid=
concat url uuid
concat url '&ticket_id=
concat url ticket
concat url '&f=
concat url f
concat url '&channel=
concat url channel
s_url=url
regex='"stream_url": "([^"]+)"
scrape
url=v1
play
channel=s_url
regex='=(.*)
match s_cookie
s_url='http://pro.gaebu.ch/index.php?q=aHR0cDovL3phdHRvby5jb20vdmlldw%3D%3D&hl=2e9
uuid=v1
regex='getTime\(\) \- ([0-9]+)
scrape
f=v1
regex='ticket_id = "([^"]+)"
match htmRaw
ticket=v1
regex='setStaticAssets[^"]+"([^"]+)"
match htmRaw
swfVfy='http://zattoo.com
concat swfVfy v1
url='http://pro.gaebu.ch/index.php?q=http%3A%2F%2Ftserver.zattoo.com%2Fjoin%3Fuuid%3D
concat url uuid
concat url '%26ticket_id%3D
concat url ticket
concat url '%26f%3D
concat url f
concat url '%26channel%3D
concat url channel
concat url '&hl=2e1
s_url=url
regex='"stream_url": "([^"]+)"
scrape
url=v1
play
}
channel Zattoo {
proxy=p1
img=http://zattoo.com/files/Zattoo_RGB_150_neg.png
login {
# Login data
url=https://zattoo.com/login
user=email
passwd=pw
type=cookie
params=remember=on
matcher=pzuid
}
folder {
img=http://zattoo.com/files/Zattoo_RGB_150_neg.png
login {
# Login data
url=http://pro.gaebu.ch/index.php?q=aHR0cHM6Ly96YXR0b28uY29tL2xvZ2lu
user=email
passwd=pw
type=cookie
params=remember=on
matcher=pzuid
}
folder {
# view
url=http://zattoo.com/view
#class="name" href="/view/sf-2"
type=empty
folder {
url=dummy_url
#original="/static/images/channels/b_42x24/BBC1.png" alt="BBC One England"
matcher=original=\"/[^\/]+/[^\/]+/[^\/]+/[^\/]+/([^\.]+)\.png\" alt=\"([^\"]+)\"
order=url,name
media {
script=zattooScript
prop=live,
}
}
}
#url=http://zattoo.com/view
url=http://pro.gaebu.ch/index.php?q=aHR0cDovL3phdHRvby5jb20vdmlldw%3D%3D&hl=2e9
#class="name" href="/view/sf-2"
type=empty
folder {
url=dummy_url
#original="/static/images/channels/b_42x24/BBC1.png" alt="BBC One England"
matcher=original=\"/[^\/]+/[^\/]+/[^\/]+/[^\/]+/([^\.]+)\.png\" alt=\"([^\"]+)\"[^\*]+?\s[^\*]+?(now-showing)\">([^\<]+)<
order=url,name+
prop=name_separator=###0,
media {
script=zattooScript
prop=live,
}
}
}
}


10 changes: 5 additions & 5 deletions src/com/sharkhunter/channel/Channel.java
Expand Up @@ -180,7 +180,7 @@ public String pwd() {
return null;
}

private ChannelAuth getAuth(Proxy p) {
private ChannelAuth getAuth(ChannelProxy p) {
ChannelAuth a=new ChannelAuth();
a.proxy=p;
a.method=-1;
Expand All @@ -197,10 +197,10 @@ private ChannelAuth getAuth(Proxy p) {

public ChannelAuth prepareCom() {
if(proxies==null) // no proxy, just regular login
return getAuth(Proxy.NO_PROXY);
return getAuth(ChannelProxy.NULL_PROXY);
Channels.debug("activeProxy "+activeProxy);
if(activeProxy!=null&&activeProxy.isUp()) {
return getAuth(activeProxy.getProxy());
return getAuth(activeProxy);
}
for(int i=0;i<proxies.length;i++) {
ChannelProxy p=Channels.getProxy(proxies[i]);
Expand All @@ -210,9 +210,9 @@ public ChannelAuth prepareCom() {
continue;
Channels.debug("use proxy "+p.getProxy().toString());
activeProxy=p;
return getAuth(p.getProxy());
return getAuth(p);
}
return getAuth(Proxy.NO_PROXY);
return getAuth(ChannelProxy.NULL_PROXY);
}

public void addSearcher(String id,SearchObj obj) {
Expand Down
2 changes: 1 addition & 1 deletion src/com/sharkhunter/channel/ChannelAuth.java
Expand Up @@ -6,5 +6,5 @@ public class ChannelAuth {
public int method;
public String authStr;
public long ttd;
public Proxy proxy;
public ChannelProxy proxy;
}
12 changes: 12 additions & 0 deletions src/com/sharkhunter/channel/ChannelFolder.java
Expand Up @@ -48,6 +48,8 @@ public class ChannelFolder implements ChannelProps, SearchObj{
private String hook;
private String tag;

private String proxy;

public ChannelFolder(ArrayList<String> data,Channel parent) {
this(data,parent,null);
}
Expand All @@ -67,6 +69,7 @@ public ChannelFolder(ChannelFolder cf) {
continues=ChannelUtil.calcCont(prop);
contAll=cf.contAll;
script=cf.script;
proxy=cf.proxy;
}

public ChannelFolder(ArrayList<String> data,Channel parent,ChannelFolder pf) {
Expand All @@ -81,6 +84,7 @@ public ChannelFolder(ArrayList<String> data,Channel parent,ChannelFolder pf) {
contAll=false;
continues=Channels.DeafultContLim;
script=null;
proxy=null;
parse(data);
continues=ChannelUtil.calcCont(prop);
if(continues<0)
Expand Down Expand Up @@ -170,6 +174,9 @@ public void parse(ArrayList<String> data) {
if(keyval[0].equalsIgnoreCase("hook")) {
hook=keyval[1];
}
if(keyval[0].equalsIgnoreCase("proxy")) {
proxy=keyval[1];
}
}
}

Expand Down Expand Up @@ -369,6 +376,11 @@ public void match(DLNAResource res,ChannelFilter filter,String urlEnd,
parent.debug("folder match url "+urlobj.toString()+" type "+type+" post "+post+" "+urlEnd);
try {
ChannelAuth a=parent.prepareCom();
if(!ChannelUtil.empty(proxy)) {// override channel proxy
ChannelProxy p0=Channels.getProxy(proxy);
if(p0!=null) // update if we found a proxy leave it other
a.proxy=p0;
}
Proxy p=ChannelUtil.proxy(a);
if(post)
page=ChannelUtil.postPage(urlobj.openConnection(p), urlEnd);
Expand Down
6 changes: 1 addition & 5 deletions src/com/sharkhunter/channel/ChannelItem.java
Expand Up @@ -98,11 +98,7 @@ public void match(DLNAResource res,String filter,String urlEnd,String backupName
String page;
try {
ChannelAuth a=parent.prepareCom();
Proxy p=null;
if(a!=null)
p=a.proxy;
if(p==null)
p=Proxy.NO_PROXY;
Proxy p=ChannelUtil.proxy(a);
page = ChannelUtil.fetchPage(urlobj.openConnection(p),a,null);
} catch (Exception e) {
page="";
Expand Down
34 changes: 28 additions & 6 deletions src/com/sharkhunter/channel/ChannelLogin.java
Expand Up @@ -8,6 +8,9 @@
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;
import java.sql.Date;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;

import javax.net.ssl.HttpsURLConnection;
Expand Down Expand Up @@ -154,14 +157,24 @@ private ChannelAuth updateCookieDb(String cookie,ChannelAuth a) {
return a;
}

private long parseTTD(String expStr) {
SimpleDateFormat sdfDate = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
java.util.Date d;
try {
d = sdfDate.parse(expStr);
return d.getTime();
} catch (ParseException e) {
return ttd;
}
}

private ChannelAuth getCookie(URLConnection connection,ChannelAuth a) throws Exception {
String hName="";
for (int j=1; (hName = connection.getHeaderFieldKey(j))!=null; j++) {
String cStr=connection.getHeaderField(j);
Channels.debug("hdr "+hName);
if (!hName.equalsIgnoreCase("Set-Cookie"))
continue;

String[] fields = cStr.split(";\\s*");
String cookie=fields[0];
int pos;
Expand All @@ -172,9 +185,15 @@ private ChannelAuth getCookie(URLConnection connection,ChannelAuth a) throws Exc
if(!auth.match())
continue;
}
ttd=System.currentTimeMillis()+(24*60*60*2*1000);
if(fields.length>1)
if(fields[1].contains("expires")) {
String[] exp=fields[1].split(",");
if(exp.length>1)
ttd=parseTTD(exp[1]);
}
tokenStr=cookie;
loggedOn=true;
ttd=System.currentTimeMillis()+(24*60*60*2);
return updateCookieDb(tokenStr,a);
}
return null;
Expand All @@ -183,7 +202,7 @@ private ChannelAuth getCookie(URLConnection connection,ChannelAuth a) throws Exc
private ChannelAuth cookieLogin(String usr,String pass,ChannelAuth a) throws Exception {
ChannelAuth a1=Channels.getCookie(trimUrl(url));
if(a1!=null) { // found some in hash
if(a1.ttd<System.currentTimeMillis()) {
if(a1.ttd>System.currentTimeMillis()) {
loggedOn=true;
tokenStr=a1.authStr;
ttd=a1.ttd;
Expand All @@ -192,13 +211,16 @@ private ChannelAuth cookieLogin(String usr,String pass,ChannelAuth a) throws Exc
return a1;
}
}
ChannelProxy proxy=a.proxy;
if(proxy==null)
proxy=ChannelProxy.NULL_PROXY;
String query=params+"&"+user+"="+URLEncoder.encode(usr,"UTF-8")+
"&"+pwd+"="+URLEncoder.encode(pass,"UTF-8");
URL u=new URL(url);
Proxy p=proxy.getProxy();
//URLConnection connection;
Proxy p=ChannelUtil.proxy(a);
if(url.startsWith("https")) {
Channels.debug("https login "+p.toString());
Channels.debug("url "+u.toString()+" query "+query);
if(u.toString().startsWith("https")) {
HttpsURLConnection connection = (HttpsURLConnection) u.openConnection(p);
HttpsURLConnection.setFollowRedirects(true);
((HttpsURLConnection) connection).setInstanceFollowRedirects(true);
Expand Down
8 changes: 6 additions & 2 deletions src/com/sharkhunter/channel/ChannelMatcher.java
Expand Up @@ -80,9 +80,9 @@ public String getMatch(String field,boolean fallbackFirst,String def) {
if(order[i].charAt(order[i].length()-1)=='+') {
// special hack here. if it ends with a '+' then we
// add all matches left to one big chunk
return concatAll(i+1,res,properties.separator(field));
return concatAll(i+1,res,fixSep(properties.separator(field)));
}
res=ChannelUtil.append(res,properties.separator(field),
res=ChannelUtil.append(res,fixSep(properties.separator(field)),
matcher.group(i+1));
}
}
Expand All @@ -94,6 +94,10 @@ public String getMatch(String field,boolean fallbackFirst,String def) {
else
return def;
}

private String fixSep(String s) {
return ChannelUtil.separatorToken(s);
}

private String concatAll(int start,String res,String sep) {
for(int i=start;i<=matcher.groupCount();i++) {
Expand Down
5 changes: 5 additions & 0 deletions src/com/sharkhunter/channel/ChannelMedia.java
Expand Up @@ -32,6 +32,7 @@ public class ChannelMedia implements ChannelProps,ChannelScraper {
private String[] subtitle;
private int format;
private String staticUrl;
private String proxy;

public ChannelMedia(ArrayList<String> data,Channel parent) {
Ok=false;
Expand All @@ -43,6 +44,7 @@ public ChannelMedia(ArrayList<String> data,Channel parent) {
scriptType=ChannelMedia.SCRIPT_LOCAL;
params=new HashMap<String,String>();
format=-1;
proxy=null;
parse(data);
if(format==-1)
format=parent.getFormat();
Expand Down Expand Up @@ -115,6 +117,9 @@ public void parse(ArrayList<String> data) {
if(keyval[0].equalsIgnoreCase("url")) {
staticUrl=keyval[1];
}
if(keyval[0].equalsIgnoreCase("proxy")) {
proxy=keyval[1];
}
}
}

Expand Down

0 comments on commit 6ae7cd8

Please sign in to comment.