Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I've also updated the script -- now you can select days by using the side arrows.
Download from the same place (link on the previous page). I'll just keep replacing it until it seems worthwhile to start giving version numbers. I'll let you know when I make significant changes.
I've looked at pylirc, and that seems like it should work for adding remote control support, so pretty soon, using Theophile's button, there should be clunky but workable mythtv support. (I personally prefer a full screen transparent terminal.)
I got a fullscreen transparent terminal using konsole profiles, class names, and wm rules. I'm not using compiz/beryl on my MythTV machine, but if you are, it's a lot easier t get a transparent terminal. I also significantly increased the font size and I'm using Xine for playback because it handles buffering better and has the ability to change the aspect ratio on the fly.
Hacked mlbviewer.py to do radio, away streams only
I just hacked up your brilliant mlbviewer.py script to deal with gameday audio. I did just enough to make it work....away streams only.
One difference is that the text section of the JSON just has the radio station call letters.
Code:
--- mlbviewer.py 2008-04-05 14:49:40.000000000 -0400
+++ mlbviewerradio.py 2008-04-05 14:51:09.000000000 -0400
@@ -61,11 +61,11 @@
# interacts oddly with terminal curses. You could also try the vlc
# option if you prefer.
-PLAYER = 'xterm -e mplayer -cache 2048 -quiet'
+PLAYER = 'xterm -e mplayer -cache 64 -quiet -playlist'
#PLAYER = 'vlc >/dev/null 2>&1'
#PLAYER = "gnome-mplayer"
-SPEED = 400
+SPEED = 12
# or 800, or 1200. If you put it any other value, it will fail
# ungracefully.
@@ -137,17 +137,12 @@
out = []
for elem in self.data:
# All contingent on it having a tv broadcast.
- if elem['mlbtv']:
+ if elem['away_audio']:
dct = {}
dct['event_time'] = elem['event_time']
dct['status'] = elem['status']
- # If things have gotten this far and they still
- # have weird text, just say that it's weird...
- try:
- dct['text'] = elem['mlbtv']['text'].split(':')[1].split('|')[0].strip()
- except:
- dct['text'] = "[mlbviewer couldn't read this...]"
- for url in elem['mlbtv']['urls']:
+ dct['text'] = elem['away_audio']['text']
+ for url in elem['away_audio']['urls']:
dct[url['speed']] = url['url']['id']
out.append((elem['gameid'], dct))
return out
@@ -162,7 +157,7 @@
# Make the workflow url
url = "http://www.mlb.com/enterworkflow.do?" +\
"flowId=media.media&keepWfParams=true&mediaId=" +\
- str(self.id) + "&catCode=mlb_lg&av=v"
+ str(self.id) + "&catCode=mlb_ga&av=a"
# Some preliminary setup...
cookieJar = ClientCookie.CookieJar()
opener = ClientCookie.build_opener(ClientCookie.HTTPCookieProcessor(cookieJar))
@@ -191,7 +186,7 @@
def url(self):
# url_pattern
- pattern = re.compile(r'(url:.*\")(mms:\/\/[^ ]*)(".*)')
+ pattern = re.compile(r'(url:.*\")(http:\/\/[^ ]*)(".*)')
game_url = re.search(pattern, self.__getInfo()).groups()[1]
return game_url
@@ -299,7 +294,7 @@
gameid = available[current_cursor][2]
g = GameStream(gameid, email, password)
u = g.url()
- subprocess.call(PLAYER+' '+u,shell=True)
+ subprocess.call(PLAYER + ' "' + u + '"',shell=True)
if c == ord('r'):
# refresh
That's great. Thanks for the patch. When I get done with my current project (adding lirc support), I'll see if I can fold that in to the larger script. Maybe press "v" for video, "a" for audion, or something...
How strange. The url looks valid -- it has the authentication part in it. I just tried out that same game (Boston-at Toronto) and it worked fine. And you could clearly log in, or else you wouldn't have gotten the authorization code. Hmm... Do the urls you get through the firebug or workflow methods work for you?
Oddly, mlbplayer.py is working for me today (no changes, haven't applied your new version yet). Maybe I'd used too many connections in too short a period for mlb.tv to like or something. Anyhow I'm happy now.
Update: I made a few more minor changes in day switching (makes sure you can't select non-games, etc), and fixed a problem with refreshing I introduced in the second version. If you're using it, you should probably download the version online now. Sorry about that -- release early, release often, and all that.
In the next revision, I think it would be helpful to move the player configuration (PLAYER =) and the stream selection (400k or 800k) to the .mlbtv config file containing the username and password. That way, we don't have to reconfigure those items every time the script is revised.
That said, this really is an amazing piece of work. Even better than Mosaic IMHO. It's simple and it actually works!
Trying a live game for the first time. Got "connection reset" messages, both in firefox and in the script. Finally those went away and I got this (using latest version):
Code:
pgk@pgk-desktop:~$ python mlbviewer.py
Traceback (most recent call last):
File "mlbviewer.py", line 342, in <module>
curses.wrapper(mainloop,datadct['user'],datadct['pass'])
File "curses/wrapper.py", line 44, in wrapper
File "mlbviewer.py", line 322, in mainloop
u = g.url()
File "mlbviewer.py", line 213, in url
game_url = re.search(pattern, self.__getInfo()).groups()[1]
AttributeError: 'NoneType' object has no attribute 'groups'
Edit: These must be due to mlb.tv's server glitches, as it started working now. I'll leave the post content just to illustrate what happens when mlb.tv's end fails.
Maybe you all could help me out with getting this to work. I made the mlbviewer.py file & the password file. I installed ClientForm, ClientCookie, and simplejson, but when I try to run it, I get:
[don@localhost ~]$ python mlbviewer.py
Traceback (most recent call last):
File "mlbviewer.py", line 48, in <module>
import ClientCookie
ImportError: No module named ClientCookie
It looks like it isn't finding ClientCookie (but what do I know?) ClientCookie is in /usr/lib/python2.2 directory. Assume I know very little about Linux and nothing about python.
Python 2.2? Maybe you need 2.4, that's what I'm running. At any rate go to your package manager (I guess Fedora uses Synaptic?) and search for clientcookie. It should be the only package containing that in the name. Make sure it's marked as installed.
Trying a live game for the first time. Got "connection reset" messages, both in firefox and in the script. Finally those went away and I got this (using latest version):.
I get those same messages on today's (4/6) games as well. Prior day's games work fine. Did you do something to correct this error?
No, I just tried again after a few minutes. The game was stuttering a little at times too (and my connection is plenty fast), and there was the firefox message right before it, so I think their servers aren't coping well. Works for me at this moment though.
I just tried the chisox/tigers game and it didn't work. Looked closely and it turned out that it was part of their weekend nationalblackout rules. I don't think that was the issue with the links earlier in the day, but they might still be working out the kinks.
Anyway, as it is now, the script isn't capable of telling you it's blacked out ahead of time (or just not listing it) but the information is available in the listing, so I'll get it in in the next version. Local team blackouts will require a more elegant error message, which I'll also add in.
It looks like it isn't finding ClientCookie (but what do I know?) ClientCookie is in /usr/lib/python2.2 directory. Assume I know very little about Linux and nothing about python.
Did you just place it in the directory or did you install it? I.e. did you follow the instructions in the INSTALL file? (This is one of the parts that I will be rewriting sooner or later, so you won't need to install this file in the future. But that rewrite might not be till a bit later.)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.