contrib/rss_downloader: report errors parsing XML
[nit.git] / contrib / rss_downloader / src / rss_downloader.nit
index e662fac..66cd969 100644 (file)
@@ -151,11 +151,7 @@ class Downloader
                for element in matches do
                        var unique_id = element.unique_id(config)
 
-                       if local_path.to_path.exists then
-                               # Do not redownload a file (we assume that the file name is unique by itself)
-                               if sys.verbose then print "File exists, skipping {element}"
-                               continue
-                       else if history.has(unique_id) then
+                       if history.has(unique_id) then
                                # Do not download a file that is not unique according to `unique_id`
                                if not element.is_unique_exception(config) then
                                        # We make some exceptions
@@ -203,7 +199,7 @@ class Downloader
                        end
 
                        for dir in source_folder.files do if dir.stat.is_dir then
-                               folder_names.add dir.to_s
+                               folder_names.add dir.filename
                        end
                end
 
@@ -260,6 +256,10 @@ redef class Text
        fun to_rss_elements: Array[Element]
        do
                var xml = to_xml
+               if xml isa XMLError then
+                       print_error "RSS Parse Error: {xml.message}:{xml.location or else "null"}"
+                       return new Array[Element]
+               end
                var items = xml["rss"].first["channel"].first["item"]
 
                var elements = new Array[Element]