Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #68512
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder7.xlned.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <jabba.laci@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.004 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'python.': 0.02; '"""': 0.07; 'args': 0.07; 'worked,': 0.09; 'cc:addr:python-list': 0.11; 'def': 0.12; 'cmd': 0.16; 'line)': 0.16; 'main():': 0.16; 'partly': 0.16; 'proc': 0.16; 'stdout': 0.16; 'url:8000': 0.16; 'command': 0.22; 'import': 0.22; 'cc:addr:python.org': 0.22; 'skip:{ 20': 0.24; '(or': 0.24; 'cc:2**0': 0.24; 'header:In-Reply- To:1': 0.27; 'external': 0.29; 'skip:g 30': 0.30; 'message- id:@mail.gmail.com': 0.30; 'url:non-standard http port': 0.33; 'subject:the': 0.34; 'subject:from': 0.34; 'could': 0.34; 'problem.': 0.35; 'something': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'hi,': 0.36; 'url:org': 0.36; 'how': 0.40; 'solve': 0.60; 'to:addr:gmail.com': 0.65; 'skip:r 40': 0.68; 'below.': 0.71; '============': 0.84; 'done;': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=NlflIhZeMgTBGBlvmrWpQRLafuSUwfw+8gajwcGDjm4=; b=q4M5n5+Iad8Ni3Xr+TXVhVHzHuHEdaOuP0z9fO9qsyw3+SrSB/CKe5sMgk4E90dcTO g3KbUH4aKirPrX6lrmZBpbr4Q2bF+3HMMLa81cW9/VTjic3jSEUd/81qAbyAMV2xAge9 txMmAY59zMYA6ZwEPzxy3Y1pXd9AHDeOUVIN07yAhabHBFz/AQJezqhqYc0zC2Gs0hFP U0o/jbYVaAD3TD0PbcXy7wddDj8etho5kxBZQWO9KXKX8EuE2sQ+w4yz7pL6GAzSXzwl NLusa4DEaj3Pn4yqmKixi65MWXCUwxk+AFfY9HdoWpTcclmxq/q6PmrWcRC3w6V0f+la /Qcg== |
| X-Received | by 10.182.33.35 with SMTP id o3mr25706224obi.15.1395165111350; Tue, 18 Mar 2014 10:51:51 -0700 (PDT) |
| MIME-Version | 1.0 |
| In-Reply-To | <CAPTjJmp7QYgW_6fsJ91-roGD-DwHD_s=s_HaD14SxvwrbiK9Aw@mail.gmail.com> |
| References | <CAOuJsM=ehKxRDmJ=2HXUCi6OZ8g0OBjQG87RQ+NWuCeBFKKedw@mail.gmail.com> <CAPTjJmp7QYgW_6fsJ91-roGD-DwHD_s=s_HaD14SxvwrbiK9Aw@mail.gmail.com> |
| From | Jabba Laci <jabba.laci@gmail.com> |
| Date | Tue, 18 Mar 2014 18:51:31 +0100 |
| Subject | Re: extract stream title from the output of mplayer |
| To | Chris Angelico <rosuav@gmail.com> |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Cc | Python mailing list <python-list@python.org> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.8256.1395165114.18130.python-list@python.org> (permalink) |
| Lines | 48 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1395165114 news.xs4all.nl 2975 [2001:888:2000:d::a6]:53933 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:68512 |
Show key headers only | View raw
> Python. (Or s/guess/hop/ if you prefer!) There are many ways this
> could be done; what have you tried, what partly worked, what did
> something unexpected?
Hi,
I managed to solve the problem. In the man of mplayer I found how to
quit after X seconds: "-endpos X". See my solution below.
Best,
Laszlo
============
import re
import shlex
from subprocess import PIPE, Popen
URL = 'http://relay2.slayradio.org:8000/'
def get_exitcode_stdout_stderr(cmd):
"""
Execute the external command and get its exitcode, stdout and stderr.
"""
args = shlex.split(cmd)
proc = Popen(args, stdout=PIPE, stderr=PIPE)
out, err = proc.communicate()
exitcode = proc.returncode
#
return exitcode, out, err
def get_title():
cmd = "mplayer -endpos 1 -ao null {url}".format(url=URL)
out = get_exitcode_stdout_stderr(cmd)[1]
for line in out.split("\n"):
# print(line)
if line.startswith('ICY Info:'):
match = re.search(r"StreamTitle='(.*)';StreamUrl=", line)
title = match.group(1)
return title
def main():
print(get_title())
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: extract stream title from the output of mplayer Jabba Laci <jabba.laci@gmail.com> - 2014-03-18 18:51 +0100
csiph-web