本文整理汇总了Python中library.MediaDB.get_all_uris方法的典型用法代码示例。如果您正苦于以下问题:Python MediaDB.get_all_uris方法的具体用法?Python MediaDB.get_all_uris怎么用?Python MediaDB.get_all_uris使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类library.MediaDB
的用法示例。
在下文中一共展示了MediaDB.get_all_uris方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: job
# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import get_all_uris [as 别名]
def job(self):
dirs = self.dirs
added = []
db_uris = set(MediaDB.get_all_uris())
alldirs = [ utils.get_path_from_uri(each_dir) for each_dir in dirs ]
for mdir in alldirs:
for dirpath, dirs, names in os.walk(mdir):
[ dirs.remove(each_dir) for each_dir in dirs if each_dir[0] == "." ]
for each_dir in dirs:
full_path_dir = os.path.join(dirpath, each_dir)
if os.path.islink(full_path_dir):
alldirs.append(os.path.realpath(full_path_dir))
valid_files = []
for name in names:
full_path_file = os.path.join(dirpath, name)
if name[0] != "." and common.file_is_supported(full_path_file):
valid_files.append(full_path_file)
yield full_path_file
valid_files = set(valid_files)
for each_file in valid_files:
real_file = os.path.realpath(each_file)
uri = utils.get_uri_from_path(real_file)
if real_file not in db_uris:
added.append(uri)
elif os.path.getctime(real_file) > MediaDB.get_song(uri).get("#ctime"):
added.append(uri)
added = set(added)
for uri in added:
self.add_to_library(uri)
yield utils.get_path_from_uri(uri)
示例2: get_combo_all_cover
# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import get_all_uris [as 别名]
def get_combo_all_cover(self, key="album"):
cover_cache_dir = get_cache_dir("cover")
if not os.path.isdir(cover_cache_dir):
return None
if len(MediaDB.get_all_uris()) < 4:
return None
if key == "album":
if self.album_all_cover != None:
return self.album_all_cover
cache_files = [f for f in os.listdir(cover_cache_dir) if "-" in f]
elif key == "artist":
if self.artist_all_cover != None:
return self.artist_all_cover
cache_files = [f for f in os.listdir(cover_cache_dir) if "-" not in f]
else:
return None
if len(cache_files) < 4:
return None
random.shuffle(cache_files)
combo_image = composite_images([os.path.join(cover_cache_dir, f) for f in cache_files[:4]],
84, 84,
get_cache_file("%s_all_cover.png" % key))
if combo_image:
if key == "album":
self.album_all_cover = gtk.gdk.pixbuf_new_from_file(combo_image)
return self.album_all_cover
else:
self.artist_all_cover = gtk.gdk.pixbuf_new_from_file(combo_image)
return self.artist_all_cover
return None