Skip to content

Commit 26e4ca6

Browse files
committed
- M3U converter:
* fixing encoding problem * making is_valid_url more tolerant to avoid rejecting valid stations - updating docs
1 parent 93e17ff commit 26e4ca6

File tree

10 files changed

+298
-246
lines changed

10 files changed

+298
-246
lines changed

Changelog

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
2025-06-18 s-n-g
1+
2025-08-18 s-n-g
22
* version 0.9.3.11.16 - 0.9.3.12-beta16
33
* heavy refactoring - expect bugs!
44
* adding player field (optional) to station's definition
5+
* adding M3U playlist support
56
* fixing #300 - General Options player select param bug
67
* fixing a potential Remote Control Server crash
78
* fixing a couple of minor bugs

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ Command line internet radio player.
3030
- [RadioBrowser](docs/radio-browser.md) support
3131
- Remote Control Server
3232
- Multiple playlist support
33+
- [M3U playlist](docs/m3u.md) support
3334
- vi like station registers
3435
- Theming support
3536
- Station editor (add/edit) with [CJK characters support](#cjk-characters-support)

docs/index.html

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ <h2 id="features">Features <span style="padding-left: 10px;"><sup style="font-si
162162
<li><a href="radio-browser.html">RadioBrowser</a> support</li>
163163
<li>Remote Control Server</li>
164164
<li>Multiple playlist support</li>
165+
<li><a href="m3u.html">M3U playlist</a> support</li>
165166
<li>vi like station registers</li>
166167
<li>Theming support</li>
167168
<li>Station editor (add/edit) with <a href="#cjk-characters-support">CJK characters support</a></li>
@@ -193,10 +194,11 @@ <h2 id="requirements">Requirements <span style="padding-left: 10px;"><sup style=
193194
<h2 id="changelog">Changelog <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
194195
<pre style="height: 200px;">
195196

196-
2025-06-18 s-n-g
197+
2025-08-18 s-n-g
197198
* version 0.9.3.11.16 - 0.9.3.12-beta16
198199
* heavy refactoring - expect bugs!
199200
* adding player field (optional) to station's definition
201+
* adding M3U playlist support
200202
* fixing #300 - General Options player select param bug
201203
* fixing a potential Remote Control Server crash
202204
* fixing a couple of minor bugs
@@ -1468,28 +1470,29 @@ <h2 id="command-line-options">Command line options <span style="padding-left: 10
14681470

14691471
Usage: pyradio [-h] [-c CONFIG_DIR] [-p [STATION_NUMBER]] [-x] [-u PLAYER]
14701472
[-l] [-lt] [-sds] [-sd] [-od] [-pc] [-d]
1471-
[--d-player-input D_PLAYER_INPUT] [-ul] [-us] [-U] [-R] [-V]
1472-
[-ls] [-s PLAYLIST] [-tlp] [-t THEME] [--show-themes]
1473+
[--d-player-input D_PLAYER_INPUT] [-ul] [-cp] [-us] [-U] [-R]
1474+
[-V] [-ls] [-s PLAYLIST] [-tlp] [-t THEME] [--show-themes]
14731475
[--no-themes] [--write-theme IN_THEME OUT_THEME,]
14741476
[--terminal TERMINAL] [--terminal-param ...] [-oc] [-sc] [-cc]
14751477
[-gc] [-r] [-or] [-lr] [-mkv MKV_FILE] [-scv PNG_FILE] [-srt]
14761478
[-ach] [--headless IP_AND_PORT] [--address] [-fd]
1479+
[-cvt CONVERT] [-o OUTPUT] [-y] [-lm LIMIT]
14771480

14781481
Curses based Internet Radio Player
14791482

14801483
General options:
14811484
-h, --help Show this help message and exit
1482-
-c CONFIG_DIR, --config-dir CONFIG_DIR
1485+
-c, --config-dir CONFIG_DIR
14831486
Use specified configuration directory instead of the
14841487
default one. PyRadio will try to create it, if it does
14851488
not exist. Not available on Windows.
1486-
-p [STATION_NUMBER], --play [STATION_NUMBER]
1489+
-p, --play [STATION_NUMBER]
14871490
Start and play.The value is num station or empty for
14881491
random.
14891492
-x, --external-player
14901493
Play station in external player. Can be combined with
14911494
--play.
1492-
-u PLAYER, --use-player PLAYER
1495+
-u, --use-player PLAYER
14931496
Use specified player. A comma-separated list can be
14941497
used to specify detection order. Supported players:
14951498
mpv, mplayer, vlc.
@@ -1508,6 +1511,8 @@ <h2 id="command-line-options">Command line options <span style="padding-left: 10
15081511
(value = 0), log accepted input (value = 1) or raw
15091512
input (value = 2).
15101513
-ul, --unlock Remove sessions&#39; lock file.
1514+
-cp, --check-playlist
1515+
Enter playlist check mode.
15111516
-us, --update-stations
15121517
Update &quot;stations.csv&quot; (if needed).
15131518
-U, --update Update PyRadio.
@@ -1517,15 +1522,14 @@ <h2 id="command-line-options">Command line options <span style="padding-left: 10
15171522
Playlist selection:
15181523
-ls, --list-playlists
15191524
List of available playlists in config dir.
1520-
-s PLAYLIST, --stations PLAYLIST
1525+
-s, --stations PLAYLIST
15211526
Load the specified playlist instead of the default
15221527
one.
15231528
-tlp, --toggle-load-last-playlist
15241529
Toggle autoload last opened playlist.
15251530

15261531
Themes:
1527-
-t THEME, --theme THEME
1528-
Use specified theme.
1532+
-t, --theme THEME Use specified theme.
15291533
--show-themes Show Internal and System Themes names.
15301534
--no-themes Disable themes (use default theme).
15311535
--write-theme IN_THEME OUT_THEME,
@@ -1553,14 +1557,14 @@ <h2 id="command-line-options">Command line options <span style="padding-left: 10
15531557
Open the Recordings folder.
15541558
-lr, --list-recordings
15551559
List recorded files.
1556-
-mkv MKV_FILE, --mkv-file MKV_FILE
1560+
-mkv, --mkv-file MKV_FILE
15571561
Specify a previously recorded MKV file to be used with
15581562
one of the following options. The MKV_FILE can either
15591563
be an absolute or a relative path, or a number
15601564
provided by the -lr command line paremater. If it is a
15611565
relative path, it should be found in the current or in
15621566
the Recordings directory.
1563-
-scv PNG_FILE, --set-mkv-cover PNG_FILE
1567+
-scv, --set-mkv-cover PNG_FILE
15641568
Add or change the cover image of a previously recorded
15651569
MKV file. PNG_FILE can either be an absolute or a
15661570
relative path. If relative, it should be found in the
@@ -1588,6 +1592,27 @@ <h2 id="command-line-options">Command line options <span style="padding-left: 10
15881592
Use this if your headless server has terminated
15891593
unexpectedly, and you cannot start a new one (you get
15901594
a message that it is already running).
1595+
1596+
m3u playlist handling:
1597+
-cvt, --convert CONVERT
1598+
Convert CSV (PyRadio playlist) to M3U and vise-versa,
1599+
based on the file extension of CONVERT. If there&#39;s no
1600+
file extension, .csv is assumed. Accepts -y, -o, -lm
1601+
(general options). With -o: provides the output file
1602+
for the CSV to M3U conversion. If not specified, the
1603+
same path (including the name) as the CONVERT
1604+
parameter is used, replacing .csv with .m3u. The file
1605+
extension .m3u will be automatically added if not
1606+
specified. With -lm: specify maximum number of
1607+
stations in an M3U file (default is 10,000, 0 disables
1608+
it, effectively accepting any number of entries).
1609+
1610+
General options:
1611+
-o, --output OUTPUT Output file path (see specific commands for default
1612+
behavior).
1613+
-y, --yes, --force Assume yes to all prompts (dangerous: overwrites files
1614+
without confirmation, etc.).
1615+
-lm, --limit LIMIT Use LIMIT as a maximim value of accected items.
15911616
</pre>
15921617
<h2 id="controls">Controls <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
15931618
<p>The following list shows a <strong>default</strong> key bindings list used within the program.</p>

docs/index.md

Lines changed: 34 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ Command line internet radio player.
8989
- [RadioBrowser](radio-browser.md) support
9090
- Remote Control Server
9191
- Multiple playlist support
92+
- [M3U playlist](m3u.md) support
9293
- vi like station registers
9394
- Theming support
9495
- Station editor (add/edit) with [CJK characters support](#cjk-characters-support)
@@ -134,28 +135,29 @@ Furthermore, please refrain from using any third-party packaging methods, such a
134135
135136
Usage: pyradio [-h] [-c CONFIG_DIR] [-p [STATION_NUMBER]] [-x] [-u PLAYER]
136137
[-l] [-lt] [-sds] [-sd] [-od] [-pc] [-d]
137-
[--d-player-input D_PLAYER_INPUT] [-ul] [-us] [-U] [-R] [-V]
138-
[-ls] [-s PLAYLIST] [-tlp] [-t THEME] [--show-themes]
138+
[--d-player-input D_PLAYER_INPUT] [-ul] [-cp] [-us] [-U] [-R]
139+
[-V] [-ls] [-s PLAYLIST] [-tlp] [-t THEME] [--show-themes]
139140
[--no-themes] [--write-theme IN_THEME OUT_THEME,]
140141
[--terminal TERMINAL] [--terminal-param ...] [-oc] [-sc] [-cc]
141142
[-gc] [-r] [-or] [-lr] [-mkv MKV_FILE] [-scv PNG_FILE] [-srt]
142143
[-ach] [--headless IP_AND_PORT] [--address] [-fd]
144+
[-cvt CONVERT] [-o OUTPUT] [-y] [-lm LIMIT]
143145
144146
Curses based Internet Radio Player
145147
146148
General options:
147149
-h, --help Show this help message and exit
148-
-c CONFIG_DIR, --config-dir CONFIG_DIR
150+
-c, --config-dir CONFIG_DIR
149151
Use specified configuration directory instead of the
150152
default one. PyRadio will try to create it, if it does
151153
not exist. Not available on Windows.
152-
-p [STATION_NUMBER], --play [STATION_NUMBER]
154+
-p, --play [STATION_NUMBER]
153155
Start and play.The value is num station or empty for
154156
random.
155157
-x, --external-player
156158
Play station in external player. Can be combined with
157159
--play.
158-
-u PLAYER, --use-player PLAYER
160+
-u, --use-player PLAYER
159161
Use specified player. A comma-separated list can be
160162
used to specify detection order. Supported players:
161163
mpv, mplayer, vlc.
@@ -174,6 +176,8 @@ General options:
174176
(value = 0), log accepted input (value = 1) or raw
175177
input (value = 2).
176178
-ul, --unlock Remove sessions' lock file.
179+
-cp, --check-playlist
180+
Enter playlist check mode.
177181
-us, --update-stations
178182
Update "stations.csv" (if needed).
179183
-U, --update Update PyRadio.
@@ -183,15 +187,14 @@ General options:
183187
Playlist selection:
184188
-ls, --list-playlists
185189
List of available playlists in config dir.
186-
-s PLAYLIST, --stations PLAYLIST
190+
-s, --stations PLAYLIST
187191
Load the specified playlist instead of the default
188192
one.
189193
-tlp, --toggle-load-last-playlist
190194
Toggle autoload last opened playlist.
191195
192196
Themes:
193-
-t THEME, --theme THEME
194-
Use specified theme.
197+
-t, --theme THEME Use specified theme.
195198
--show-themes Show Internal and System Themes names.
196199
--no-themes Disable themes (use default theme).
197200
--write-theme IN_THEME OUT_THEME,
@@ -219,14 +222,14 @@ Recording stations:
219222
Open the Recordings folder.
220223
-lr, --list-recordings
221224
List recorded files.
222-
-mkv MKV_FILE, --mkv-file MKV_FILE
225+
-mkv, --mkv-file MKV_FILE
223226
Specify a previously recorded MKV file to be used with
224227
one of the following options. The MKV_FILE can either
225228
be an absolute or a relative path, or a number
226229
provided by the -lr command line paremater. If it is a
227230
relative path, it should be found in the current or in
228231
the Recordings directory.
229-
-scv PNG_FILE, --set-mkv-cover PNG_FILE
232+
-scv, --set-mkv-cover PNG_FILE
230233
Add or change the cover image of a previously recorded
231234
MKV file. PNG_FILE can either be an absolute or a
232235
relative path. If relative, it should be found in the
@@ -255,6 +258,27 @@ Headless operation:
255258
unexpectedly, and you cannot start a new one (you get
256259
a message that it is already running).
257260
261+
m3u playlist handling:
262+
-cvt, --convert CONVERT
263+
Convert CSV (PyRadio playlist) to M3U and vise-versa,
264+
based on the file extension of CONVERT. If there's no
265+
file extension, .csv is assumed. Accepts -y, -o, -lm
266+
(general options). With -o: provides the output file
267+
for the CSV to M3U conversion. If not specified, the
268+
same path (including the name) as the CONVERT
269+
parameter is used, replacing .csv with .m3u. The file
270+
extension .m3u will be automatically added if not
271+
specified. With -lm: specify maximum number of
272+
stations in an M3U file (default is 10,000, 0 disables
273+
it, effectively accepting any number of entries).
274+
275+
General options:
276+
-o, --output OUTPUT Output file path (see specific commands for default
277+
behavior).
278+
-y, --yes, --force Assume yes to all prompts (dangerous: overwrites files
279+
without confirmation, etc.).
280+
-lm, --limit LIMIT Use LIMIT as a maximim value of accected items.
281+
258282
```
259283

260284
## Controls

docs/m3u.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ <h3 id="convert-m3u-to-pyradio-csv">Convert M3U to PyRadio CSV</h3>
5252
<p>The default maximum number of stations in an M3U file is 10,000.</p>
5353
<p>You can perform M3U to CSV conversion in two ways:</p>
5454
<ol type="1">
55-
<li><p><strong>Command line conversion</strong> using the --convert option.<br />
55+
<li><p><strong>Command line conversion</strong> using the <em>convert</em> option.<br />
5656
<br />
5757
This is ideal for batch conversions of multiple files (or M3U URLs).<br />
5858
<br />
59-
It also provides a way to convert very large M3Us to CSV; the “-lm” / “--limit” parameter will help you overcome the default 10,000 stations limit.</p></li>
59+
It also provides a way to convert very large M3Us to CSV; the “<em>-lm</em>” / “<em>limit</em>” parameter will help you overcome the default 10,000 stations limit; setting it to 0 will disable any such check.</p></li>
6060
<li><p><strong>Automatic conversion within PyRadio</strong> when selecting M3U playlists from the playlist browser<br />
6161
<br />
6262
<strong>PyRadio</strong> automatically detects M3U files in your playlists directory and labels them with ” (m3u)” suffix. When you select an M3U playlist from within <strong>PyRadio</strong>, it transparently converts it to CSV format for editing and use within the application.<br />

docs/m3u.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ The default maximum number of stations in an M3U file is 10,000.
1818

1919
You can perform M3U to CSV conversion in two ways:
2020

21-
1. **Command line conversion** using the `--convert` option. \
21+
1. **Command line conversion** using the "*--convert*" option. \
2222
\
2323
This is ideal for batch conversions of multiple files (or M3U URLs). \
2424
\
25-
It also provides a way to convert very large M3Us to CSV; the "`-lm`" / "`--limit`" parameter will help you overcome the default 10,000 stations limit.
25+
It also provides a way to convert very large M3Us to CSV; the "*-lm*" / "*--limit*" parameter will help you overcome the default 10,000 stations limit; setting it to 0 will disable any such check.
2626

2727
2. **Automatic conversion within PyRadio** when selecting M3U playlists from the playlist browser \
2828
\

pyradio/config.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1146,10 +1146,10 @@ def read_playlists(self):
11461146
self.playlists.append([a_file_name + ' (m3u)', a_file_time, a_file_size, a_file])
11471147
self.playlists.sort()
11481148

1149-
logger.error('\n\n')
1150-
for n in self.playlists:
1151-
logger.error(f'{n}')
1152-
logger.error('\n\n')
1149+
# logger.error('\n\n')
1150+
# for n in self.playlists:
1151+
# logger.error(f'{n}')
1152+
# logger.error('\n\n')
11531153

11541154
''' get already loaded playlist id '''
11551155
for i, a_playlist in enumerate(self.playlists):

0 commit comments

Comments
 (0)