}
try {
ByteArrayInputStream bais = new ByteArrayInputStream( page.getBytes("UTF-8"));
RSSFeed rssFeed = StaticUtilities.getRSSFeed( bais );
RSSChannel[] channels = rssFeed.getChannels();
List results = new ArrayList();
for ( int i=0; i<channels.length; i++ ){
RSSChannel channel = channels[i];
SimpleXMLParserDocumentNode[] channel_kids = channel.getNode().getChildren();
int auto_dl_state = AUTO_DL_SUPPORTED_YES;
for ( int j=0; j<channel_kids.length; j++ ){
SimpleXMLParserDocumentNode child = channel_kids[j];
String lc_full_child_name = child.getFullName().toLowerCase();
if ( lc_full_child_name.equals( "vuze:auto_dl_enabled" )){
if ( !child.getValue().equalsIgnoreCase( "true" )){
auto_dl_state = AUTO_DL_SUPPORTED_NO;
}
}
}
setLocalLong( LD_AUTO_DL_SUPPORTED, auto_dl_state );
RSSItem[] items = channel.getItems();
for ( int j=0 ; j<items.length; j++ ){
RSSItem item = items[j];
WebResult result = new WebResult(this,getRootPage(),getBasePage(),getDateParser(),"");
result.setPublishedDate(item.getPublicationDate());
result.setNameFromHTML(item.getTitle());
URL cdp_link = item.getLink();
if ( cdp_link != null ){
result.setCDPLink(cdp_link.toExternalForm());
}
String uid = item.getUID();
if ( uid != null ){
result.setUID( uid );
}
boolean got_seeds_peers = false;
SimpleXMLParserDocumentNode node = item.getNode();
if ( node != null ){
SimpleXMLParserDocumentNode[] children = node.getChildren();
boolean vuze_feed = false;
for ( int k=0; k<children.length; k++ ){
SimpleXMLParserDocumentNode child = children[k];
String lc_full_child_name = child.getFullName().toLowerCase();
if ( lc_full_child_name.startsWith( "vuze:" )){
vuze_feed = true;
break;
}
}
for ( int k=0; k<children.length; k++ ){
SimpleXMLParserDocumentNode child = children[k];
String lc_child_name = child.getName().toLowerCase();
String lc_full_child_name = child.getFullName().toLowerCase();
String value = child.getValue();
if (lc_child_name.equals( "enclosure" )){
SimpleXMLParserDocumentAttribute typeAtt = child.getAttribute("type");
if( typeAtt != null && typeAtt.getValue().equalsIgnoreCase( "application/x-bittorrent")) {
SimpleXMLParserDocumentAttribute urlAtt = child.getAttribute("url");
if( urlAtt != null ){
result.setTorrentLink(urlAtt.getValue());
}
SimpleXMLParserDocumentAttribute lengthAtt = child.getAttribute("length");
if (lengthAtt != null){
result.setSizeFromHTML(lengthAtt.getValue());
}
}
}else if(lc_child_name.equals( "category" )) {
result.setCategoryFromHTML( value );
}else if(lc_child_name.equals( "comments" )){
result.setCommentsFromHTML( value );
}else if ( lc_child_name.equals( "link" ) || lc_child_name.equals( "guid" )) {
String lc_value = value.toLowerCase();
try{
URL url = new URL(value);
if ( lc_value.endsWith( ".torrent" ) ||
lc_value.startsWith( "magnet:" ) ||
lc_value.startsWith( "bc:" ) ||
lc_value.startsWith( "bctp:" ) ||
lc_value.startsWith( "dht:" )){
result.setTorrentLink(value);
}else if ( lc_child_name.equals( "link" ) && !vuze_feed ){
long test = getLocalLong( LD_LINK_IS_TORRENT, 0 );
if ( test == 1 ){
result.setTorrentLink( value );
}else if ( test == 0 || SystemTime.getCurrentTime() - test > 60*1000 ){
if ( linkIsToTorrent( url )){
result.setTorrentLink(value);
setLocalLong( LD_LINK_IS_TORRENT, 1 );
}else{
setLocalLong( LD_LINK_IS_TORRENT, SystemTime.getCurrentTime());
}
}
}
}catch( Throwable e ){
// see if this is an atom feed
// <link rel="alternate" type="application/x-bittorrent" href="http://asdasd/
SimpleXMLParserDocumentAttribute typeAtt = child.getAttribute( "type" );
if ( typeAtt != null && typeAtt.getValue().equalsIgnoreCase("application/x-bittorrent")) {
SimpleXMLParserDocumentAttribute hrefAtt = child.getAttribute( "href" );
if ( hrefAtt != null ){
String href = hrefAtt.getValue().trim();
try{
result.setTorrentLink( new URL( href ).toExternalForm() );
}catch( Throwable f ){
}
}
}
}
}else if ( lc_child_name.equals( "content" ) && rssFeed.isAtomFeed()){
SimpleXMLParserDocumentAttribute srcAtt = child.getAttribute( "src" );
String src = srcAtt==null?null:srcAtt.getValue();