|
35 | 35 | import com.biglybt.core.metasearch.impl.web.WebResult;
|
36 | 36 | import com.biglybt.core.util.ByteFormatter;
|
37 | 37 | import com.biglybt.core.util.Debug;
|
| 38 | +import com.biglybt.core.util.RegExUtil; |
38 | 39 | import com.biglybt.core.util.SystemTime;
|
39 | 40 | import com.biglybt.core.util.UrlUtils;
|
40 | 41 | import com.biglybt.pif.utils.StaticUtilities;
|
|
48 | 49 | RSSEngine
|
49 | 50 | extends WebEngine
|
50 | 51 | {
|
51 |
| - private Pattern seed_leecher_pat = Pattern.compile("([0-9]+)\\s+(seed|leecher)s", Pattern.CASE_INSENSITIVE); |
52 |
| - private Pattern size_pat = Pattern.compile("([0-9\\.]+)\\s+(B|KB|KiB|MB|MiB|GB|GiB|TB|TiB)", Pattern.CASE_INSENSITIVE); |
| 52 | + private Pattern seed_leecher_pat1 = Pattern.compile("([0-9]+)" + RegExUtil.PAT_WHITE_SPACE + "(seed|seeder|leech|leecher)s", Pattern.CASE_INSENSITIVE ); |
| 53 | + private Pattern seed_leecher_pat2 = Pattern.compile("(seed|seeder|leech|leecher)s" + RegExUtil.PAT_WHITE_SPACE + "([0-9]+)", Pattern.CASE_INSENSITIVE ); |
| 54 | + |
| 55 | + private Pattern size_pat = Pattern.compile("([0-9\\.]+)" + RegExUtil.PAT_WHITE_SPACE + "(B|KB|KiB|MB|MiB|GB|GiB|TB|TiB)", Pattern.CASE_INSENSITIVE ); |
53 | 56 |
|
54 | 57 | public static EngineImpl
|
55 | 58 | importFromBEncodedMap(
|
|
641 | 644 |
|
642 | 645 | desc = desc.replaceAll( "\\(s\\)", "s" );
|
643 | 646 |
|
644 |
| - desc = desc.replaceAll( "seeders", "seeds" ); |
| 647 | + desc = desc.replace( ":", " " ); |
| 648 | + |
| 649 | + desc = Result.removeHTMLTags( desc ); |
| 650 | + |
| 651 | + Matcher m = seed_leecher_pat1.matcher( desc ); |
645 | 652 |
|
646 |
| - Matcher m = seed_leecher_pat.matcher( desc ); |
| 653 | + if ( m.find()){ |
| 654 | + |
| 655 | + do{ |
| 656 | + String num = m.group(1); |
647 | 657 |
|
648 |
| - while( m.find()){ |
| 658 | + String type = m.group(2); |
649 | 659 |
|
650 |
| - String num = m.group(1); |
| 660 | + if ( type.toLowerCase().charAt(0) == 's' ){ |
651 | 661 |
|
652 |
| - String type = m.group(2); |
| 662 | + result.setNbSeedsFromHTML( num ); |
653 | 663 |
|
654 |
| - if ( type.toLowerCase().charAt(0) == 's' ){ |
| 664 | + }else{ |
655 | 665 |
|
656 |
| - result.setNbSeedsFromHTML( num ); |
| 666 | + result.setNbPeersFromHTML( num ); |
| 667 | + } |
| 668 | + }while( m.find()); |
| 669 | + |
| 670 | + }else{ |
| 671 | + |
| 672 | + m = seed_leecher_pat2.matcher( desc ); |
657 | 673 |
|
658 |
| - }else{ |
| 674 | + while( m.find()){ |
| 675 | + |
| 676 | + String num = m.group(2); |
659 | 677 |
|
660 |
| - result.setNbPeersFromHTML( num ); |
| 678 | + String type = m.group(1); |
| 679 | + |
| 680 | + if ( type.toLowerCase().charAt(0) == 's' ){ |
| 681 | + |
| 682 | + result.setNbSeedsFromHTML( num ); |
| 683 | + |
| 684 | + }else{ |
| 685 | + |
| 686 | + result.setNbPeersFromHTML( num ); |
| 687 | + } |
661 | 688 | }
|
662 | 689 | }
|
663 |
| - |
| 690 | + |
664 | 691 | m = size_pat.matcher( desc );
|
665 | 692 |
|
666 | 693 | if ( m.find()){
|
|
0 commit comments