Skip to content

Commit

Permalink
Version 0.8.8-beta5 (adding vlc windows support)
Browse files Browse the repository at this point in the history
  • Loading branch information
s-n-g committed Nov 23, 2020
1 parent bc210b0 commit b2121fe
Show file tree
Hide file tree
Showing 15 changed files with 825 additions and 211 deletions.
17 changes: 12 additions & 5 deletions README.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,29 @@
<title>PyRadio README</title>
<style type="text/css">
html {margin: 2em;}
h2 {margin-top: 2.5em; border-bottom:1px solid #D6D6D6;}
h3 {margin-top: 2em;}
h2 {margin-top: 2.5em; border-bottom:1px solid SaddleBrown; color: SaddleBrown;}
h3 {margin-top: 2em; color: SaddleBrown;}
h4 {margin-top: 2em; color: SaddleBrown;}
STRONG {color: SaddleBrown;}
dl {margin: 2em;}
dd {margin: 1em;}
dt {font-weight: bold;}
pre { background-color: #F6F6F6; padding: 1.5em; border: 1px solid #E6E6E6; overflow: auto;}
TABLE {border: 1px solid SaddleBrown;}
TH {text-align: left; color: SaddleBrown;border: 1px solid SaddleBrown;}
TD {text-align: left; padding-right: 8px;border: 1px solid SaddleBrown;}
pre { background-color: rgba(139, 69, 19, 0.80); color: #fff; padding: 1.5em; border: 1px solid #A87207; border-radius: 15px; overflow: auto;}
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
a{ color: SaddleBrown;}
a:visited{color: SaddleBrown;}
</style>
</head>
<body>
<header>
</header>
<h1 id="pyradio">PyRadio</h1>
<h1 style="color: SaddleBrown"id="pyradio">PyRadio</h1>
<p>Command line internet radio player.</p>
<p>Ben Dowling - <a target="_blank" href="https://github.com/coderholic" class="uri">https://github.com/coderholic</a></p>
<h2 id="table-of-contents">Table of contents <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></style></h2>
Expand Down
17 changes: 12 additions & 5 deletions build.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,29 @@
<title>PyRadio Build Instructions</title>
<style type="text/css">
html {margin: 2em;}
h2 {margin-top: 2.5em; border-bottom:1px solid #D6D6D6;}
h3 {margin-top: 2em;}
h2 {margin-top: 2.5em; border-bottom:1px solid SaddleBrown; color: SaddleBrown;}
h3 {margin-top: 2em; color: SaddleBrown;}
h4 {margin-top: 2em; color: SaddleBrown;}
STRONG {color: SaddleBrown;}
dl {margin: 2em;}
dd {margin: 1em;}
dt {font-weight: bold;}
pre { background-color: #F6F6F6; padding: 1.5em; border: 1px solid #E6E6E6; overflow: auto;}
TABLE {border: 1px solid SaddleBrown;}
TH {text-align: left; color: SaddleBrown;border: 1px solid SaddleBrown;}
TD {text-align: left; padding-right: 8px;border: 1px solid SaddleBrown;}
pre { background-color: rgba(139, 69, 19, 0.80); color: #fff; padding: 1.5em; border: 1px solid #A87207; border-radius: 15px; overflow: auto;}
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
span.underline{text-decoration: underline;}
div.column{display: inline-block; vertical-align: top; width: 50%;}
</style>
a{ color: SaddleBrown;}
a:visited{color: SaddleBrown;}
</style>
</head>
<body>
<header>
</header>
<h1 id="pyradio-build-instructions">PyRadio Build Instructions</h1>
<h1 style="color: SaddleBrown"id="pyradio-build-instructions">PyRadio Build Instructions</h1>
<p><strong>PyRadio</strong>: Command line internet radio player.</p>
<p>Ben Dowling - <a target="_blank" href="https://github.com/coderholic" class="uri">https://github.com/coderholic</a></p>
<h2 id="table-of-contents">Table of contents <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></style></h2>
Expand Down
25 changes: 18 additions & 7 deletions devel/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# convert TABs to SPACEs in Changelog
sed -i 's/\t/ /g' Changelog
# Create HTML file from md files
for afile in README.md build.md windows.md
for afile in README.md build.md windows.md windows-mplayer.md
do
#[ -z "$(git status | grep ${afile})" ] || {
out=${afile/%.md/.html}
Expand All @@ -12,6 +12,8 @@ do
echo '% PyRadio Build Instructions' > tmp.md
elif [ "$afile" = "windows.md" ];then
echo '% PyRadio on Windows' > tmp.md
elif [ "$afile" = "windows-mplayer.md" ];then
echo '% MPlayer Installation on Windows' > tmp.md
fi
cat ${afile} >> tmp.md
pandoc -s -t html tmp.md -o ${out} || {
Expand All @@ -21,12 +23,17 @@ do
}
sed -i '/<style[^>]*>/a \
html {margin: 2em;} \
h2 {margin-top: 2.5em; border-bottom:1px solid #D6D6D6;} \
h3 {margin-top: 2em;} \
h2 {margin-top: 2.5em; border-bottom:1px solid SaddleBrown; color: SaddleBrown;} \
h3 {margin-top: 2em; color: SaddleBrown;} \
h4 {margin-top: 2em; color: SaddleBrown;} \
STRONG {color: SaddleBrown;} \
dl {margin: 2em;} \
dd {margin: 1em;} \
dt {font-weight: bold;} \
pre { background-color: #F6F6F6; padding: 1.5em; border: 1px solid #E6E6E6; overflow: auto;}' ${out}
TABLE {border: 1px solid SaddleBrown;} \
TH {text-align: left; color: SaddleBrown;border: 1px solid SaddleBrown;} \
TD {text-align: left; padding-right: 8px;border: 1px solid SaddleBrown;} \
pre { background-color: rgba(139, 69, 19, 0.80); color: #fff; padding: 1.5em; border: 1px solid #A87207; border-radius: 15px; overflow: auto;}' ${out}
sed -i -e 's/<code>//g' \
-e 's{</code>{{g' \
-e 's{<a href="#pyradio">pyradio</a>{[pyradio]{' \
Expand All @@ -37,10 +44,14 @@ do
-e 's/\.md">/.html">/g' \
-e '/h1 class="title"/d' \
-e 's/<a href="http/<a target="_blank" href="http/g' \
-e 's{</h2>{ <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></style>&{' ${out}
-e 's{</h2>{ <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></style>&{' \
-e 's|<.style>$|a{ color: SaddleBrown;}\na:visited{color: SaddleBrown;}\n</style>|' \
-e 's/<h1 /<h1 style="color: SaddleBrown"/' \
${out}
sed -i '/max-width/d' "${out}"
rm tmp.md
if [ "$out" = "windows.html" ];then
sed -i -e 's/h3 {margin-top: 2em;}/h3 {margin-top: 2.5em; border-bottom:1px solid #D6D6D6;}/' \
if [ "$out" = "windows.html" ] || [ "$out" = "windows-mplayer.html" ];then
sed -i -e 's/h3 {margin-top: 2em; color: SaddleBrown;}/h3 {margin-top: 2.5em; color: SaddleBrown; border-bottom:1px solid SaddleBrown;}/' \
-e 's{</h3>{ <span style="padding-left: 10px;"><sup style="font-size: 50%"><a href="#" title="Go to top of the page">Top</a></sup></style>&{' \
"$out"
fi
Expand Down
2 changes: 1 addition & 1 deletion pyradio/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# New stable version: ''
# Beta version: 'betax', x=1,2,3...
# RC version: 'RCx', x=1,23...
app_state = 'beta4'
app_state = 'beta5'

__version__ = version = '.'.join(map(str, version_info))
__project__ = __name__
Expand Down
9 changes: 9 additions & 0 deletions pyradio/config
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,15 @@ default_encoding = utf-8
# Default value: 10
connection_timeout = 10

# Force http connections
# Most radio stations use plain old http protocol to broadcast, but
# some of them use https. If this is enabled, all connections will
# use http; results depend on the combination of station/player.
#
# Valid values: True, true, False, false
# Default value: False
force_http = False

# Default theme
# Hardcooded themes:
# dark (default) (8 colors)
Expand Down
7 changes: 3 additions & 4 deletions pyradio/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1188,10 +1188,9 @@ def read_config(self):
if sp[1] == '':
return -2
if sp[0] == 'player':
if platform.startswith('win'):
self.opts['player'][1] = 'mplayer'
else:
self.opts['player'][1] = sp[1].lower().strip()
self.opts['player'][1] = sp[1].lower().strip()
if sys.platform.startswith('win'):
self.opts['player'][1] = self.opts['player'][1].replace('mpv,', '')
elif sp[0] == 'connection_timeout':
self.opts['connection_timeout'][1] = sp[1].strip()
# check integer number and set to 10 if error
Expand Down
22 changes: 9 additions & 13 deletions pyradio/config_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,10 @@ class PyRadioConfigWindow(object):
_num_of_help_lines = 0
_help_text = []
_help_text.append(None)
if platform.startswith('win'):
_help_text.append(['When running on Windows, PyRadio can only use mplayer as its player.', '|',
'Thus, this option is disabled.'])
else:
_help_text.append(['Specify the player to use with PyRadio, or the player detection order.', '|',
'This is the eqivelant to the -u , --use-player command line option.', '|',
'Example:', ' player = vlc', 'or', ' player = vlc,mpv, mplayer', '|',
'Default value: mpv,mplayer,vlc'])
_help_text.append(['Specify the player to use with PyRadio, or the player detection order.', '|',
'This is the eqivelant to the -u , --use-player command line option.', '|',
'Example:', ' player = vlc', 'or', ' player = vlc,mpv, mplayer', '|',
'Default value: mpv,mplayer,vlc'])
_help_text.append(['This is the playlist to open at start up, if none is specified.', '|',
'This is the equivalent to the -s , --stations command line option.', '|',
'Default value: stations'])
Expand Down Expand Up @@ -400,10 +396,7 @@ def keypress(self, char):
vals = list(self._config_options.items())
sel = vals[self.selection][0]
if sel == 'player':
if platform.startswith('win'):
return -1, []
else:
return self.n_u.SELECT_PLAYER_MODE, []
return self.n_u.SELECT_PLAYER_MODE, []
elif sel == 'default_encoding':
return self.n_u.SELECT_ENCODING_MODE, []
elif sel == 'theme':
Expand Down Expand Up @@ -438,7 +431,10 @@ class PyRadioSelectPlayer(object):

_win = None

_players = ( 'mpv', 'mplayer', 'vlc' )
if platform == 'win32':
_players = ( 'mplayer', 'vlc' )
else:
_players = ( 'mpv', 'mplayer', 'vlc' )
_working_players = [ [], [] ]

# REMINDER: column 1 is acive players - displayed right
Expand Down
26 changes: 26 additions & 0 deletions pyradio/del_vlc_log.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import os
from sys import platform

def RemoveWinVlcLogFiles(*args):
""" Removes all VLC log files within pyradio config
directory on Windows.
Files currently in use will not be deleted.
"""
if platform.startswith('win'):
adir = args[0]
#print('config = "{}"'.format(adir))
files = [file for file in os.listdir(adir) if 'vlc_log.' in file]
if files:
for afile in files:
#print(afile)
try:
#print('removing "{}"'.format(afile))
os.remove(os.path.join(adir, afile))
except:
pass

if __name__ == "__main__":
# example:
import threading
threading.Thread(target=RemoveWinVlcLogFiles('C:\\Users\\Spiros\\AppData\\Roaming\\pyradio')).start()
10 changes: 8 additions & 2 deletions pyradio/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@

PATTERN = '%(asctime)s - %(name)s - %(levelname)s - %(message)s'

IMPLEMENTED_PLAYERS =('mpv', 'mplayer', 'cvlc')
if platform.startswith('win'):
IMPLEMENTED_PLAYERS =('mplayer', 'cvlc')
else:
IMPLEMENTED_PLAYERS =('mpv', 'mplayer', 'cvlc')

@contextmanager
def pyradio_config_file():
Expand Down Expand Up @@ -182,7 +185,10 @@ def shell():

if args.debug:
__configureLogger()
print('Debug mode activated; printing messages to file: "~/pyradio.log"')
if platform.startswith('win'):
print('Debug mode activated\n printing messages to file: "{}\pyradio.log"'.format(getenv('USERPROFILE')))
else:
print('Debug mode activated; printing messages to file: "~/pyradio.log"')
else:
''' Refer to https://docs.python.org/3.7/howto/logging.html
section "What happens if no configuration is provided"
Expand Down
Loading

0 comments on commit b2121fe

Please sign in to comment.