Skip to content

Commit b57d2c2

Browse files
authored
v24.11.1 update
1 parent ca216bb commit b57d2c2

File tree

3 files changed

+47
-66
lines changed

3 files changed

+47
-66
lines changed

code/README.txt

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
Minimal MPD Client - v2.1.0
1+
Minimal MPD Client - v24.11.1
22

3-
Check out the offline help under the Help menu. (updated for v2.1.0)
4-
5-
v2.1.0
6-
- Provided a kinder solution when trying to run MMC4W against a server that is not running.
7-
- Added Config menu option to delete the debug log file.
8-
- Corrected bug preventing logo from being displayed when there is no album art.
3+
Check out the offline help under the Help menu. (updated for v24.11.1)
94

5+
v24.11.1
6+
- Changed versioning scheme. I like the year (24.) month (11.) iteration (1) numbering.
7+
- Incorporated a code change based on a recommendation from donburch888. Thanks Don!
8+
- Added an option under the Queue menu to save the current queue to a .m3u file
9+
in the folder of your choice. This helped me get my favorites on my phone.
10+
- I also added the 'requirements.txt' file from my Windows 'venv' to the repo.
1011

code/mmc4w.py

Lines changed: 30 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import tkinter as tk
1010
from tkinter import messagebox
1111
from tkinter import simpledialog
12+
from tkinter import filedialog
1213
from tkinter.font import Font
1314
import datetime
1415
from time import sleep
@@ -32,18 +33,10 @@
3233
ctypes.windll.shcore.SetProcessDpiAwareness(0)
3334
ctypes.windll.user32.SetProcessDPIAware()
3435

35-
version = "v2.1.0"
36+
version = "v24.11.1"
37+
# v24.11.1 - Save playlist to file. Also shift to different version number scheme.
3638
# v2.1.0 - Gently handle attempting to run with no server. Add 'delete debug log'.
3739
# v2.0.9 - Finally get scale factors working. Renamed menus. Browse help.html.
38-
# v2.0.8 - Use buttons in search windows for added flexibility.
39-
# v2.0.7 - Trade pathlib for os.path. Deal with 'already connected' error.
40-
# v2.0.6 - Fine tuning lookups and search windows. Completely revamp win size methods.
41-
# v2.0.5 - Way better Playlist Build Mode.
42-
# v2.0.4 - Doing things a better way.
43-
# v2.0.1 - Handling the queue.
44-
# v2.0.0 - Introduced classes for some windows. Tons more stability tweaks.
45-
# v1.0.0 - Fixed error in the fiver() function.
46-
# v0.9.9 - tk.Scrollbars on all windows. Windows are more uniform.
4740

4841

4942
client = musicpd.MPDClient() # create client object
@@ -414,7 +407,7 @@ def connext(): ## Checks connection, then connects if necessary.
414407
else:
415408
logger.debug("D1| Second level errvar: {}".format(err2var))
416409
cxstat = 0
417-
endWithError('Second level connection error:\n' + str(err2var) + '\nQuitting now.')
410+
endWithError("The server you selected is not responding.\nEdit mmc4w.ini to ensure the 'lastsrvr' IP address is for a running server.")
418411
return cxstat
419412

420413

@@ -631,38 +624,6 @@ def volbtncolor(vol_int): # Provide visual feedback on volume buttons.
631624
confparse.write(SLcnf)
632625
logger.info('Saved volume to mmc4w.ini. lastvol is {}.'.format(lastvol))
633626
#
634-
## FIVER() ROUNDS VOLUME NUMBERS TO MULTIPLES OF 5.
635-
#
636-
def fiver(invar): # invar should be a string of numbers: 0 - 100. Returns string.
637-
fivevar = ''
638-
firDig = ''
639-
secDig = ''
640-
if len(invar) == 1:
641-
secDig = invar
642-
elif len(invar) == 2:
643-
firDig = invar[:1]
644-
secDig = invar[1:2]
645-
if invar == '100':
646-
fivevar = invar
647-
zerovals = ('0','1','2')
648-
zeroplusvals = ('8','9')
649-
fivevals = ('3','4','5','6','7')
650-
if secDig in zerovals:
651-
secDig = '0'
652-
if secDig in zeroplusvals:
653-
secDig = '0'
654-
if firDig == '':
655-
firDig = '0'
656-
firDig = str(int(firDig) + 1)
657-
if secDig in fivevals:
658-
secDig = '5'
659-
if fivevar != '100':
660-
if firDig > "":
661-
fivevar = firDig + secDig
662-
else:
663-
fivevar = secDig
664-
return fivevar
665-
666627
def toglrandom():
667628
connext()
668629
ranstat = client.status()
@@ -762,6 +723,9 @@ def getcurrsong():
762723
buttonvar = newstate
763724
logger.debug('D2| Retrieving "cs" in getcurrsong().')
764725
cs = client.currentsong()
726+
# if 'duration' not in cs:
727+
# msg = "The server cannot provide the required song duration value. Exiting."
728+
# endWithError(msg)
765729
logger.debug('D2| Got cs (client.currentsong()) with a length of {}.'.format(len(cs)))
766730
if cs == {}:
767731
client.stop()
@@ -783,8 +747,10 @@ def getcurrsong():
783747
artw.aartLabel.configure(image=aart)
784748
if 'volume' in stat:
785749
lastvol = stat['volume']
786-
vol_fives = fiver(lastvol)
787-
vol_int = int(vol_fives)
750+
# next two lines courtesy of Donburch888. Replaces entire fiver() function.
751+
vol_fives = int( (float(lastvol)+3) /5 ) # map 0-100 to range of 0-20
752+
vol_int = int(vol_fives * 5) # and back to 0-100
753+
#
788754
volbtncolor(vol_int)
789755
logger.info('3) Volume is {}, Random is {}, Repeat is {}.'.format(lastvol,stat['random'],stat['repeat']))
790756
gpstate = stat['state']
@@ -1158,16 +1124,16 @@ def exit():
11581124
globsongtitle = ""
11591125
aatgl = '0'
11601126

1161-
def makeeverything():
1127+
def makeeverything():
11621128
connext()
1163-
client.clear()
1129+
client.clear() # clears the queue
11641130
pllist = client.listplaylists()
11651131
if 'Everything' in str(pllist):
11661132
client.rm('Everything')
1167-
client.add('/')
1168-
client.save('Everything')
1133+
client.add('/') # adds all songs in library to the queue.
1134+
client.save('Everything') # Saves a new 'Everything.m3u' file to disk.
11691135
logger.info('The playlist named "Everything" was just updated.')
1170-
PLSelWindow()
1136+
PLSelWindow() # opens the playlist selection dialog.
11711137
#
11721138
## A CLASS TO CREATE ERROR MESSAGEBOXES (USED VERBATIM FROM STACKOVERFLOW)
11731139
## https://stackoverflow.com/questions/6666882/tkinter-python-catching-exceptions
@@ -1738,6 +1704,19 @@ def createnewpl():
17381704
PLSelWindow()
17391705
logger.info("NPL) A new saved Playlist named '{}' was created.".format(newpl))
17401706
#
1707+
def writeqtofile():
1708+
file_path = filedialog.askdirectory(parent=window,initialdir="~",title='Please select a directory')
1709+
print(file_path)
1710+
if file_path != ():
1711+
songlist=[]
1712+
songlistq = client.playlistinfo()
1713+
for s in songlistq:
1714+
songlist.append(s['file'])
1715+
with open(Path(file_path,"mmc4w_playlist.m3u"), 'w') as plout:
1716+
plout.write('\n'.join(songlist))
1717+
window.update()
1718+
artw.update()
1719+
#
17411720
def browserplayer():
17421721
global buttonvar
17431722
outputsraw = getoutputs()[0]
@@ -1803,6 +1782,7 @@ def browserplayer():
18031782
queueMenu.add_command(label='Find and Play in Queue',command=lambda: queuewin('title'))
18041783
queueMenu.add_command(label="Toggle PL Build Mode", command=buildpl)
18051784
queueMenu.add_command(label="Launch Browser Player", command=browserplayer)
1785+
queueMenu.add_command(label='Write Queue to .m3u File', command=writeqtofile)
18061786
menu.add_cascade(label="Queue", menu=queueMenu)
18071787

18081788
helpMenu = tk.Menu(menu, tearoff=False)

code/mmc4w_help.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
<!doctype html>
2-
<html markdown="1">
3-
<body markdown="1">
41
# MMC4W - Minimal MPD Client for Windows
52

6-
This help file was updated for the v2.1.0 release. As of v2.0.8 the same Python code runs in Linux without needing any tweaks.
3+
This help file was updated for the v24.11.1 release. As of v2.0.8 the same Python code runs in Linux without needing any tweaks.
74

8-
I recommend reading the **First Run Process** section below before installing.
5+
I recommend reading the **First Run Process** section below before installing. Of course, that assumes you're reading this on Github before you downloaded and installed MMC4W.
96

107
# Putting the Music First
118

@@ -64,6 +61,7 @@ The interface contains the basic required buttons to control a MPD server:
6461
- **Find and Play** : Opens a window displaying the songs in the queue. See below for more detail.
6562
- **Toggle PL Build Mode** : Sets PL Build Mode. Easily add or delete songs from saved playlists.
6663
- **Launch Browser Player** : If a streaming HTTP output is enabled on the server, opens your browser there.
64+
- **Write Queue to .m3u File** : Write current queue to a local .m3u file. Artist/Album/Track is the basic format.
6765

6866

6967
### The 'Help' menu contains:
@@ -228,6 +226,8 @@ You load playlists into the queue and then MPD plays that queue using the settin
228226

229227
**MMC4W** will create a special playlist called "Everything" that contains all the songs in your library. That option is found in the **'Lists'** Menu.
230228

229+
If you want to get a playlist out of the MPD server and onto your local computer, look in the Queue menu for the option to save the queue to a .m3u file. The saved file will have an Artist/Album/Track format. Note that this has only been tested with a curated library of songs with complete metadata. If the library on the server is missing some metadata, it's a good bet it will have a unwanted effect.
230+
231231
### You can manipulate playlists in these ways:
232232

233233
- Load a playlist into the queue. **Lists Menu** - Select a Playlist.
@@ -236,6 +236,7 @@ You load playlists into the queue and then MPD plays that queue using the settin
236236
- Create a new empty playlist. **Lists Menu** - Create New Saved Playlist.
237237
- Delete a playlist. **Lists Menu** - Remove Saved Playlist.
238238
- Add or remove the currently playing song to any saved playlist. **Queue Menu** - Toggle PL Build Mode.
239+
- **NEW** Save the current queue to a local .m3u playlist file.
239240

240241
## Adding and Removing Songs in a Saved Playlist:
241242

@@ -256,7 +257,7 @@ You can move and resize that window to suit your tastes. When you exit PLBuild
256257

257258
**NOTE:** If you press **Quit** while in PLBuild Mode, **MMC4W** first turns PLBuild Mode off, then exits.
258259

259-
**That's it.**
260+
**It's just that easy.**
260261

261262
#### Deleting a song from the current saved playlist is just as easy:
262263

@@ -400,7 +401,7 @@ With the exception of the serverlist, all of these entries are filled in by the
400401

401402
### Minutia
402403

403-
MMC4W was developed and tested in Windows 10. As of v2.0.6, the same Python code will run on Linux. So far it's only tested on Ubuntu. **MPD** is running on three different Debian-type computers here, one i7 Ubuntu, one i3 Ubuntu and one Raspberry Pi. My music library is made up exclusively of FLAC files. I rip my CD's (remember those?) using [Music Bee](https://getmusicbee.com/). I create a 'folder.jpg' file (I'll probably switch to 'cover.png') for each album and embed the art in the songs using **[MP3TAG](https://www.mp3tag.de/en/)** or **Music Bee** depending on the circumstances.
404+
MMC4W was developed and tested in Windows 10 and 11. As of v2.0.6, the same Python code will run on Linux. So far it's only tested on Ubuntu. **MPD** is running on three different Debian-type computers here, one i7 Ubuntu, one i3 Ubuntu and one Raspberry Pi. My music library is made up exclusively of FLAC files. I rip my CD's (remember those?) using [Music Bee](https://getmusicbee.com/). I create a 'folder.jpg' file (I'll probably switch to 'cover.png') for each album and embed the art in the songs using **[MP3TAG](https://www.mp3tag.de/en/)** or **Music Bee** depending on the circumstances.
404405

405406
I hope you enjoy using this as much as I do.<br><br>
406407

@@ -409,5 +410,4 @@ I hope you enjoy using this as much as I do.<br><br>
409410
**Thanks** to [kaliko](https://gitlab.com/kaliko) for the [python-musicpd](https://gitlab.com/kaliko/python-musicpd) library!
410411
And of course none of this would be possible without the excellent contribution of [MPD](https://github.com/MusicPlayerDaemon) by Max Kellermann. **Thanks!!**
411412
&copy;2023-2024 - Gregory A. Sanders (dr.gerg@drgerg.com)
412-
</body>
413-
</html>
413+

0 commit comments

Comments
 (0)