Author Topic: Windows (and Python) programming question  (Read 1164 times)

0 Members and 1 Guest are viewing this topic.

Offline Matamore!

  • Hero Member
  • *****
  • Posts: 4,118
    • View Profile
Windows (and Python) programming question
« on: April 02, 2014, 09:00:42 PM »
In the good old days of the BBC\'s RealAudio streams, I mainly used to listen to radio programmes by running a fairly short (but ugly) MS-DOS batch file, \'radio.bat\', which took as its three parameters: a channel number (e.g. \'7\' for BBC7); day of the week (e.g. \'fri\'); and time of day (e.g. \'2300\'). Using these, in a fairly obvious (but messy) way, it constructed a URL for the stream, and passed it as an argument to ReaPlayer (which could be run from the command line).

I found this method quick and convenient for everyday listening, but I always thought it would be neater (and more portable) to learn a scripting language like Python or Perl, and use that, instead of the horrible MS-DOS batch language.

Unfortunately, the BBC, in its infinitesimal wisdom, replaced the RA streams with WMA streams, and the only application I could persuade to play these on my somewhat buggered Windows 98SE system was Winamp, which did not seem to run from the command line, so I gave up the idea.

Now, under Windows XP, I find that the program XMPlay does everything I want, and it can be run manually from the command line, so my interest in the project has revived.

I could easily adapt my old batch file \'radio.bat\' to work with XMPlay instead of ReaPlayer, and the (\'Beebobodge\'-style) URLs for the new WMA streams in place of those for the old RA streams; but I would like instead to write a more elegant Python script (and incidentally to learn Python in the process).

(As well as being more elegant, a Python script would be much easier than a Windows batch file to extend cleanly so as to understand a more complex argument syntax, for instance to identify a weekly or daily broadcast from the first few characters of its name, and play it without requiring you, the user, to remember the time of day at which it is broadcast.)

My first very crude stab at writing such a script does work, but it has at least one awkward feature, which is that the Python interpreter waits for the command running XMPlay to terminate, before the Python script itself can terminate.

In contrast to that, I want to keep XMPlay running on the desktop (with its option to \"allow multiple instances\" disabled, so that there is always only one copy of it running), and keep a command window open, typing a new command every time I want to listen to a new programme.

I certainly don\'t want to keep having to terminate XMPlay after every programme, only to have to start it up again to listen to the next programme.

I\'ve looked at the online Python documentation (it doesn\'t seem to be a Python 3 versus Python 2 issue, by the way), and a couple of old Python books I have lying around, but I can\'t work out how to do what seems as if it should be a simple thing!

The version that leave the Python interpreter hanging, while I listen to the radio programme, uses either \'subprocess.call()\' or \'os.system()\' (they seem to be pretty much equivalent, with the former being preferred).

The available alternatives would seem to be:

(1) the Windows-specific \'startfile()\' (which doesn\'t seem to allow the passing of any arguments to the process);

(2) a pair of calls to \'os.fork()\' and \'os.exec()\', which looks rather technical and error-prone (at least in my inexperienced, Mickey Mouse, sorcerer\'s apprentice\'s hands!), and also seems to require the \'parent process\' still to wait around for the \'child process\' to finish, and then clean up after it (\'reaping\'), which rather defeats the object (and if you don\'t do it, you apparently risk unleashing \'zombie processes\', which doesn\'t sound good);

(3) something formally simpler, but apparently essentially identical, called \'os.spawnv(os.P_NOWAIT, ...)\'.

My head is spinning, I\'m becoming bad-tempered, and I\'ve stopped even trying to read about this stuff, so I forget some of the details, but my impression is that (2) or (3) doesn\'t even solve the problem, and risks creating further problems.

Among other things, you seem to have to pass your arguments as a tuple or a list (instead of a simple string of characters, which is all I want to pass), and you even seem to have to pass the program name twice, the second time as the first item in the list or tuple. I may have got that wrong, but I just lost heart for trying to make sense of it.

I really hope I don\'t have to go back to using the wretched Windows batch language! Surely Python must provide some simple way of doing this simple thing? Have I just failed to notice it in the documentation, or is it that what I am trying to do only seems to be simple, but is in fact conceptually incoherent?

(The fact that it is perfectly possible to do it manually, and it is also perfectly possible to do it using a Windows batch file, suggests that it is not incoherent, and it is simple. So it\'s probably just my unfamiliarity with Python, and my general lack of programming experience, that\'s the problem.)

Offline Truthyness

  • Administrator
  • Hero Member
  • *****
  • Posts: 8,309
    • View Profile
Re: Windows (and Python) programming question
« Reply #1 on: April 02, 2014, 11:30:16 PM »
Erm:S wouldn\'t want to wreck the party Mat, but aren\'t Bill Gates and consorts distributing parachutes and/or cyanide pills to XP users ahead of April 8th, cut off point at which \"support\" (the liberties these folk take with the language!) for the OS ceases and Vogons sweep down to annihilate Earthlings? All XP users will die of bugs and viruses while the NSA steals their electronic wallets and identities.

Microsoft\'s wrist lock pass is intended to force the uptake of new systems and software. Already, legions spit upon Windows 8 regretting Windows 7 which is no longer on sale.

Turns out that, for once the timing of this latest MS wheeze fits my plan. Whether the threats turn out to be true or not our system was due to for euthanasia round about now so a new one was foreseen.

And my point is do you want to invest time and effort on this exercise, if you\'ll likely not be using XP much longer?

A commitment to Mod\'nAdminlyness: I understand that  r-e-s-i-s-t-a-n-c-e  *i - s*    f-u-t-i-l-e.
I shall not be starc

Offline Matamore!

  • Hero Member
  • *****
  • Posts: 4,118
    • View Profile
Re: Windows (and Python) programming question
« Reply #2 on: April 03, 2014, 12:15:19 AM »
[sidetrack]

(1) The question wasn\'t specific to XP, and it would be the same for Windows 7 - or even 98SE.

(The only thing that stops me \'backporting\' the arrangement with XMPlay to 98SE - which I\'m still using, in a dual-boot configuration, and where I also have a version of Python installed - is that I would first have to fix the severely buggered WMA codecs, and, although the makers of XMPlay supply a codecs package, possibly from Microsoft, which might do the job, I\'m afraid that if it isn\'t compatible with Win98SE, I might have to reinstall that OS, which would surely wreck the dual-boot setup, and I\'d have to reinstall XP as well. I try to do as little as possible with 98SE now, for fear of upsetting it.)

(2) If, as you\'re suggesting, I\'m in a bad fix with XP, I\'ve probably been in a worse fix using 98SE for so many years!

(3) Although M$ aren\'t going to be bringing out any new security updates, they are going to continue supplying all the updates for XP that have already been brought out, so for instance it will still be possible to reinstall XP if something goes wrong.

I had been worried that M$ might be intending to be so irresponsible as not even to continue providing this level of service, but the following article is quite reassuring on this point:

When Windows XP support ends, this is how you secure your PC and save all updates | Expert Reviews:

(1) It\'s worth repeating the main point, which is that my question as to how to use Python to launch XMPlay has nothing to do with XP in particular! I only mentioned XP because it is not Win98SE, and because on Win98SE I was prevented from trying to do anything like what I\'m trying to do now because I had a very specific problem with WMA codecs not working, and I was forced to use Winamp, which I couldn\'t run from the command line (not even using an MS-DOS batch file, never mind Python).

(1) I repeat again, this has nothing to do with XP in particular! It\'s a general question about all versions of Windows.

(1) Have I repeated that often enough yet? ;)

[/sidetrack]

Offline Truthyness

  • Administrator
  • Hero Member
  • *****
  • Posts: 8,309
    • View Profile
Re: Windows (and Python) programming question
« Reply #3 on: April 03, 2014, 12:53:39 AM »
I don\'t doubt your repetitions M (rather like schedules at the BBC eh!) Just a general warning that the NSA will be watching you and all other retrogrades who don\'t bite the Microsoft bullet!

There was never this fuss when W98 was \"replaced\" was there! The whiff of a wheeze is strong! Still they say hackers are more refined these days and thus better equipped to raid systems and gobble them up! There\'s a hint of the Y2K heist about all this isn\'t there?

Those in the know do seem to agree MS will continue providing XP essentials for another year yet.

Wonderful to learn your elegant language-in-the-making will work on the W7 OS too, though officially, that is being phased out as well -already it is no longer available from MS- 8-) but doubtless that isn\'t relevant to your current exercise either.

A commitment to Mod\'nAdminlyness: I understand that  r-e-s-i-s-t-a-n-c-e  *i - s*    f-u-t-i-l-e.
I shall not be starc

Offline Matamore!

  • Hero Member
  • *****
  • Posts: 4,118
    • View Profile
Re: Windows (and Python) programming question
« Reply #4 on: April 03, 2014, 05:00:15 AM »
Truthyness Wrote:
-------------------------------------------------------
> Just a general warning that the NSA will be watching you and all other
> retrogrades who don\'t bite the Microsoft bullet!

Now, there\'s a thought:

Oi, NSA! How do you execute a Windows command from within a Python script without having to wait for it to finish?

Offline Matamore!

  • Hero Member
  • *****
  • Posts: 4,118
    • View Profile
Re: Windows (and Python) programming question
« Reply #5 on: April 03, 2014, 05:43:37 AM »
There may be a workaound.

However, not only is it specific to Windows, it also depends on something XMPlay can do that other audio players may not be able to do.

Perhaps I shouldn\'t expect there to be a general solution, because it is only in virtue of the known behaviour of XMPlay that it even makes sense to call it from the command line and not wait for the execution of the command to terminate? That may just not be a sensible thing to want to do in general.

Anyway, the idea is to use this option (from the documentation file, xmplay.txt):

Code: [Select]

Monitor the clipboard URLs:
    XMPlay can monitor the clipboard for URLs of playable files, which
    it will automatically play or add to the playlist. When you see a
    playable file on a webpage, simply right-click and \"Copy Shortcut\"
    to have XMPlay stream it.


and then do this in Python [edited slightly for Python 3, and of course needs some more editing]:

How do I copy a string to the clipboard on Windows using Python? - Stack Overflow

Code: [Select]

from tkinter import Tk
r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(\'i can has clipboardz?\')
r.destroy()


I\'ve never done any GUI programming, and I\'m not about to start trying in the middle of the night (bound to go wrong), but it doesn\'t look too terrifying as something to try doing tomorrow.

Still, I bet when I do try to do it, my computer will misinterpret the last line, and try to
Code: [Select]

destroy all humans!

How do you program Asimov\'s laws in Python?

Offline Forget_It

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
Re: Windows (and Python) programming question
« Reply #6 on: April 03, 2014, 08:04:13 AM »
I\'ve been scripting with Python on Windows (w2k,xp,win7) to download BBC Radio files wma for several years and I\'ll share my system with you guys if you like.

In brief:

I use the last free version of Net Transport (v1.87, from 2004)
Each day my python script (always running in the background) wakes up at, say, 06.00 am and overwrites the
Net Transport\'s schedule file for that day, then re/launches Net Transport - which automatically goes and get the files (usually 10 to 20 in number).
I pre-set Net Transport so it downloads two files at once but uses 6 separate threads for each file - so it all works faster than real-time listening.
The schedule file is in a horrid binary format and python is handy for generating that format for the day in question given a textfile that consists of line-by-line addresses like:

mms://wm.bbc.co.uk/wms/radio4fmcoyopa/radio_4_fm_-_monday_0945.wma
mms://wm.bbc.co.uk/wms/radio4fmcoyopa/radio_4_fm_-_monday_1045.wma
mms://wm.bbc.co.uk/wms/radio4fmcoyopa/radio_4_fm_-_monday_1130.wma

i.e. the format you can manually insert into Net Transport any time of the day.

I\'m ever in fear of  the BBC cancelling these kinds of url for a DRMed approach.
Crossing fingers forever!


I\'ll share and enjoy my scripts if any one shows interest.
But I\'ve not time to support/maintain it to all comers.

Offline Matamore!

  • Hero Member
  • *****
  • Posts: 4,118
    • View Profile
Re: Windows (and Python) programming question
« Reply #7 on: April 03, 2014, 01:04:52 PM »
Now that I\'ve got Win98SE out of my hair, it\'s about time that I installed a downloader, instead of relying on Jan or whoever to  have already happened to have downloaded some programme or other that I have missed! And I might consider changing my way of listening to radio programmes as a result, first downloading them in batches and then listening to them at leisure.

But, knowing myself and my bad ways, I fear I would end up with hundreds of unlistened-to programmes! I have over 500 VHS tapes full of unwatched TV programmes, some of which I\'m only now getting round to watching after recording them in 2007, or 2004, or even 2001.

The two problems are probably complementary (unless I\'ve misunderstood your description).

The script I want to write would generate URLs in that \'coyopa\' format (which I also live in dread of the BBC ceasing to use!), and could easily be adapted to produce a text file of the kind which your script seems to use to generate a binary schedule file for Net Transport.

But before getting into that (or getting into using a downloader at all), I want to automate part of my present routine of radio listening, which is to pick a programme almost ad hoc, with no system at all (although of course there has to be an overall movement forward in time!), and listen to it, usually by means of the Beebotron\'s \"What Was On\" pages, although in the days of RealAudio streams I found it quicker and more convenient to use an MS-DOS batch file to generate the URL.

I do have an elaborate but only semi-formal system for listing the programmes I\'m interested in. It\'s a real mess, would make little sense to anybody else, and certainly fails to make total sense even to me, so I\'ll just list a little bit of it, to give the flavour:

Code: [Select]

* wanted
- either not wanted, or not broadcast
? not sure
. heard
/ missed (not sure if it always meant this)
X didn\'t bother

[Mon--Sun] 6 Music  03:00-04:00  [6 Music Live Hour]-.----*|**-***?|
[Mon--Fri] Radio 3  09:00-12:00  [Essential Classics]
[Mon--Fri] Radio 4  09:45-10:00  [Book of the Week]
[Mon--Fri] Radio 3  10:30-11:00  [Essential Classics - guest]
[Mon--Fri] Radio 4  10:45-11:00  [15 Minute Drama]
[Mon--Fri] Radio 3  12:00-13:00  [Composer of the Week]
[Mon--Fri] Radio 3  13:00-14:00  [Radio 3 Lunchtime Concert]
[Mon--Fri] Radio 4  13:45-14:00  Five Hundred Years of Friendship|*****--|*****--|?
[Mon--Fri] Radio 3  14:00-16:30  [Afternoon on 3]
[Mon--Fri] Radio 4  14:15-15:00  [Afternoon Drama]|--*----|
[Mon--Fri] 4 Extra  14:45-15:00  [Radio 4 Extra Book of the Week]
[Mon--Thu] 4 Extra  18:00-18:15  LP Hartley: Short Stories|****----|
[Mon--Fri] 4 Extra  18:15-18:30  Elspeth Davie - A Collection of Bones|*****---|
[Mon--Fri] Radio 4  19:15-19:45  [Front Row]
[Mon--Fri] Radio 3  19:30-22:00  [Radio 3 Live in Concert]
[Mon--Fri] Radio 3  20:xx-20:yy  [Twenty Minutes]
[Mon--Thu] Radio 3  22:00-22:45  [Night Waves]
[Mon--Fri] Radio 3  22:00-22:45  [Free Thinking]
[Mon--Fri] Radio 3  22:45-23:00  [The Essay]
[Mon--Fri] Radio 4  22:45-23:00  [Book at Bedtime]
[Tue--Thu] Radio 3  23:00-24:30  [Late Junction]

Monday     4 Extra  07:00-07:30  Stiff Upper Lip, Jeeves
Monday     Radio 4  11:00-11:30  [various programmes]
Monday     4 Extra  11:15-12:00  [Loose Ends (first of three repeats)]
Monday     Radio 4  15:30-16:00  [The Food Programme]
Monday     Radio 4  16:00-16:30  [various programmes]
Monday     Radio 4  16:30-17:00  [Beyond Belief]
Monday     Radio 4  18:30-19:00  Just a Minute
Monday     Radio 4  18:30-19:00  (The Unbelievable Truth)
Monday     Deli Ag  19:00-21:00  [Stainless Steel Prog]
Monday     Radio 4  20:00-20:30  [various programmes]
Monday     Deli Ag  20:00-23:00??[Sonic Kaleidoscope]
Monday     4 Extra  23:00-23:45  News Quiz Extra
Monday     4 Extra  23:45-24:00  Hamish and Dougal: You\'ll Have Had Your Tea

Tuesday    4 Extra  08:00-08:30  The Goon Show
Tuesday    4 Extra  08:30-09:00  Flywheel, Shyster and Flywheel
Tuesday    Radio 4  09:00-09:30  The Life Scientific
Tuesday    Radio 4  11:00-11:30  [various programmes]
Tuesday    4 Extra  11:15-12:00  
Tuesday    Radio 4  11:30-12:00  [Soul Music]
Tuesday    Radio 4  11:30-12:00  [various programmes]
Tuesday    Radio 4  16:30-17:00  [A Good Read]
Tuesday    Deli Ag  16:00-19:00!![The Rickter Scale]
Tuesday    Radio 4  20:00-20:40  [File on 4]
Tuesday    Radio 2  22:00-23:00  
Tuesday    4 Extra  23:45-24:00  All the World\'s a Globe


As you can probably see, some bits of it are wildly out of date, and even if it were kept religiously up to date, it would still not be suitable as input to a program.

I was going to devise a new, simple, and completely formal system for listing daily or weekly broadcasts, in two text files which would be used by the Python script.

In case anyone else want to try using the same script, I was going to solicit suggestions for the format of these files, and the format of arguments passed to the script.

I would probably continue to use my present semi-formal system, but supplement it by using it as a basis for producing the formal text files to be used by the Python script.

I wasn\'t going to talk about this yet, because it makes things look more complicated than they are eventually going to be.

First, I just wanted to get an extremely simple prototype script actually working, and I haven\'t even done that yet!

Just woken up, after a badly disturbed night\'s sleep.  Will probably try that \'tkinter\' trick with the clipboard today (unless warned that it\'s a bad idea).

Offline Matamore!

  • Hero Member
  • *****
  • Posts: 4,118
    • View Profile
Re: Windows (and Python) programming question
« Reply #8 on: April 03, 2014, 02:42:29 PM »
What do you know, it works ... :)

In outline, then (and for a Windows system only):

1. Download xmplay38.zip (or whatever the latest version is) from .

2. Unzip its contents into any convenient folder.

(No installation is required. However, you can if you wish associate XMPlay with file types of your choice. I have it set to play PLS files, so that it can substitute for Winamp.)

3. Run xmplay.exe, and, in an admin account, disable the option to \"Allow multiple instances\" (under \"Miscellaneous\" ).

4. Enable the option \"Monitor clipboard for URLs\" (under \"Integration\" ).

(I think if you want this to become the default, you have to enable it in an admin account, but you can do it in a limited account for one run at a time.)

5. Run any Python script which creates the URL for a WMA stream, or indeed, any kind of URL which XMPlay can handle, such as a PLS file - I\'ll call it \'bbc_wma_url\', for purposes of illustration - and which executes some code like this:

Code: [Select]

from tkinter import Tk

[... Python code to assemble value of bbc_wma_url as string of characters ...]

r = Tk()
r.withdraw()
r.clipboard_clear()
r.clipboard_append(bbc_wma_url)
r.destroy()


6. Enjoy The Hitchhiker\'s Guide to The Galaxy, or whatever else takes your fancy! :)

Offline ricklous

  • Administrator
  • Sr. Member
  • *****
  • Posts: 322
    • View Profile
Re: Windows (and Python) programming question
« Reply #9 on: April 04, 2014, 09:17:06 PM »
Slightly off-topic.
What\'s the reason for using old OS\'es?

Offline Matamore!

  • Hero Member
  • *****
  • Posts: 4,118
    • View Profile
Re: Windows (and Python) programming question
« Reply #10 on: April 04, 2014, 09:43:04 PM »
Old PC.
Lack of money.
Lack of energy and confidence for getting to grips with new technology. (Still ill-at-ease even handling DVDs!)
Aversion to all things Microsoft (didn\'t even want to use XP), but particular lack of confidence that I could manage Linux.
Probably several other reasons.

Offline Matamore!

  • Hero Member
  • *****
  • Posts: 4,118
    • View Profile
Re: Windows (and Python) programming question
« Reply #11 on: April 04, 2014, 09:56:06 PM »
On the main topic:

I think what was most fundamentally wrong with my approach was that I was trying to use Python as if it could be a substitute for the Windows command shell. It would probably be healthier to use a batch file to run XMPlay, and call the Python interpreter just to process the arguments and convert them into a URL (which could perhaps be passed to XMPlay as a temporary text file). I have a book with a chapter on the Windows Script Host, so I\'ll look into that as well.

Meanwhile, I\'ve just gone back to using a version of my crude old batch file, which I\'ve tidied up a bit. (What follows has not been tested much yet, but it seems to basically work. I\'ve edited it some more since last using it - I\'m listening to a long radio programme at the moment, and don\'t want to interrupt it - if there\'s some awful error in the code, I\'ll come back later and edit it.)

[I have done so, because the code for playing the \'A\' stream instead of the \'B\' stream had just been inserted while I was listening to that programme, and so it had never been tested at all - and it didn\'t work at all! But it seems OK now.]

Code: [Select]

@echo off
REM
REM E:\\Arya\\Command\\radio.bat
REM
REM Play BBC radio streaming audio file
REM
REM Matamore!
REM
REM Sat 11 Oct 2008  (created)
REM Fri 26 Dec 2008  (changed - to take account of changed syntax of URLs)
REM Sun 28 Dec 2008  (corrected)
REM Fri  4 Apr 2014  (adapted for (1) WMA streams, (2) 4 Extra, (3) WinXP)
REM Fri  4 Apr 2014  (first parameter is now one of 2, 3, 4, 4x, 6)
REM
REM Examples of use:
REM
REM   radio                Play Delicious Agony Progressive Rock Radio
REM   radio 3              Play Radio 3 live
REM   radio 6              Play 6 Music live
REM   radio 4 thu 0900     Play Radio 4 from last Thursday at 09:00
REM   radio 4x sun 2345    Play Radio 4 Extra from last Sunday at 23:45
REM   radio 2 tue 2200 a   Play Radio 2 Tuesday 22:00, using \'A\' stream
REM
REM (Parameter error checking is only rudimentary.)

set play=\"I:\\NoInstal\\XMPlay\\xmplay.exe\"
REM From .

set Prog=http://208.53.158.48:9564/listen.pls
REM == Delicious Agony Progressive Rock Radio

if \"%1\"==\"\" (
   %play% %Prog%
   goto :eof
   )

set live=http://bbc.co.uk/radio/listen/live/r
REM BBC listen live.

if \"%2\"==\"\" (
   %play% %live%%1.asx
   goto :eof
   )

if \"%3\"==\"\" (
   echo You didn\'t specify when the programme started!
   goto :eof
   )

set Bstr=http://wm.bbc.co.uk/wms/
REM BBC Listen Again, \'B\' stream (usually works better for me).
set Astr=http://wm-acl.bbc.co.uk/wms/
REM BBC Listen Again, \'A\' stream, supposed to work best in UK!

if \"%4\"==\"\" (
   set Beeb=%Bstr%
   ) else (
   set Beeb=%Astr%
   )

set fudge=radio%1
set hack=radio_%1

if %1==4x set hack=radio_4_extra

if %1==4 (
   set fudge=radio4fm
   set hack=radio_4_fm
   )

if %1==6 (
   set fudge=6music
   set hack=6music
   )

set filler=
if %2==tue set filler=s
if %2==wed set filler=nes
if %2==thu set filler=rs
if %2==sat set filler=ur

set URL=%Beeb%%fudge%coyopa/%hack%_-_%2%filler%day_%3.wma
%play% %URL%

REM end radio.bat

Offline Matamore!

  • Hero Member
  • *****
  • Posts: 4,118
    • View Profile
Re: Windows (and Python) programming question
« Reply #12 on: April 05, 2014, 09:30:47 PM »
Just in case anyone else is thinking of using this batch file with XMPlay (while the BBC\'s present file naming conventions last!):

Code: [Select]

[... as before ...]
REM Sat  5 Apr 2014  (minor reorganisation of code; added warning comment)
[... as before ...]
REM IMPORTANT: Ensure that XMPlay is already running before executing
REM this command, otherwise execution will not terminate until XMPlay
REM itself is terminated.

set Prog=http://208.53.158.48:9564/listen.pls
REM == Delicious Agony Progressive Rock Radio

if \"%1\"==\"\" (
   set URL=%Prog%
   goto play_URL
   )

set live=http://bbc.co.uk/radio/listen/live/r
REM BBC listen live.

if \"%2\"==\"\" (
   set URL=%live%%1.asx
   goto play_URL
   )

[... as before ...]

set URL=%Beeb%%fudge%coyopa/%hack%_-_%2%filler%day_%3.wma

:play_URL
set play=\"I:\\NoInstal\\XMPlay\\xmplay.exe\"
%play% %URL%

REM end radio.bat


and of course, the value of the \'play\' variable has to be replaced by the location you have chosen for XMPlay on your system - and even more obviously, the variable \'Prog\' is to be replaced by whatever other radio station you want to listen to by default.

Offline Forget_It

  • Jr. Member
  • **
  • Posts: 78
    • View Profile
Re: Windows (and Python) programming question
« Reply #13 on: April 06, 2014, 09:58:22 AM »
Matamore wrote:
Quote
The script I want to write would generate URLs in that \'coyopa\' format


I\'ve found in some exceptional circumstances (following rescheduling of programmes,
e.g. due to Death of Mandela, or accidently playing te wrong episode of BookAtBedtime)
generated names of programmes the next day/week can contain unexpected start-times
- that you can only discover by visiting the iPlayer and snooping the html for that programme.

So if you rely on a 100% automated script - you might occassionally miss odd episodes.

good luck

Offline Matamore!

  • Hero Member
  • *****
  • Posts: 4,118
    • View Profile
Re: Windows (and Python) programming question
« Reply #14 on: April 06, 2014, 11:35:35 AM »
If it fails, of course I can fall back on the Beebotron, or even (shudder) the iPlayer. The only thing that\'s automated is the tedium of generating URLs; otherwise, my listening is spontaneous, except for being forced to listen to programmes when they are just about to fall victim to the 7-day limit.

I get an overview of what\'s on from a combination of DigiGuide and the Beebotron. I condense it down into my semi-formal schedule, containing only programmes I\'m interested in, which can be surveyed in seconds. (This Heath Robinson contrivance is too crazy and rickety to explain in detail, but it contains weeks\' worth of information in a plain text file of about 140 lines.)

It all works very well, so long as the Beeb don\'t change their system!







(I miss the Address Bar - removed from the XP taskbar after SP3, for silly reasons - but the batch file works very well in conjunction with the Run prompt on the Start menu, providing a kind of drop-down menu, with auto-completion and editing of programme days and times. I\'m starting to remember how convenient it all used to be. Of course, the folder containing the batch file has to be added to the system path, so that all you need to type is \'radio\', followed by any parameters needed.)



Added Grumpy Old Man rant:

I view my condensed schedule in a text editor. I always have a multi-tab text editor open all the time on any computer that I\'m using. I don\'t understand how anyone manages to use a computer, without going mad, without using a text editor. Not M$ Notepad, of course - that\'s handy for small one-off jobs (such as editing files of saved Beebotron posts), but lousy for almost everything else - I use Notepad++ , and on Win98SE (and Win95) I used PFE32. (On Unix at college, I used XEmacs, in a very limited way - never even tried to get to grips with all the things it could do.) Yet most people don\'t even seem to know what a text editor is! They use clunky unreliable ugly monstrosities like M$ Word even for writing simple little notes. Mad, quite mad! I don\'t use a word processor at all - I always have MiKTeX running, to use for any text processing task that requires \'typesetting\'. (I hardly ever print anything, but I like things to be readable on the screen. Using MiKTeX or some other version of LaTeX is virtually essential if you have mathematical symbols to deal with, but it\'s great even if you don\'t.)