Downloading Directly From DailyMotion


older notes:

Open a video, open developer-tools (CTRL + SHIFT + I)
mouse-click the play button and look for incoming requests looking like
http://proxy-041.dc3.dailymotion.com/sec(5c84dd58dc367bb3ac9639da30dcfb44)/frag(1)/video/151/637/230736151_mp4_h264_aac.ts

The .TS (mimetype video/mp2t), a.k.a “MPEG-2 Transport Stream” is preety much similar to mp4 format.

I use Orbitdownloader, adding group of downloads with the following URL:
http://proxy-041.dc3.dailymotion.com/sec(5c84dd58dc367bb3ac9639da30dcfb44)/frag(1)/video/151/637/230736151_mp4_h264_aac.ts
2016-05-15_000611

you can figure out sort-of the length of the segment, since each seg. is ~10 seconds,
and the body of the page (source html) has “buildPlayer({…….})…” which has
the part “client_embedder=&country=IL&length=2723&mode=vod&”, divide the number by 10 and you’ll get 272,

2016-05-15_000907

I’ve ignored any real-“length” calculation or estimation, and just added to Orbitdownloader the range of 0 to 299,
it have stopped after 273, so I’ve paused and deleted the rest,

joining the ts files to one mp4 is quite an “go ask google” thing..

/so-that-s–that../

another weird solutions..

ffmpeg -i “http://proxy-25.dailymotion.com/sec(e3532866da5b7e6ff4023e3691e36ada)/video/926/888/93888629_mp4_h264_aac_hq.m3u8” -c:v copy -c:a copy -bsf:a aac_adtstoasc 93888629_mp4_h264_aac_hq.mp4
ffmpeg -i “http://proxy-25.dailymotion.com/sec(e3532866da5b7e6ff4023e3691e36ada)/video/926/888/93888629_mp4_h264_aac_hq.m3u8” -c copy t1.ts
ffmpeg -i “http://proxy-32.dailymotion.com/sec(75a791d8d28b23314bdf5737b2555eb0)/video/980/998/93899089_mp4_h264_aac_hq.m3u8” -c copy t2.ts

ffmpeg -i “http://proxy-25.dailymotion.com/sec(e3532866da5b7e6ff4023e3691e36ada)/video/926/888/93888629_mp4_h264_aac_hq.m3u8” -c:v copy -c:a copy -bsf:a aac_adtstoasc 93888629_mp4_h264_aac_hq.mp4


newer notes:

I’ve I’ve found out that removing the /frag(...) part and replacing the .ts part with m3u8 works fine with ffmpeg, I’ve just used:

ffmpeg -i "http://proxy-041.dc3.dailymotion.com/sec(5c84dd58dc367bb3ac9639da30dcfb44)/video/151/637/230736151_mp4_h264_aac.m3u8" d.mp4

which will re-encode video and audio, it might take more time but will render a perfectly working video..
2016-05-15_003753


even newer notes:

now.. if you’ll try to use copy stream to make things faster, which is a good idea,

ffmpeg -threads 4 -i "http://proxy-041.dc3.dailymotion.com/sec(5c84dd58dc367bb3ac9639da30dcfb44)/video/151/637/230736151_mp4_h264_aac.m3u8" -threads 4 -vcodec copy -acodec copy d2.mp4

you’ll get:

[mp4 @ 04b21660] malformated aac bitstream, use -absf aac_adtstoasc
av_interleaved_write_frame(): Operation not permitted

but -absf aac_adtstoasc (by the doc.s -absf audio bitstream_filters) is deprecated,
using the newer directive is better: -bsf:a aac_adtstoasc

so the command should look something like:

2016-05-15_004838


even even newer notes:

I was looking over the page’s http://www.dailymotion.com/video/x3tdh5j_%D7%90%D7%A8%D7%A5-%D7%A0%D7%94%D7%93%D7%A8%D7%AA-%D7%A2%D7%95%D7%A0%D7%94-13-%D7%A4%D7%A8%D7%A7-4_tv‘s requests,
and I’ve noticed a manifest (just as before.. from the download.. stuff..)

http://www.dailymotion.com/cdn/manifest/video/x3tdh5j.m3u8?auth=1463431092-2688-ylnddc03-411c7491899659ca18506faa8e6dfbaf

looking at the page’s source, seems that the body’s html (well.. script..) code has it, 100% complete..
2016-05-15_011129

so sending a xhr to the address (along with the fact it is cross-domain friendly) should be fairly-reasonable..

opening the url in a new tab works fine too.. so.. minimal auth will work.
here is an example content for that http://www.dailymotion.com/cdn/manifest/video/x3tdh5j.m3u8?auth=1463431092-2688-ylnddc03-411c7491899659ca18506faa8e6dfbaf
manifest:

#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=460560,CODECS="mp4a.40.5,avc1.420016",RESOLUTION=512x288,NAME="380"
http://proxy-041.dc3.dailymotion.com/sec(5c84dd58dc367bb3ac9639da30dcfb44)/video/151/637/230736151_mp4_h264_aac.m3u8#cell=core
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=460560,CODECS="mp4a.40.5,avc1.420016",RESOLUTION=512x288,NAME="380"
http://proxy-057.dc3.dailymotion.com/sec(5c84dd58dc367bb3ac9639da30dcfb44)/video/151/637/230736151_mp4_h264_aac.m3u8#cell=core
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=246440,CODECS="mp4a.40.5,avc1.42000d",RESOLUTION=320x184,NAME="240"
http://proxy-041.dc3.dailymotion.com/sec(deef645bdd5e51071942bcfc5078f1ea)/video/151/637/230736151_mp4_h264_aac_ld.m3u8#cell=core
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=246440,CODECS="mp4a.40.5,avc1.42000d",RESOLUTION=320x184,NAME="240"
http://proxy-057.dc3.dailymotion.com/sec(deef645bdd5e51071942bcfc5078f1ea)/video/151/637/230736151_mp4_h264_aac_ld.m3u8#cell=core
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=836280,CODECS="mp4a.40.2,avc1.64001f",RESOLUTION=624x352,NAME="480"
http://proxy-041.dc3.dailymotion.com/sec(c016709adc127cd3bea56eeee596f932)/video/151/637/230736151_mp4_h264_aac_hq.m3u8#cell=core
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=836280,CODECS="mp4a.40.2,avc1.64001f",RESOLUTION=624x352,NAME="480"
http://proxy-057.dc3.dailymotion.com/sec(c016709adc127cd3bea56eeee596f932)/video/151/637/230736151_mp4_h264_aac_hq.m3u8#cell=core

parsing the EXTM3U format can help you get various qualities the highers were the last two (by BANDWIDTH value).

there are two values, which seems to be two available proxies,
and (operating some logic here..)
I’ve noticed that the response-time header for the domain is exposed,
so the website may serve the the content from either of those proxies/cdn(s), the decisions is done at client side apparently which is kind’a weird (but still ok…)

so selecting the last one, and running:

ffmpeg -threads 4 -i "http://proxy-057.dc3.dailymotion.com/sec(c016709adc127cd3bea56eeee596f932)/video/151/637/230736151_mp4_h264_aac_hq.m3u8#cell=core" -vcodec copy -acodec copy -bsf:a aac_adtstoasc  "eretz_nehederet_s13e04.mp4"

the #cell=core makes ffmpeg break..
2016-05-15_012336

I don’t really want to escape stuff.. so I’ve just removed the “URI-hash” (#cell=core suffix)
and it works ok…

2016-05-15_012459


even newer^5 notes:

this code will extract the “main”-manifest, the one which has whole resolutions.
document.querySelector(‘html’).cloneNode(true).innerHTML.match(/\”[^\”]*\:\/\/[^\”]+manifest[^\”]+\”/gim).shift()

– I’ve using document.querySelector('html').cloneNode(true) as a trick,
cloning node will give you back the “from HTML source” initial rendering, so even if for some reason, to make things harder, some JavaScript will delete the script element from the page (leaving only the one in memory),
it won’t matter, and still be operations.

– another way is fetching the entire page online using xhr, which is (same domain..) cross-domain-safe, and either parsing or text-matching to find it (the “main”-manifest that is..), but this way you’ll be using the web again..


new^6 notes:

this is probably a better regex..
document.querySelector('html').cloneNode(true).innerHTML.match(/\"[^\"]+manifest[^\"]+video[^\"]+\.m3u8[^\"]+auth[^\"]+\"/gi)[1]

resulting with

""http:\/\/www.dailymotion.com\/cdn\/manifest\/video\/x3quehc.m3u8?auth=1463438444-2688-9g5iifnr-c3c53d7b37d06eee90bcdc88061ceaa2""

new^7 notes:

JSON.parse(
document.querySelector('html').cloneNode(true).innerHTML.match(/\"[^\"]+manifest[^\"]+video[^\"]+\.m3u8[^\"]+auth[^\"]+\"/gi)[1]
);

will ‘unescape’ the backslash and possibly other characters without messing around with any additional regular-expressions and string-replace calls.

all you have to do is use the ‘ffmpeg’ solution
(download ffmpeg for windows from here, here or here – choose the ‘static’ version)

ffmpeg -i ___the_m3u8_url___ -threads 8 -vcodec copy -acodec copy -scodec copy output.mp4

you can later follow the guide at iCompile – FFMPEG Fixes Your Video Files to fix the output de-interlace, remove repeating frames and properly encode to play at mobile-devices or to be streamed / uploaded to youtube..