Skip to content
This repository has been archived by the owner on Jun 4, 2023. It is now read-only.

Commit

Permalink
Update 0.8.9
Browse files Browse the repository at this point in the history
Changelog:
~Improved search algorithm
-Removed unused icons
~Fixed crash when playing wav files
  • Loading branch information
MateuszPerczak committed May 30, 2022
1 parent 34c0c07 commit 84caf83
Show file tree
Hide file tree
Showing 6 changed files with 47 additions and 112 deletions.
73 changes: 0 additions & 73 deletions src/Resources/Dumps/sounder_dump.txt
Original file line number Diff line number Diff line change
@@ -1,73 +0,0 @@
ERROR:root:'NoneType' object has no attribute 'info'
Traceback (most recent call last):
File "e:/Python/New Projects/Sounder5/Sounder5.py", line 1208, in scan_folders
self.new_song(song)
File "e:/Python/New Projects/Sounder5/Sounder5.py", line 1580, in new_song
self.cache_song(song)
File "e:/Python/New Projects/Sounder5/Sounder5.py", line 1574, in cache_song
self.songs_cache[song] = {'title': song_title, 'artist': song_artist, 'album': album, 'album_art': album_art, 'length': song_metadata.info.length,
AttributeError: 'NoneType' object has no attribute 'info'
ERROR:root:'NoneType' object has no attribute 'info'
Traceback (most recent call last):
File "e:/Python/New Projects/Sounder5/Sounder5.py", line 1209, in scan_folders
self.new_song(song)
File "e:/Python/New Projects/Sounder5/Sounder5.py", line 1583, in new_song
self.cache_song(song)
File "e:/Python/New Projects/Sounder5/Sounder5.py", line 1577, in cache_song
self.songs_cache[song] = {'title': song_title, 'artist': song_artist, 'album': album, 'album_art': album_art, 'length': song_metadata.info.length,
AttributeError: 'NoneType' object has no attribute 'info'
ERROR:root:Position not implemented for music type
Traceback (most recent call last):
File "e:/Python/New Projects/Sounder5/Sounder5.py", line 1720, in mixer_play
mixer.music.play(start=start)
pygame.error: Position not implemented for music type
ERROR:root:can't multiply sequence by non-int of type 'float'
Traceback (most recent call last):
File "e:/Python/New Projects/Sounder5/Sounder5.py", line 1456, in sort_panels
print(song, score, score * "-")
TypeError: can't multiply sequence by non-int of type 'float'
ERROR:root:can't multiply sequence by non-int of type 'float'
Traceback (most recent call last):
File "e:/Python/New Projects/Sounder5/Sounder5.py", line 1456, in sort_panels
print(song, score, score * "-")
TypeError: can't multiply sequence by non-int of type 'float'
ERROR:root:can't multiply sequence by non-int of type 'float'
Traceback (most recent call last):
File "e:/Python/New Projects/Sounder5/Sounder5.py", line 1456, in sort_panels
print(song, score, score * "-")
TypeError: can't multiply sequence by non-int of type 'float'
ERROR:root:can't multiply sequence by non-int of type 'float'
Traceback (most recent call last):
File "e:/Python/New Projects/Sounder5/Sounder5.py", line 1456, in sort_panels
print(song, score, score * "-")
TypeError: can't multiply sequence by non-int of type 'float'
ERROR:root:local variable 'sensitivity' referenced before assignment
Traceback (most recent call last):
File "e:/Python/New Projects/Sounder5/Sounder5.py", line 1449, in sort_panels
if score > sensitivity:
UnboundLocalError: local variable 'sensitivity' referenced before assignment
ERROR:root:local variable 'sensitivity' referenced before assignment
Traceback (most recent call last):
File "e:/Python/New Projects/Sounder5/Sounder5.py", line 1449, in sort_panels
if score > sensitivity:
UnboundLocalError: local variable 'sensitivity' referenced before assignment
ERROR:root:local variable 'sensitivity' referenced before assignment
Traceback (most recent call last):
File "e:/Python/New Projects/Sounder5/Sounder5.py", line 1449, in sort_panels
if score > sensitivity:
UnboundLocalError: local variable 'sensitivity' referenced before assignment
ERROR:root:local variable 'sensitivity' referenced before assignment
Traceback (most recent call last):
File "e:/Python/New Projects/Sounder5/Sounder5.py", line 1449, in sort_panels
if score > sensitivity:
UnboundLocalError: local variable 'sensitivity' referenced before assignment
ERROR:root:local variable 'sensitivity' referenced before assignment
Traceback (most recent call last):
File "e:/Python/New Projects/Sounder5/Sounder5.py", line 1449, in sort_panels
if score > sensitivity:
UnboundLocalError: local variable 'sensitivity' referenced before assignment
ERROR:root:local variable 'tokens' referenced before assignment
Traceback (most recent call last):
File "e:/Python/New Projects/Sounder5/Sounder5.py", line 1434, in sort_panels
self.settings['search_compensation'] * (tokens - 1))
UnboundLocalError: local variable 'tokens' referenced before assignment
77 changes: 42 additions & 35 deletions src/Sounder5.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def init_important_panels(self: Tk) -> None:
ttk.Label(error_content, image=self.icons['error'], text='Something went wrong',
compound='top', style='second.TLabel').pack(side='top')
self.error_label: ttk.Label = ttk.Label(
error_content, text='We are unable to display the error message!', style='third.TLabel')
error_content, text='If you see this message, something went wrong. Not sure what tho :D', style='third.TLabel')
self.error_label.pack(side='top')
ttk.Button(error_content, text='Exit', style='third.TButton',
command=self.exit_app).pack(side='top', pady=(50, 0), padx=10)
Expand Down Expand Up @@ -123,10 +123,10 @@ def init_notifications(self: Tk) -> None:
def init_settings(self: Tk) -> None:
try:
# variables
default_settings: dict = {'played_percent': 2, 'menu_position': 'left', 'search_compensation': 0.7, 'delete_missing': False, 'follow': 1, 'crossfade': 100, 'shuffle': False, 'start_playback': False, 'playlist': 'Library', 'repeat': 'None', 'buffer': 'Normal', 'last_song': '',
default_settings: dict = {'played_percent': 2, 'menu_position': 'left', 'search_compensation': 0.5, 'delete_missing': False, 'follow': 1, 'crossfade': 100, 'shuffle': False, 'start_playback': False, 'playlist': 'Library', 'repeat': 'None', 'buffer': 'Normal', 'last_song': '',
'volume': 0.5, 'sort_by': 'A-Z', 'scan_subfolders': False, 'geometry': '800x500', 'wheel_acceleration': 1.0, 'updates': True, 'folders': [], 'use_system_theme': True, 'theme': 'Light', 'page': 'Library', 'playlists': {'Favorites': {'Name': 'Favorites', 'Songs': []}}}
self.settings: dict = {}
self.version: tuple = ('0.8.8', '300522')
self.version: tuple = ('0.8.9', '300522')
# load settings
if isfile(r'Resources\\Settings\\Settings.json'):
with open(r'Resources\\Settings\\Settings.json', 'r') as data:
Expand Down Expand Up @@ -1407,43 +1407,50 @@ def search(self: Tk, _: Event = None) -> None:
def sort_panels(self: Tk, search_word: str, songs: list, refresh_panels: bool = False) -> None:
try:
temp_songs: list = []
score: float = 0.0
ratio: float = 2.0
song_srore: float = 0.0
song_scores: dict = {}
max_srore: float = 0.0
# apply search
if search_word:
for song in songs:
score = 0.0
tokens: int = len(self.songs_cache[song]['search_tokens'])
ratio = (
self.settings['search_compensation'] * (tokens - 1))
song_srore = 0.0
for token in self.songs_cache[song]['search_tokens']:
if song in temp_songs:
continue
for word in search_word.split():
if word in token:
song_srore += 1.0
song_srore += SequenceMatcher(a=token,
b=search_word).quick_ratio()
if search_word in token or search_word == token:
score += 1.0
score += SequenceMatcher(a=token,
b=search_word).quick_ratio()
if score >= ratio:
song_srore += 2.5
song_scores[song] = song_srore - \
self.settings['search_compensation']
if song_srore > max_srore:
max_srore = song_srore
for song in songs:
if song_scores[song] / max_srore > 0.5:
temp_songs.append(song)
temp_songs.sort(
key=lambda song: song_scores[song], reverse=True)

else:
temp_songs = songs.copy()
# apply sort
if self.settings['sort_by'] == 'A-Z':
temp_songs.sort(key=self.sort_songs)
elif self.settings['sort_by'] == 'Z-A':
temp_songs.sort(key=self.sort_songs, reverse=True)
elif self.settings['sort_by'] == 'NOP':
temp_songs.sort(key=self.sort_by_plays, reverse=True)
if not temp_songs:
self.no_songs.pack(side='top', fill='x', pady=5, padx=10)
else:
self.no_songs.pack_forget()
# apply search
if self.playlist == 'Library':
self.songs = temp_songs.copy()
# apply shuffle
if self.songs and self.settings['shuffle']:
shuffle(self.songs)
# apply sort
if self.settings['sort_by'] == 'A-Z':
temp_songs.sort(key=self.sort_songs)
elif self.settings['sort_by'] == 'Z-A':
temp_songs.sort(key=self.sort_songs, reverse=True)
elif self.settings['sort_by'] == 'NOP':
temp_songs.sort(key=self.sort_by_plays, reverse=True)
if not temp_songs:
self.no_songs.pack(side='top', fill='x', pady=5, padx=10)
else:
self.no_songs.pack_forget()
# apply search
if self.playlist == 'Library':
self.songs = temp_songs.copy()
# apply shuffle
if self.songs and self.settings['shuffle']:
shuffle(self.songs)
# forget panels
if refresh_panels:
for song in filter(lambda song: song in self.library and song in self.song_panels and self.song_panels[song].winfo_ismapped(), self.library):
Expand Down Expand Up @@ -1506,7 +1513,7 @@ def toggle_shuffle(self: Tk) -> None:

def cache_song(self: Tk, song: str) -> None:
album_art = self.icons['note']
song_title: str = splitext(basename(song))[0]
song_title, extension = splitext(basename(song))
song_artist: str = 'Unknown'
album: str = 'Unknown'
genre: str = 'Unknown'
Expand Down Expand Up @@ -1559,7 +1566,7 @@ def cache_song(self: Tk, song: str) -> None:

# cache data
self.songs_cache[song] = {'title': song_title, 'artist': song_artist, 'album': album, 'album_art': album_art, 'length': song_metadata.info.length,
'kbps': song_metadata.info.bitrate, 'genre': genre, 'search_tokens': search_tokens.lower().split(), 'plays': 0}
'kbps': song_metadata.info.bitrate, 'genre': genre, 'search_tokens': search_tokens.lower().split(), 'extension': extension, 'plays': 0}
self.songs_cache[song]['search_tokens'].extend(
[song_title.lower(), song_artist.lower(), album.lower()])

Expand Down Expand Up @@ -1747,7 +1754,7 @@ def panel_play(self: Tk, song: str) -> None:
self.mixer_play(song)

def progress_play(self: Tk, event: Event) -> None:
if self.song in self.songs_cache:
if self.song in self.songs_cache and self.songs_cache[self.song]['extension'] not in ('.wav'):
self.mixer_play(self.song, (event.x / self.progress_bar.winfo_width())
* self.songs_cache[self.song]['length'])

Expand Down
5 changes: 3 additions & 2 deletions updates/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Changelog:
+Removed old stuff
~Improved search function
~Improved search algorithm
-Removed unused icons
~Fixed crash when playing wav files
2 changes: 1 addition & 1 deletion updates/hash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
23d4693e4634f7ea7c0714c6f8d408200cdaa5d19dfd803098967c38ba758d06
2e70a723beefc5dd6d967e07bbdd8178a12f0bf0f741a8ee06e361ba8b74bf39
Binary file modified updates/package.zip
Binary file not shown.
2 changes: 1 addition & 1 deletion updates/version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.8.8
0.8.9

0 comments on commit 84caf83

Please sign in to comment.