Compare commits
No commits in common. "f45f25dd9d2fbbb5cea42e29735c1842237ebd09" and "970bb33b46702bafe8a9b3340688883a8c8f6c1a" have entirely different histories.
f45f25dd9d
...
970bb33b46
1
.gitignore
vendored
1
.gitignore
vendored
@ -124,7 +124,6 @@ celerybeat.pid
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
.envrc
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
|
11
README.txt
11
README.txt
@ -19,15 +19,10 @@ the sample scripts are described in the examples/README
|
||||
a small set of samples are provided. all of them make use of the module
|
||||
pywmgeneral.
|
||||
|
||||
[REQUIREMENTS DEBIAN/UBUNTU]
|
||||
apt-get install mplayer python3-setuptools libx11-dev libxpm-dev libxext-dev
|
||||
|
||||
[INSTALLATION]
|
||||
sudo python ./setup install
|
||||
python ./setup install
|
||||
|
||||
[CONTACT]
|
||||
This project was originally started as as a Python 2 application. By Mario
|
||||
Fransca <mfrasca@interia.pl>. I thank him for all the hard work.
|
||||
Anything related to this piece of software can be e-mailed to me, Mario
|
||||
Frasca <mfrasca@interia.pl>.
|
||||
|
||||
The project has been ported to Python 3 and now maintained by Fredrick
|
||||
Warren <fwarren@fastmail.com>
|
||||
|
@ -2,20 +2,14 @@
|
||||
|
||||
"""pywmnop.py
|
||||
|
||||
WindowMaker dockapp internet radio player
|
||||
WindowMaker dockapp doing nothing
|
||||
|
||||
Copyright (C) 2006 Mario Frasca
|
||||
|
||||
Licensed under the GNU General Public License.
|
||||
"""
|
||||
|
||||
from codecs import open
|
||||
from fcntl import fcntl, F_GETFL, F_SETFL
|
||||
from os import environ, sep, O_NONBLOCK
|
||||
from re import compile
|
||||
from select import select
|
||||
from signal import signal, SIGCHLD
|
||||
from subprocess import Popen, DEVNULL, PIPE
|
||||
import sys, time
|
||||
from wmdocklib import wmoo as wmoo
|
||||
|
||||
class Application(wmoo.Application):
|
||||
@ -39,12 +33,16 @@ class Application(wmoo.Application):
|
||||
self.reset()
|
||||
|
||||
self._buffered = ''
|
||||
self._feedback = compile(r'.+A:.*?% ([0-9\.]+)%')
|
||||
import re
|
||||
self._feedback = re.compile(r'.+A:.*?% ([0-9\.]+)%')
|
||||
|
||||
configfile = sep.join([environ['HOME'], '.pyradiorc'])
|
||||
import fileinput, os
|
||||
configfile = os.sep.join([os.environ['HOME'], '.pyradiorc'])
|
||||
|
||||
with open(configfile, 'r', 'utf-8') as f:
|
||||
t = f.read()
|
||||
import codecs
|
||||
f = codecs.open(configfile, 'r', 'utf-8')
|
||||
t = f.read()
|
||||
f.close()
|
||||
for i in t.split(u'\n'):
|
||||
radiodef = i.split('\t')
|
||||
radioname = radiodef[0].lower()
|
||||
@ -59,6 +57,7 @@ class Application(wmoo.Application):
|
||||
|
||||
def handler(self, num, frame):
|
||||
if self._expectdying:
|
||||
print(self._expectdying)
|
||||
self._expectdying -= 1
|
||||
else:
|
||||
self.reset()
|
||||
@ -66,41 +65,37 @@ class Application(wmoo.Application):
|
||||
self._colour = 1
|
||||
|
||||
def startPlayer(self):
|
||||
import os, subprocess, signal
|
||||
commandline = [mplayer,
|
||||
'-cache',
|
||||
str(abs(int(self.radioList[self.currentRadio][2]))),
|
||||
'-cache', self.radioList[self.currentRadio][2],
|
||||
self.radioList[self.currentRadio][1]
|
||||
]
|
||||
# if cache is negative then this is a playlist
|
||||
if int(self.radioList[self.currentRadio][2]) < 0:
|
||||
commandline.insert(2, '-playlist')
|
||||
self.child = Popen(commandline,
|
||||
stdin =PIPE,
|
||||
stdout=PIPE,
|
||||
stderr=DEVNULL)
|
||||
signal(SIGCHLD, self.handler)
|
||||
self.child = subprocess.Popen(commandline,
|
||||
stdin =subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.DEVNULL)
|
||||
signal.signal(signal.SIGCHLD, self.handler)
|
||||
self._flash = 0
|
||||
self._paused = False
|
||||
self._buffered = ''
|
||||
self._buffering = 1
|
||||
self._cacheLevel = 0
|
||||
flags = fcntl(self.child.stdout, F_GETFL)
|
||||
fcntl(self.child.stdout, F_SETFL, flags | O_NONBLOCK)
|
||||
flags = fcntl(self.child.stdin, F_GETFL)
|
||||
fcntl(self.child.stdin, F_SETFL, flags | O_NONBLOCK)
|
||||
import fcntl
|
||||
flags = fcntl.fcntl(self.child.stdout, fcntl.F_GETFL)
|
||||
fcntl.fcntl(self.child.stdout, fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
||||
flags = fcntl.fcntl(self.child.stdin, fcntl.F_GETFL)
|
||||
fcntl.fcntl(self.child.stdin, fcntl.F_SETFL, flags | os.O_NONBLOCK)
|
||||
|
||||
def stopPlayer(self):
|
||||
if self.child:
|
||||
# print(self._expectdying)
|
||||
print(self._expectdying)
|
||||
self.child.stdin.write(b'q')
|
||||
self.child.stdin.flush()
|
||||
self._expectdying += 1
|
||||
self.child = None
|
||||
|
||||
def muteStream(self, event):
|
||||
if self.child and self._buffering == 0:
|
||||
self.child.stdin.write(b'm')
|
||||
self.child.stdin.flush()
|
||||
self.putPattern(9*self._muting, 0, 9, 11, 30, 29)
|
||||
self._muting = 1 - self._muting
|
||||
|
||||
@ -133,7 +128,6 @@ class Application(wmoo.Application):
|
||||
def pauseStream(self, event):
|
||||
if self.child and not self._buffering:
|
||||
self.child.stdin.write(b' ')
|
||||
self.child.stdin.flush()
|
||||
self._paused = not self._paused
|
||||
if self._paused:
|
||||
self._colour = 1
|
||||
@ -169,7 +163,8 @@ class Application(wmoo.Application):
|
||||
return
|
||||
self._count = 0
|
||||
if self.child:
|
||||
[i, o, e] = select([self.child.stdout], [], [], 0)
|
||||
import select
|
||||
[i, o, e] = select.select([self.child.stdout], [], [], 0)
|
||||
if i:
|
||||
line = self.child.stdout.read(102400).decode("utf-8")
|
||||
self._buffered += line
|
||||
|
@ -16,10 +16,3 @@ bbcws rtsp://rmlive.bbc.co.uk/bbc-rbs/rmlive/ev7/live24/worldservice/liveinfent.
|
||||
bbc3 rtsp://rmlive.bbc.co.uk/bbc-rbs/rmlive/ev7/live24/radio3/live/r3_dsat_g2.ra 256
|
||||
bbc4 rtsp://rmlive.bbc.co.uk/bbc-rbs/rmlive/ev7/live24/radio4/live/r4_dsat_g2.ra 256
|
||||
|
||||
# lines starting with # is ignored OR
|
||||
# lines without exactly two tabs \t in it is ignored
|
||||
# lines with \t<variable>\t<value> becomes a global variable
|
||||
# lines with <name>\t<url>\t<bytes-cached> become a station
|
||||
# <bytes-cached> must be 32 or larger
|
||||
# positve <bytes-cached> ( 32) are stream urls
|
||||
# negative <bytes-cached> (-32) are playlist urls
|
||||
|
Loading…
Reference in New Issue
Block a user