def __init__(self, directory):
    core.Media.__init__(self)
    info = os.path.join(directory, '.directory')
    if os.path.isfile(info):
        f = open(info)
        for l in f.readlines():
            if l.startswith('Icon='):
                image = l[5:].strip()
                if (not image.startswith('/')):
                    image = os.path.join(directory, image)
                if os.path.isfile(image):
                    self._set('image', image)
            if l.startswith('Name='):
                self.title = l[5:].strip()
            if l.startswith('Comment='):
                self.comment = l[8:].strip()
        f.close()
    binsxml = os.path.join(directory, 'album.xml')
    if os.path.isfile(binsxml):
        bins = BinsParser(binsxml)
        for (key, value) in list(bins.items()):
            if (key == 'sampleimage'):
                image = os.path.join(directory, kaa.unicode_to_str(value))
                if os.path.isfile(image):
                    self._set('image', image)
                continue
            self._set(key, value)
    folderjpg = os.path.join(directory, 'folder.jpg')
    if os.path.isfile(folderjpg):
        self._set('image', folderjpg)
    self.mime = 'text/directory'
def __init__(self, directory):
    core.Media.__init__(self)
    info = os.path.join(directory, '.directory')
    if os.path.isfile(info):
        f = open(info)
        for l in f.readlines():
            if l.startswith('Icon='):
                image = l[5:].strip()
                if (not image.startswith('/')):
                    image = os.path.join(directory, image)
                if os.path.isfile(image):
                    self._set('image', image)
            if l.startswith('Name='):
                self.title = l[5:].strip()
            if l.startswith('Comment='):
                self.comment = l[8:].strip()
        f.close()
    binsxml = os.path.join(directory, 'album.xml')
    if os.path.isfile(binsxml):
        bins = BinsParser(binsxml)
        for (key, value) in list(bins.items()):
            if (key == 'sampleimage'):
                image = os.path.join(directory, kaa.unicode_to_str(value))
                if os.path.isfile(image):
                    self._set('image', image)
                continue
            self._set(key, value)
    folderjpg = os.path.join(directory, 'folder.jpg')
    if os.path.isfile(folderjpg):
        self._set('image', folderjpg)
    self.mime = 'text/directory'