Bug ffmpeg/player not setting cookies correctly
#1
I have a rather complex authentication for live feeds which requires cookies to be set correctly by the player.
There seems to be an issue where there are multiple cookies set for a domain and some have an expiry = 0.

I have posted the pertinent portion of the log here: http://xbmclogs.com/pta4wx8du

The main gist is:

Code:
--->>00:15:14 T:2840   DEBUG: Curl::Debug - TEXT: Replaced cookie hdntl="exp=1437279309~acl=%2f*~data=hdntl~hmac=b08e1b31a89f71a44ef5d077aef183acf685e3f9fb1b3675764128e855f1c974" for domain hgtv-i.akamaihd.net, path /, expire 0
--->>00:15:14 T:2840   DEBUG: Curl::Debug - HEADER_IN: Set-Cookie: hdntl=exp=1437279309~acl=%2f*~data=hdntl~hmac=b08e1b31a89f71a44ef5d077aef183acf685e3f9fb1b3675764128e855f1c974; path=/; domain=hgtv-i.akamaihd.net;

.......

--->>00:15:14 T:564   DEBUG: Curl::Debug - HEADER_OUT: Cookie: _alid_=oLDVFcHkrEccedJC8yPzCg==; hdntl=exp=1437279261~acl=%2f*~data=hdntl~hmac=310d36eaca21c199cdb66b15f797ac972b494b33d7487adb6e4dc1b7b81133e6
EDIT: I have no idea why the data above shows a commit url - if you do a quote it goes away

Running Isengard 15.0 RC2 on Windows 8.1.

As you can see in the later request with compound cookies the hdntl expiry is earlier than the one being set prior to the later request (meaning it's not right). The exp=1437279261 cookie is the one that is in the cookies.dat file, rather than the one being set in the earlier request. I think that a expire=0 is a session cookie, so I'm not sure why this is in the cookies.dat file.

I'm not sure if it matters or not, but there are cookies also set for similar domains in the cookie.dat file:
.cookingchanneltv-i.akamaihd.net
.b-diynetwork-i.akamaihd.net
.travelchannel-i.akamaihd.net

If I just keep playing the same channel it keeps working ok. If I play any other one with a similar domain name, the original one stops working because the cookie is wrong (not up to date). I'm not sure if this is because of the way session cookies are handled, the compound cookies or some weird domain match issue.
I had to remove the tokens from some of the requests to maintain privacy in the logs.

This is a really irritating issue and was hard to even narrow down. I'm not sure about my conclusions, but I think they're in the neighborhood of the problem.
Let me know what else is needed to help resolve.
Reply
#2
If no one is able to help on the above, does anyone know how to clear the session cookies for ffmpeg/player, short of finding and deleting the cookies.dat file? (Which actually doesn't work because it appears to be cached somewhere).
Reply
#3
from a quick glance, there is no API method to clear cookies, but you can set a cookie via URL protocol options.
Reply
#4
(2015-07-20, 19:27)wsnipex Wrote: from a quick glance, there is no API method to clear cookies, but you can set a cookie via URL protocol options.

Thanks, I tried to clear the cookie using the URL protocol, but wasn't able to. I think one issue might be that I need to clear a cookie in a different domain than the url. I tried a number of different combinations that work with HTTP, but couldn't get the cookie to reset.
Reply
#5
I still don't fully understand the issue, but to be able to delete stored cookies a new protocol option could be added here: https://github.com/xbmc/xbmc/blob/master...e.cpp#L799

it'd have to do:
Code:
g_curlInterface.easy_setopt(h, CURLOPT_COOKIELIST, "SESS");
Reply
#6
(2015-07-20, 20:24)wsnipex Wrote: I still don't fully understand the issue, but to be able to delete stored cookies a new protocol option could be added here: https://github.com/xbmc/xbmc/blob/master...e.cpp#L799

it'd have to do:
Code:
g_curlInterface.easy_setopt(h, CURLOPT_COOKIELIST, "SESS");

I'm not 100% sure what the issue is either (probably less than 50%). It has to do with session cookies. I have 5 live streams that each work perfectly if I don't change between the streams, i.e. I keep playing and replaying the same stream. Once I play a different stream and come back to the previous stream, the cookies are not correct.

The streams are in independent, but similarly named domains:
.cookingchanneltv-i.akamaihd.net
.b-diynetwork-i.akamaihd.net
.travelchannel-i.akamaihd.net
.hgtv-i.akamaihd.net
.foodnetwork-i.akamaihd.net

If I present the correct urls with the correct autho contents in the correct order through a browser I can play the urls (actually read the playable files) everytime without issue. Doing the same in Kodi causes previous channels to not play again because the hdtl cookie is incorrect and not the latest one for the given domain. That is visible in the snippet and log given in my first post. I can only guess that there is an issue with session cookies, which I can imagine are difficult to manage in the Kodi player (e.g., what is a session?). I can get the streams to play everytime in Kodi if I delete cookies.dat and do an http access in between (which I guess flushes/renews the cookie cache after the delete).

Lots of guesses, not much knowledge on my part.
Reply
#7
As an aside, I coded an addon that opens a cookiejar and goes through the play files in sequence and had no trouble loading the .ts segments, which I could play with the player. It's just a royal pain in the rear to emulate the .m3u8 code correctly within an addon in Python. I'd be really surprised if I could get it to work without jumping/skipping video on some platforms, so I don't think that's a viable solution. These are 1080 streams running at about 6 Mbps.
Reply
#8
I have a similar problem. I get server error 403 despite I have setting cookie. The same request works with firefox's firebug and mitmproxy but doesn't work with kodi.
Below the log.
Thanks in advance.

Code:
20:57:15.725 T:139928658753280    INFO: CPythonInvoker(13, /home/matteo/.kodi/addons/plugin.video.mtv.it/default.py): script successfully run
20:57:15.741 T:139929956341504   DEBUG: Thread scriptobs 139929956341504 terminating
20:57:15.741 T:139931449338240    INFO: easy_aquire - Created session to https://cp105701-f.akamaihd.net
20:57:15.774 T:139928658753280    INFO: Python script stopped
20:57:15.774 T:139928658753280   DEBUG: Thread LanguageInvoker 139928658753280 terminating
20:57:16.376 T:139931449338240   DEBUG: CCurlFile::GetMimeType - https://cp105701-f.akamaihd.net/i/mtviestor/_!/intlod/MTVInternational/MBUS/TACTIC/201606/VIAMTVIPYC3186ZBVO8/it_awkward_524_clip04_,384x216_400_m30,512x288_750_m30,640x360_1200_m30,768x432_1700_m30,960x540_2200_m31,1280x720_3500_h32,.mp4.csmil/index_5_av.m3u8?e=e2006a2dec61af0a&id=AgBf9U9qX2VyHw0AAVk4Rva4b1zqNHViq1683krXKNixV7FNFpQWlpFdp7gF7953JXlG%2f24WfSpE6A%3d%3d&__s__=&__a__=off|Cookie=hdnea2%3Dexpires%3D1493324172%7Eaccess%3D%2F%2A%7Emd5%3Df168b329b3ed22565cdfef7599dfd00d%3B+path%3D%2F%3B+domain%3Dcp105701-f.akamaihd.net%3B -> application/vnd.apple.mpegurl
20:57:16.378 T:139931449338240   DEBUG: Loading settings for https://cp105701-f.akamaihd.net/i/mtviestor/_!/intlod/MTVInternational/MBUS/TACTIC/201606/VIAMTVIPYC3186ZBVO8/it_awkward_524_clip04_,384x216_400_m30,512x288_750_m30,640x360_1200_m30,768x432_1700_m30,960x540_2200_m31,1280x720_3500_h32,.mp4.csmil/index_5_av.m3u8?e=e2006a2dec61af0a&id=AgBf9U9qX2VyHw0AAVk4Rva4b1zqNHViq1683krXKNixV7FNFpQWlpFdp7gF7953JXlG%2f24WfSpE6A%3d%3d&__s__=&__a__=off|Cookie=hdnea2%3Dexpires%3D1493324172%7Eaccess%3D%2F%2A%7Emd5%3Df168b329b3ed22565cdfef7599dfd00d%3B+path%3D%2F%3B+domain%3Dcp105701-f.akamaihd.net%3B
20:57:16.379 T:139931449338240   DEBUG: CPlayerCoreFactory::GetPlayers(https://cp105701-f.akamaihd.net/i/mtviestor/_!/intlod/MTVInternational/MBUS/TACTIC/201606/VIAMTVIPYC3186ZBVO8/it_awkward_524_clip04_,384x216_400_m30,512x288_750_m30,640x360_1200_m30,768x432_1700_m30,960x540_2200_m31,1280x720_3500_h32,.mp4.csmil/index_5_av.m3u8?e=e2006a2dec61af0a&id=AgBf9U9qX2VyHw0AAVk4Rva4b1zqNHViq1683krXKNixV7FNFpQWlpFdp7gF7953JXlG%2f24WfSpE6A%3d%3d&__s__=&__a__=off|Cookie=hdnea2%3Dexpires%3D1493324172%7Eaccess%3D%2F%2A%7Emd5%3Df168b329b3ed22565cdfef7599dfd00d%3B+path%3D%2F%3B+domain%3Dcp105701-f.akamaihd.net%3B)
20:57:16.379 T:139931449338240   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: system rules
20:57:16.379 T:139931449338240   DEBUG: CPlayerSelectionRule::GetPlayers: matches rule: system rules
20:57:16.379 T:139931449338240   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: mms/udp
20:57:16.379 T:139931449338240   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: lastfm/shout
20:57:16.379 T:139931449338240   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: rtmp
20:57:16.379 T:139931449338240   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: rtsp
20:57:16.379 T:139931449338240   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: streams
20:57:16.379 T:139931449338240   DEBUG: CPlayerSelectionRule::GetPlayers: matches rule: streams
20:57:16.379 T:139931449338240   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: aacp/sdp
20:57:16.379 T:139931449338240   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: mp2
20:57:16.379 T:139931449338240   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: dvd
20:57:16.379 T:139931449338240   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: dvdimage
20:57:16.379 T:139931449338240   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: sdp/asf
20:57:16.379 T:139931449338240   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: nsv
20:57:16.379 T:139931449338240   DEBUG: CPlayerSelectionRule::GetPlayers: considering rule: radio
20:57:16.379 T:139931449338240   DEBUG: CPlayerCoreFactory::GetPlayers: matched 0 rules with players
20:57:16.379 T:139931449338240   DEBUG: CPlayerCoreFactory::GetPlayers: adding videodefaultplayer (VideoPlayer)
20:57:16.379 T:139931449338240   DEBUG: CPlayerCoreFactory::GetPlayers: for video=1, audio=0
20:57:16.379 T:139931449338240   DEBUG: CPlayerCoreFactory::GetPlayers: for video=1, audio=1
20:57:16.379 T:139931449338240   DEBUG: CPlayerCoreFactory::GetPlayers: added 1 players
20:57:16.380 T:139931449338240   DEBUG: Radio UECP (RDS) Processor - new CDVDRadioRDSData
20:57:16.380 T:139931449338240  NOTICE: VideoPlayer: Opening: https://cp105701-f.akamaihd.net/i/mtviestor/_!/intlod/MTVInternational/MBUS/TACTIC/201606/VIAMTVIPYC3186ZBVO8/it_awkward_524_clip04_,384x216_400_m30,512x288_750_m30,640x360_1200_m30,768x432_1700_m30,960x540_2200_m31,1280x720_3500_h32,.mp4.csmil/index_5_av.m3u8?e=e2006a2dec61af0a&id=AgBf9U9qX2VyHw0AAVk4Rva4b1zqNHViq1683krXKNixV7FNFpQWlpFdp7gF7953JXlG%2f24WfSpE6A%3d%3d&__s__=&__a__=off|Cookie=hdnea2%3Dexpires%3D1493324172%7Eaccess%3D%2F%2A%7Emd5%3Df168b329b3ed22565cdfef7599dfd00d%3B+path%3D%2F%3B+domain%3Dcp105701-f.akamaihd.net%3B
20:57:16.380 T:139931449338240 WARNING: CDVDMessageQueue(player)::Put MSGQ_NOT_INITIALIZED
20:57:16.775 T:139931449338240   DEBUG: CCurlFile::GetMimeType - https://cp105701-f.akamaihd.net/i/mtviestor/_!/intlod/MTVInternational/MBUS/TACTIC/201606/VIAMTVIPYC3186ZBVO8/it_awkward_524_clip04_,384x216_400_m30,512x288_750_m30,640x360_1200_m30,768x432_1700_m30,960x540_2200_m31,1280x720_3500_h32,.mp4.csmil/index_5_av.m3u8?e=e2006a2dec61af0a&id=AgBf9U9qX2VyHw0AAVk4Rva4b1zqNHViq1683krXKNixV7FNFpQWlpFdp7gF7953JXlG%2f24WfSpE6A%3d%3d&__s__=&__a__=off|Cookie=hdnea2%3Dexpires%3D1493324172%7Eaccess%3D%2F%2A%7Emd5%3Df168b329b3ed22565cdfef7599dfd00d%3B+path%3D%2F%3B+domain%3Dcp105701-f.akamaihd.net%3B -> application/vnd.apple.mpegurl
20:57:16.775 T:139931449338240   DEBUG: LinuxRendererGL: Cleaning up GL resources
20:57:16.776 T:139931449338240   DEBUG: CLinuxRendererGL::PreInit - precision of luminance 16 is 16
20:57:16.776 T:139929956341504   DEBUG: Thread VideoPlayer start, auto delete: false
20:57:16.776 T:139929956341504  NOTICE: Creating InputStream
20:57:16.776 T:139929956341504   DEBUG: CurlFile::Open(0x7f43fb574670) https://cp105701-f.akamaihd.net/i/mtviestor/_!/intlod/MTVInternational/MBUS/TACTIC/201606/VIAMTVIPYC3186ZBVO8/it_awkward_524_clip04_,384x216_400_m30,512x288_750_m30,640x360_1200_m30,768x432_1700_m30,960x540_2200_m31,1280x720_3500_h32,.mp4.csmil/index_5_av.m3u8?e=e2006a2dec61af0a&id=AgBf9U9qX2VyHw0AAVk4Rva4b1zqNHViq1683krXKNixV7FNFpQWlpFdp7gF7953JXlG%2f24WfSpE6A%3d%3d&__s__=&__a__=off
20:57:17.061 T:139929956341504   ERROR: CCurlFile::FillBuffer - Failed: HTTP returned error 403
20:57:17.061 T:139929956341504   ERROR: CCurlFile::Open failed with code 403 for https://cp105701-f.akamaihd.net/i/mtviestor/_!/intlod/MTVInternational/MBUS/TACTIC/201606/VIAMTVIPYC3186ZBVO8/it_awkward_524_clip04_,384x216_400_m30,512x288_750_m30,640x360_1200_m30,768x432_1700_m30,960x540_2200_m31,1280x720_3500_h32,.mp4.csmil/index_5_av.m3u8?e=e2006a2dec61af0a&id=AgBf9U9qX2VyHw0AAVk4Rva4b1zqNHViq1683krXKNixV7FNFpQWlpFdp7gF7953JXlG%2f24WfSpE6A%3d%3d&__s__=&__a__=off|Cookie=hdnea2%3Dexpires%3D1493324172%7Eaccess%3D%2F%2A%7Emd5%3Df168b329b3ed22565cdfef7599dfd00d%3B+path%3D%2F%3B+domain%3Dcp105701-f.akamaihd.net%3B
20:57:17.062 T:139929956341504  NOTICE: Creating Demuxer
20:57:17.062 T:139929956341504   DEBUG: CDVDDemuxFFmpeg::GetFFMpegOptionsFromInput() adding ffmpeg option 'cookies: hdnea2=expires=1493324172~access=/*~md5=f168b329b3ed22565cdfef7599dfd00d; path=/; domain=cp105701-f.akamaihd.net;'
20:57:17.276 T:139931449338240   DEBUG: ------ Window Init (DialogBusy.xml) ------
20:57:17.339 T:139929956341504   DEBUG: ffmpeg[7F43FB575700]: [https] HTTP error 403 Forbidden
20:57:17.341 T:139929956341504   DEBUG: Error, could not open file https://cp105701-f.akamaihd.net/i/mtviestor/_!/intlod/MTVInternational/MBUS/TACTIC/201606/VIAMTVIPYC3186ZBVO8/it_awkward_524_clip04_,384x216_400_m30,512x288_750_m30,640x360_1200_m30,768x432_1700_m30,960x540_2200_m31,1280x720_3500_h32,.mp4.csmil/index_5_av.m3u8?e=e2006a2dec61af0a&id=AgBf9U9qX2VyHw0AAVk4Rva4b1zqNHViq1683krXKNixV7FNFpQWlpFdp7gF7953JXlG%2f24WfSpE6A%3d%3d&__s__=&__a__=off
20:57:17.341 T:139929956341504   ERROR: OpenDemuxStream - Error creating demuxer
20:57:17.341 T:139929956341504  NOTICE: CVideoPlayer::OnExit()
20:57:17.341 T:139929956341504   DEBUG: OnPlayBackStopped: play state was 1, starting 1
20:57:17.341 T:139931449338240   DEBUG: OnPlayBackStopped: play state was 3, starting 0
20:57:17.341 T:139931449338240   ERROR: Playlist Player: skipping unplayable item: 0, path [plugin://plugin.video.mtv.it/?action=v&at=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJVU0VSSUQ6ZHBsYXlpdDo2NWZmZjMzYi1kMjAwLTQ3MjEtYTk1Ni01Y2FiZDYxM2E5MDYiLCJqdGkiOiJ0b2tlbi01MGNhN2E0Yi1mNzk2LTRmMWMtYjY0ZS03YzhkZmI3OGI2NDciLCJhbm9ueW1vdXMiOnRydWUsImlhdCI6MTQ5MzMxOTQzMH0%3D.xZCtZuGO55Zl2i4bNqqBMPpbJ5ZxC4eBa_iyylEQkzQ%3D__%21__IvBoGoxQFdz5NGMV%2BcYXh%2BY8%2B3Feek9FHS4%2BO6Fd0dI%3D&value=5221]
20:57:17.341 T:139931449338240   DEBUG: Playlist Player: no more playable items... aborting playback
20:57:17.341 T:139929956341504   DEBUG: Thread VideoPlayer 139929956341504 terminating
20:57:17.341 T:139929956341504   DEBUG: Thread BackgroundLoader start, auto delete: false
Reply

Logout Mark Read Team Forum Stats Members Help
ffmpeg/player not setting cookies correctly0