On Wednesday, 27 August 2014 01:21:32 UTC+1, Chris Angelico wrote: > On Wed, Aug 27, 2014 at 10:08 AM, Twirlip2 wrote: > > On Wednesday, 27 August 2014 01:04:18 UTC+1, Steven D'Aprano wrote: > >> Twirlip2 wrote: > >> > > >> > Since I require Python in order to listen to my beloved radio > >> > programmes reliably (don't get me started on the subject of the > >> > thrice-accursed BBC website!), I therefore have IDLE running all the > >> > time, very probably sometimes for weeks on end. > > >> Well, don't keep us in suspenders, tell us what you use! > > > Sorry, I don't understand. [...] > > [...] But > the rest of the question is serious. What is it you do with Idle that > lets you listen to the radio reliably? I'm guessing this is streamed > over the internet and you're getting around some stupid limitation, > but I second Steven's request that you share your tricks!
I'm happy to oblige, but: (1) it's past my bedtime, so I'll have to be brief; (2) the background, concerning the BBC's "Listen Again" facility, is quite complicated; and (3) my present Python code is simply awful (it was my first serious Python program, apart from a few short mathematical routines for computing values of some complex analytic functions), which is why, during the last week or so, I've been dipping into Chun's book on Python, reading through Bertrand Meyer's 'Object-Oriented Software Construction' (2nd ed. 1997), and trying to reorganised my awful code into classes and smaller modules, so that I can begin to rewrite it in a more robust way (i.e. (a) it will work more robustly, and (b) it also won't fall apart as soon as I try to change it). So, please give me a few weeks to improve my code, before posting it. (I recently came across somewhere on the Web where you can post code, but I forget where.) As for the background: All I used to need to use was a simple Windows batch file (of course, a simple Python script would have been better, but there was no real need for it) which called XMPlay with some WMA audio stream URLs, which were easily calculable from the day of the week and the time of day at which the desired programme was transmitted. But a few months ago, the BBC, in their wisdom, changed all that, in such a way that it is now logically impossible to calculate the WMA audio stream URLs from any information available to anyone except a BBC technical insider. A more sophisticated approach therefore became necessary. At the Beebotron, where I post under the pseudonym 'Matamore!' (named after a deluded grandiose lunatic, if you must know!), there was a very long and convoluted discussion about the problem. Here is the thread (but you won't thank me for pointing you to something so rambling!): <http://beebotron.org/phorum/read.php?5,57006> "No international streams after 9:30am 01-May-2014" I followed some of the suggestions made in that thread, by people more knowledgeable than myself, and set about using Python to automate the manual procedures they described. I just hacked the code together [in one of the two pejorative senses of the verb "to hack"!] - in a single module, with dozens of global variables, precious little error-checking, and an idiotic dependence on the BBC not changing any detail of their website (in spite of the fact that they muck about with it regularly!). Still, the code works, well enough that I can rely on it for my daily fix of radio. It would probably even work for anyone else who tried it (on Windows, Linux, or just about any other OS). It's a mess, but it does at least keep local dependencies in a configuration file. (I had no trouble getting it to run on two different PCs, under both XP and Win98SE - and, if I recall correctly, also Vista, but I never use that laptop.) It just pulls a lot of HTML and XML from the website, and extracts the addresses of various other pages, and eventually *.WMA streams, and hands the stream URLs over to XMPlay <http://www.un4seen.com/>. It 'knows' what pages to visit, because I have manually built up a plain text file containing a list of (at the moment) 274 BBC radio programmes, represented by 579 different mnemonic key strings - of which the user only needs to type in a sufficiently long initial segment to disambiguate. Anyone else could use the same list, or build up their own, or use mine as a basis for their own. (I just maintain it using a text editor. I haven't [yet] attempted to do any database programming.) I have plenty of ideas for improving the program, but first I have to re-organise the present spaghetti code in a more logical fashion. That's what I've been doing for the last week or so. (Did I say I'd be brief? Zzzzz...) -- https://mail.python.org/mailman/listinfo/python-list