Index: mythvideo/mythvideo/videolist.cpp
===================================================================
--- mythvideo/mythvideo/videolist.cpp	(revision 13058)
+++ mythvideo/mythvideo/videolist.cpp	(working copy)
@@ -423,8 +423,10 @@
   public:
     VideoListImp();
 
-    void build_generic_tree(GenericTree *dst, meta_dir_node *src,
-                            bool include_updirs);
+  int build_generic_tree(GenericTree *dst, 
+			 meta_dir_node *src,
+			 bool include_updirs
+			 );
     GenericTree *buildVideoList(bool filebrowser, bool flatlist,
                                 int parental_level, bool include_updirs);
 
@@ -501,6 +503,8 @@
     void buildFileList(smart_dir_node &directory, metadata_list &metalist,
                        const QString &prefix);
 
+    GenericTree *addDirNode(GenericTree *where_to_add, GenericTree *sub_node,
+			  bool add_up_dirs);
     GenericTree *addDirNode(GenericTree *where_to_add, const QString &dname,
                             bool add_up_dirs);
     int addFileNode(GenericTree *where_to_add, const QString &name, int id);
@@ -623,28 +627,40 @@
             gContext->GetNumSetting("mythvideo.sort_ignores_case", 1);
 }
 
-void VideoListImp::build_generic_tree(GenericTree *dst, meta_dir_node *src,
-                                      bool include_updirs)
+int VideoListImp::build_generic_tree(GenericTree *dst, 
+				      meta_dir_node *src,
+                                      bool include_updirs
+				      )
 {
+  int total_files=0;
+  int node_files =0;
+
     for (meta_dir_node::const_dir_iterator dir = src->dirs_begin();
          dir != src->dirs_end(); ++dir)
     {
-        GenericTree *t = addDirNode(dst, (*dir)->getName(), include_updirs);
+      GenericTree *t = new GenericTree( (*dir)->getName().stripWhiteSpace(),
+					kSubFolder,
+					false);
+      node_files      = build_generic_tree(t, dir->get(), include_updirs);
+      if (node_files > 0) {
+	addDirNode(dst, dst->addNode(t), include_updirs);
         t->setAttribute(kFolderPath, m_folder_id);
         m_folder_id_to_path.
                 insert(id_string_map::value_type(m_folder_id,
                                                  (*dir)->getFQPath()));
         ++m_folder_id;
-
-        build_generic_tree(t, dir->get(), include_updirs);
+	total_files += node_files;
     }
+    }
 
     for (meta_dir_node::const_entry_iterator entry = src->entries_begin();
          entry != src->entries_end(); ++entry)
     {
         addFileNode(dst, (*entry)->getData()->Title(),
                     (*entry)->getData()->getFlatIndex());
+      total_files++;
     }
+  return total_files;
 }
 
 // Build a generic tree containing the video files. You can control the
@@ -943,11 +959,11 @@
     m_metadata.setList(ml);
 }
 
-GenericTree *VideoListImp::addDirNode(GenericTree *where_to_add,
-                                      const QString &dname, bool add_up_dirs)
+GenericTree *VideoListImp::addDirNode(GenericTree *where_to_add, 
+				      GenericTree *sub_node, 
+				      bool add_up_dirs)
 {
     // Add the subdir node...
-    GenericTree *sub_node = where_to_add->addNode(dname, kSubFolder, false);
     sub_node->setAttribute(kNodeSort, kOrderSub);
     sub_node->setOrderingIndex(kNodeSort);
 
@@ -963,6 +979,13 @@
     return sub_node;
 }
 
+GenericTree *VideoListImp::addDirNode(GenericTree *where_to_add,
+                                      const QString &dname, bool add_up_dirs)
+{
+  // Add the subdir node...
+  return addDirNode(where_to_add,where_to_add->addNode(dname, kSubFolder, false),add_up_dirs);
+}
+
 int VideoListImp::addFileNode(GenericTree *where_to_add, const QString &name,
                               int index)
 {
