parent
3329e3ed8f
commit
5b314fd899
2
build.sh
2
build.sh
|
@ -4,7 +4,7 @@ if [ -d unpack ]; then
|
||||||
sudo rm -rf unpack
|
sudo rm -rf unpack
|
||||||
fi
|
fi
|
||||||
|
|
||||||
version="1.0.1"
|
version="1.0.2"
|
||||||
|
|
||||||
mkdir -p unpack/DEBIAN
|
mkdir -p unpack/DEBIAN
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
Package: sonist
|
Package: sonist
|
||||||
Version: 1.0.1
|
Version: 1.0.2
|
||||||
Section: X11
|
Section: X11
|
||||||
Architecture: all
|
Architecture: all
|
||||||
Author: Yutent
|
Author: Yutent
|
||||||
|
|
|
@ -21,7 +21,7 @@ class AboutWindow(Gtk.AboutDialog):
|
||||||
self.set_logo(GdkPixbuf.Pixbuf.new_from_file(image_dict['sonist']))
|
self.set_logo(GdkPixbuf.Pixbuf.new_from_file(image_dict['sonist']))
|
||||||
|
|
||||||
self.set_license_type(Gtk.License.MIT_X11)
|
self.set_license_type(Gtk.License.MIT_X11)
|
||||||
self.set_version('1.0.1')
|
self.set_version('1.0.2')
|
||||||
self.set_website('https://github.com/app-cat/sonist-gtk')
|
self.set_website('https://github.com/app-cat/sonist-gtk')
|
||||||
self.set_website_label('官网')
|
self.set_website_label('官网')
|
||||||
self.set_authors([
|
self.set_authors([
|
||||||
|
|
|
@ -67,12 +67,12 @@ class CommandError(Exception):
|
||||||
self.command = None
|
self.command = None
|
||||||
self.msg = None
|
self.msg = None
|
||||||
|
|
||||||
match = ERROR_PATTERN.match(error)
|
matches = ERROR_PATTERN.match(error)
|
||||||
if match:
|
if matches:
|
||||||
self.errno = FailureResponseCode(int(match.group("errno")))
|
self.errno = FailureResponseCode(int(matches.group("errno")))
|
||||||
self.offset = int(match.group("offset"))
|
self.offset = int(matches.group("offset"))
|
||||||
self.command = match.group("command")
|
self.command = matches.group("command")
|
||||||
self.msg = match.group("msg")
|
self.msg = matches.group("msg")
|
||||||
|
|
||||||
|
|
||||||
class CommandListError(Exception):
|
class CommandListError(Exception):
|
||||||
|
|
|
@ -18,12 +18,15 @@ home_dir = os.getenv('HOME')
|
||||||
|
|
||||||
|
|
||||||
def get_music_dir():
|
def get_music_dir():
|
||||||
with open(f'{home_dir}/.mpd/mpd.conf', 'r') as f:
|
mpd_config = f'{home_dir}/.mpd/mpd.conf'
|
||||||
data = f.read()
|
|
||||||
|
|
||||||
matches = re.search('music_directory\s*"(.*)"', data).groups()
|
if os.path.isfile(mpd_config):
|
||||||
if len(matches) > 0:
|
with open(f'{home_dir}/.mpd/mpd.conf', 'r') as f:
|
||||||
return matches[0]
|
data = f.read()
|
||||||
|
|
||||||
|
matches = re.search('music_directory\s*"(.*)"', data).groups()
|
||||||
|
if len(matches) > 0:
|
||||||
|
return matches[0]
|
||||||
|
|
||||||
return '/data/music'
|
return '/data/music'
|
||||||
|
|
||||||
|
|
|
@ -48,23 +48,22 @@ class OptionMenu(Gtk.Menu):
|
||||||
|
|
||||||
|
|
||||||
def on_menu_select(self, item):
|
def on_menu_select(self, item):
|
||||||
match(item.name):
|
if item.name == '首选项':
|
||||||
case '首选项':
|
self.app.preferences.show()
|
||||||
self.app.preferences.show()
|
|
||||||
|
|
||||||
case '窗口置顶':
|
elif item.name == '窗口置顶':
|
||||||
self.on_top = not self.on_top
|
self.on_top = not self.on_top
|
||||||
self.app.window.set_keep_above(self.on_top)
|
self.app.window.set_keep_above(self.on_top)
|
||||||
if self.on_top:
|
if self.on_top:
|
||||||
item.select()
|
item.select()
|
||||||
else:
|
else:
|
||||||
item.deselect()
|
item.deselect()
|
||||||
|
|
||||||
case '退出应用':
|
elif item.name == '退出应用':
|
||||||
self.app.quit_all()
|
self.app.quit_all()
|
||||||
|
|
||||||
case '关于播放器':
|
elif item.name == '关于播放器':
|
||||||
self.app.about.present()
|
self.app.about.present()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -129,7 +129,6 @@ class SonistWindow(Gtk.Window):
|
||||||
#ImageButton:hover {{
|
#ImageButton:hover {{
|
||||||
background-color: rgba(255,255,255,.1);
|
background-color: rgba(255,255,255,.1);
|
||||||
outline: transparent;
|
outline: transparent;
|
||||||
box-shadow:none;
|
|
||||||
}}
|
}}
|
||||||
|
|
||||||
#Slider {{
|
#Slider {{
|
||||||
|
@ -188,35 +187,34 @@ class SonistWindow(Gtk.Window):
|
||||||
|
|
||||||
|
|
||||||
def ctrl_clicked(self, box, btn):
|
def ctrl_clicked(self, box, btn):
|
||||||
match(btn):
|
if btn == 'play_btn':
|
||||||
case 'play_btn':
|
self.toggle_play()
|
||||||
self.toggle_play()
|
|
||||||
|
|
||||||
case 'mode_btn':
|
elif btn == 'mode_btn':
|
||||||
# repeat all
|
# repeat all
|
||||||
if self.ctrl_box.curr_mode == 0:
|
if self.ctrl_box.curr_mode == 0:
|
||||||
self.mpd.repeat(1)
|
self.mpd.repeat(1)
|
||||||
self.mpd.random(0)
|
self.mpd.random(0)
|
||||||
self.mpd.single(0)
|
self.mpd.single(0)
|
||||||
# random
|
# random
|
||||||
elif self.ctrl_box.curr_mode == 1:
|
elif self.ctrl_box.curr_mode == 1:
|
||||||
self.mpd.repeat(0)
|
self.mpd.repeat(0)
|
||||||
self.mpd.random(1)
|
self.mpd.random(1)
|
||||||
self.mpd.single(0)
|
self.mpd.single(0)
|
||||||
# single
|
# single
|
||||||
else:
|
else:
|
||||||
self.mpd.repeat(0)
|
self.mpd.repeat(0)
|
||||||
self.mpd.random(0)
|
self.mpd.random(0)
|
||||||
self.mpd.single(1)
|
self.mpd.single(1)
|
||||||
|
|
||||||
case 'prev_btn':
|
elif btn == 'prev_btn':
|
||||||
self.prev_song()
|
self.prev_song()
|
||||||
|
|
||||||
case 'next_btn':
|
elif btn == 'next_btn':
|
||||||
self.next_song()
|
self.next_song()
|
||||||
|
|
||||||
case 'vol_btn':
|
elif btn == 'vol_btn':
|
||||||
self.toggle_play()
|
self.toggle_play()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -254,9 +252,6 @@ class SonistWindow(Gtk.Window):
|
||||||
|
|
||||||
if is_play:
|
if is_play:
|
||||||
self.handler.reset(image_dict['handler_a'])
|
self.handler.reset(image_dict['handler_a'])
|
||||||
# song = self.mpd.currentsong()
|
|
||||||
# 更新歌曲信息
|
|
||||||
# self.title_box.update(f"{song.get('artist')} - {song.get('title')}")
|
|
||||||
else:
|
else:
|
||||||
self.handler.reset(image_dict['handler'])
|
self.handler.reset(image_dict['handler'])
|
||||||
|
|
||||||
|
@ -286,20 +281,21 @@ class SonistWindow(Gtk.Window):
|
||||||
|
|
||||||
# 首次启动时, 更新数据库
|
# 首次启动时, 更新数据库
|
||||||
if first:
|
if first:
|
||||||
if self.app.config_data['auto_scan']:
|
self.mpd.update()
|
||||||
self.mpd.update()
|
song_num = int(self.mpd.stats().get('songs') or 0)
|
||||||
song_num = int(self.mpd.stats().get('songs'))
|
playlist = [it['file'] for it in self.mpd.playlistinfo()]
|
||||||
playlist = [it['file'] for it in self.mpd.playlistinfo()]
|
|
||||||
|
|
||||||
# 这里只做添加, 不做删除, 重建播放列表在设置里
|
self.ctrl_box.disabled = song_num == 0
|
||||||
if len(playlist) < song_num:
|
|
||||||
songs = self.mpd.listall()
|
|
||||||
for it in songs:
|
|
||||||
if it['file'] in playlist:
|
|
||||||
continue
|
|
||||||
self.mpd.add(it['file'])
|
|
||||||
|
|
||||||
self.get_mpd_stat()
|
# 这里只做添加, 不做删除, 重建播放列表在设置里
|
||||||
|
if song_num > 0 and len(playlist) < song_num:
|
||||||
|
songs = self.mpd.listall()
|
||||||
|
for it in songs:
|
||||||
|
if it['file'] in playlist:
|
||||||
|
continue
|
||||||
|
self.mpd.add(it['file'])
|
||||||
|
|
||||||
|
self.get_mpd_stat()
|
||||||
|
|
||||||
|
|
||||||
self.update_play_stat(state == 'play')
|
self.update_play_stat(state == 'play')
|
||||||
|
@ -316,35 +312,37 @@ class SonistWindow(Gtk.Window):
|
||||||
if state != 'stop':
|
if state != 'stop':
|
||||||
|
|
||||||
song = song or self.mpd.currentsong()
|
song = song or self.mpd.currentsong()
|
||||||
# 更新歌曲信息
|
|
||||||
self.title_box.update(f"{song.get('artist')} - {song.get('title')}")
|
|
||||||
|
|
||||||
title = song['file']
|
if song.get('id'):
|
||||||
title_hex = base64.b64encode(title.encode()).hex()
|
# 更新歌曲信息
|
||||||
|
self.title_box.update(f"{song.get('artist')} - {song.get('title')}")
|
||||||
|
|
||||||
filepath = f"{self.app.album_cache_dir}/{title_hex}.png"
|
title = song.get('title')
|
||||||
songpath = f"{self.app.music_dir}/{title}"
|
title_hex = base64.b64encode(title.encode()).hex()
|
||||||
|
|
||||||
if os.path.isfile(filepath):
|
filepath = f"{self.app.album_cache_dir}/{title_hex}.png"
|
||||||
self.update_album(filepath)
|
songpath = f"{self.app.music_dir}/{title}"
|
||||||
else:
|
|
||||||
|
|
||||||
id3 = mutagen.File(songpath)
|
if os.path.isfile(filepath):
|
||||||
pic = None
|
self.update_album(filepath)
|
||||||
try:
|
else:
|
||||||
if id3.tags.get('APIC:'):
|
|
||||||
pic = id3.tags['APIC:']
|
|
||||||
elif len(id3.pictures) > 0:
|
|
||||||
pic = id3.pictures[0]
|
|
||||||
|
|
||||||
if pic is None:
|
id3 = mutagen.File(songpath)
|
||||||
self.update_album()
|
pic = None
|
||||||
else:
|
try:
|
||||||
album = pic_to_pixbuf(pic)
|
if id3.tags.get('APIC:'):
|
||||||
self.update_album(album)
|
pic = id3.tags['APIC:']
|
||||||
|
elif len(id3.pictures) > 0:
|
||||||
|
pic = id3.pictures[0]
|
||||||
|
|
||||||
except Exception as err:
|
if pic is None:
|
||||||
pass
|
self.update_album()
|
||||||
|
else:
|
||||||
|
album = pic_to_pixbuf(pic)
|
||||||
|
self.update_album(album)
|
||||||
|
|
||||||
|
except Exception as err:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue