def add_path(self, path, album=False, session=None): self.log.info("add_path: %s, album=%s" % (path, album)) assert session eid = None record = None record_a = None if not isinstance(path, unicode): path_u = to_unicode(path) else: path_u = path if os.path.isdir(path): eid = MediaManager.uuid(path) if album: record = self.Album(path) else: record = self.Artist(path) self.log.info("adding directory: %s, %s " % (eid, path_u)) elif MediaManager.is_allowed_extension(path_u): try: record = self.Media(path) # Create a virtual album using a mock album id # every song with the same virtual album (artist,album) # is tied to it. if record.album != basename(path) and record.artist and record.album: vpath = join("/", record.artist, record.album) record_a = self.Album(vpath) record.albumId = MediaManager.uuid(vpath) eid = record.id self.log.info("adding file: %s, %s " % ( eid, path_u)) except UnsupportedMediaError, e: raise IposonicException(e)
def add_path(self, path, album=False): """Create an entry from path and add it to the DB.""" if os.path.isdir(path): self.log.warn( "Adding %s: %s " % ("album" if album else "artist", stringutils.to_unicode(path))) eid = MediaManager.uuid(path) if album: self.albums[eid] = IposonicDB.Album(path) else: self.artists[eid] = IposonicDB.Artist(path) self.log.info(u"adding directory: %s, %s " % (eid, stringutils.to_unicode(path))) return eid elif MediaManager.is_allowed_extension(path): try: info = MediaManager.get_info(path) info.update({ 'coverArt': MediaManager.cover_art_uuid(info) }) self.songs[info['id']] = info self.log.info("adding file: %s, %s " % (info['id'], path)) return info['id'] except UnsupportedMediaError as e: raise IposonicException(e) raise IposonicException("Path not found or bad extension: %s " % path)
def add_path(self, path, album=False): """Create an entry from path and add it to the DB.""" if os.path.isdir(path): self.log.warn( "Adding %s: %s " % ("album" if album else "artist", stringutils.to_unicode(path))) eid = MediaManager.uuid(path) if album: self.albums[eid] = IposonicDB.Album(path) else: self.artists[eid] = IposonicDB.Artist(path) self.log.info(u"adding directory: %s, %s " % (eid, stringutils.to_unicode(path))) return eid elif MediaManager.is_allowed_extension(path): try: info = MediaManager.get_info(path) info.update({'coverArt': MediaManager.cover_art_uuid(info)}) self.songs[info['id']] = info self.log.info("adding file: %s, %s " % (info['id'], path)) return info['id'] except UnsupportedMediaError as e: raise IposonicException(e) raise IposonicException("Path not found or bad extension: %s " % path)