Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

live_from_start option is ignored during MLB games #39

Open
fang2415 opened this issue Jul 21, 2020 · 9 comments
Open

live_from_start option is ignored during MLB games #39

fang2415 opened this issue Jul 21, 2020 · 9 comments

Comments

@fang2415
Copy link

My config.yaml looks like this:

profiles:
    default:
        providers:
            mlb:
                credentials:
...
                defaults:
                    #resolution: 540p
                    resolution: 360p
                    media: video
                    live_from_start: True # True to watch live streams from beginning

... but running streamglob download://mlb/2020-07-20.chc during the game downloads the live stream, not from the start.

I can work around this with something like streamglob download://mlb/2020-07-20.chc:offset=4800 (or, if i don't mind missing the pregame, streamglob download://mlb/2020-07-20.chc:offset=T1. But if I do want the pregame (which I usually do), it takes some guesswork to get the offset right, so it'd be nice to have the option work correctly (or, at minimum, an offset name for the broadcast start, and a way to discover what it is).

@fang2415
Copy link
Author

I can work around this with something like streamglob download://mlb/2020-07-20.chc:offset=4800 (or, if i don't mind missing the pregame, streamglob download://mlb/2020-07-20.chc:offset=T1

Whoops, I take it back: none of these offsets work as expected during the game. Not only that, they change depending on when they are run! For example, offset=4800 started before the pregame when I first posted but now starts in the middle of the fifth inning. offset=T1 now starts the download in bottom of the fourth with one out (during a wild pitch). This all makes recovering from stream drops rather time-consuming!

The fact that it changes makes me think that part of what might be going on is that the offsets are being taken from the live time rather than from the broadcast start? Sorry I don't know how to debug further, but it looks like the codebase is well enough abstracted that I can't understand it. :) If there are any resources to guide me in the right direction please let me know.

@tonycpsu
Copy link
Owner

I'll try to take a look at this tonight during a live game.

@fang2415
Copy link
Author

Awesome, many thanks! I'm blacked out for a few days, but if it's not clear by then what's going on then please let me know if there's any info I can gather.

Now watch BAM change everything for the start of the season and make the issue irrelevant anyway...

@tonycpsu
Copy link
Owner

Workaround: add :offset=start to the command line, e.g.:

streamglob download://mlb/2020-07-20.chc:offset=start

Fix: in the unstable branch.

@fang2415
Copy link
Author

Many thanks! Unfortunately I now seem to be erroneously blacked out of all live games on my one-team subscription (even using the web client, so I might have to complain to MLBAM); so I can't test this for now. Hopefully I'll get that issue sorted so I'll be able to test soon.

@fang2415
Copy link
Author

fang2415 commented Aug 6, 2020

Okay, finally got a chance to test this. Unfortunately, the workaround streamglob -v download://mlb/2020-08-05.chc:offset=Start does not work for me: when I ran it a few minutes ago, the download started midway through the eighth inning (which I'm guessing is the live position).

I tried pulling the unstable branch and installing it, but it crashed when I ran it. Unfortunately, when I switched back to the stable branch and ran pip install . again, the crash persists; so apparently installing the unstable version borked my system so that now I can't use streamglob at all. I guess I'll open another issue for that.

Here's the result of running the stable branch (back when it worked for me) with -v. Let me know if any other info would be useful.

$ streamglob -v download://mlb/2020-08-05.chc:offset=Start
2020-08-05 22:26:41 [         session:105 ] [   debug] creating new session: (), {'username': 'changeme', 'password': 'CHANGEME'}
2020-08-05 22:26:41 [        __main__:645 ] [   debug] streamglob starting
2020-08-05 22:26:41 [ selector_events:53  ] [   debug] Using selector: EpollSelector
2020-08-05 22:26:41 [             bam:1862] [   debug] getting schedule: 1, None, 2020-08-05, 2020-08-05, None, None, None
2020-08-05 22:26:41 [             bam:1882] [   debug] http://statsapi.mlb.com/api/v1/schedule?sportId=1&startDate=2020-08-05&endDate=2020-08-05&gameType=&gamePk=&teamId=&hydrate=linescore,team,game(content(summary,media(epg),editorial(preview,recap),highlights(highlights(items))))
2020-08-05 22:26:44 [             bam:1047] [   debug] geting media for game 631417
2020-08-05 22:26:45 [             bam:1047] [   debug] geting media for game 631544
2020-08-05 22:26:45 [             bam:1047] [   debug] geting media for game 631174
2020-08-05 22:26:45 [             bam:1047] [   debug] geting media for game 630110
2020-08-05 22:26:45 [             bam:1047] [   debug] geting media for game 631085
2020-08-05 22:26:45 [             bam:1047] [   debug] geting media for game 631043
2020-08-05 22:26:45 [             bam:1047] [   debug] geting media for game 631220
2020-08-05 22:26:45 [             bam:1047] [   debug] geting media for game 630591
2020-08-05 22:26:46 [             bam:1047] [   debug] geting media for game 630878
2020-08-05 22:26:46 [             bam:1047] [   debug] geting media for game 630972
2020-08-05 22:26:46 [             bam:1047] [   debug] geting media for game 631140
2020-08-05 22:26:46 [             bam:1047] [   debug] geting media for game 631570
2020-08-05 22:26:46 [             bam:1047] [   debug] geting media for game 630307
2020-08-05 22:26:46 [             bam:1047] [   debug] geting media for game 631518
2020-08-05 22:26:46 [             bam:1047] [   debug] geting media for game 631127
2020-08-05 22:26:46 [             bam:1047] [   debug] geting media for game 631339
2020-08-05 22:26:46 [             bam:1047] [   debug] geting media for game 631471
2020-08-05 22:26:46 [             bam:1047] [   debug] geting media for game 631320
2020-08-05 22:26:46 [             bam:1047] [   debug] geting media for game 630497
2020-08-05 22:26:46 [             bam:1047] [   debug] geting media for game 630994
2020-08-05 22:26:46 [             bam:1862] [   debug] getting schedule: 1, None, 2020-08-05, 2020-08-05, None, 112, None
2020-08-05 22:26:46 [             bam:1882] [   debug] http://statsapi.mlb.com/api/v1/schedule?sportId=1&startDate=2020-08-05&endDate=2020-08-05&gameType=&gamePk=&teamId=112&hydrate=linescore,team,game(content(summary,media(epg),editorial(preview,recap),highlights(highlights(items))))
2020-08-05 22:26:47 [             bam:2197] [   debug] milestones: AttrDict([('Start', 3309), ('T1', 3647), ('B1', 3984), ('T2', 4577), ('B2', 5033), ('T3', 5621), ('B3', 6005), ('T4', 6820), ('B4', 7726), ('T5', 8316), ('B5', 8728), ('T6', 9173), ('B6', 9721), ('T7', 10546), ('B7', 11210), ('T8', 11745), ('B8', 13238), ('T9', 13688), ('B9', 14560), ('Live', None)])
2020-08-05 22:26:47 [             bam:2208] [   debug] live stream
2020-08-05 22:26:47 [           tasks:70  ] [   debug] task_manager starting
2020-08-05 22:26:47 [             mlb:682 ] [   debug] getting stream https://edge.svcs.mlb.com/media/2eb4df7c-50cd-4aa5-82f3-d3d8cc5a7c9a/scenarios/browser~csai
2020-08-05 22:26:47 [             mlb:687 ] [   debug] stream response: {'stream': {'renditions': {'audio': [], 'subtitles': []}, 'attributes': {'drms': [], 'encryptionType': 'AES-128', 'audioSegmentTypes': ['PACKED_AUDIO'], 'videoSegmentTypes': ['TS'], 'videoRanges': ['SDR']}, 'variants': [], 'complete': 'https://hlslive-llc-ewr1.media.mlb.com/token=exp=1596770807~id=00u7ipfq0sMtfBgJv356~data=2eb4df7c-50cd-4aa5-82f3-d3d8cc5a7c9a~hash=24b0debcabace549c2cc3bd3e0eedd98e5df3e6b/ls01/mlb/2020/08/06/Away_VIDEO_eng_Chicago_Cubs_Kansas_City__20200806_1596666941039/master_desktop_complete.m3u8'}, 'tracking': {'conviva': {'pbs': 'browser~csai', 'fguid': '0c9ca97a-310c-4c75-a8f9-124e94fe9de6', 'locationName': 'EWR1_LIMELIGHT-SECURE', 'experiments': '', 'encryptionType': 'AES-128', 'med': 'video', 'userid': '00u7ipfq0sMtfBgJv356', 'prt': 'mlbtv', 'videoSegmentTypes': 'TS', 'videoRanges': 'SDR', 'videoCodecs': 'h.264', 'cdnName': 'LIMELIGHT-SECURE', 'plt': 'browser', 'conid': '2eb4df7c-50cd-4aa5-82f3-d3d8cc5a7c9a', 'state': 'ON', 'productType': 'LIVE'}, 'telemetry': {'fguid': '0c9ca97a-310c-4c75-a8f9-124e94fe9de6', 'mediaId': '2eb4df7c-50cd-4aa5-82f3-d3d8cc5a7c9a'}, 'adEngine': {'cdn': 'LIMELIGHT-SECURE', 'corigin': 'EWR1', 'fguid': '0c9ca97a-310c-4c75-a8f9-124e94fe9de6'}, 'qos': {}}}
2020-08-05 22:26:49 [          player:512 ] [    info] downloader: <StreamlinkHelper: streamlink []>
2020-08-05 22:26:49 [          player:539 ] [    info] <StreamlinkHelper: streamlink []> downloading https://hlslive-llc-ewr1.media.mlb.com/token=exp=1596770807~id=00u7ipfq0sMtfBgJv356~data=2eb4df7c-50cd-4aa5-82f3-d3d8cc5a7c9a~hash=24b0debcabace549c2cc3bd3e0eedd98e5df3e6b/ls01/mlb/2020/08/06/Away_VIDEO_eng_Chicago_Cubs_Kansas_City__20200806_1596666941039/master_desktop_complete.m3u8 to ./[email protected]
2020-08-05 22:26:49 [          player:644 ] [    info] resolution: 360p
2020-08-05 22:26:49 [          player:654 ] [    info] time offset: -3309
2020-08-05 22:26:49 [          player:406 ] [   debug] cmd: streamlink --hls-start-offset -3309 --http-header Authorization=eyJraWQiOiI5NDljZjE1ZS1mMTYwLTRlMzctYTRhOS1jYWMxYWFmMjk3ZWEiLCJhbGciOiJFZERTQSJ9.eyJzdWIiOiIwMHU3aXBmcTBzTXRmQmdKdjM1NiIsIm5iZiI6MTU5NjY4NDMyNiwicGFydG5lck5hbWUiOiJtbGJ0diIsImlzcyI6InVybjpiYW10ZWNoOnNlcnZpY2U6dG9rZW4iLCJjb250ZXh0Ijp7ImFjdGl2ZV9wcm9maWxlX2lkIjoiIiwidXBkYXRlZF9vbiI6IjIwMjAtMDgtMDZUMDM6MjU6MjYuNTI0KzAwMDAiLCJzdWJzY3JpcHRpb25zIjpbeyJlbnRpdGxlbWVudHMiOlsiTUxCVFZfU1RQX0NIQyIsIklQSE9ORUFUQkFUIiwiQU5EUk9JREFUQkFUIiwiU1VCU0NSSUJFUlZPRCJdLCJyZW5ld3Nfb24iOiIiLCJleHBpcmVzX29uIjoiIiwiZ3JhbnRDb250ZXh0U291cmNlIjoiYWNjb3VudF9ncmFudCIsImlkIjoiIn1dLCJleHBpcmVzX29uIjoiMjAyMC0wOC0wNlQwNzoyNToyNi41MjQrMDAwMCIsImV4cGVyaW1lbnRzIjp7fSwicHJvZmlsZXMiOltdLCJpcF9hZGRyZXNzIjoiNzUuNi4xODMuMTcxIiwidHlwZSI6IlJFR0lTVEVSRUQiLCJ2ZXJzaW9uIjoiVjIuMC4wIiwiYmxhY2tvdXRzIjp7ImVudGl0bGVtZW50cyI6W10sImRhdGEiOnt9LCJydWxlcyI6eyJ2aW9sYXRlZCI6W119fSwicGFydG5lciI6eyJuYW1lIjoibWx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a260ee37fa1596258703 --http-cookie DT=DI0t2q8qMFAQeuAcRt7AkXjFQ --http-cookie proximity_97b3f52375a0d00a2b1e684b20ade1dc=RPnr8SEgETKylIodL9KirZ9Efe0DkK4meHAwkPyRZw1AVFA1Hu4Q460BSUXaR4m0SGmGMbei61bCSQl68tqGJqcGtUlJaZSrke11F3GM6Z96KpkZ5EuaYN3jNiD58lt7GPqWw/WYRSv9YCJy/7LGGaN6SOQhBCLEeblhRK2DevTpuXnLjZYm+9Iy8Y7cjd7E --http-cookie sid=102iaLtPhsDRKuIukWCy7nESg https://hlslive-llc-ewr1.media.mlb.com/token=exp=1596770807~id=00u7ipfq0sMtfBgJv356~data=2eb4df7c-50cd-4aa5-82f3-d3d8cc5a7c9a~hash=24b0debcabace549c2cc3bd3e0eedd98e5df3e6b/ls01/mlb/2020/08/06/Away_VIDEO_eng_Chicago_Cubs_Kansas_City__20200806_1596666941039/master_desktop_complete.m3u8 360p -o ./[email protected]

@fang2415
Copy link
Author

fang2415 commented Aug 6, 2020

I tried pulling the unstable branch and installing it, but it crashed when I ran it. Unfortunately, when I switched back to the stable branch and ran pip install . again, the crash persists; so apparently installing the unstable version borked my system so that now I can't use streamglob at all. I guess I'll open another issue for that.

Okay, got streamglob working again by pip uninstall streamglob, removing ~/.config/streamglob, and then resintalling. I guess switching branches got it in a bad state somehow.

@fang2415
Copy link
Author

fang2415 commented Aug 6, 2020

Hmm, just realized that I used offset=Start rather than offset=start as you suggested. The game is archived now and so everything works as expected, so I can't test it without the capital letter. I'll see if I can catch it tomorrow to debug further.

@fang2415
Copy link
Author

fang2415 commented Aug 12, 2020

Hey, my team is playing baseball again! So I can finally debug this further.

Both offset=Start and offset=start worked just fine last night about two hours after game time. That is a little unnerving, since it suggests that the problem is intermittent (since I'm not aware of anything I did differently from the attempt that didn't work above); or at least that it depends on some difference in the way MLBAM serves different streams?

Is there anything else I should look for if offset=start fails again? Or will the fix in unstable be merged in soon enough to make the point moot anyway?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants