예제 #1
0
 def listMetadataMountpoint(self, mountpoint, subdir):
     dbPlugin = mpfd.getDBPlugin()
     toplevelDict = dbPlugin.getDB(
         "filesMetadataArtists" if mountpoint.mpType[0] ==
         'artist' else "filesMetadataAlbums")
     if len(subdir) == 0:
         return [{
             'name': x,
             'realname': x,
             'type': 'dir'
         } for x in toplevelDict]
     else:
         subdirPath = subdir.split(mpfd.path_separator)
         if len(subdirPath) > len(mountpoint.mpType):
             return []
         if not subdirPath[0] in toplevelDict:
             return []
         fileList = toplevelDict[subdirPath[0]]
         for i in xrange(1, len(subdirPath)):
             fileList = [
                 x for x in fileList
                 if x[mountpoint.mpType[i]] == subdirPath[i]
             ]
         if len(subdirPath) == len(mountpoint.mpType):
             return [{
                 'name': hashlib.md5(x['filepath']).hexdigest(),
                 'realname': x['title'],
                 'type': 'file'
             } for x in fileList]
         lastCriterion = mountpoint.mpType[len(subdirPath)]
         return [{
             'name': x,
             'realname': x,
             'type': 'dir'
         } for x in set(x[lastCriterion] for x in fileList)]
예제 #2
0
 def run(self):
     metadataPlugins = [
         x for x in mpfd.plugins if hasattr(x, 'getFileMetadata')
     ]
     dbPlugin = mpfd.getDBPlugin()
     artistDict = {}
     albumDict = {}
     for root, _, files in os.walk(self.plugin.root):
         for f in files:
             for plugin in metadataPlugins:
                 md = plugin.getFileMetadata(os.path.join(root, f))
                 if md:
                     if 'artist' in md:
                         if not md['artist'] in artistDict:
                             artistDict[md['artist']] = []
                         artistDict[md['artist']].append(md)
                     if 'album' in md:
                         if not md['album'] in albumDict:
                             albumDict[md['album']] = []
                         albumDict[md['album']].append(md)
                     break
         if self.stopping:
             return
     dbPlugin.storeDB("filesMetadataArtists", artistDict)
     dbPlugin.storeDB("filesMetadataAlbums", albumDict)
예제 #3
0
 def playMetadataFile(self,mountpoint,subfile):
     dbPlugin=mpfd.getDBPlugin()
     toplevelDict=dbPlugin.getDB("filesMetadataArtists" if mountpoint.mpType[0]=='artist' else "filesMetadataAlbums")
     if not mpfd.path_separator in subfile:
         return False
     subfilePath=subfile.split(mpfd.path_separator)
     if len(subfilePath)!=len(mountpoint.mpType)+1:
         return False
     if not subfilePath[0] in toplevelDict:
         return []
     fileList=toplevelDict[subfilePath[0]]
     for i in xrange(1,len(mountpoint.mpType)):
         fileList=[x for x in fileList if x[mountpoint.mpType[i]]==subfilePath[i]]
     fpath=next((x['filepath'] for x in fileList if hashlib.md5(x['filepath']).hexdigest()==subfilePath[-1]),None)
     return mpfd.playLocalFile(fpath)
예제 #4
0
 def listMetadataMountpoint(self, mountpoint, subdir):
     dbPlugin=mpfd.getDBPlugin()
     toplevelDict=dbPlugin.getDB("filesMetadataArtists" if mountpoint.mpType[0]=='artist' else "filesMetadataAlbums")
     if len(subdir)==0:
         return [{'name': x, 'realname': x, 'type': 'dir'} for x in toplevelDict]
     else:
         subdirPath=subdir.split(mpfd.path_separator)
         if len(subdirPath)>len(mountpoint.mpType):
             return []
         if not subdirPath[0] in toplevelDict:
             return []
         fileList=toplevelDict[subdirPath[0]]
         for i in xrange(1,len(subdirPath)):
             fileList=[x for x in fileList if x[mountpoint.mpType[i]]==subdirPath[i]]
         if len(subdirPath)==len(mountpoint.mpType):
             return [{'name':hashlib.md5(x['filepath']).hexdigest(), 'realname':x['title'], 'type':'file'} for x in fileList]
         lastCriterion=mountpoint.mpType[len(subdirPath)]
         return [{'name':x, 'realname':x, 'type':'dir'} for x in set(x[lastCriterion] for x in fileList)]
예제 #5
0
 def run(self):
     metadataPlugins=[x for x in mpfd.plugins if hasattr(x, 'getFileMetadata')]
     dbPlugin=mpfd.getDBPlugin()
     artistDict={}
     albumDict={}
     for root, _, files in os.walk(self.plugin.root):
         for f in files:
             for plugin in metadataPlugins:
                 md=plugin.getFileMetadata(os.path.join(root,f))
                 if md:
                     if 'artist' in md:
                         if not md['artist'] in artistDict:
                             artistDict[md['artist']]=[]
                         artistDict[md['artist']].append(md)
                     if 'album' in md:
                         if not md['album'] in albumDict:
                             albumDict[md['album']]=[]
                         albumDict[md['album']].append(md)
                     break
         if self.stopping:
             return
     dbPlugin.storeDB("filesMetadataArtists",artistDict)
     dbPlugin.storeDB("filesMetadataAlbums",albumDict)
예제 #6
0
 def playMetadataFile(self, mountpoint, subfile):
     dbPlugin = mpfd.getDBPlugin()
     toplevelDict = dbPlugin.getDB(
         "filesMetadataArtists" if mountpoint.mpType[0] ==
         'artist' else "filesMetadataAlbums")
     if not mpfd.path_separator in subfile:
         return False
     subfilePath = subfile.split(mpfd.path_separator)
     if len(subfilePath) != len(mountpoint.mpType) + 1:
         return False
     if not subfilePath[0] in toplevelDict:
         return []
     fileList = toplevelDict[subfilePath[0]]
     for i in xrange(1, len(mountpoint.mpType)):
         fileList = [
             x for x in fileList
             if x[mountpoint.mpType[i]] == subfilePath[i]
         ]
     fpath = next(
         (x['filepath'] for x in fileList
          if hashlib.md5(x['filepath']).hexdigest() == subfilePath[-1]),
         None)
     return mpfd.playLocalFile(fpath)