LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This 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


Reply
  Search this Thread
Old 04-09-2008, 09:11 PM   #181
jkr
Member
 
Registered: Apr 2008
Posts: 115

Rep: Reputation: 15

Quote:
Originally Posted by daftcat View Post
This is really just informational, jkr. Unless I run into a problem that is also present on Linux, I don't expect you to support the cygwin version.
Don't worry -- I don't assume any expectation. My only desire is to watch Tim Lincecum on TV. My plan is this:

1. get a version that meets my needs and is *relatively* bug-free.

2. Put it on sourceforge or some other cvs/svn place.

3. Let people hack around on it, play around with it. Give anyone who know a bit of what they're doing svn access.

4. Commit anything that seems useful/cool.

After I get the login/concurrent thing figured out, it's all gravy for me.

If possible, I'd love for things like mlbrecord etc. to be possible modules that users could load, in some sort of larger program. I've also worked to keep the nut'n'bolts separate from the ui, so if anyone wants to create a cgi interface or a gtk interface, more power to 'em.

BTW, as a good guide for playing with Python (aimed at non-idiots) let me be the millionth person to suggest Dive into Python, available free online.
 
Old 04-09-2008, 11:54 PM   #182
daftcat
mlbviewer Maintainer
 
Registered: Apr 2008
Posts: 1,883

Rep: Reputation: 86
So I'm having trouble with the new version and archives. It's your very helpful error message. ;-)

So this is what I have in mind. There's 15 games in a full schedule plus two lines of header. Most term types have at least 24 lines of display. If we dedicate one more line to a footer rule, that means we have four lines for a status window. That's probably more than we need so if we only use two lines for status, we still have two lines left for double-headers.

Right now I'm just using the single window and aiming for curses.LINES-1 to print out status. The status line (or status window) can contain things line status flag from mlb.tv, url returned, command-string executing, error strings, etc. Do you get pitching match-ups in the listings? That would be another candidate for the status lines (or status window.)

This is really just thinking out loud. I'm with you. Anything beyond getting the network layer for live/archive working flawlessly is just gravy.

Thanks for the "book" recommendation. :-)
 
Old 04-10-2008, 02:06 AM   #183
daftcat
mlbviewer Maintainer
 
Registered: Apr 2008
Posts: 1,883

Rep: Reputation: 86
Theophile, I'm watching and recording the same game even on this old 750mhz/256mb. It seems to be working pretty well. Sometimes I forget that I can fast forward through a commercial and about a minute into "I wish the game would come back," I remember and say, "dang, this is cool!"

Now....

If only we could get Netflix Instant working with Linux.... :-)
 
Old 04-10-2008, 02:49 AM   #184
daftcat
mlbviewer Maintainer
 
Registered: Apr 2008
Posts: 1,883

Rep: Reputation: 86
Okay, I got it working under cygwin (again) on my home machine using mplayer. I've even got a desktop icon for it. So cool! Cropping doesn't always work correctly and I can't test live games right now.

jkr

I have a minor patch for you:

Code:
u = g.url()
if '%s' in myplayer:
    cmd_str = myplayer.replace('%s', '"' + u + '"')
else:
    cmd_str = myplayer + ' "' + u + '" '
myscr.clear()
myscr.addstr(0,0,cmd_str)
myscr.refresh()
time.sleep(3)
I added the last four lines which clears the screen and prints out the command-line being used. Not only is this helpful to see the url or to see if video_player variable is being used as you'd like, but it also provides a nice continuity between command and command output. I imagine this could also be useful for any of us to copy and paste in here if we ever needed to. Of course, you don't have to take it, but I like it.
 
Old 04-10-2008, 06:22 AM   #185
jkr
Member
 
Registered: Apr 2008
Posts: 115

Rep: Reputation: 15
Looks cool. Not sure about the sleep(), though. It should stay on the screen till the video player exits anyway, right? That's what the Popen.wait() should force. So the sleep seems like it will just make the download seem slower.

This is a good idea, for all the reasons you mentioned. What I'd probably suggest (for most additions) is making it a configurable option. This is easy: putting the entire thing inside a "if show_player_command:". Then at the bottom, add a default setting to the settings dict:

Code:
datadct = {'speed': DEFAULT_SPEED,
           'video_player': DEFAULT_PLAYER,
           'blackout': [],
           'show_player_command': 1}
This way, if people don't want it, they can just add "show_player_command = 0" to their .mlbtv.

Edit: On second thought, this takes a simple addition to the config reading routine to make it aware of booleans. Something like:

Code:
            # These are the ones that take multiple string values
            if key in ('blackout'):
                datadct[key].append(val)
            # These are the booleans
            elif key in ('show_player_command'):
                if val.isdigit():
                    datadct[key] = bool(int(val))
                else:
                    if val.lower() in ('false', 'no', 'none'):
                        datadct[key] = False
                    elif val.lower() in ('true', 'yes'):
                        datadct[key] = True
                        # Otherwise stick with the default.
                    else:
                        pass
            # And these are the ones that only take one string value,
            # and so, replace the defaults.
            else:
                datadct[key] = val
At some point, it might become worthwhile to switch over to configparser or configobj, but they still seem like overkill for the time being... If we add any more booleans, we can just add it to the tuple in the if statement, or ultimately, make some dictionary that it checks against.

Last edited by jkr; 04-10-2008 at 06:44 AM.
 
Old 04-10-2008, 11:20 AM   #186
daftcat
mlbviewer Maintainer
 
Registered: Apr 2008
Posts: 1,883

Rep: Reputation: 86
The sleep is just there to give me a second or three to verify the command and url looks valid before the screen starts running away with mplayer output. If it's all good, it runs off the screen. If it's not good, the screen quickly jumps back to the menu. That's why I have the sleep there so I can figure out what's not good about the command.

I'm working on something different where I use myscr.getch() and "Press a key to continue..." to leave debug error messages on the screen long enough to look over them. This is because with my mlbrecord, I'm getting your beta error message a lot so I'm putting in my own try: and except: calls to try to figure out where I'm failing.
 
Old 04-10-2008, 12:11 PM   #187
pheedthemonkey
LQ Newbie
 
Registered: Apr 2008
Posts: 5

Rep: Reputation: 0
Question from a brand-spanking newbie.

First of all, THANK YOU jkr. I've been tearing my hair out trying to watch MLB.tv this year.

I followed your instructions as best I could (did I mention that 1 month ago I did not know what a "linux" was?), and the only problem is that the games play in black and white. No color. Is there an easy fix for this? Where should I look for the problem? How could I provide you with more useful information about this situation?

Anyways, thanks again. Black and white beats the hell out of no baseball (even if the Astros will suck this year).
 
Old 04-10-2008, 01:11 PM   #188
jkr
Member
 
Registered: Apr 2008
Posts: 115

Rep: Reputation: 15
Ah -- I see. Makes sense. It's sort of different in my setup, because I run mplayer from an external xterm, so the output doesn't clutter up the screen.

Asking for a keypress makes a lot of sense, but if it were going to get integrated, it would lead to a few problems with the LIRC code (i.e. I've already told it to stop listening to the remote, so you wouldn't be able to get out of it). I think I could just move the part where I shut off LIRC to after that.

Of course, if you want this and don't want LIRC, no worries -- to each their own branch. But if it seems cool, it'll be worth trying to fold it into the larger thing that will work for everyone.
 
Old 04-10-2008, 01:16 PM   #189
jkr
Member
 
Registered: Apr 2008
Posts: 115

Rep: Reputation: 15
Quote:
Originally Posted by pheedthemonkey View Post
...the only problem is that the games play in black and white. No color. Is there an easy fix for this? Where should I look for the problem? How could I provide you with more useful information about this situation?
Sounds like an mplayer problem. Do you have recent w32 codecs? (They'll either be available from you distribution of the mplayer site.) Did you try it out with a different media player (xine, vlc)? You can configure that with the "video_player" option in the .mlbtv file.
 
Old 04-10-2008, 01:31 PM   #190
pheedthemonkey
LQ Newbie
 
Registered: Apr 2008
Posts: 5

Rep: Reputation: 0
Well...

...now it works perfectly, though I did absolutely nothing other than restart my computer. Well, thanks again.
 
Old 04-10-2008, 02:35 PM   #191
daftcat
mlbviewer Maintainer
 
Registered: Apr 2008
Posts: 1,883

Rep: Reputation: 86
Are pitcher probables available in the listings returned? That would be kind of a fun addition. I could code that up myself, I suppose. What's in the listings and is there a way to dump all that information? I'm asking not as a feature request but more a python question of how the data is stored and if there's an routine to print it out or walk through it? I suppose I can dig deeper this weekend.

mlbrecord is coming along. I poll the subprocess and if it's not done yet, I refresh the screen with a seconds counter and an ls -lh on the dumpfile. Now the last big piece is scheduling the recording of games in 'W' state.
 
Old 04-10-2008, 02:44 PM   #192
daftcat
mlbviewer Maintainer
 
Registered: Apr 2008
Posts: 1,883

Rep: Reputation: 86
Quote:
Originally Posted by jkr View Post
Ah -- I see. Makes sense. It's sort of different in my setup, because I run mplayer from an external xterm, so the output doesn't clutter up the screen.

Asking for a keypress makes a lot of sense, but if it were going to get integrated, it would lead to a few problems with the LIRC code (i.e. I've already told it to stop listening to the remote, so you wouldn't be able to get out of it). I think I could just move the part where I shut off LIRC to after that.

Of course, if you want this and don't want LIRC, no worries -- to each their own branch. But if it seems cool, it'll be worth trying to fold it into the larger thing that will work for everyone.
Because of my particular setup, an external xterm wouldn't work. I don't sit at the Linux computer. It's connected into my stereo and an LCD mounted on the wall across the room. The last time I had to login to the gui, I typed "xhost +" so I can launch mplayer from a putty window across the room. Before your script, I was busy encoding my DVD's to divx so I could launch them from across the room the same way. I'm a big Dragonball Z junkie and it was getting annoying having to change the DVD's all the time (even with a DVD changer.)

Anyway, I have no idea how LIRC works because the laptop I'm usually parked at across the room is my remote control. ;-) We might very well branch off in different directions. When I get a usable alpha of mlbrecord (or anything I find useful enough to add to mlbviewer), I'll be sure to send a copy your way to see if you want to incorporate any changes into the main line.

Btw, I was so pleased and relieved that I finally found my error in mlbviewer/mlbrecord (mistyped curses command) that I failed to express my relief that live games are working for me with the new version even under cygwin.
 
Old 04-10-2008, 04:33 PM   #193
jkr
Member
 
Registered: Apr 2008
Posts: 115

Rep: Reputation: 15
Quote:
Originally Posted by daftcat View Post
We might very well branch off in different directions. When I get a usable alpha of mlbrecord (or anything I find useful enough to add to mlbviewer), I'll be sure to send a copy your way to see if you want to incorporate any changes into the main line.
Sounds good to me. Whatever promotes the general good.

Ideally, what I'd love to see would be a modular setup, where there would be a directory containing mlbtv.py (containing the class definitions), and then mlbviewer_curses.py, mlbviewer_html.py, mlbrecord.py, etc. Sort of the way the official BitTorrent client does it. So for example, the mlbviewer curses one would just be the LIRC part and the curses mainloop, and the rest would be imported from the libraries. That way, the backend libraries could stay in one place, and it would cut down on the amount of repeated work.

This probably wouldn't be a problem -- most of the more interface specific stuff happens in the final steps. The libraries are pretty general. But the trimTVList step could be more general, for example.

If this sounds like a good idea, when you get mlbrecord together, send it along, and I'll see if there's an intuitive way to break out the libraries and maybe distribute them together as separate apps. And maybe, as I said, keep them in source control, so we could both maintain and develop our particular pet.
 
Old 04-10-2008, 04:49 PM   #194
jkr
Member
 
Registered: Apr 2008
Posts: 115

Rep: Reputation: 15
Quote:
Originally Posted by daftcat View Post
Are pitcher probables available in the listings returned? That would be kind of a fun addition. I could code that up myself, I suppose. What's in the listings and is there a way to dump all that information?
There aren't pitchers on the listings. (You could pull them from elsewhere, probably, but that would take some time for all the games. Maybe make it a command on a game by game basis.)

Schedules come from this url:

http://mlb.mlb.com/components/game/y...amesbydate.jsp

Changer month and day as required. If you want to follow the flow, it goes like this:

An MLBSchedule (call it m) object initializes with an attribute, m.url. That defaults to today, unless you explicitly pass along other days. (We do explicitly pass these along later to switch days.)

The next few private methods (1) pull down the page info, (2) make a few cosmetic changes to make the JSP into JSON, which python can easily import, and then (3) import it.

And then that m.getData() method puts all the private methods together and fills the data attribute of the MLBScedule instance.

So if you want to play around with it, open up a python console,

Code:
>>> import mlbviewer
>>> m = mlbviewer.MLBSchedule()
>>> m.url
'http://mlb.mlb.com/components/game/year_2008/month_04/day_10/gamesbydate.jsp'
>>> m.getData()
That fills up m.data. Then just play around with m.data.

Code:
>>> for game in m.data: game['gameid']
... 
u'2008/04/10/seamlb-tbamlb-1'
u'2008/04/10/cinmlb-milmlb-1'
u'2008/04/10/atlmlb-colmlb-1'
u'2008/04/10/balmlb-texmlb-1'
u'2008/04/10/balmlb-texmlb-2'
u'2008/04/10/chnmlb-pitmlb-1'
u'2008/04/10/detmlb-bosmlb-1'
u'2008/04/10/oakmlb-tormlb-1'
u'2008/04/10/flomlb-wasmlb-1'
u'2008/04/10/phimlb-nynmlb-1'
u'2008/04/10/nyamlb-kcamlb-1'
u'2008/04/10/minmlb-chamlb-1'
u'2008/04/10/slnmlb-sfnmlb-1'

Last edited by jkr; 04-10-2008 at 05:20 PM.
 
Old 04-10-2008, 06:51 PM   #195
daftcat
mlbviewer Maintainer
 
Registered: Apr 2008
Posts: 1,883

Rep: Reputation: 86
Yeah, I looked at the code and visited a listings page. When viewing the archive it's sometimes helpful to know who pitched to remind me which game I'm looking at. That will be a gravy feature I might add later.

I like the idea of modularizing it and separating interface from engine. This way if I implement gravy features in the mlbviewer interface, we could include two separate interfaces for personal preferences.

I used to frequent the yahoo Linux, Freebsd, Solaris:1 chat room years ago and someone had created a really sharp curses based interface for yahoo chat using multiple windows, menus, status bars, inputs, and saved files. If I implement more gravy features, I'll be going towards that direction (though maybe not quite as elaborate.) I'll probably add a status bar at the bottom which would include things like gameid and scores (if a user sets the 'spoiler' variable in the config file or toggles some flag in the "gui.")

I also know that someone is dying to write a Qt or Gtk interface for this and they just don't know it yet. ;-)

I ended up using the curses gui for mlbrecord. I imagine it wouldn't be too hard to do it without it though.

But it's kind of nice right now....

How about a screenshot:

http://www.eds.org/~straycat/mlbrecord-1.jpg

I use subprocess.Popen() to launch the mplayer command (I autogenerate a filename based on gameid and date but I'll change to that team codes and date this weekend.) Then I poll() that process at five second intervals. If it's not done yet, I clear the screen, write out the mplayer dump command-line and a status which right now is just the number of seconds elapsed and the ls -lh output of the file being created. mplayer itself generates nothing in the way of status output when it's dumping a stream. When it's finished, I print out a very "acidrip"-like message of "Command completed. Hope it worked!" and a "Press a key to continue..." getch(). I should probably print out one more 'ls -lh' line. When someone presses a key, I return back to the menu.

I still don't have a) audio support, and b) scheduling support. It's also very sensitive. When I leave my laptop in one place, I can usually dump to completion. If I move the laptop from room to room (like I do when I lock it away from my cat when I'm not around), then I sometimes lose the stream and there's no way to reconnect. I suppose with a fixed machine, this is probably less of an issue.

I'll likely have an alpha ready by the end of the weekend.

I'm having mixed feelings about it though. I like its potential in honest hands but I really don't want to see games appearing on torrent networks. Besides stealing revenue and income (especially from hidden people like the developers who work hard to bring us this service), I'd hate to see mlb implement more restrictive ways to block Linux users if piracy were to become a problem. I know that even if I sat on my code, though, someone else would implement the same thing. At least mine could have a proper "be a good sport" README file.
 
  


Reply

Tags
help, install, installation, instructions, seek, vlc, windows



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mlb.com gameday audio stream statmobile Linux - Newbie 6 05-06-2008 10:16 PM
link dies intermittently-seemingly at random- between win<->linux not linux<->linux?? takahaya Linux - Networking 10 03-09-2007 10:37 PM
triple boot linux/linux/linux No Windows involved toastermaker Linux - Newbie 12 03-02-2006 10:40 PM
Redhat (rhel v2.1) bootup problem with linux (linux vs linux-up) namgor Linux - Software 2 06-24-2004 02:49 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration