mlbstreamer icon indicating copy to clipboard operation
mlbstreamer copied to clipboard

mlbstreamer failure at runtime

Open ChrisVine opened this issue 5 years ago • 19 comments

mlbstreamer was working fine for me as at its May 24th 2018 version (92eb0adf3) until the authentication changes of a couple of days ago. So to deal with those changes I checked out out the latest version in git (March 30) and installed that.

On then running it I first had a runtime failure with an undocumented dependency - requests_toolbelt. I installed that and then when I now try to watch a game I get this failure:

Uncaught exception
Traceback (most recent call last):
  File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer-0.0.11.dev0-py3.7.egg/mlbstreamer/play.py", line 354, in main
    (provider, game) = options.game.split("/", 1)
ValueError: not enough values to unpack (expected 2, got 1)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/chris/.local/bin/mlbplay", line 11, in <module>
    load_entry_point('mlbstreamer==0.0.11.dev0', 'console_scripts', 'mlbplay')()
  File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer-0.0.11.dev0-py3.7.egg/mlbstreamer/play.py", line 357, in main
    provider = list(config.settings.profile.providers.keys())[0]
AttributeError: 'NoneType' object has no attribute 'keys'

Possibly there is some other unmet dependency that is not satisfied. Any ideas? I am using the latest streamlink available from pip.

ChrisVine avatar Apr 02 '19 20:04 ChrisVine

It looks as if there has been an undocumented change to config.yaml. When I do something which approximates to the latest sample file, I now get this:

2019-04-02 23:51:43 [   DEBUG] checking for existing log in
2019-04-02 23:51:45 [   DEBUG] attempting new log in
Traceback (most recent call last):
  File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer/session.py", line 180, in new
    return cls.load()
  File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer/session.py", line 195, in load
    state = yaml.load(open(SESSION_FILE), Loader=AttrDictYAMLLoader)
FileNotFoundError: [Errno 2] No such file or directory: '/home/chris/.config/mlbstreamer/session'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/chris/.local/bin/mlbplay", line 11, in <module>
    load_entry_point('mlbstreamer==0.0.11.dev0', 'console_scripts', 'mlbplay')()
  File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer/play.py", line 321, in main
    state.session = MLBSession.new(no_cache=options.no_cache)
  File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer/session.py", line 184, in new
    **kwargs)
  File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer/session.py", line 121, in __init__
    self.login()
  File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer/session.py", line 274, in login
    raise MLBSessionException("Couldn't get ipid / fingerprint")
mlbstreamer.session.MLBSessionException: Couldn't get ipid / fingerprint

I am definitely getting warmer but something is still wrong. In particular, an exception is thrown for a non-existent session file, but it should regenerate. After that, a different exception arises.

ChrisVine avatar Apr 02 '19 22:04 ChrisVine

Make sure you copy the sample config from the doc folder.

Also the new command would be like example: mlbplay mlb/2019-03-30.sd

jgshier avatar Apr 02 '19 23:04 jgshier

@jgshier config.yaml is in the format in the docs directory and the new (undocumented) command format makes no difference from the former documented one - it produces the same errors:

2019-04-03 00:36:27 [   DEBUG] attempting new log in
Traceback (most recent call last):
  File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer/session.py", line 180, in new
    return cls.load()
  File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer/session.py", line 195, in load
    state = yaml.load(open(SESSION_FILE), Loader=AttrDictYAMLLoader)
FileNotFoundError: [Errno 2] No such file or directory: '/home/chris/.config/mlbstreamer/session'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/chris/.local/bin/mlbplay", line 11, in <module>
    load_entry_point('mlbstreamer==0.0.11.dev0', 'console_scripts', 'mlbplay')()
  File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer/play.py", line 321, in main
    state.session = MLBSession.new(no_cache=options.no_cache)
  File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer/session.py", line 184, in new
    **kwargs)
  File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer/session.py", line 121, in __init__
    self.login()
  File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer/session.py", line 274, in login
    raise MLBSessionException("Couldn't get ipid / fingerprint")
mlbstreamer.session.MLBSessionException: Couldn't get ipid / fingerprint

This is disappointing.

ChrisVine avatar Apr 02 '19 23:04 ChrisVine

I am running python 3.6.7. I deleted my old config, copied the new one which is way different. Updated it manually and did not use the —init-config. Removed everything but the updated config.yaml in the .config directory.

Works great.

Maybe try a fresh git?

On Tue, Apr 2, 2019 at 4:39 PM ChrisVine [email protected] wrote:

@jgshier https://github.com/jgshier config.yaml is in the format in the docs directory and the new (undocumented) command format makes no difference from the former documented one - it produces the same errors:

2019-04-03 00:36:27 [ DEBUG] attempting new log in Traceback (most recent call last): File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer/session.py", line 180, in new return cls.load() File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer/session.py", line 195, in load state = yaml.load(open(SESSION_FILE), Loader=AttrDictYAMLLoader) FileNotFoundError: [Errno 2] No such file or directory: '/home/chris/.config/mlbstreamer/session'

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/home/chris/.local/bin/mlbplay", line 11, in load_entry_point('mlbstreamer==0.0.11.dev0', 'console_scripts', 'mlbplay')() File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer/play.py", line 321, in main state.session = MLBSession.new(no_cache=options.no_cache) File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer/session.py", line 184, in new **kwargs) File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer/session.py", line 121, in init self.login() File "/home/chris/.local/lib/python3.7/site-packages/mlbstreamer/session.py", line 274, in login raise MLBSessionException("Couldn't get ipid / fingerprint") mlbstreamer.session.MLBSessionException: Couldn't get ipid / fingerprint

This is disappointing.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/tonycpsu/mlbstreamer/issues/42#issuecomment-479256231, or mute the thread https://github.com/notifications/unsubscribe-auth/AAuJSJbd9kvDpykeJV1InwW_k5orH63fks5vc-oXgaJpZM4cZDpn .

-- Mahalo, Jon Shier

jgshier avatar Apr 02 '19 23:04 jgshier

@jgshier I have tried starting with a clean config directory (apart from config.yaml) which is why the session file does not exist, and which is the overt cause of the first error I get. However, I strongly suspect that there is an undocumented dependency which is not fulfilled which causes a failure to regenerate a session file, but who knows. Given that even the current command format of mlbplay is not documented that is perhaps not surprising.

ChrisVine avatar Apr 02 '19 23:04 ChrisVine

I have got it semi-working now. It does seem to be in part a dependency issue: I resorted to deleting everything in ~/.local/bin and ~/.local/lib, reinstalled mlbstreamer using pip (so forcing pip to reinstall and so upgrade all mlbstreamer dependencies from scratch), then installed requests_toolbelt, then rebuilt mlbstreamer from git master and then deleted everything in .config/mlbstreamer so mlbstreamer would rebuild them.

Unfortunately though the -b option no longer seems to work. What is the correct way to use the -b option with the new command line syntax?

ChrisVine avatar Apr 03 '19 11:04 ChrisVine

Sorry for all the trouble, @ChrisVine. The MLB.tv authentication changes forced me to push things out before I've had a chance to do adequate testing, and it just wasn't practical to fork mlbstreamer as of the previous release, maintain mlbstreamer with the other changes since then, and continue to expand the functionality and improve the stability of streamglob.

At this point, support for mlbstreamer is going to fall into the "best effort" category given that streamglob is available. I understand that this won't work for folks who are forced to / choose to remain on Python 2.x or Python < 3.7, but you seem to be running 3.7, so my advice to you for the best experience would be to run streamglob. Neither supports starting with a particular inning / offset right now, but that will be forthcoming.

I will leave this ticket open as a reminder to try to fix start offset functionality in mlbstreamer, but I can't say when that will happen.

tonycpsu avatar Apr 03 '19 14:04 tonycpsu

@tonycpsu Thanks. On the -b option point, being able to start at the beginning of the game for a game already in play, or second best being able to wind back to the beginning, seems to me to be a fairly fundamental feature and it worked absolutely fine up to and including commit 0532d1ae. I can live without the T1, B2, etc inning options, but an option which takes 0 or the number of seconds from the start would be really useful.

On the subject of streamglob, I don't honestly need all the bells and whistles that streamglob provides: all I want is something which will play mlb. However, I did try it but when I attempted to run it I got:

Traceback (most recent call last):
  File "/home/chris/.local/bin/streamglob", line 11, in <module>
    load_entry_point('streamglob==0.0.11.dev0', 'console_scripts', 'streamglob')()
  File "/usr/lib64/python3.7/site-packages/pkg_resources/__init__.py", line 489, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/usr/lib64/python3.7/site-packages/pkg_resources/__init__.py", line 2793, in load_entry_point
    return ep.load()
  File "/usr/lib64/python3.7/site-packages/pkg_resources/__init__.py", line 2411, in load
    return self.resolve()
  File "/usr/lib64/python3.7/site-packages/pkg_resources/__init__.py", line 2417, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/chris/.local/lib/python3.7/site-packages/streamglob-0.0.11.dev0-py3.7.egg/streamglob/__main__.py", line 23, in <module>
    from panwid.tabview import *
ModuleNotFoundError: No module named 'panwid.tabview'

I can open an issue on the streamglob git repository but it is obviously another dependency issue. Presumably pip, when re-installing mlbstreamer, supplied too old a version of panwid for streamglob. Is that the problem and if so what do you suggest? (As I say, subject to the -b option point mlbstreamer meets my needs.)

This is at least a reminder what a horrible mess python can end up with with long dependency chains, where it is a matter of luck whether any particular combination of packages is capable of being assembled which meets the base requirements of the software to be installed. Ugh.

ChrisVine avatar Apr 03 '19 15:04 ChrisVine

@ChrisVine: Yes, that is the problem. Again -- streamglob was rushed out before I could address a lot of upstream backwards compatibility issues, hence the disclaimer in the README. mlbstreamer was in sort of an in-between state at the time, and I wanted to make sure folks could watch the games, so I released streamglob as it was, pushed what I had to mlbstreamer, and back-ported the authentication fixes with very minimal testing.

The solution is to re-run the pip install -r requirements.txt step for streamglob. The panwid it installs will be from the git master, and that should solve the import problem. If you install mlbstreamer, it will pull in the older panwid. It's going to take me some time to get this all to a state that's more manageable. The alternative was holding off the release and having nobody be able to watch any games -- I chose the path that got something into everyone's hands, even if there are still issues, and in some cases, a need to be more hands-on than one might like to be.

tonycpsu avatar Apr 03 '19 21:04 tonycpsu

@tonycpsu Thanks. Your work is appreciated and it was good of you to commit a fix as soon as you did: my comments were intended as comments not criticism.

Implementing a basic offset for the -b option via streamlink would be nice however, in either mlbstreamer or streamglob.

ChrisVine avatar Apr 03 '19 23:04 ChrisVine

I have done a quick hack for the interim which works for me: I just make mlbstreamer's -b option hand off its argument string to streamlink's --hls-start-offset option. The offset works "backwards" on live streams but that's OK: it's good enough.

ChrisVine avatar Apr 04 '19 14:04 ChrisVine

@ChrisVine: The commit referenced in https://github.com/tonycpsu/streamglob/issues/15 should fix offset functionality in streamglob. I've also pushed a panwid dev version to PyPi that should work for both projects. I will try to work on restoring offset functionality to mlbstreamer as well, but in the mean time, see if streamglob meets your needs.

tonycpsu avatar Apr 04 '19 19:04 tonycpsu

@tonycpsu pip3 still tries to install panwid-0.2.5, which is too old, so streamglob still does not work for me. (Version 0.2.5 is also the version revealed by PyPi's search interface.)

By the way, if the session token file mlb.session is more than an hour or two old, you have to delete it by hand to get mlbstreamer to work. I see from the git log that this has been fixed in streamglob.

ChrisVine avatar Apr 05 '19 10:04 ChrisVine

@ChrisVine : Are you just running pip install panwid? In that case, it's not going to get the new version because it's a pre-release (dev) version. You need to run pip install -r requirements.txt as stated in the README, or pip install -U . from the streamglob directory will work as well.

If you must do it manually, you can do pip install "panwid==0.3.0.dev10". pip install --pre panwid should also work.

I'll try to fix the session timeout thing in mlbstreamer as well.

tonycpsu avatar Apr 05 '19 15:04 tonycpsu

That resolves panwid. Now it is

ModuleNotFoundError: No module named 'tonyc_utils'

By the way I have ported your fix for the out-of-date session token from streamglob to mlbstreamer. I can e-mail the patch to you if that saves you having to duplicate the effort.

ChrisVine avatar Apr 05 '19 15:04 ChrisVine

They should all be installed automatically if you just install streamglob as directed. If you insist on installing each individually, you will of course have some that aren't installed until you install them...

tonycpsu avatar Apr 05 '19 15:04 tonycpsu

By the way I have ported your fix for the out-of-date session token from streamglob to mlbstreamer. I can e-mail the patch to you if that saves you having to duplicate the effort.

Have you tested that it works and refreshes the access token when the session token expires?

tonycpsu avatar Apr 05 '19 15:04 tonycpsu

Ah my mistake. I did 'pip install -r requirements.txt' instead of 'pip3 install -r requirements.txt'. With that, streamglob works except that I cannot get the -b option to work.

On the out-of-date session token, yes mlbstreamer seems to replace the token file correctly.

ChrisVine avatar Apr 05 '19 18:04 ChrisVine

Ah my mistake. I did 'pip install -r requirements.txt' instead of 'pip3 install -r requirements.txt'. With that, streamglob works except that I cannot get the -b option to work.

There is no -b option. It's just, e.g:

mlb/2019-03-31.chc:offset=B7

tonycpsu avatar Apr 05 '19 18:04 tonycpsu