Repository: streamlink/streamlink

Issue:
Plugin for Livestream.com not working right?  exit's quickly for hls and not at all for normal streams
I am trying to get a live stream on livestreamer.com to work and i can't get it to play more then about 35 seconds...

When I run this command:
streamlink "http://livestream.com/Miraclenet/events/5004281" 270p --fifo --player omxplayer

it gives me an error about an swf being needed.  When I run this command:
streamlink "http://livestream.com/Miraclenet/events/5004281" 270p_hls --fifo --player omxplayer

it will play the stream but just for about 35 seconds or so...  I kinda don't want to have to restart it every 35 seconds to watch this stream...  I'd like it to run until I stop it myself...

Any help for this non-python, non-linux guy would be very helpful...

btw, this is running on a Raspberry Pi.  Just got a nice little 7 inch lcd for it and set it up on my desk to be able to watch it while I work, but can't get it to play for long at a time...

(edited to correct commands used)


Discussion:
A little additional information if it helps...

With the HLS stream, after about 35 seconds and it stops the text output on the command line says that the stream has ended...

... For starters, this is the **streamlink** issue tracker; your original post commands 
seem to reference _livestreamer_:

> livestreamer "http://livestream.com/Miraclenet/events/5004281" 270p --fifo --player omxplayer
> (snip)
> livestreamer "http://livestream.com/Miraclenet/events/5004281" 270p_hls --fifo --player omxplayer

If those are typos and you indeed meant "streamlink", 
then this is surely a duplicate of your previous #101 
FWIW, I don't own a Pi to test, but on Windows (Vista SP2 x86): 

`streamlink -o "Miraclenet_270.ts" "http://livestream.com/Miraclenet/events/5004281" 270p` => 

```
[Streamlink for Windows]
[cli][info] Found matching plugin livestream for URL http://livestream.com/Mirac
lenet/events/5004281
[cli][info] Available streams: 270p_hls, 486p_hls, 432p_hls, 270p (worst), 432p,
 486p (best)
[cli][info] Opening stream: 270p (akamaihd)
[cli][error] Could not open stream: A SWF URL is required to create session token
```

so this must be an issue with the plugin itself; the SWF URL on that page is: 
`https://cdn.livestream.com/swf/LSPlayer.swf`
The POST request on my browser is: 
`https://livestream-f.akamaihd.net/control/18265544_5004281_lsi8gash3zeu6woo8ja_1_678@25357?cmd=sendingNewToken&v=3.8.0.52&r=CVLHK&g=GPGJOYRSKNUS&lvl1=0,10,0.75,0,0,NaN,0,0,1,678,0,1479661942.435,0,0,0,0,5955,NaN,0,0,0,4628,u,false&swf=https%3A//cdn.livestream.com/swf/LSPlayer.swf`
Unless the non-hls streams are fixed by a dev in the know, 
switch to the hls ones, as suggested to you...
Using latest streamlink code snapshot (git-96c0bfa), 270p_hls variant 
is dumped without interruptions: 
`streamlink -o "Miraclenet_270.ts" "http://livestream.com/Miraclenet/events/5004281" 270p_hls` => 

```
[Streamlink for Windows]
[cli][info] Found matching plugin livestream for URL http://livestream.com/Mirac
lenet/events/5004281
[cli][info] Available streams: 486p_hls, 270p_hls, 432p_hls, 270p (worst), 432p,
 486p (best)
[cli][info] Opening stream: 270p_hls (hls)
File Miraclenet_270.ts already exists! Overwrite it? [y/N] y
[download][Miraclenet_270.ts] Written 6.3 MB (3m3s @ 30.6 KB/s)
```

Here it is being played back in a Windows player: 

![miraclenet_270p_hls](https://cloud.githubusercontent.com/assets/9669492/20464819/c8aaeb16-af57-11e6-84f7-48ddf87637d1.jpg)

So maybe the stream interruption you observe is related to Raspbian and/or omxplayer... 
Sorry I couldn't help more...

yes, that livestreamer part was a typo because that's what I used to use and I was away for a while taking care of some family business (My mother had past and I had to travel half way around the world almost, to help take care of some things and with one of the memorial services for her)...

and yes, I had closed that previous report because I got it to be playing for a short period of time and that was enough for then (about 35 seconds)...    When you play the stream in windows media player with streamlink, how long will it play for?  did you use mostly the same command as me but changing the player?

I think this is due to a regression in livestream #1277 - see my updated comment there: https://github.com/chrippa/livestreamer/pull/1277#issuecomment-237193950
It's now been fixed by @intact on livestream (amazingly fast work, beat me to it!), so hopefully will be here soon.

@Junior1544 
Very sorry for your loss; my most sincere condolences...

The screenshot I posted was of a player (MPC-BE) playing back 
a downloaded .ts file - I, mostly, first download and then watch.

But I did try to use the "-p" switch to feed the stream in real time to VLC.exe 
and (although VLC did not display stream duration) the stream managed 
to play continuously for at least 5min, when I exited the player...
(BTW, when MPC-HC 1.7.10, latest stable release, was tried, only the audio 
part of the stream was played back, with no video at all!). 
So, I guess, the hls streams look OK here...

EDIT: I managed to pipe the hls live stream to MPC-BE (that shows played 
stream duration), as you can see it was at 02:24 when the screenshot was taken: 

![mpcbe](https://cloud.githubusercontent.com/assets/9669492/20465238/931cf868-af61-11e6-9698-5cda22a442a2.jpg)

I just manually applied @intact's livestreamer changes (mentioned above) to streamlink's livestream.py, and can confirm @intact's fix works on streamlink too for non-HLS streams (thanks!). HLS streams stop after a minute or so still.

@intact do you mind if we pull your patch for livestreamer in to streamlink? 

I just did the code changes in my livestream.py that was in @intact's patch, and it seems to be working at about 4 minutes now...   so much better then the 35 seconds I was getting before...   I'm hoping it'll run for at least half an hour before stopping because that I can deal with!

I really hope this can be put into the next releases of the code base here because it'll make it so much easier to update to the next release of streamlink...

If I knew how, push the code in here myself, but i'm just barely learning the github system here and really don't know linux much yet...   still very much a newbie here!

Thank you all for all your help and i'll post again once I have a better idea of how long this will run for before stopping on it's own...
--James

ok, it's been running for almost 3 hours now without problem!

Thank you guys for pointing me to the right solution for this problem!  maybe there can be an hls solution somewhere, but this is working great for me!

Thank you!
--James

Since no-one in this thread felt the need to comment, despite me posting screenshots, 
does any of the developers have any clue as to why the livestream hls stream seems to function 
properly here (no interruptions), whereas both the original poster (@Junior1544) and @stevekmcc 
experience sudden terminations (the former after 35secs, the latter after 1min or so)?
Does streamlink (or the embedded Python 3.5.2) behave differently on Windows 32bit? 

BTW, in one other experiment, I left the "MiracleNet" stream going on, 
it was still strong at 02h03min56sec when the following shot was taken: 

![mpc-be](https://cloud.githubusercontent.com/assets/9669492/20467535/57eb414c-af92-11e6-8edb-199833b4ded3.jpg)

Just being curious, that's all :smile: 
Well, I'm using this on a raspberry pi and it's using python 2.7 i believe...

I don't know if that'll make any difference but just wanted to let you know...   
raspberry pi B+, Raspbian Jessie up to date, python 2.7, omxplayer. HLS streams probably haven't worked for months (at least they didn't in April nor now). I've attached debug output for an HLS run,with time logged at the start and end.
[hls.txt](https://github.com/streamlink/streamlink/files/602516/hls.txt)

I can't reproduce the '35 seconds bug' in both Python 2.7 and Python 3.5.2 maybe it depends on OS or Player (like @Vangelis66 say) ? In my case im using Windows 10

Resolving patch:
diff --git a/src/streamlink/plugins/livestream.py b/src/streamlink/plugins/livestream.py
--- a/src/streamlink/plugins/livestream.py
+++ b/src/streamlink/plugins/livestream.py
@@ -22,7 +22,10 @@
             ),
         }, None)
     },
-    validate.optional("playerUri"): validate.text
+    validate.optional("playerUri"): validate.text,
+    validate.optional("viewerPlusSwfUrl"): validate.url(scheme="http"),
+    validate.optional("lsPlayerSwfUrl"): validate.text,
+    validate.optional("hdPlayerSwfUrl"): validate.text
 })
 _smil_schema = validate.Schema(validate.union({
     "http_base": validate.all(
@@ -93,7 +96,7 @@ def _get_streams(self):
 
         play_url = stream_info.get("play_url")
         if play_url:
-            swf_url = info.get("playerUri")
+            swf_url = info.get("playerUri") or info.get("hdPlayerSwfUrl") or info.get("lsPlayerSwfUrl") or info.get("viewerPlusSwfUrl")
             if swf_url:
                 if not swf_url.startswith("http"):
                     swf_url = "http://" + swf_url


Test patch: