(no commit message)
authorerik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Tue, 21 Mar 2006 21:31:37 +0000 (21:31 +0000)
committererik <erik@77661180-640e-0410-b3a8-9f9b13e6d0e0>
Tue, 21 Mar 2006 21:31:37 +0000 (21:31 +0000)
crawler/kiss/conf/kiss/programs.xml
crawler/kiss/src/org/wamblee/crawler/kiss/main/KissCrawler.java
crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramAction.java
crawler/kiss/src/org/wamblee/crawler/kiss/main/ProgramActionExecutor.java
crawler/kiss/src/org/wamblee/crawler/kiss/notification/MailNotifier.java

index fabc9fbcbec0c5cc095cce74f9a73e5c7a89eeb4..82de82faaa9c20f29ed35da6ebe59dc283a2b8f7 100644 (file)
@@ -36,7 +36,7 @@
   <program>
     <category>documentaires</category>
     <action>notify</action>
-    <match>(zembla)|(uur.*wolf)</match>
+    <match>(zembla)|(uur.*wolf)|(andere tijden)</match>
   </program>
   
   <program>
index 6cdaa17a55da35f9aec05a0794cb03c5e63441c5..5d7e85ca94868eb0a283b6e9739462bf3f06772a 100644 (file)
@@ -16,7 +16,6 @@
 
 package org.wamblee.crawler.kiss.main;
 
-import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.FileNotFoundException;
@@ -25,26 +24,15 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintStream;
 import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Date;
 import java.util.List;
-import java.util.Properties;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import javax.mail.MessagingException;
-import javax.mail.Session;
-import javax.mail.internet.InternetAddress;
-import javax.xml.transform.TransformerException;
 
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.apache.commons.mail.EmailException;
-import org.apache.commons.mail.HtmlEmail;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
-import org.w3c.dom.Document;
 import org.wamblee.crawler.Action;
 import org.wamblee.crawler.Configuration;
 import org.wamblee.crawler.Crawler;
@@ -60,8 +48,6 @@ import org.wamblee.crawler.kiss.guide.Time;
 import org.wamblee.crawler.kiss.guide.TimeInterval;
 import org.wamblee.crawler.kiss.notification.NotificationException;
 import org.wamblee.crawler.kiss.notification.Notifier;
-import org.wamblee.io.FileResource;
-import org.wamblee.xml.XSLT;
 
 /**
  * The KiSS crawler for automatic recording of interesting TV shows.
@@ -183,7 +169,7 @@ public class KissCrawler {
         }
         executor.commit();
         try {
-            aNotifier.send(executor.getXmlReport());
+            aNotifier.send(executor.getReport());
         } catch (NotificationException e) { 
             throw new RuntimeException(e);
         }
@@ -306,51 +292,4 @@ public class KissCrawler {
         }
         return new Channel(aChannel, programs);
     }
-
-    /**
-     * Sends a summary mail to the user.
-     * 
-     * @param aText
-     *            Text of the mail.
-     * @throws MessagingException
-     *             In case of problems sending mail.
-     */
-    private void sendMail(ProgramActionExecutor aExecutor) throws MessagingException {
-        String textReport = aExecutor.getReport();
-        System.out.println("Text report: \n" + textReport);
-        System.out.println("XML report:\n" + aExecutor.getXmlReport().asXML());
-        
-        
-        Properties props = new Properties();
-        props.put("mail.transport.protocol", "smtp");
-        props.put("mail.smtp.host", "falcon");
-        props.put("mail.smtp.port", "25");
-
-        Session mailSession = Session.getInstance(props);
-        InternetAddress from = new InternetAddress("erik@brakkee.org");
-    
-        HtmlEmail mail = new HtmlEmail();
-        mail.setMailSession(mailSession);
-        try {
-            mail.setFrom("erik@brakkee.org");
-            mail.setTo(Arrays.asList(new InternetAddress[] { from }));
-            mail.setSentDate(new Date());
-            mail.setSubject("KiSS Crawler Update");
-            String html = aExecutor.getXmlReport().asXML(); 
-            Document document = new XSLT().transform(html.getBytes(), new FileResource(new File("reportToHtml.xsl")));
-            ByteArrayOutputStream xhtml = new ByteArrayOutputStream();
-            XMLSerializer serializer = new XMLSerializer(xhtml, new OutputFormat());
-            serializer.serialize(document);
-            mail.setHtmlMsg(xhtml.toString());
-            mail.setTextMsg(textReport);
-            mail.send();
-        } catch (EmailException e) {
-            throw new RuntimeException(e);
-        } catch (TransformerException e) { 
-            throw new RuntimeException(e);
-        } catch (IOException e) { 
-            throw new RuntimeException(e);
-        }
-    }
-
 }
index d67c26d13eba6c501dc2c24f495129d96bff0a81..e9d3bcbe84c9cef2cdb2ff21cf09661a5c2e1252 100644 (file)
@@ -26,7 +26,7 @@ public interface ProgramAction {
     /**
      * Executes the action. 
      * @param aProgram Program to execute the action for. 
-     * @param aReport Report to use. 
+     * @param aExecutor Report to use. 
      */
-    void execute(Program aProgram, ProgramActionExecutor aReport);
+    void execute(Program aProgram, ProgramActionExecutor aExecutor);
 }
index 3ef511cffe4ce9c8b36c445d163e12c57dd7886e..27297a6f0d2c625c9383bf069f81821a60817819 100644 (file)
@@ -99,50 +99,11 @@ public class ProgramActionExecutor {
         }
     }
     
-    /**
-     * Gets the report describing what was done. 
-     * @return Report. 
-     */
-    public String getReport() {
-        StringBuffer msg = new StringBuffer("Summary of KiSS crawler: \n\n\n");
-        
-        boolean printed = false; 
-
-        for (RecordingResult result : RecordingResult.values()) {
-            if (_recordings.get(result).size() > 0) {
-                msg.append(result.getDescription() + "\n\n");
-                for (Program program : _recordings.get(result)) {
-                    msg.append(program + "\n\n");
-                    printed = true; 
-                }
-            }
-        }
-        
-        if ( _interestingShows.size() > 0 ) { 
-            msg.append("Possibly interesting shows:\n\n");
-            for (String category: _interestingShows.keySet()) { 
-                if ( category.length() > 0 ) { 
-                    msg.append("Category: " + category + "\n\n");
-                }
-                for (Program program: _interestingShows.get(category)) { 
-                    msg.append(program + "\n\n");
-                    printed = true; 
-                }
-            }
-        
-        }
-        if (!printed) {
-            msg.append("No suitable programs found");
-        }
-
-        return msg.toString(); 
-    }
-    
     /**
      * Get report as XML. 
      * @return XML report 
      */
-    public Element getXmlReport() { 
+    public Element getReport() { 
         DocumentFactory factory = DocumentFactory.getInstance(); 
         Element report = factory.createElement("report"); 
         
index 1c970a7151f11f1260583a873636299b3397ab5b..47c3edd59c19d3be265f25403a8062b667986be6 100644 (file)
@@ -4,7 +4,6 @@
  */
 package org.wamblee.crawler.kiss.notification;
 
-import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
 import java.util.Arrays;
@@ -16,10 +15,7 @@ import javax.xml.transform.TransformerException;
 
 import org.apache.commons.mail.EmailException;
 import org.apache.commons.mail.HtmlEmail;
-import org.apache.xml.serialize.OutputFormat;
-import org.apache.xml.serialize.XMLSerializer;
 import org.dom4j.Element;
-import org.w3c.dom.Document;
 import org.wamblee.io.FileResource;
 import org.wamblee.io.InputResource;
 import org.wamblee.xml.XSLT;