Skip to content

Commit f73a9c0

Browse files
committed
- fixing "P" command
- starting setup.py -> pip transition for linux and mac - simplifying mpv and mplayer installation on Windows
1 parent 6451329 commit f73a9c0

File tree

9 files changed

+91
-193
lines changed

9 files changed

+91
-193
lines changed

devel/build_install_pyradio

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ function help(){
33
if [[ $(uname -s) = "Darwin" ]] || [[ $(uname -s) = "darwin" ]]; then
44
echo "Usage: $0 [2/-u]"
55
else
6-
echo "Usage: $0 [2/-u/--user]"
6+
echo "Usage: $0 [2/-u/--root]"
77
fi
88
echo "
99
Available options:
1010
2 build using python v. 2.x
11-
-R remove (uninstall) pyradio
12-
--user user install (in ~/.local)
11+
-R remove (uninstall) pyradi
12+
--root system wide installation
1313
1414
If no option is used, will build using Python 3
15+
and will install in your HOME directory
1516
1617
Checking python availability:"
1718

@@ -68,10 +69,10 @@ function uninstall(){
6869
}
6970
# keep this sudo as to not break lines
7071
sudo echo 'Uninstalling PyRadio'
71-
user=$(which pyradio | grep '\.local')
72+
user=$(which pyradio 2>/dev/null| grep '\.local')
7273
[ -z "$user" ] && {
7374
echo -n '** Removing executable ... '
74-
sudo rm -f `which pyradio` 2>/dev/null
75+
sudo rm -f `which pyradio 2>/dev/null` 2>/dev/null
7576
if [ -d /usr/share/doc/pyradio ];then
7677
sudo rm -rf /usr/share/doc/pyradio 2>/dev/null
7778
else
@@ -84,7 +85,7 @@ function uninstall(){
8485
echo done
8586
} || {
8687
echo -n '** Removing executable ... '
87-
rm -f `which pyradio` 2>/dev/null
88+
rm -f `which pyradio 2>/dev/null` 2>/dev/null
8889
echo done
8990
echo -n '** Removing help files ... '
9091
if [ -d ~/.local/share/doc/pyradio ];then
@@ -188,6 +189,7 @@ function do_exit(){
188189
TO_PYTHON=3
189190
TO_PYTHON_FROM_X=''
190191
NO_DEV=''
192+
TO_USER=1
191193
while [[ $# -gt 0 ]]
192194
do
193195
key="$1"
@@ -204,14 +206,18 @@ do
204206
uninstall
205207
exit
206208
;;
207-
--user)
208-
TO_USER=1
209-
if [[ $(uname -s) = "Darwin" ]] || [[ $(uname -s) = "darwin" ]]; then
210-
echo "Parameter --user not supported on this OS"
211-
exit 1
212-
fi
209+
--root)
210+
unset TO_USER
213211
shift
214212
;;
213+
# --user)
214+
# TO_USER=1
215+
# if [[ $(uname -s) = "Darwin" ]] || [[ $(uname -s) = "darwin" ]]; then
216+
# echo "Parameter --user not supported on this OS"
217+
# exit 1
218+
# fi
219+
# shift
220+
# ;;
215221
2)
216222
[ -z "${TO_PYTHON_FROM_X}" ] && TO_PYTHON=2
217223
shift
@@ -296,7 +302,7 @@ then
296302
[ -z "$TO_USER" ] && {
297303
echo "***** installing..."
298304
do_dev
299-
sudo python"${TO_PYTHON}" setup.py install
305+
sudo python"${TO_PYTHON}" -m pip install .
300306
if [ $? -eq 0 ]
301307
then
302308
[ -z "${NO_DEV}" ] && mv pyradio/config.py.dev pyradio/config.py
@@ -329,7 +335,7 @@ then
329335
} || {
330336
echo "***** installing for user..."
331337
do_dev
332-
python"${TO_PYTHON}" setup.py install --user
338+
python"${TO_PYTHON}" -m pip install .
333339
if [ $? -eq 0 ]
334340
then
335341
[ -z "${NO_DEV}" ] && mv pyradio/config.py.dev pyradio/config.py

pyradio/player.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,25 @@ def find_vlc_on_windows(config_dir=None):
120120
# result.append(os.path.join(root, name))
121121
#return result
122122

123+
def find_mpv_on_windows():
124+
for a_path in (
125+
os.path.join(os.getenv('APPDATA'), 'pyradio', 'mpv', 'mpv.exe'),
126+
os.path.join(os.getenv('APPDATA'), 'mpv', 'mpv.exe'),
127+
os.path.join(expanduser("~"), 'mpv', 'mpv.exe')
128+
):
129+
if os.path.exists(a_path):
130+
return a_path
131+
return 'mpv'
132+
133+
def find_mplayer_on_windows():
134+
for a_path in (
135+
os.path.join(os.getenv('APPDATA'), 'pyradio', 'mplayer', 'mplayer.exe'),
136+
os.path.join(os.getenv('APPDATA'), 'mplayer', 'mplayer.exe'),
137+
os.path.join(expanduser("~"), 'mplayer', 'mplayer.exe')
138+
):
139+
if os.path.exists(a_path):
140+
return a_path
141+
return 'mplayer'
123142

124143
def info_dict_to_list(info, fix_highlight, max_width):
125144
max_len = 0
@@ -1524,6 +1543,11 @@ class MpvPlayer(Player):
15241543

15251544
PLAYER_NAME = 'mpv'
15261545
PLAYER_CMD = 'mpv'
1546+
WIN = False
1547+
if platform.startswith('win'):
1548+
WIN = True
1549+
if WIN:
1550+
PLAYER_CMD = find_mpv_on_windows()
15271551
NEW_PROFILE_STRING = 'volume=50\n\n'
15281552
if pywhich(PLAYER_CMD):
15291553
executable_found = True
@@ -1951,6 +1975,11 @@ class MpPlayer(Player):
19511975

19521976
PLAYER_NAME = 'mplayer'
19531977
PLAYER_CMD = 'mplayer'
1978+
WIN = False
1979+
if platform.startswith('win'):
1980+
WIN = True
1981+
if WIN:
1982+
PLAYER_CMD = find_mplayer_on_windows()
19541983
NEW_PROFILE_STRING = 'softvol=1\nsoftvol-max=300\nvolstep=1\nvolume=50\n\n'
19551984
if pywhich(PLAYER_CMD):
19561985
executable_found = True

pyradio/radio.py

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5084,7 +5084,7 @@ def keypress(self, char):
50845084
elif char == ord('P') and self.ws.operation_mode in \
50855085
(self.ws.NORMAL_MODE, self.ws.PLAYLIST_MODE):
50865086
self._reset_status_bar_right()
5087-
self._goto_playing_station
5087+
self._goto_playing_station()
50885088
return
50895089

50905090
elif self.ws.operation_mode == self.ws.NOT_IMPLEMENTED_YET_MODE:
@@ -6443,7 +6443,6 @@ def keypress(self, char):
64436443
elif self._cnf.browsing_station_service:
64446444
''' go back to playlist history '''
64456445
if self._cnf.online_browser.is_config_dirty():
6446-
logger.error('DE \n\nonline config is dirty\n\n')
64476446
self._ask_to_save_browser_config_to_exit()
64486447
else:
64496448
self._open_playlist_from_history()
@@ -6474,10 +6473,8 @@ def keypress(self, char):
64746473
reset_playing=False
64756474
)
64766475
self.ctrl_c_handler(0,0)
6477-
logger.error('RETURN -1')
64786476
return -1
64796477
else:
6480-
logger.error('\n\nRETURN\n\n')
64816478
return
64826479

64836480
if char in (curses.KEY_DOWN, ord('j')):

windows-mplayer.html

Lines changed: 10 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ <h2 id="table-of-contents">Table of Contents <span style="padding-left: 10px;"><
4242
<!-- vim-markdown-toc Marked -->
4343
<ul>
4444
<li><a href="#mplayer-installation">MPlayer installation</a></li>
45-
<li><a href="#adding-mplayer-to-the-path">Adding MPlayer to the PATH</a></li>
4645
</ul>
4746
<!-- vim-markdown-toc -->
4847
<p><a href="windows.html">[Back to Build Instructions]</a> <a href="README.html">[Back to README]</a></p>
@@ -53,33 +52,18 @@ <h2 id="mplayer-installation">MPlayer installation <span style="padding-left: 10
5352
<p style="margin: 1.5em 4em 0 4em; text-indent: -2.5em;"><strong>Note:</strong> <em>MPlayer</em> provides CPU type dependent builds. In case you select the wrong <em>mplayer</em> build, you will end up connecting to stations but having no sound. If this is the case, please do go back to the download page and get the right build for your system / CPU.</p>
5453
<p>Extract this directory to whatever place you like and <strong>rename</strong> it to <strong>mplayer</strong>.</p>
5554
<p>Here comes the tricky part…</p>
56-
<p>Move the <strong>mplayer</strong> directory to either on of the following locations:</p>
57-
<ol type="a">
58-
<li><strong>%USERPROFILE%</strong></p>
59-
<p>This is actually your <em>Home</em> directory.</p>
60-
<p>Please make a note that you will add “<strong>%USERPROFILE%\mplayer</strong> to PATH.</p></li>
61-
<li><strong>%APPDATA%\pyradio</strong></p>
62-
<p>This is (or will be) “<em>PyRadio’s configuration directory</em>”.</p>
63-
<p>In case the <strong>pyradio</strong> directory does not exit, you just go ahead and create it.</p>
64-
<p>(Make a note that you will add “<strong>%APPDATA%\pyradio\mplayer</strong> to PATH)</p></li>
65-
</ol>
55+
<p>Move the <strong>mplayer</strong> directory to either on of the following locations (<strong>PyRadio</strong> will look for it there, when executed):</p>
56+
<ul>
57+
<li><strong>%APPDATA%\pyradio</strong><br />
58+
This is (or will be) <em>PyRadio’s configuration directory</em>.<br />
59+
In case the “<em>pyradio</em>” directory does not exit, you just go ahead and create it.</p></li>
60+
<li><strong>%APPDATA%</strong><br />
61+
This is your “Roaming” folder.</p></li>
62+
<li><strong>%USERPROFILE%</strong><br />
63+
This is actually your “<em>Home</em>” directory.</p></li>
64+
</ul>
6665
<p>In either case, in order to do that, open an <strong>Explorer File Manager</strong> window, and enter at its location field <strong>%USERPROFILE%</strong> or <strong>%APPDATA%</strong>.</p>
6766
<p>If you are unsure on how to do that, please refer to the following image (you can ENTER <strong>%USERPROFILE%</strong> or <strong>%APPDATA%</strong> or any other Windows System Variable this way).</p>
6867
<a href="https://members.hellug.gr/sng/pyradio/appdata.jpg" target="_blank"><img src="https://members.hellug.gr/sng/pyradio/appdata.jpg" alt="Navigating to %APPDATA%" /></a>
69-
<h2 id="adding-mplayer-to-the-path">Adding MPlayer to the PATH <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></style></h2>
70-
<p>The final step is to add MPlayer to the PATH System Variable.</p>
71-
<p>Now, you already know the <strong>path string</strong> that has to be added (you have made a note of it in the previous step).</p>
72-
<p>There’s just one thing to say here: Windows provide a “<em>User variable for User</em>” and a “<em>System variables</em>” section in the “<em>Environment Variables</em>” window.</p>
73-
<p>Add the <strong>path string</strong> to the “<em>User variables for User</em>” section.</p>
74-
<p>In order to make the actual addition, please refer to the following image.</p>
75-
<a href="https://members.hellug.gr/sng/pyradio/path.jpg" target="_blank"><img src="https://members.hellug.gr/sng/pyradio/path.jpg" alt="Adding MPlayer to the PATH" /></a>
76-
<p>After applying the changes you should <strong>log off and back on</strong> or <strong>restart the system</strong>, because changes done to the PATH variable will take effect the next time you log into the system.</p>
77-
<p>When you are back on, verify that you can run <strong>MPlayer</strong>; open a console (press the <strong>Win</strong> key, type <strong>cmd</strong> and press <strong>ENTER</strong>) and type “<strong>mplayer</strong>”.</p>
78-
<p>If you get something similar to the following snippet, you are all good.</p>
79-
<pre>MPlayer Redxii-SVN-r38119-6.2.0 (x86_64) (C) 2000-2018 MPlayer Team
80-
Using FFmpeg N-92801-g7efe84aebd (2018-12-25 00:44:17 +0100)
81-
Compiled on 2018-12-25 13:55:17 EST (rev. 1)
82-
Usage: mplayer [options] [url|path/]filename</pre>
83-
<p>If <strong>mplayer</strong> was not found, you just have to go through the PATH modification procedure again.</p>
8468
</body>
8569
</html>

windows-mplayer.md

Lines changed: 8 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Ben Dowling - [https://github.com/coderholic](https://github.com/coderholic)
99
<!-- vim-markdown-toc Marked -->
1010

1111
* [MPlayer installation](#mplayer-installation)
12-
* [Adding MPlayer to the PATH](#adding-mplayer-to-the-path)
1312

1413
<!-- vim-markdown-toc -->
1514

@@ -29,21 +28,18 @@ Extract this directory to whatever place you like and **rename** it to **mplayer
2928

3029
Here comes the tricky part...
3130

32-
Move the **mplayer** directory to either on of the following locations:
31+
Move the **mplayer** directory to either on of the following locations (**PyRadio** will look for it there, when executed):
3332

34-
a. **%USERPROFILE%**
33+
- **%APPDATA%\\pyradio** \
34+
This is (or will be) "*PyRadio's configuration directory*". \
35+
In case the "*pyradio*" directory does not exit, you just go ahead and create it.
3536

36-
This is actually your "*Home*" directory.
37+
- **%APPDATA%** \
38+
This is your "Roaming" folder.
3739

38-
Please make a note that you will add "**%USERPROFILE%\\mplayer** to PATH.
40+
- **%USERPROFILE%** \
41+
This is actually your "*Home*" directory.
3942

40-
b. **%APPDATA%\\pyradio**
41-
42-
This is (or will be) "*PyRadio's configuration directory*".
43-
44-
In case the **pyradio** directory does not exit, you just go ahead and create it.
45-
46-
(Make a note that you will add "**%APPDATA%\\pyradio\\mplayer** to PATH)
4743

4844
In either case, in order to do that, open an **Explorer File Manager** window, and enter at its location field **%USERPROFILE%** or **%APPDATA%**.
4945

@@ -52,29 +48,3 @@ If you are unsure on how to do that, please refer to the following image (you ca
5248
![Navigating to %APPDATA%](https://members.hellug.gr/sng/pyradio/appdata.jpg)
5349

5450

55-
## Adding MPlayer to the PATH
56-
57-
The final step is to add MPlayer to the PATH System Variable.
58-
59-
Now, you already know the **path string** that has to be added (you have made a note of it in the previous step).
60-
61-
There's just one thing to say here: Windows provide a "*User variable for User*" and a "*System variables*" section in the "*Environment Variables*" window.
62-
63-
Add the **path string** to the "*User variables for User*" section.
64-
65-
In order to make the actual addition, please refer to the following image.
66-
67-
![Adding MPlayer to the PATH](https://members.hellug.gr/sng/pyradio/path.jpg)
68-
69-
After applying the changes you should **log off and back on** or **restart the system**, because changes done to the PATH variable will take effect the next time you log into the system.
70-
71-
When you are back on, verify that you can run **MPlayer**; open a console (press the **Win** key, type **cmd** and press **ENTER**) and type "**mplayer**".
72-
73-
If you get something similar to the following snippet, you are all good.
74-
75-
MPlayer Redxii-SVN-r38119-6.2.0 (x86_64) (C) 2000-2018 MPlayer Team
76-
Using FFmpeg N-92801-g7efe84aebd (2018-12-25 00:44:17 +0100)
77-
Compiled on 2018-12-25 13:55:17 EST (rev. 1)
78-
Usage: mplayer [options] [url|path/]filename
79-
80-
If **mplayer** was not found, you just have to go through the PATH modification procedure again.

windows-mpv.html

Lines changed: 10 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ <h2 id="table-of-contents">Table of Contents <span style="padding-left: 10px;"><
4242
<!-- vim-markdown-toc Marked -->
4343
<ul>
4444
<li><a href="#mpv-installation">MPV installation</a></li>
45-
<li><a href="#adding-mpv-to-the-path">Adding MPV to the PATH</a></li>
4645
</ul>
4746
<!-- vim-markdown-toc -->
4847
<p><a href="windows.html">[Back to Build Instructions]</a> <a href="README.html">[Back to README]</a></p>
@@ -52,53 +51,18 @@ <h2 id="mpv-installation">MPV installation <span style="padding-left: 10px;"><su
5251
<p>You will end up downloading a <a target="_blank" href="https://www.7-zip.org/">7z archive</a>, which contains a directory whose name is similar to <strong>mpv-0.34.-x86_64.7z</strong>.</p>
5352
<p>Extract this archive to whatever place you like and <strong>rename</strong> it to <strong>mpv</strong>.</p>
5453
<p>Here comes the tricky part…</p>
55-
<p>Move the <strong>mpv</strong> directory to either on of the following locations:</p>
56-
<ol type="a">
57-
<li><strong>%USERPROFILE%</strong></p>
58-
<p>This is actually your <em>Home</em> directory.</p>
59-
<p>Please make a note that you will add “<strong>%USERPROFILE%\mpv</strong> to PATH.</p></li>
60-
<li><strong>%APPDATA%\pyradio</strong></p>
61-
<p>This is (or will be) “<em>PyRadio’s configuration directory</em>”.</p>
62-
<p>In case the <strong>pyradio</strong> directory does not exit, you just go ahead and create it.</p>
63-
<p>(Make a note that you will add “<strong>%APPDATA%\pyradio\mpv</strong> to PATH)</p></li>
64-
</ol>
54+
<p>Move the <strong>mpv</strong> directory to either on of the following locations (<strong>PyRadio</strong> will look for it there, when executed):</p>
55+
<ul>
56+
<li><strong>%APPDATA%\pyradio</strong><br />
57+
This is (or will be) <em>PyRadio’s configuration directory</em>.<br />
58+
In case the “<em>pyradio</em>” directory does not exit, you just go ahead and create it.</p></li>
59+
<li><strong>%APPDATA%</strong><br />
60+
This is your “Roaming” folder.</p></li>
61+
<li><strong>%USERPROFILE%</strong><br />
62+
This is actually your “<em>Home</em>” directory.</p></li>
63+
</ul>
6564
<p>In either case, in order to do that, open an <strong>Explorer File Manager</strong> window, and enter at its location field <strong>%USERPROFILE%</strong> or <strong>%APPDATA%</strong>.</p>
6665
<p>If you are unsure on how to do that, please refer to the following image (you can ENTER <strong>%USERPROFILE%</strong> or <strong>%APPDATA%</strong> or any other Windows System Variable this way).</p>
6766
<a href="https://members.hellug.gr/sng/pyradio/appdata.jpg" target="_blank"><img src="https://members.hellug.gr/sng/pyradio/appdata.jpg" alt="Navigating to %APPDATA%" /></a>
68-
<h2 id="adding-mpv-to-the-path">Adding MPV to the PATH <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></style></h2>
69-
<p>The final step is to add MPV to the PATH System Variable.</p>
70-
<p>Now, you already know the <strong>path string</strong> that has to be added (you have made a note of it in the previous step).</p>
71-
<p>There’s just one thing to say here: Windows provide a “<em>User variable for User</em>” and a “<em>System variables</em>” section in the “<em>Environment Variables</em>” window.</p>
72-
<p>Add the <strong>path string</strong> to the “<em>User variables for User</em>” section.</p>
73-
<p>In order to make the actual addition, please refer to the following image.</p>
74-
<a href="https://members.hellug.gr/sng/pyradio/path.jpg" target="_blank"><img src="https://members.hellug.gr/sng/pyradio/path.jpg" alt="Adding MPV to the PATH" /></a>
75-
<p><strong>Note</strong>: This image is the one used in the relevant <strong>mplayer</strong> page; in this case you just replace <strong>mplayer</strong> with <strong>mpv</strong>.</p>
76-
<p>After applying the changes you should <strong>log off and back on</strong> or <strong>restart the system</strong>, because changes done to the PATH variable will take effect the next time you log into the system.</p>
77-
<p>When you are back on, verify that you can run <strong>MPV</strong>; open a console (press the <strong>Win</strong> key, type <strong>cmd</strong> and press <strong>ENTER</strong>) and type “<strong>mpv</strong>”.</p>
78-
<p>If you get something similar to the following snippet, you are all good.</p>
79-
<pre>mpv 0.34.0 Copyright © 2000-2021 mpv/MPlayer/mplayer2 projects
80-
built on Sun Nov 7 20:16:38 +08 2021
81-
FFmpeg library versions:
82-
libavutil 57.7.100
83-
libavcodec 59.12.100
84-
libavformat 59.8.100
85-
libswscale 6.1.100
86-
libavfilter 8.16.101
87-
libswresample 4.0.100
88-
FFmpeg version: git-2021-11-06-1728127e
89-
90-
Usage: mpv [options] [url|path/]filename
91-
92-
Basic options:
93-
--start=&lt;time&gt; seek to given (percent, seconds, or hh:mm:ss) position
94-
--no-audio do not play sound
95-
--no-video do not play video
96-
--fs fullscreen playback
97-
--sub-file=&lt;file&gt; specify subtitle file to use
98-
--playlist=&lt;file&gt; specify playlist file
99-
100-
--list-options list all mpv options
101-
--h=&lt;string&gt; print options which contain the given string in their name</pre>
102-
<p>If <strong>mpv</strong> was not found, you just have to go through the PATH modification procedure again.</p>
10367
</body>
10468
</html>

0 commit comments

Comments
 (0)