Skip to content

Commit ccadd7b

Browse files
committed
Add page_split + use on svt
1 parent be9368e commit ccadd7b

File tree

7 files changed

+47
-7
lines changed

7 files changed

+47
-7
lines changed

channels/svt.ch

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version=0.98
1+
version=1.00
22

33
scriptdef svtFilter{
44
url=s_url
@@ -145,7 +145,7 @@ channel SVTPlay {
145145
type=ATZ
146146
url=http://www.svtplay.se/program
147147
folder {
148-
matcher=<a href=\"(/[^\"]+)\".*?class=\".*?play_alphabetic-li[^\"]+\">([^<]+)</a>
148+
matcher=<a href=\"(/[^\"]+)\" title.*?class=\".*?play_alphabetic-li[^\"]+\">([^<]+)</a>
149149
order=url,name
150150
url=http://www.svtplay.se/
151151
prop=matcher_dotall,monitor
@@ -155,7 +155,7 @@ channel SVTPlay {
155155
matcher=<a title=\"[^\"]+\".*?href=\"(/video/[^\"]+)\".*?class=\"[^\"]+\".*?<img.*?alt=\"([^\"]+)\".*?src=\"([^\"]+)\"
156156
order=url,name,thumb
157157
action_name=crawl
158-
prop=matcher_dotall,monitor,crawl_mode=FLA+HML
158+
prop=matcher_dotall,monitor,crawl_mode=FLA+HML,page_split=(.*)Mer fr.n <a href=\"
159159
folder {
160160
type=empty
161161
matcher=data-json-href=\"([^\"]+)\"

src/com/sharkhunter/channel/Channel.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,7 @@ public ChannelAuth prepareCom() {
361361
}
362362

363363
public void addSearcher(String id,SearchObj obj) {
364-
searchFolders.put(id,obj);
364+
searchFolders.put(id, obj);
365365
}
366366

367367
public void research(String str,String id,DLNAResource res) {
@@ -383,6 +383,13 @@ public void research(String str,String id,DLNAResource res) {
383383
if(obj==null)
384384
return;
385385
obj.search(str, res);
386+
}
387+
public void searchAll(String str, DLNAResource res) {
388+
for(String id : searchFolders.keySet()) {
389+
SearchObj sobj = searchFolders.get(id);
390+
if(sobj!=null)
391+
sobj.search(str,res);
392+
}
386393
}
387394

388395
public HashMap<String,String> getSubMap(String realName,int id) {

src/com/sharkhunter/channel/ChannelMatcher.java

+11
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ public class ChannelMatcher implements ChannelProps{
1212
private Matcher matcher;
1313
private Channel parent;
1414
private int flags;
15+
private String pageReg;
1516
private HashMap<String,ChannelMatcher> embed;
1617

1718
private static final String lcbr="###lcbr###";
@@ -28,6 +29,7 @@ public class ChannelMatcher implements ChannelProps{
2829
this.properties=prop;
2930
regexp=null;
3031
parent=null;
32+
pageReg = null;
3133
flags=Pattern.MULTILINE;
3234
embed=new HashMap<String,ChannelMatcher>();
3335
}
@@ -41,6 +43,7 @@ public void processProps(String[] props) {
4143
flags|=Pattern.DOTALL;
4244
if(ChannelUtil.getProperty(props, "no_case"))
4345
flags|=Pattern.CASE_INSENSITIVE;
46+
pageReg = ChannelUtil.getPropertyValue(props, "page_split");
4447
for(String key : embed.keySet()) {
4548
ChannelMatcher m=embed.get(key);
4649
m.processProps(props);
@@ -72,6 +75,14 @@ public void startMatch(String str) {
7275
if(ChannelUtil.empty(regStr))
7376
return;
7477
regexp=Pattern.compile(fixReg(regStr),flags);
78+
if(!ChannelUtil.empty(pageReg)) {
79+
// inherit flags
80+
Pattern re = Pattern.compile(fixReg(pageReg), flags);
81+
Matcher m1 = re.matcher(str);
82+
if(m1.find()) {
83+
str = m1.group(1);
84+
}
85+
}
7586
this.matcher=this.regexp.matcher(str);
7687
}
7788

src/com/sharkhunter/channel/ChannelMonitor.java

+10-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public class ChannelMonitor {
1616
private boolean scanning;
1717
private String templ;
1818
private String search;
19+
private boolean try_search;
1920

2021
ChannelMonitor(ChannelFolder cf,ArrayList<String> oldEntries,String name) {
2122
this.cf=cf;
@@ -24,6 +25,7 @@ public class ChannelMonitor {
2425
templ=null;
2526
search=null;
2627
scanning=false;
28+
try_search = false;
2729
}
2830

2931
public void setTemplate(String t) {
@@ -33,6 +35,8 @@ public void setTemplate(String t) {
3335
public void setSearch(String s) {
3436
search=s;
3537
}
38+
39+
public void setTrySearch(boolean b) { try_search = b; }
3640

3741
public void scan() {
3842
if(scanning)
@@ -43,8 +47,13 @@ public void scan() {
4347
try {
4448
if(!ChannelUtil.empty(search))
4549
cf.search(search, dummy);
46-
else
50+
else {
51+
if(try_search) {
52+
Channel ch = cf.getChannel();
53+
ch.searchAll(name, dummy);
54+
}
4755
cf.match(dummy);
56+
}
4857
} catch (MalformedURLException e) {
4958
scanning=false;
5059
return;

src/com/sharkhunter/channel/ChannelPMSSaveFolder.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ public InputStream getThumbnailInputStream() {
241241
}
242242

243243
public void childDone() {
244-
childDone=System.currentTimeMillis();
244+
//childDone=System.currentTimeMillis();
245245
}
246246

247247
public boolean preventAutoPlay() {

src/com/sharkhunter/channel/ChannelPMSSubSelector.java

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.TreeMap;
66
import java.util.TreeSet;
77

8+
import net.pms.dlna.DLNAMediaSubtitle;
89
import org.apache.commons.lang.StringUtils;
910

1011
import net.pms.dlna.DLNAResource;

src/com/sharkhunter/channel/Channels.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
public class Channels extends VirtualFolder implements FileListener {
4141

4242
// Version string
43-
public static final String VERSION="2.22";
43+
public static final String VERSION="2.25";
4444
public static final String ZIP_VER="211";
4545

4646
// Constants for RTMP string constructions
@@ -1293,6 +1293,7 @@ private void parseMonitorFile() {
12931293
StringBuilder sb=null;
12941294
String templ=null;
12951295
String search=null;
1296+
boolean try_search = false;
12961297
while ((str = in.readLine()) != null) {
12971298
if(ChannelUtil.empty(str))
12981299
continue;
@@ -1316,13 +1317,15 @@ private void parseMonitorFile() {
13161317
ChannelMonitor m=new ChannelMonitor(mf,entries,name);
13171318
m.setTemplate(templ);
13181319
m.setSearch(search);
1320+
m.setTrySearch(try_search);
13191321
monMgr.add(m);
13201322
// Clear all vars
13211323
name=null;
13221324
templ=null;
13231325
entries=null;
13241326
owner=null;
13251327
search=null;
1328+
try_search = false;
13261329
}
13271330
}
13281331
}
@@ -1354,6 +1357,10 @@ private void parseMonitorFile() {
13541357
sb=new StringBuilder();
13551358
continue;
13561359
}
1360+
if(str.startsWith("try_search=")) {
1361+
try_search = str.substring(11).equalsIgnoreCase("true");
1362+
continue;
1363+
}
13571364
if(str.startsWith("name=")) {
13581365
if(ChannelUtil.empty(name)) { // only pick 1st name, just to simplify parsing
13591366
name=str.substring(5);
@@ -1409,6 +1416,7 @@ public static void monitor(DLNAResource res,ChannelFolder cf,
14091416
String nameProp=cf.getProp("monitor_name");
14101417
String washedName=monNameWash(res.getName(),templ,searched,nameProp);
14111418
StringBuffer sb=new StringBuffer();
1419+
boolean try_search = cf.getProperty("monitor_try_search");
14121420
if(newFile) {
14131421
sb.append("######\n");
14141422
sb.append("## NOTE!!!!!\n");
@@ -1423,6 +1431,8 @@ public static void monitor(DLNAResource res,ChannelFolder cf,
14231431
ChannelUtil.appendVarLine(sb, "templ", templ);
14241432
if(!ChannelUtil.empty(searched))
14251433
ChannelUtil.appendVarLine(sb, "search", searched);
1434+
if(try_search)
1435+
ChannelUtil.appendVarLine(sb, "try_search", "true");
14261436
ArrayList<String> entries=new ArrayList<String>();
14271437
for(DLNAResource r : res.getChildren()) {
14281438
if(ChannelUtil.filterInternals(r))
@@ -1440,6 +1450,7 @@ public static void monitor(DLNAResource res,ChannelFolder cf,
14401450
String str=lines[i].trim();
14411451
if(str.startsWith("monitor")||
14421452
str.startsWith("owner")||
1453+
str.startsWith("try_search") ||
14431454
str.startsWith("templ")) {
14441455
// skip the start lines
14451456
continue;
@@ -1453,6 +1464,7 @@ public static void monitor(DLNAResource res,ChannelFolder cf,
14531464
ChannelMonitor m=new ChannelMonitor(mf,entries,washedName);
14541465
m.setTemplate(templ);
14551466
m.setSearch(searched);
1467+
m.setTrySearch(try_search);
14561468
inst.monMgr.add(m);
14571469
continue;
14581470
}

0 commit comments

Comments
 (0)