chrippa / livestreamer

Command-line utility that extracts streams from various services and pipes them into a video player of choice. No longer maintained, use streamlink or youtube-dl instead.
http://livestreamer.io/
BSD 2-Clause "Simplified" License
3.88k stars 582 forks source link

auth token valid for only 300 seconds #1065

Open beatsmaster opened 9 years ago

beatsmaster commented 9 years ago

this request is somewhat related to #704

I'm trying to capture a live stream from globo.com which is hls m3u8 based

livestreamer "hlsvariant://http://live.hls.globo.com/dvr/msw24ha/master-playlist.m3u8?h=0411442344198761626871814423476792852704500ygcmZQdFmF_ADTJAN6ScUg&k=html5&a=F&u=52dfc02cdd23810590000f57_a1c8a93c-2d6a-42df-b336-4b00c476b0db" best -o globo.ts

this gives: (403 Client Error: Forbidden)

if I pass a cookie via the --http-header switch it works

livestreamer --http-header "Cookie=vssession=5RTSWkXrccnM2ZMB8uEtcQ14423446870464480623/dvr/msw24ha/?0411442344198761626871814423476792852704500ygcmZQdFmF_ADTJAN6ScUg|F|52dfc02cdd23810590000f57_a1c8a93c-2d6a-42df-b336-4b00c476b0db; OAX=sUNRfVXhpPwAAqBB; glb_uid="8gEoIFAdeaGR4PWd2VnglhLYf_30u6Z00Pwm9CB8HgA="; __utma=100629313.1973354966.1440851200.1442166859.1442343991.8; __utmz=100629313.1440851200.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); nav13574=17077001200|2_815_5:4:1:11:14:2_2:1:2:44:95-97-27-150-15-3:2; nvgoas=_g:2_a:2_e:1_i:95_i:97_i:27_i:150_i:15_i:3_m:1_o:2_l:44_; cX_P=i7k7z6uavtnne0uk; wmp_uuid=7ee92a2d-1730-43dc-bab1-274da002c36a; utag_main=v_id:014f9481a43f00bce278176e33b010048002c00d00bd0$_sn:5$_ss:1$_st:1442345792344$_pn:1%3Bexp-session$ses_id:1442343991471%3Bexp-session; __gads=ID=155c93867140ae38:T=1441305571:S=ALNI_Ma74TH1H4fu4s75lkzste7MXvJUSQ; __utmc=100629313; cX_S=ieitreiluxx80jv0; WMPTOKEN_52dfc02cdd23810590000f57=402f59aee4833d6e78622af5b74cbfa3; __utmb=100629313.4.10.1442343991; __utmt_b=1; locksession=db2d7ab806ea18fd1e8bc7d98faa2db6" "hlsvariant://http://live.hls.globo.com/dvr/msw24ha/master-playlist.m3u8?h=0411442344198761626871814423476792852704500ygcmZQdFmF_ADTJAN6ScUg&k=html5&a=F&u=52dfc02cdd23810590000f57_a1c8a93c-2d6a-42df-b336-4b00c476b0db" best -o globo.ts>
[cli][info] Found matching plugin stream for URL hlsvariant://http://live.hls.globo.com/dvr/msw24ha/master-playlist.m3u8?h=0411441305743213924947314413092253720779763M8j5Rkqx9RzGMB
zNhvfOrg&k=html5&a=F&u=52dfc02cdd23810590000f57_a1c8a93c-2d6a-42df-b336-4b00c476b0db
[cli][info] Available streams: 1264k, 1864k, 2564k (best), 264k, 464k, 64k (worst), 750k
[cli][info] Opening stream: 2564k (hls)
[download][globo.ts] Written 49.0 MB (2m28s @ 312.0 KB/s)

that cookie is only valid for 300 seconds, after that time

stream.hls][warning] Failed to reload playlist: Unable to open URL: http://live.hls.globo.com/dvr/msw24ha/msw24ha_2564/playlist.m3u8 (403 Client Error: Forbidden)
[stream.hls][warning] Failed to reload playlist: Unable to open URL: http://live.hls.globo.com/dvr/msw24ha/msw24ha_2564/playlist.m3u8 (403 Client Error: Forbidden)

In FireFox I can see my "vssession cookie" has indeed changed, this changed cookie is not passed to livestreamer when capturing.

Is there a way I can make livestreamer update that cookie automatically? Any help would be appreciated.

The streaming website (http://globosatplay.globo.com) is only accessible via subscription.

un saludo

micaelsilva commented 8 years ago

Maybe there is something broken on your Python installation or in the Livestreamer, because here it works fine. The main playlist send an cookie an Livestreamer stores it to use on the requests made onwards, there is no need to declare an "--http-cookie"

Livestreamer by default sends an user-agent as Python, maybe they have implemented an security measure to block it. Try using and "--http-header=User-Agent="