anyone can I help me to download a streaming video from vod movistar.es?
I tried to download with youtube-dl but it's not working...
+ Reply to Thread
Results 1 to 4 of 4
This video not playing when i add to my player online
Lately I've been trying to download VoD from Movistar without luck. Both URLs you post are perfectly valid, but they're encrypted in a way I struggle to understand.
In this post I'll to explain what I've found so far, so anyone interested could solve this once and for all
1. Getting stream data
Ok, let's take your first link as an starting point for this example: http://XXXXX.vod.cdn.telefonica.com/.../index-02-spa.m3u8
This M3U8 file contains all SD qualities available for that digital content. But, and here's the trick, if we request index-01-spa.m3u8 instead, we get all available streams (both SD and HD):
#EXTM3U #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=5895680,RESOLUTION=1280x720,CODECS="avc1.4d4020,mp4a.40.2" 01.m3u8 #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=4355584,RESOLUTION=1280x720,CODECS="avc1.4d4020,mp4a.40.2" 03.m3u8 #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2815488,RESOLUTION=1024x576,CODECS="avc1.4d401f,mp4a.40.2" 05.m3u8 #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2200352,RESOLUTION=1024x576,CODECS="avc1.4d401e,mp4a.40.2" 07.m3u8 #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=2200352,RESOLUTION=640x360,CODECS="avc1.4d4015,mp4a.40.2" 09.m3u8 #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1481440,RESOLUTION=640x360,CODECS="avc1.4d401f,mp4a.40.2" 11.m3u8 #EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=1173120,RESOLUTION=480x270,CODECS="avc1.4d401f,mp4a.40.2" 13.m3u8
#EXTM3U #EXT-X-VERSION:3 #EXT-X-TARGETDURATION:11 #EXT-X-MEDIA-SEQUENCE:0 #EXT-X-KEY:METHOD=AES-128,URI="http://www.nagra.com/key=268327&prm=eyJjb250ZW50SWQiOiIyNjgzMjciLCJrZXlJZCI6ImFhZTk5NzhjLWJkZGUtNDMyZi1hMDg3LTYxNTI4MjVkZjVlZCJ9",IV=0x00000000000000000000000000000000 #EXTINF:10, 01-0.ts #EXTINF:10, 01-1.ts [...] #EXTINF:5.6, 01-326.ts #EXT-X-ENDLIST
2. Extracting the key
Now, this is when this gets tricky. Due to the stream being encrypted we need a way to decrypt it before merging all TS files. This is usually achieved by using FFMPEG:
ffmpeg -protocol_whitelist "file,http,https,tcp,tls,crypto" -allowed_extensions ALL -i "http://XXXXX.vod.cdn.telefonica.com/.../01.m3u8" -c copy "output.ts"
FFMPEG is trying to download the key specified in the M3U8, which is supposed to be located at http://www.nagra.com/key=268327&prm=a_really_long_base64_string. But that URL doesn't exists, and the Movistar player has to be taking the decryption key from somewhere.
After doing some traffic captures, I came to the conclusion that the key has to be hidden inside the M3U8 file.
3. Understanding the key
Let's take that long string from the fake key URL: eyJjb250ZW50SWQiOiIyNjgzMjciLCJrZXlJZCI6ImFhZTk5Nz hjLWJkZGUtNDMyZi1hMDg3LTYxNTI4MjVkZjVlZCJ9.
If we Base64-decode it, we get this JSON object:
We seem to have found the decryption key: 0xaae9978cbdde432fa0876152825df5ed. But... that doesn't work either, as FFMPEG returns this error message:
Error when loading first segment 'http://b38545.1.vod.cdn.telefonica.com/38545/prod/hls/cplus-1422250_cplus-1422250-hls_20170921_083550/01-0.ts' D:\ConsoleProjects\tmp\stream.m3u8: Invalid data found when processing input
This is what I've got so far. I've have no idea why this doesn't work, so any help will be appreciated. I attach three files if you want to test this for yourself:
- stream.m3u8: contains the parsed stream file with the key path fixed
- stream.key: the 16 bytes decryption key
- command.bat: the FFMPEG command