add "divx" as known file extension
[enigma2.git] / lib / python / Components / FileList.py
index e064d0527305fe41c98477675f60dff2c00704a6..231fde2f948db21af169eeac0c5385691ea41f33 100644 (file)
@@ -1,29 +1,31 @@
-import re
-
+from re import compile as re_compile
 from os import path as os_path, listdir
 from MenuList import MenuList
 from Components.Harddisk import harddiskmanager
 
 from Tools.Directories import SCOPE_SKIN_IMAGE, resolveFilename
 
-from enigma import RT_HALIGN_LEFT, eListbox, eListboxPythonMultiContent, \
+from enigma import RT_HALIGN_LEFT, eListboxPythonMultiContent, \
        eServiceReference, eServiceCenter, gFont
 from Tools.LoadPixmap import LoadPixmap
 
 EXTENSIONS = {
+               "mp2": "music",
                "mp3": "music",
                "wav": "music",
                "ogg": "music",
+               "flac": "music",
                "jpg": "picture",
                "jpeg": "picture",
                "png": "picture",
                "bmp": "picture",
                "ts": "movie",
                "avi": "movie",
+               "divx": "movie",
                "mpg": "movie",
                "mpeg": "movie",
                "mkv": "movie",
-               "avi": "movie",
+               "mp4": "movie"
        }
 
 def FileEntryComponent(name, absolute = None, isDir = False):
@@ -44,7 +46,7 @@ def FileEntryComponent(name, absolute = None, isDir = False):
        return res
 
 class FileList(MenuList):
-       def __init__(self, directory, showDirectories = True, showFiles = True, showMountpoints = True, matchingPattern = None, useServiceRef = False, inhibitDirs = False, inhibitMounts = False, enableWrapAround = False, additionalExtensions = None):
+       def __init__(self, directory, showDirectories = True, showFiles = True, showMountpoints = True, matchingPattern = None, useServiceRef = False, inhibitDirs = False, inhibitMounts = False, isTop = False, enableWrapAround = False, additionalExtensions = None):
                MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
                self.additional_extensions = additionalExtensions
                self.mountpoints = []
@@ -54,6 +56,7 @@ class FileList(MenuList):
                self.showDirectories = showDirectories
                self.showMountpoints = showMountpoints
                self.showFiles = showFiles
+               self.isTop = isTop
                # example: matching .nfi and .ts files: "^.*\.(nfi|ts)"
                self.matchingPattern = matchingPattern
                self.inhibitDirs = inhibitDirs or []
@@ -162,7 +165,7 @@ class FileList(MenuList):
                                                directories.append(directory + x + "/")
                                                files.remove(x)
 
-               if directory is not None and self.showDirectories:
+               if directory is not None and self.showDirectories and not self.isTop:
                        if directory == self.current_mountpoint and self.showMountpoints:
                                self.list.append(FileEntryComponent(name = "<" +_("List of Storage Devices") + ">", absolute = None, isDir = True))
                        elif (directory != "/") and not (self.inhibitMounts and self.getMountpoint(directory) in self.inhibitMounts):
@@ -183,7 +186,7 @@ class FileList(MenuList):
                                        path = directory + x
                                        name = x
 
-                               if (self.matchingPattern is None) or re.compile(self.matchingPattern).search(path):
+                               if (self.matchingPattern is None) or re_compile(self.matchingPattern).search(path):
                                        self.list.append(FileEntryComponent(name = name, absolute = x , isDir = False))
 
                self.l.setList(self.list)