本文整理汇总了Python中library.MediaDB.get_song方法的典型用法代码示例。如果您正苦于以下问题:Python MediaDB.get_song方法的具体用法?Python MediaDB.get_song怎么用?Python MediaDB.get_song使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类library.MediaDB
的用法示例。
在下文中一共展示了MediaDB.get_song方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: job
# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import get_song [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: load
# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import get_song [as 别名]
def load(self):
'''load configure'''
if not self.__need_load_prefs:
return
# get uri
uri = config.get("player", "uri")
# get seek
seek = int(config.get("player", "seek"))
# get state
state = config.get("player", "state")
# Init player state
play = False
self.logdebug("player load %s in state %s at %d", uri, state, seek)
if config.getboolean("player", "play_on_startup") and state == "playing":
play = True
# load uri
if uri:
song = MediaDB.get_song(uri)
if song and song.exists():
if not config.getboolean("player", "resume_last_progress") or not play:
seek = None
self.set_song(song, play, self.get_crossfade() * 2, seek)
self.emit("loaded")
示例3: __songs_changed
# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import get_song [as 别名]
def __songs_changed(self, db, infos):
indexs = []
view_songs = self.get_songs()
for each_song in infos:
if each_song in view_songs:
indexs.append(view_songs.index(each_song))
if indexs:
for index in indexs:
item = self.items[index]
item.update(MediaDB.get_song(item.get_song().get("uri")), True)
示例4: play_uris
# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import get_song [as 别名]
def play_uris(self, uris, pos=None, sort=True):
self.get_toplevel().window.set_cursor(None)
songs = []
for uri in uris:
song = MediaDB.get_song(uri)
if song:
songs.append(song)
if not songs:
return
if sort: songs.sort()
self.add_songs(song, pos, sort, True)
示例5: load_taginfo
# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import get_song [as 别名]
def load_taginfo(self, uris, pos=None, sort=True):
start = time.time()
if pos is None:
pos = len(self.items)
for uri in uris:
song = MediaDB.get_song(uri)
if not song:
continue
self.add_song_cache.append(song)
end = time.time()
if end - start > 0.2:
self.render_song(self.add_song_cache, pos, sort)
pos += len(self.add_song_cache)
del self.add_song_cache[:]
start = time.time()
if self.add_song_cache:
self.render_song(self.add_song_cache, pos, sort)
del self.add_song_cache[:]
示例6: restore_status
# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import get_song [as 别名]
def restore_status(self):
uri = config.get("player", "uri")
seek = int(config.get("player", "seek"))
state = config.get("player", "state")
play = False
if config.getboolean("player", "play_on_startup") and state == "playing":
play = True
if uri and self.current_item:
song = MediaDB.get_song(uri)
if song.get_type() == "cue":
seek = seek + song.get("seek", 0)
if song and song.exists():
if not config.getboolean("player", "resume_last_progress") or not play:
if song.get_type() == "cue":
seek = song.get("seek", 0)
else:
seek = None
self.current_item.song_view.play_song(song, play, seek)
示例7: save_taginfo
# 需要导入模块: from library import MediaDB [as 别名]
# 或者: from library.MediaDB import get_song [as 别名]
def save_taginfo(self, widget):
tags_modifiable = {}
new_title = self.title_entry.get_text()
new_artist = self.artist_entry.get_text()
new_album = self.album_entry.get_text()
new_genre = self.genre_entry.get_text()
new_date = self.date_entry.get_text()
db_song = MediaDB.get_song(self.song.get("uri"))
if new_title != db_song.get_str("title"):
tags_modifiable.update({"title" : new_title})
if new_artist != db_song.get_str("artist"):
tags_modifiable.update({"artist" : new_artist})
if new_album != db_song.get_str("album"):
tags_modifiable.update({"album" : new_album})
if new_genre != db_song.get_str("genre"):
tags_modifiable.update({"genre" : new_genre})
if new_date != db_song.get_str("date"):
tags_modifiable.update({"date" : new_date})
if tags_modifiable:
MediaDB.set_property(db_song, tags_modifiable, write_to_file=True)