LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 03-05-2018, 08:48 AM   #5026
tonycpsu
Member
 
Registered: Apr 2014
Posts: 71

Rep: Reputation: Disabled

Quote:
Originally Posted by freddysmith View Post
Sorry misunderstanding, I use streamlink with other sports, NFL,NHL an NBA , Kinda want to use the same , Altho your plugin looks good . rather just use streamlink on its own to pass the stream to VLC just not understanding how to get the cookies and header stuff to access the stream, Last year it used to be included in the curl which was easy, any way for you to help with that ? thanks
OK, well the whole point of mlbplay (the command-line portion of mlbstreamer) is to get the necessary token to pass to streamlink. If you don't want to use mlbplay, you'd have to basically do what that code is doing anyway, or manually extract the tokens from your browser. And you'd have to do this regularly, as the tokens expire. This isn't really a workflow I'm interested in supporting when I wrote a tool to do exactly that already.
 
Old 03-18-2018, 05:27 PM   #5027
virtual_marcus
LQ Newbie
 
Registered: Mar 2018
Posts: 1

Rep: Reputation: Disabled
Registered an account just to say thank you for this, tonycpsu. I have linux mint and have been able to stream Spring Training games in whatever player MLB.tv embeds via Chrome. However, they inevitably freeze up on me at some point.

Once I got through some python library issues, I've been able to use your program flawlessly with MPV, and it seems much, much smoother for me.

Thanks for what you're doing.
 
Old 03-19-2018, 07:48 PM   #5028
chrisVV
Member
 
Registered: Aug 2010
Posts: 548

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Having just tried mlbstreamer, a few comments.

First, although I have only tested it briefly, mlbplay seems to work fine - well done. However mlbstreamer crashes at start up with:
Code:
Traceback (most recent call last):
  File "/usr/bin/mlbstreamer", line 11, in <module>
    load_entry_point('mlbstreamer==0.0.1', 'console_scripts', 'mlbstreamer')()
  File "/usr/lib64/python2.7/site-packages/mlbstreamer/__main__.py", line 382, in main
    view = ScheduleView()
  File "/usr/lib64/python2.7/site-packages/mlbstreamer/__main__.py", line 297, in __init__
    self.toolbar = Toolbar()
  File "/usr/lib64/python2.7/site-packages/mlbstreamer/__main__.py", line 242, in __init__
    ]) , label="League: ")
  File "/usr/lib64/python2.7/site-packages/panwid/dropdown.py", line 458, in __init__
    right_chars = right_chars_top if right_chars_top else right_chars
  File "/usr/lib64/python2.7/site-packages/panwid/dropdown.py", line 66, in __init__
    left_chars=left_chars, right_chars=right_chars
  File "/usr/lib64/python2.7/site-packages/panwid/dropdown.py", line 40, in __init__
    ], dividechars=0)
  File "/usr/lib64/python2.7/site-packages/urwid/container.py", line 1095, in __init__
    raise ColumnsError, "widget list item invalid: %r" % (w,)
urwid.container.ColumnsError: widget list item invalid: (0, <Text flow widget ''>)
Secondly, I liked mlbviewer's ability to start at the beginning of a particular inning. It would be great if mlbstreamer could do the same. I couldn't seek on the stream either but that may be a limitation of my video player (mplayer).

Thirdly, I suggest the set-up instructions set out in earlier postings here are put in the README, and likewise a note on the options (I struggled to work out how the -r option worked until I read one of the postings here).
 
Old 03-20-2018, 08:19 AM   #5029
chrisVV
Member
 
Registered: Aug 2010
Posts: 548

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
One other oddity I have found about mlbplay is that it cannot look up LA Angels or LA Dodgers games using the 'laa' and 'lad' team codes. mlbplay reports a KeyError if you do so: to watch LAA/LAD games you have to use the game number.

Last edited by chrisVV; 03-20-2018 at 08:25 AM.
 
Old 03-20-2018, 01:35 PM   #5030
pajamian
Member
 
Registered: Oct 2009
Posts: 38

Rep: Reputation: 1
Quote:
Originally Posted by chrisVV View Post
One other oddity I have found about mlbplay is that it cannot look up LA Angels or LA Dodgers games using the 'laa' and 'lad' team codes. mlbplay reports a KeyError if you do so: to watch LAA/LAD games you have to use the game number.
I believe the code for the Angels is "ANA". Dodgers might be "LOS"?
 
Old 03-20-2018, 02:15 PM   #5031
mkomko
Member
 
Registered: Mar 2010
Posts: 97

Rep: Reputation: 3
The Dodgers are "la". You can see the codes here ("fileCode"):
http://statsapi.mlb.com/api/v1/teams...=1&season=2018
 
Old 03-20-2018, 03:17 PM   #5032
chrisVV
Member
 
Registered: Aug 2010
Posts: 548

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Quote:
Originally Posted by pajamian View Post
I believe the code for the Angels is "ANA". Dodgers might be "LOS"?
Ah yes thanks, that works for the Angels. 'los' for LAD doesn't work though.

On another matter I have found that the -b option doesn't work. I get this when starting the stream with that option:

Code:
Traceback (most recent call last):
  File "/usr/bin/mlbplay", line 11, in <module>
    load_entry_point('mlbstreamer==0.0.1', 'console_scripts', 'mlbplay')()
  File "/usr/lib64/python2.7/site-packages/mlbstreamer/play.py", line 160, in main
    live_from_beginning = options.beginning)
  File "/usr/lib64/python2.7/site-packages/mlbstreamer/play.py", line 49, in play_stream
    game = state.session.schedule(game_id)["dates"][0]["games"][0]
KeyError: 'dates'
The stream works fine if reading from the current state of the game without the -b option.

Last edited by chrisVV; 03-20-2018 at 03:18 PM.
 
Old 03-20-2018, 03:26 PM   #5033
chrisVV
Member
 
Registered: Aug 2010
Posts: 548

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Quote:
Originally Posted by chrisVV View Post
'los' for LAD doesn't work though.
By trial and error, I have found that the team code for the Dodgers is 'la'.

Perhaps a glossary should be included in the mlbstreamer package.
 
Old 03-20-2018, 03:29 PM   #5034
mkomko
Member
 
Registered: Mar 2010
Posts: 97

Rep: Reputation: 3
Quote:
Originally Posted by chrisVV View Post
By trial and error, I have found that the team code for the Dodgers is 'la'.
You could have read post #5031, just above your previous post.

Quote:
Originally Posted by chrisVV View Post
Perhaps a glossary should be included in the mlbstreamer package.
It's just an alpha version, I'm sure a lot of improvements can and hopefully will be made. It would also be possible to support the other team codes as well.
 
Old 03-20-2018, 04:11 PM   #5035
chrisVV
Member
 
Registered: Aug 2010
Posts: 548

Rep: Reputation: 370Reputation: 370Reputation: 370Reputation: 370
Quote:
Originally Posted by mkomko View Post
You could have read post #5031, just above your previous post.
I could. All depends on when you refresh your browser. If you feel personally affronted, please don't - no offense was intended: as you can see, I hadn't read it.
 
Old 03-21-2018, 03:38 PM   #5036
friggo
LQ Newbie
 
Registered: May 2012
Posts: 10

Rep: Reputation: Disabled
Quote:
Originally Posted by chrisVV View Post
Ah yes thanks, that works for the Angels. 'los' for LAD doesn't work though.

On another matter I have found that the -b option doesn't work. I get this when starting the stream with that option:

Code:
Traceback (most recent call last):
  File "/usr/bin/mlbplay", line 11, in <module>
    load_entry_point('mlbstreamer==0.0.1', 'console_scripts', 'mlbplay')()
  File "/usr/lib64/python2.7/site-packages/mlbstreamer/play.py", line 160, in main
    live_from_beginning = options.beginning)
  File "/usr/lib64/python2.7/site-packages/mlbstreamer/play.py", line 49, in play_stream
    game = state.session.schedule(game_id)["dates"][0]["games"][0]
KeyError: 'dates'
The stream works fine if reading from the current state of the game without the -b option.
The following patch applied to play.py should allow you to use the -b option. It is a crude fix as it will make the stream start from the start of the transmission, which is often 30-60 minutes before the game begins.

Code:
diff --git a/mlbstreamer/play.py b/mlbstreamer/play.py
index c73be84..59cbc94 100755
--- a/mlbstreamer/play.py
+++ b/mlbstreamer/play.py
@@ -46,17 +46,19 @@ def play_stream(game_id, resolution, live_from_beginning=False):
 
 
     if live_from_beginning and media_state == "MEDIA_ON": # live stream
-        game = state.session.schedule(game_id)["dates"][0]["games"][0]
-        start_time = dateutil.parser.parse(game["gameDate"])
+        #game = state.session.schedule(game_id)["dates"][0]["games"][0]
+        #start_time = dateutil.parser.parse(game["gameDate"])
         # print(start_time)
         # print(datetime.now(pytz.utc))
         # calculate HLS offset, which is negative from end of stream
         # for live streams
-        offset =  datetime.now(pytz.utc) - (start_time.astimezone(pytz.utc))
-        hours, remainder = divmod(offset.seconds, 3600)
-        minutes, seconds = divmod(remainder, 60)
-        offset = "%d:%02d:%02d" %(hours, minutes, seconds)
-        logger.info("starting at time offset %s" %(offset))
+        #offset =  datetime.now(pytz.utc) - (start_time.astimezone(pytz.utc))
+        #hours, remainder = divmod(offset.seconds, 3600)
+        #minutes, seconds = divmod(remainder, 60)
+        #offset = "%d:%02d:%02d" %(hours, minutes, seconds)
+        #logger.info("starting at time offset %s" %(offset))
+        logger.info("starting at beginning of transmission")
+        offset = True
 
     cmd = [
         "streamlink",
@@ -68,7 +70,8 @@ def play_stream(game_id, resolution, live_from_beginning=False):
         resolution,
     ]
     if offset:
-        cmd += ["--hls-start-offset", offset]
+        #cmd += ["--hls-start-offset", offset]
+        cmd += ["--hls-live-restart"]
     logger.debug(" ".join(cmd))
     # if options.output_file:
     #     cmd += ["-o", options.output_file]

Last edited by friggo; 03-21-2018 at 03:43 PM.
 
Old 03-21-2018, 04:15 PM   #5037
friggo
LQ Newbie
 
Registered: May 2012
Posts: 10

Rep: Reputation: Disabled
Did some more debugging and found the way it should be to enable -b option.

It seems to work for me when I test it at least.

Code:
diff --git a/mlbstreamer/play.py b/mlbstreamer/play.py
index c73be84..f667379 100755
--- a/mlbstreamer/play.py
+++ b/mlbstreamer/play.py
@@ -7,6 +7,7 @@ import os
 # import re
 import subprocess
 import argparse
+import pytz
 from datetime import datetime
 
 import dateutil.parser
@@ -46,7 +47,7 @@ def play_stream(game_id, resolution, live_from_beginning=False):
 
 
     if live_from_beginning and media_state == "MEDIA_ON": # live stream
-        game = state.session.schedule(game_id)["dates"][0]["games"][0]
+        game = state.session.schedule(game_id=game_id)["dates"][0]["games"][0]
         start_time = dateutil.parser.parse(game["gameDate"])
         # print(start_time)
         # print(datetime.now(pytz.utc))

Last edited by friggo; 03-21-2018 at 04:18 PM.
 
1 members found this post helpful.
Old 03-21-2018, 04:21 PM   #5038
friggo
LQ Newbie
 
Registered: May 2012
Posts: 10

Rep: Reputation: Disabled
The following patch enables the -o options if you need that for some reason:

Code:
--- a/mlbstreamer/play.py       2018-03-21 22:17:29.954868449 +0100
+++ b/mlbstreamer/play.py       2018-03-21 22:17:04.016944114 +0100
@@ -19,7 +19,7 @@
 class MLBPlayException(Exception):
     pass
 
-def play_stream(game_id, resolution, live_from_beginning=False):
+def play_stream(game_id, resolution, live_from_beginning=False, output=False):
 
     live = False
     offset = None
@@ -71,8 +71,8 @@
     if offset:
         cmd += ["--hls-start-offset", offset]
     logger.debug(" ".join(cmd))
-    # if options.output_file:
-    #     cmd += ["-o", options.output_file]
+    if output:
+        cmd += ["-o", output]
 
 
     logger.debug(cmd)
@@ -158,7 +158,8 @@
         proc = play_stream(
             game_id,
             options.resolution,
-            live_from_beginning = options.beginning)
+            live_from_beginning = options.beginning,
+            output = options.output_file)
         proc.wait()
     except MLBPlayException as e:
         logger.error(e)
 
Old 03-26-2018, 07:08 PM   #5039
BostonPeng
Member
 
Registered: Jul 2009
Location: Boston, MA
Distribution: SolydK Testing + KDE 4.9.5
Posts: 113

Rep: Reputation: Disabled
Is there a way to try this out (that I have forgotten about)? MLB's giving two days of free plays and I'd love to give it a spin while I watch my boys in blue.
 
Old 03-27-2018, 01:18 AM   #5040
mkomko
Member
 
Registered: Mar 2010
Posts: 97

Rep: Reputation: 3
Quote:
Originally Posted by BostonPeng View Post
Is there a way to try this out (that I have forgotten about)? MLB's giving two days of free plays and I'd love to give it a spin while I watch my boys in blue.
https://www.linuxquestions.org/quest...ml#post5826059
 
1 members found this post helpful.
  


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 05:50 AM.

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