allow MediaPlayer AudioCD playback only for what appear to be AudioCDs
[enigma2.git] / lib / python / Components / Scanner.py
index 860918c034d75add219167a8ca64a971476f639c..f7e307b7876744a89c5776fca7bbcd796882c36f 100644 (file)
@@ -24,6 +24,14 @@ def getType(file):
                        return "application/x-debian-package"
                elif ext == "ogg":
                        return "application/ogg"
+               elif ext == "dmpkg":
+                       return "application/x-dream-package"
+               elif ext == "ts":
+                       return "video/MP2T"
+               elif ext == "iso":
+                       return "video/x-dvd-iso"
+               elif file[-12:].lower() == "video_ts.ifo":
+                       return "video/x-dvd"
        return type
 
 class Scanner:
@@ -72,7 +80,7 @@ class ScanFile:
        def __init__(self, path, mimetype = None, size = None, autodetect = True):
                self.path = path
                if mimetype is None and autodetect:
-                       (self.mimetype, _) = guess_type(path)
+                       self.mimetype = getType(path)
                else:
                        self.mimetype = mimetype
                self.size = size
@@ -118,6 +126,14 @@ def scanDevice(mountpoint):
 
        # convert to list
        paths_to_scan = list(paths_to_scan)
+       
+       from Components.Harddisk import HarddiskManager 
+       class CdromManager(HarddiskManager):
+               def __init__(self):
+                       pass
+       cdaman = CdromManager()
+       blockdev = mountpoint.split('/')[2]
+       error, blacklisted, removable, is_cdrom, partitions = cdaman.getBlockDevInfo(blockdev)
 
        # now scan the paths
        for p in paths_to_scan:
@@ -125,7 +141,11 @@ def scanDevice(mountpoint):
 
                for root, dirs, files in os_walk(path):
                        for f in files:
-                               sfile = ScanFile(os_path.join(root, f))
+                               path = os_path.join(root, f)
+                               if is_cdrom and path.endswith(".wav") and path[-13:-6] == ("/track-"):
+                                       sfile = ScanFile(path,"audio/x-cda")
+                               else:
+                                       sfile = ScanFile(path)
                                for s in scanner:
                                        s.handleFile(res, sfile)