LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   MLB.TV in Linux (https://www.linuxquestions.org/questions/linux-software-2/mlb-tv-in-linux-432479/)

jkr 04-05-2008 09:08 AM

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.)

Theophile 04-05-2008 01:24 PM

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.

I love it! Thanks!

TrisMcC 04-05-2008 02:08 PM

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


jkr 04-05-2008 05:38 PM

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...

Hoth 04-06-2008 02:30 AM

Quote:

Originally Posted by jkr (Post 3111662)
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.

jkr 04-06-2008 06:24 AM

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.

Theophile 04-06-2008 09:14 AM

If I may make a suggestion:

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!

Hoth 04-06-2008 01:01 PM

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.

Fugazi 04-06-2008 02:20 PM

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.

Thanks

Hoth 04-06-2008 03:14 PM

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.

ilikerobots 04-06-2008 03:31 PM

Quote:

Originally Posted by Hoth (Post 3112677)
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?

Hoth 04-06-2008 03:39 PM

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.

jkr 04-06-2008 07:59 PM

Thanks for reporting the errors.

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.

jkr 04-06-2008 08:05 PM

Quote:

Originally Posted by Fugazi (Post 3112745)
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.)

daftcat 04-07-2008 02:50 AM

Hi jkr,

I get the following when trying to run mlbviewer.py:

matthew@tango:~$ ./mlbviewer.py
File "./mlbviewer.py", line 78
class MLBSchedule():
^
SyntaxError: invalid syntax


Vague and frustrating, isn't it? And I thought oracle error tracebacks were bad. :-(

I'm using Debian Etch with python2.4 installed plus python-clientcookie, python-clientform, and python-simplejson.

If I can get this working, I can add this to my howto page if you'd like.

Thanks,
Matthew


All times are GMT -5. The time now is 07:26 PM.