szymex / xbmc-finnish-tv

XBMC Video Plugins for playing Finnish television content containers.
GNU General Public License v3.0
31 stars 38 forks source link

Katsomo: Alternative user-agent is needed to stream #57

Closed GoodDragon closed 10 years ago

GoodDragon commented 10 years ago

Looks that they have changed something again. Now only News works using current user-agent header.

What I tested with iPad it looks that you need download "http://m.katsomo.fi/?progId=..." using user-agent: "Mozilla/5.0 (iPad; CPU OS 7_1_1 like Mac OS X) AppleWebKit/537.51.2 (KHTML, like Gecko) Mobile/11D201"

and after that you need use this user-agent (for playlist.m3u8, chunklist.m3u8, etc): "AppleCoreMedia/1.0.0.11D201 (iPad; U; CPU OS 7_1_1 like Mac OS X; fi_fi)"

Unfortunately I don't have enough understand of this plugin for fix this problem. User-agent parameters is needed somehow send to ffmpeg?

schulerjoe commented 10 years ago

I don't think this is an User Agent issue. Looks more like a code issue.

Unfortunately my python coding skills are very limited. Would be nice if the owner could have a look and fix it, thanks!

XMBC Debug log: http://xbmclogs.com/show.php?id=214147

GoodDragon commented 10 years ago

schulerjoe, problem on yours log file looks different on that this one is. You probably have some some dependecies missing etc. Create another issue about that if you are sure that your installation is ok.

On this problem playlist.m3u8 download success but after that when plugin tries download chunklist.m3u8 it fails. Error lines from log: "15:50:12 T:2880435264 INFO: CDVDInputStreamFFmpeg: Auto-selecting http://mtvhlsvod.edgesuite.net/mtv3_viihde_vod/_definst_/mp4:2014-05-14/Salatut_el_m_t_340027_WC!340027,T5-3HLSH!.mp4/chunklist.m3u8?wowzasessionid=1122171579&hdnea=st%3D1401123375%7Eexp%3D1401123495%7Eacl%3D%2Fmtv3_viihde_vod%2F_definst_%2Fmp4%3A2014-05-14%2FSalatut_el_m_t_340027_WC%21340027%2CT5-3HLSH%21.mp4%2Fplaylist.m3u8*%7Ehmac%3De9728a7bd216f2c538bbba7cae142a8fc33cc2eacf86bab00e829c196f5c3274 based on configured bandwidth. 15:50:12 T:2880435264 NOTICE: Creating Demuxer 15:50:12 T:2880435264 DEBUG: ffmpeg[ABAFF440]: [http] HTTP error 403 Forbidden 15:50:12 T:2880435264 DEBUG: Error, could not open file http://mtvhlsvod.edgesuite.net/mtv3_viihde_vod/_definst_/mp4:2014-05-14/Salatut_el_m_t_340027_WC!340027,T5-3HLSH!.mp4/chunklist.m3u8?wowzasessionid=1122171579&hdnea=st%3D1401123375%7Eexp%3D1401123495%7Eacl%3D%2Fmtv3_viihde_vod%2F_definst_%2Fmp4%3A2014-05-14%2FSalatut_el_m_t_340027_WC%21340027%2CT5-3HLSH%21.mp4%2Fplaylist.m3u8*%7Ehmac%3De9728a7bd216f2c538bbba7cae142a8fc33cc2eacf86bab00e829c196f5c3274 15:50:12 T:2880435264 ERROR: OpenDemuxStream - Error creating demuxer 15:50:12 T:2880435264 NOTICE: COMXPlayer::OnExit() 15:50:12 T:2880435264 NOTICE: COMXPlayer::OnExit() deleting input stream"

But if I try download that file using AppleCoreMedia... user-agent it works. So I would say that this is user-agent issue. Without correct user-agent and cookie server will give 403 error.

szymex commented 10 years ago

In my android phone (4.4 Kitkat) those videos does not work.

GoodDragon commented 10 years ago

Links above not working directly and reason for that is below.

I did more investications using Fiddler and here you can see series loading works on iPad:

So like I said earlier. User-agent changes after first step and another thing what I noticed was that when you loading chunklist.m3u8 and media_*.ts -files you need also have cookie included to request. Without them server will give you 403 error.

I can see that xbmc supports send user-agent and cookies to ffmpeg but I don't understand how to do that: https://github.com/xbmc/xbmc/blob/master/xbmc/cores/dvdplayer/DVDDemuxers/DVDDemuxFFmpeg.cpp

schulerjoe commented 10 years ago

hmm, this is getting really complicated now...

btw, katsomo mobile website is still in beta and they can or will change it any day i think. would be nice to sniff the traffic from the katsomo apps (andorid/iphone) and find out how they stream the content there. dunno if it even makes sense to put that much effort in making the addon woking with the mobile website cause the quality, as far as i can see, is crappy anyways.

GoodDragon commented 10 years ago

One option would be use Windows Phone's method. It calls url http://cdn.katsomo.fi/api/mobileapp/asset//play url where ID is same than on m.katsomo.fi url.

On my Windows Phone 8.1 device user-agent is "User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/35.0.1916.114 Safari/537.36" but it looks like it doesn't matter which user-agent you using when calling that cdn api. But I don't know how compilicated is it get ism support to xbmc.

That iPad method what I described earlier was sniffed from katsomo app and I think that iPhone uses same method.

You can do same thing like this with your devices

GoodDragon commented 10 years ago

Actually I found way send user-agent to ffmpeg. It is now included to my repository: GoodDragon@beee959c90d9420894105bf337730a6a0b0782c5

but there is still another problem because ffmpeg uses by default "Range: bytes=0-" header on its requests and looks that they are added detection for them. I confirmed that using my test script that if you use that header when calling chunklist file server will return 403 error and without it you will get right answer.

GoodDragon commented 10 years ago

Found solution. Please, merge #58 and release new version.

szymex commented 10 years ago

Just pushed release. Thanks again.

szymex commented 10 years ago

Could you check issue #18? Maybe you could figure out what parameters to provide so video is in sync with audio after seek.