mirror of
https://github.com/SoongNoonien/mpdevil.git
synced 2023-08-10 21:12:44 +03:00
removed duplicated code
This commit is contained in:
parent
823d574ea4
commit
f63f781718
@ -263,6 +263,16 @@ class Client(MPDClient):
|
|||||||
base_song["human_duration"]=str(datetime.timedelta(seconds=int(float(base_song["duration"])))).lstrip("0").lstrip(":")
|
base_song["human_duration"]=str(datetime.timedelta(seconds=int(float(base_song["duration"])))).lstrip("0").lstrip(":")
|
||||||
return base_song
|
return base_song
|
||||||
|
|
||||||
|
def calc_display_length(self, songs):
|
||||||
|
length=float(0)
|
||||||
|
for song in songs:
|
||||||
|
try:
|
||||||
|
dura=float(song["duration"])
|
||||||
|
except:
|
||||||
|
dura=0.0
|
||||||
|
length=length+dura
|
||||||
|
return str(datetime.timedelta(seconds=int(length))).lstrip("0").lstrip(":")
|
||||||
|
|
||||||
def comp_list(self, *args): #simulates listing behavior of python-mpd2 1.0
|
def comp_list(self, *args): #simulates listing behavior of python-mpd2 1.0
|
||||||
if "group" in args:
|
if "group" in args:
|
||||||
raise ValueError("'group' is not supported")
|
raise ValueError("'group' is not supported")
|
||||||
@ -1264,14 +1274,7 @@ class AlbumIconView(Gtk.IconView):
|
|||||||
if not self.stop_flag:
|
if not self.stop_flag:
|
||||||
cover=Cover(lib_path=music_lib, song_file=album["songs"][0]["file"])
|
cover=Cover(lib_path=music_lib, song_file=album["songs"][0]["file"])
|
||||||
#tooltip
|
#tooltip
|
||||||
length=float(0)
|
length_human_readable=self.client.calc_display_length(album["songs"])
|
||||||
for song in album["songs"]:
|
|
||||||
try:
|
|
||||||
dura=float(song["duration"])
|
|
||||||
except:
|
|
||||||
dura=0.0
|
|
||||||
length=length+dura
|
|
||||||
length_human_readable=str(datetime.timedelta(seconds=int(length))).lstrip("0").lstrip(":")
|
|
||||||
try:
|
try:
|
||||||
discs=int(album["songs"][-1]["disc"])
|
discs=int(album["songs"][-1]["disc"])
|
||||||
except:
|
except:
|
||||||
@ -1620,14 +1623,7 @@ class PlaylistView(Gtk.Box):
|
|||||||
def refresh_playlist_info(self):
|
def refresh_playlist_info(self):
|
||||||
songs=self.client.playlistinfo()
|
songs=self.client.playlistinfo()
|
||||||
if not songs == []:
|
if not songs == []:
|
||||||
whole_length=float(0)
|
whole_length_human_readable=self.client.calc_display_length(songs)
|
||||||
for song in songs:
|
|
||||||
try:
|
|
||||||
dura=float(song["duration"])
|
|
||||||
except:
|
|
||||||
dura=0.0
|
|
||||||
whole_length=whole_length+dura
|
|
||||||
whole_length_human_readable=str(datetime.timedelta(seconds=int(whole_length))).lstrip("0").lstrip(":")
|
|
||||||
self.playlist_info.set_text(_("%(total_tracks)i titles (%(total_length)s)") % {"total_tracks": len(songs), "total_length": whole_length_human_readable})
|
self.playlist_info.set_text(_("%(total_tracks)i titles (%(total_length)s)") % {"total_tracks": len(songs), "total_length": whole_length_human_readable})
|
||||||
else:
|
else:
|
||||||
self.playlist_info.set_text("")
|
self.playlist_info.set_text("")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user