Skip to content

Commit edfe95e

Browse files
committed
- install.py:
* psutil installed by default * if installed psutil and / or rich, show message to restart the installation - added profile and buffering to playylist fields - playlist verion now depends on Station(IntEnum) - reg.py and unreg.py: simplified installation and uninstallation - updated docs
1 parent 9c6bfcd commit edfe95e

File tree

9 files changed

+326
-171
lines changed

9 files changed

+326
-171
lines changed

devel/reg.py

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,27 @@
55
rkey = r'Software\Microsoft\Windows\CurrentVersion\Run'
66

77
rhandle = winreg.OpenKey(hkey, rkey, 0, winreg.KEY_ALL_ACCESS)
8-
appdata = winreg.ExpandEnvironmentStrings('%appdata%')
9-
bat = os.path.join(appdata,
8+
bat = os.path.join('%APPDATA%',
109
'pyradio',
11-
'help',
12-
'pyradio.bat')
13-
if ' ' in bat:
14-
bat = '"' + bat + '"'
10+
'data',
11+
'pyradio.lock')
12+
bat = '"' + bat + '"'
1513

1614
try:
17-
winreg.SetValueEx(rhandle,
18-
'PyRadioLockFile',
19-
0, winreg.REG_SZ,
20-
bat)
21-
with open(bat, "w") as f:
22-
f.write('echo "Windows started" > "{}"\n'.format(os.path.join(
23-
appdata,
24-
'pyradio',
25-
'data',
26-
'_windows.lock')))
15+
winreg.SetValueEx(
16+
rhandle,
17+
'PyRadioLockFile',
18+
0, winreg.REG_SZ,
19+
'cmd.exe /C DEL ' + bat
20+
)
21+
except FileNotFoundError:
22+
print("Error: The specified registry key could not be found.")
23+
except PermissionError:
24+
print("Error: You do not have sufficient permissions to modify the registry.")
25+
except OSError as e:
26+
print(f"OS Error: An operating system error occurred: {e}")
27+
except Exception as e:
28+
print(f"An unexpected error occurred: {e}")
2729
finally:
2830
winreg.CloseKey(rhandle)
2931

devel/unreg.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@
66

77
rhandle = winreg.OpenKey(hkey, rkey, 0, winreg.KEY_ALL_ACCESS)
88

9-
bat = os.path.join(winreg.ExpandEnvironmentStrings('%appdata%'),
10-
'pyradio',
11-
'help',
12-
'pyradio.bat')
13-
if ' ' in bat:
14-
bat = '"' + bat + '"'
15-
169
try:
1710
winreg.DeleteValue(rhandle, 'PyRadioLockFile')
1811
except:

docs/index.html

Lines changed: 87 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ <h2 id="table-of-contents">Table of Contents <span style="padding-left: 10px;"><
9191
<li><a href="#changing-player-mid-session">Changing player mid-session</a></li>
9292
<li><a href="#specifying-a-station&#39;s-referer-url">Specifying a station’s Referer URL</a>
9393
<ul>
94-
<li><a href="#a-note-of-caution">A note of caution</a></li>
9594
<li><a href="#note-about-mplayer">Note about MPlayer</a></li>
95+
<li><a href="#referer-support-in-the-playlist">Referer support in the playlist</a></li>
9696
</ul></li>
9797
<li><a href="#extra-player-parameters">Extra Player Parameters</a>
9898
<ul>
@@ -1639,9 +1639,78 @@ <h3 id="the-user-config-file">The user config file</h3>
16391639
<p>If saving the configuration file fails, <strong>PyRadio</strong> will create a back up file and terminate. When restarted, <strong>PyRadio</strong> will try to restore previously used settings from the said back up file.</p>
16401640
<h2 id="about-playlist-files">About Playlist files <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></span></h2>
16411641
<p><strong>PyRadio</strong> reads the stations to use from a CSV file, where each line contains two columns, the first being the station name and the second being the stream URL.</p>
1642-
<p>Optionally, two more columns can be used.</p>
1643-
<p>The third column will define the encoding used by the station (more on this at <a href="#specifying-stations-encoding">Specifying stations’ encoding</a>).</p>
1644-
<p>The fourth column will set an <em>Icon URL</em>, to be used when displaying <a href="#desktop-notifications">Desktop Notifications</a>.</p>
1642+
<p>Optionally, a number of more columns can be used.</p>
1643+
<ul>
1644+
<li><p>The third column will define the encoding used by the station (more on this at <a href="#specifying-stations-encoding">Specifying stations’ encoding</a>).</p></li>
1645+
<li><p>The fourth column will set an <em>Icon URL</em>, to be used when displaying <a href="#desktop-notifications">Desktop Notifications</a>.</p></li>
1646+
<li><p>The fifth column is the profile to be used with this station.</p></li>
1647+
<li><p>The sixth column will determine whether <strong>Buffering</strong> will be used (more on this at <a href="#buffering">Buffering</a>).</p></li>
1648+
<li><p>The seventh column will determine whether the station will be forced to be using http instead of https (more on this at <a href="#player-connection-protocol">Player connection protocol</a>).</p></li>
1649+
<li><p>The eight column defines the volume value to be used.</p></li>
1650+
<li><p>The last column will define the referer to be used (more on this at <a href="##specifying-a-station&#39;s-referer-url">Specifying a station’s Referer URL</a>).</p></li>
1651+
</ul>
1652+
<p>The following table presents the <strong>Station’s fields</strong> and the current level of support.</p>
1653+
<table>
1654+
<colgroup>
1655+
<col style="width: 22%" />
1656+
<col style="width: 39%" />
1657+
<col style="width: 38%" />
1658+
</colgroup>
1659+
<thead>
1660+
<tr>
1661+
<th>Station Field</th>
1662+
<th>Takes Effect in Playlist</th>
1663+
<th>Customizable in Program</th>
1664+
</tr>
1665+
</thead>
1666+
<tbody>
1667+
<tr>
1668+
<td>Name</td>
1669+
<td>&lt;0.9.3.11.5</td>
1670+
<td>&lt;0.9.3.11.5</td>
1671+
</tr>
1672+
<tr>
1673+
<td>URL</td>
1674+
<td>&lt;0.9.3.11.5</td>
1675+
<td>&lt;0.9.3.11.5</td>
1676+
</tr>
1677+
<tr>
1678+
<td>Encoding</td>
1679+
<td>&lt;0.9.3.11.5</td>
1680+
<td>&lt;0.9.3.11.5</td>
1681+
</tr>
1682+
<tr>
1683+
<td>Icon</td>
1684+
<td>&lt;0.9.3.11.5</td>
1685+
<td>&lt;0.9.3.11.5</td>
1686+
</tr>
1687+
<tr>
1688+
<td>Profile</td>
1689+
<td><strong>No</strong></td>
1690+
<td><strong>No</strong></td>
1691+
</tr>
1692+
<tr>
1693+
<td>Buffering</td>
1694+
<td><strong>No</strong></td>
1695+
<td><strong>No</strong></td>
1696+
</tr>
1697+
<tr>
1698+
<td>Force HTTP</td>
1699+
<td><strong>No</strong></td>
1700+
<td><strong>No</strong></td>
1701+
</tr>
1702+
<tr>
1703+
<td>Volume</td>
1704+
<td><strong>No</strong></td>
1705+
<td>0.9.3.11.5</td>
1706+
</tr>
1707+
<tr>
1708+
<td>Referer URL</td>
1709+
<td>&lt;0.9.3.11.5</td>
1710+
<td><strong>No</strong><br>Using a referer file</td>
1711+
</tr>
1712+
</tbody>
1713+
</table>
16451714
<p><strong>PyRadio</strong> will by default load the user’s stations file (e.g. <em>~/.config/pyradio/stations.csv</em>) to read the stations from. If this file is not found, it will be created and populated with a default set of stations.</p>
16461715
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> Older versions used to use <strong>~/.pyradio</strong> as default stations file. If this file is found, it will be copied to use’s config directory (e.g. <strong>~/.config/pyradio</strong>) and renamed to <strong>stations.csv</strong> or if this file exists, to <strong>pyradio.csv</strong>. In this case, this file will be the default one.</p>
16471716
<h3 id="defining-and-using-groups">Defining and using Groups</h3>
@@ -1850,9 +1919,6 @@ <h3 id="specifying-a-stations-referer-url">Specifying a station’s Referer URL<
18501919
<p>To rectify the situation, a file containing the referer URL would have to be saved in the config directory: its name must be the name of the station as it is in the playlist, followed by the “<strong>.referer.txt</strong>” extension.</p>
18511920
<p>In our example above, the file will have to be named:</p>
18521921
<p><strong>“My video station.referer.txt”</strong></p>
1853-
<h4 id="a-note-of-caution">A note of caution</h4>
1854-
<p>If such a file has been created for a station, please do not rename the station in the playlist manually; the “link” to the referer file will be lost.</p>
1855-
<p>Rename the station using <strong>PyRadio</strong> rename functionality and save the playlist instead; the referer file will be renamed as well.</p>
18561922
<h4 id="note-about-mplayer">Note about MPlayer</h4>
18571923
<p>This will unfortunately not work with <strong>MPlayer</strong>.</p>
18581924
<p>It seems it will not use the <strong>Referer</strong> provided, as shown in the following part of the command execution output:</p>
@@ -1866,6 +1932,20 @@ <h4 id="note-about-mplayer">Note about MPlayer</h4>
18661932
Icy-MetaData: 1
18671933

18681934
[https @ 0x7f4a42c7fa60]HTTP error 403 Forbidden</pre>
1935+
<h4 id="referer-support-in-the-playlist">Referer support in the playlist</h4>
1936+
<p>As of v. <strong>0.9.3.11.5</strong>, support for the referer in the playilist has been implemented.</p>
1937+
<p>In this case, if a referer file is found for a station, <strong>PyRadio</strong> will:</p>
1938+
<ol type="1">
1939+
<li>update the station info in the playlist</li>
1940+
<li>mark the playlist as <strong>modified</strong></li>
1941+
<li>remove the referer file</li>
1942+
<li>inform the user so that he saves the playlist</li>
1943+
</ol>
1944+
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> At this point, inserting the referer from <strong>PyRadio</strong> TUI has not yet been implemented.<br />
1945+
<br />
1946+
One can either use the referer file method described above, or just manually edit the playlist file and add it using the following format:</p>
1947+
<pre>Station Name,Station URL,,,,,,Referer URL</pre>
1948+
<p>Please note the number of commas inserted after the <em>Station URL</em>.</p>
18691949
<h3 id="extra-player-parameters">Extra Player Parameters</h3>
18701950
<p>All three supported players can accept a significant number of “<em>command line options</em>”, which are well documented and accessible through man pages (on linux and MacOs) or the documentation (on Windows).</p>
18711951
<p><strong>PyRadio</strong> uses some of these parameters in order to execute and communicate with the players. In particular, the following parameters are in use <strong>by default</strong>:</p>

docs/index.md

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ Command line internet radio player.
4040
* [Player detection / selection](#player-detection-/-selection)
4141
* [Changing player mid-session](#changing-player-mid-session)
4242
* [Specifying a station's Referer URL](#specifying-a-station's-referer-url)
43-
* [A note of caution](#a-note-of-caution)
4443
* [Note about MPlayer](#note-about-mplayer)
44+
* [Referer support in the playlist](#referer-support-in-the-playlist)
4545
* [Extra Player Parameters](#extra-player-parameters)
4646
* [Using the Configuration Window](#using-the-configuration-window)
4747
* [Player connection protocol](#player-connection-protocol)
@@ -421,11 +421,36 @@ If saving the configuration file fails, **PyRadio** will create a back up file a
421421

422422
**PyRadio** reads the stations to use from a CSV file, where each line contains two columns, the first being the station name and the second being the stream URL.
423423

424-
Optionally, two more columns can be used.
424+
Optionally, a number of more columns can be used.
425425

426-
The third column will define the encoding used by the station (more on this at [Specifying stations' encoding](#specifying-stations-encoding)).
426+
- The third column will define the encoding used by the station (more on this at [Specifying stations' encoding](#specifying-stations-encoding)).
427+
428+
- The fourth column will set an *Icon URL*, to be used when displaying [Desktop Notifications](#desktop-notifications).
429+
430+
- The fifth column is the profile to be used with this station.
431+
432+
- The sixth column will determine whether **Buffering** will be used (more on this at [Buffering](#buffering)).
433+
434+
- The seventh column will determine whether the station will be forced to be using http instead of https (more on this at [Player connection protocol](#player-connection-protocol)).
435+
436+
- The eight column defines the volume value to be used.
437+
438+
- The last column will define the referer to be used (more on this at [Specifying a station's Referer URL](##specifying-a-station's-referer-url)).
439+
440+
The following table presents the **Station's fields** and the current level of support.
441+
442+
| Station Field | Takes Effect in Playlist | Customizable in Program |
443+
|-----------------|------------------------------|-----------------------------|
444+
| Name | <0.9.3.11.5 | <0.9.3.11.5 |
445+
| URL | <0.9.3.11.5 | <0.9.3.11.5 |
446+
| Encoding | <0.9.3.11.5 | <0.9.3.11.5 |
447+
| Icon | <0.9.3.11.5 | <0.9.3.11.5 |
448+
| Profile | **No** | **No** |
449+
| Buffering | **No** | **No** |
450+
| Force HTTP | **No** | **No** |
451+
| Volume | **No** | 0.9.3.11.5 |
452+
| Referer URL | <0.9.3.11.5 | **No**<br>Using a referer file |
427453

428-
The fourth column will set an *Icon URL*, to be used when displaying [Desktop Notifications](#desktop-notifications).
429454

430455
**PyRadio** will by default load the user's stations file (e.g. *~/.config/pyradio/stations.csv*) to read the stations from. If this file is not found, it will be created and populated with a default set of stations.
431456

@@ -751,12 +776,6 @@ In our example above, the file will have to be named:
751776

752777
**"My video station.referer.txt"**
753778

754-
#### A note of caution
755-
756-
If such a file has been created for a station, please do not rename the station in the playlist manually; the "link" to the referer file will be lost.
757-
758-
Rename the station using **PyRadio** rename functionality and save the playlist instead; the referer file will be renamed as well.
759-
760779
#### Note about MPlayer
761780

762781
This will unfortunately not work with **MPlayer**.
@@ -776,6 +795,25 @@ Icy-MetaData: 1
776795
[https @ 0x7f4a42c7fa60]HTTP error 403 Forbidden
777796
```
778797

798+
#### Referer support in the playlist
799+
800+
As of v. **0.9.3.11.5**, support for the referer in the playilist has been implemented.
801+
802+
In this case, if a referer file is found for a station, **PyRadio** will:
803+
804+
1. update the station info in the playlist
805+
2. mark the playlist as **modified**
806+
3. remove the referer file
807+
4. inform the user so that he saves the playlist
808+
809+
**Note:** At this point, inserting the referer from **PyRadio** TUI has not yet been implemented. \
810+
\
811+
One can either use the referer file method described above, or just manually edit the playlist file and add it using the following format:
812+
813+
Station Name,Station URL,,,,,,Referer URL
814+
815+
Please note the number of commas inserted after the *Station URL*.
816+
779817
### Extra Player Parameters
780818

781819
All three supported players can accept a significant number of "*command line options*", which are well documented and accessible through man pages (on linux and MacOs) or the documentation (on Windows).

docs/pyradio.1

Lines changed: 66 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -388,14 +388,43 @@ If saving the configuration file fails, \fBpyradio\fR will create a back up file
388388
.SH About Playlist Files
389389
.PP
390390
\fBpyradio\fR reads the stations to use from a CSV file, where each line contains two columns, the first being the station name and the second being the stream URL.
391+
391392
.PP
392-
Optionally, a third column can be inserted, stating the encoding used by the station (more on this at \fBSpecifying Stations' Encoding\fR).
393-
.PP
394-
Optionally, two more columns can be used.
395-
.PP
396-
The third column will define the encoding used by the station (more on this at \fBSpecifying Stations' Encoding\fR).
397-
.PP
398-
The fourth column will set an \fIIcon URL\fR, to be used when displaying \fBDesktop Notifiacations\fR.
393+
Optionally, a number of more columns can be used.
394+
.IP - 3
395+
The third column will define the encoding used by the station (more on this at \fISpecifying stations' encoding\fR).
396+
.IP - 3
397+
The fourth column will set an *Icon URL*, to be used when displaying \fIDesktop Notifications\fR.
398+
.IP - 3
399+
The fifth column is the profile to be used with this station.
400+
.IP - 3
401+
The sixth column will determine whether **Buffering** will be used (more on this at \fIBuffering\fR).
402+
.IP - 3
403+
The seventh column will determine whether the station will be forced to be using http instead of https (more on this at \fIPlayer connection protocol\fR).
404+
.IP - 3
405+
The eighth column defines the volume value to be used.
406+
.IP - 3
407+
The last column will define the referer to be used (more on this at \fISpecifying a station's Referer URL\fR).
408+
.PP
409+
The following table presents the \fBStation's fields\fR and the current level of support.
410+
.P
411+
.TS
412+
center;
413+
l l.
414+
\fBStation field Takes Effect Customizable
415+
in Playlist in Program
416+
_
417+
\fIName\fR <0.9.3.11.5 <0.9.3.11.5
418+
\fIURL\fR <0.9.3.11.5 <0.9.3.11.5
419+
\fIEncoding\fR <0.9.3.11.5 <0.9.3.11.5
420+
\fIIcon\fR <0.9.3.11.5 <0.9.3.11.5
421+
\fIProfile\fR \fBNo No\fR
422+
\fIBuffering\fR \fBNo No\fR
423+
\fIForce HTTP\fR \fBNo No\fR
424+
\fIVolume\fR \fBNo\fR 0.9.3.11.5
425+
\fIReferer URL\fR <0.9.3.11.5 \fBNo\fR (\fIUsing a referer file\fR)
426+
.TE
427+
399428
.PP
400429
\fBpyradio\fR will by default load the user's stations file (e.g. \fI~/.config/pyradio/stations.csv\fR). If this file is not found, it will be created and populated with a default set of stations.
401430

@@ -864,13 +893,6 @@ In our example above, the file will have to be named:
864893
"\fIMy video station.referer.txt\fR"
865894
.RE
866895

867-
\fBA note of caution\fR
868-
.RS
869-
If such a file has been created for a station, please do not rename the station in the playlist manually; the "link" to the referer file will be lost.
870-
871-
Rename the station using \fBpyradio\fR rename functionality and save the playlist instead; the referer file will be renamed as well.
872-
.RE
873-
874896
\fBNote\fR
875897
.RS 2
876898

@@ -897,6 +919,36 @@ Icy-MetaData: 1
897919
[https @ 0x7f4a42c7fa60]\fBHTTP error 403 Forbidden\fR
898920
.RE
899921

922+
\fBReferer support in the playlist\fR
923+
924+
As of v. \fB0.9.3.11.5\fR, support for the referer in the playilist has been implemented.
925+
926+
In this case, if a referer file is found for a station, \fBpyradio\fR will:
927+
928+
.IP
929+
1. update the station info in the playlist
930+
.IP
931+
2. mark the playlist as \fBmodified\fR
932+
.IP
933+
3. remove the referer file
934+
.IP
935+
4. inform the user so that he saves the playlist
936+
937+
.P
938+
\fBNote\fR
939+
.RS 2
940+
At this point, inserting the referer from \fBpyradio\fR TUI has not yet been implemented. \
941+
\
942+
One can either use the referer file method described above, or just manually edit the playlist file and add it using the following format:
943+
944+
\fIStation Name,Station URL,,,,,,Referer URL\fR
945+
.RE
946+
947+
.P
948+
.RS 2
949+
Please note the number of commas inserted after the \fIStation URL\fR.
950+
.RS
951+
900952

901953
.SH Extra Player Parameters
902954

0 commit comments

Comments
 (0)