优酷真实下载地址解析
时间:2017-7-25 14:45
热度:3455°
评论:0 条
下载各大网站的视频,对于小白用户可以直接下载相应的网站客户端,如优酷客户端
有些网站可能没有,那你可以去硕鼠上下http://www.flvcd.com/
对于程序员来说就要从根本上了解了。
ok,那就举个优酷的具体例子。时间:2012-11-19,如果有一天这个方法不行了,那是优酷改算法了....
首先你要找到你想下载的视频的播放页面
如:http://v.youku.com/v_show/id_XNDc2Mzc1MTU2.html //(布兰妮)
2 将上面id_XNDc2Mzc1MTU2.html 的XNDc2Mzc1MTU2 放到下面的地址里
http://v.youku.com/player/getPlayList/VideoIDS/
组合为:http://v.youku.com/player/getPlayList/VideoIDS/XNDc2Mzc1MTU2
3 ok,在浏览器里面打开上面的网址
会看到下面一大堆代码(你在本地看的时候最大化这个文本文档)
{"data":[{"ct":"f","cs":"2124|2232|2125","logo":"http:\/\/g1.ykimg.com\/1100641F4650A7A9B0385400E68D47ED32E247-01C1-BB97-442B-
74F5E03E4534","seed":6344,"tags":["\u5e03\u5170\u59ae","Britney","Spears","CHER","ADELE","Darkness","MV","\u6df7
\u97f3"],"categories":"95","videoid":"119093789","vidEncoded":"XNDc2Mzc1MTU2","username":"\u7334\u59c6","userid":"15109447","title":"\u3010
\u7334\u59c6\u72ec\u5bb6\u3011\u5e03\u5170\u59ae\u3001Cher\u3001Adele\u3001The Darkness\u5de8\u597d\u542c\u6df7
\u97f3mv\uff01","up":142,"down":14,"ts":"NpdKxziap0I5epCpAfdzpgc","tsup":"NpdO7Tuap0I5epCpAt13pgc","key1":"b3460bb4","key2":"9245d1c8e7e32933
","tt":"0","videoSource":"1","seconds":"276.55","streamfileids":
{"hd2":"14*0*14*14*14*41*14*41*14*14*64*14*49*28*49*56*49*20*41*20*12*56*14*14*8*9*58*26*51*28*9*51*8*64*0*12*51*51*1*9*41*56*28*1*49*14*51*5
8*1*58*12*26*9*1*56*64*14*8*64*0*12*58*20*51*28*8*","mp4":"14*0*14*14*14*58*14*41*14*14*64*14*49*28*49*28*56*58*41*20*12*56*14*14*8*9*58*26*5
1*28*9*51*8*64*0*12*51*51*1*9*41*56*28*1*49*14*51*58*1*58*12*26*9*1*56*64*14*8*64*0*12*58*20*51*28*8*","flv":"14*0*14*14*14*12*14*41*14*14*64
*14*49*28*49*0*20*9*41*20*12*56*14*14*8*9*58*26*51*28*9*51*8*64*0*12*51*51*1*9*41*56*28*1*49*14*51*58*1*58*12*26*9*1*56*64*14*8*64*0*12*58*20
*51*28*8*"},"segs":{"hd2":[{"no":0,"size":"41588469","seconds":"277","k":"2d7095f6398c7a8a282826e4","k2":"19f87ff924a26ece3"}],"mp4":
[{"no":0,"size":"19022745","seconds":"277","k":"83f2d20acdbe2f03282826e4","k2":"1ebc63639b671b482"}],"flv":
[{"no":0,"size":"9932910","seconds":"277","k":"4be592cfae8eea21282826e4","k2":"167f8074bfb7bdca7"}]},"streamsizes":
{"hd2":"41588469","mp4":"19022745","flv":"9932910"},"stream_ids":{"hd2":"96664057","mp4":"96662457","flv":"96659445"},"streamlogos":
{"hd2":"1","mp4":"1","flv":"1"},"streamtypes":["hd2","mp4","flv"],"streamtypes_o":["hd2","flvhd","mp4"]}],"user":{"id":0},"controller":
{"search_count":true,"mp4_restrict":1,"stream_mode":2,"share_disabled":false,"download_disabled":false,"video_capture":true,"area_code":31000
0,"dma_code":4812,"continuous":1,"playmode":"normal","circle":false}}
4 下面从里面找到几个关键的信息// 可以使用ctrl+f 查找一下
"seed":6344 //程序中用来计算key的时间种子
"key1":"b3460bb4"
"key2":"9245d1c8e7e32933" //两个key 这个key1 key2 在以前的优酷上是有用的,现在可以不使用了
"streamfileids":// 可以看到 这里面分为hd2 mp4 flv,不是每个视频都有这三种格式的{
"hd2":[{"no":0,"size":"41588469","seconds":"277","k":"2d7095f6398c7a8a282826e4","k2":"19f87ff924a26ece3"}],
"mp4":[{"no":0,"size":"19022745","seconds":"277","k":"83f2d20acdbe2f03282826e4","k2":"1ebc63639b671b482"}],
"flv":[{"no":0,"size":"9932910","seconds":"277","k":"4be592cfae8eea21282826e4","k2":"167f8074bfb7bdca7"}]}
5 组合下载地址
现在的优酷下载地址比起以前来已经简单了其实只有两部分数据 我用$P1、$P2 来代表,另外类型不同 地址也不同 我以flv为例
得到$P1 $P2 把他们放到下面的地址里面
http://f.youku.com/player/getFlvPath/sid/00_00/st/flv/fileid/ $P1?K=$P2
上面地址里有st/flv 如果你下载的是其他的类型,如mp4 只要改为st/mp4就可以了
6 下面我重点说下 如何得到$P1 、$P2
$P1是由算法得到的
下面这个是c#版本的,c/c++版本的不便透漏,可以自己试着改下,不难
调用getFileID
参数说明:
fileid//即为"streamfiledids" 里面相应类型的那一串
如flv的
"14*0*14*14*14*12*14*41*14*14*64*14*49*28*49*0*20*9*41*20*12*56*14*14*8*9*58*26*51*28*9*51*8*64*0*12*51*51*1*9*41*56*28*1*49*14*51*58*1*58*12*26*9*1*56*64*14*8*64*0*12*58*20*51*28*8*"
seed 就是上面的"seed":6344
返回值:即为$P1 = 030002010050A7A3B61B2900E68D4764E53244-6197-A048-82D6-950E5328B47E
public static String getFileID(String fileid, double seed)
{
String mixed = getFileIDMixString(seed);
String[] ids = fileid.Split('*');
StringBuilder realId = new StringBuilder();
int idx;
for (int i = 0; i < ids.Length - 1; i++)
{
idx = int.Parse(ids[i]);
realId.Append(mixed[idx]);
}
//Console.Write(realId.ToString());
return realId.ToString();
}
public static String getFileIDMixString(double seed)
{
StringBuilder mixed = new StringBuilder();
StringBuilder source = new StringBuilder("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/\\:._-1234567890");
int index, len = source.Length;
for (int i = 0; i < len; ++i)
{
seed = (seed * 211 + 30031) % 65536;
index = (int)Math.Floor(seed / 65536 * source.Length);
mixed.Append(source[index]);
source.Remove(index, 1);
}
return mixed.ToString();
}
7 $P2的来源
看到segs字段了么,如flv的
"flv":[{"no":0,"size":"9932910","seconds":"277","k":"4be592cfae8eea21282826e4","k2":"167f8074bfb7bdca7"}]}
可以在这里面看到"k":"4be592cfae8eea21282826e4" OK,这个就是$P2了,也就是key,注意k2是没法用的
以前网上流传的算法其实都是通过key1 key2通过算法得到的key,现在不知道为什么优酷直接显示出来了。
8 ok,既然$P1 $P2都已经找到了,那么下载地址也就找到了
根据:http://f.youku.com/player/getFlvPath/sid/00_00/st/flv/fileid/ $P1?K=$P2
得到:http://f.youku.com/player/getFlvPath/sid/00_00/st/flv/fileid/030002010050A7A3B61B2900E68D4764E53244-6197-A048-82D6-950E5328B47E?
K=4be592cfae8eea21282826e4
Don't worry, 你如果想下载这个视频 重新在浏览器里面输入
http://v.youku.com/player/getPlayList/VideoIDS/XNDc2Mzc1MTU2 对,没错就是它,第2步里面的那个地址
输入后在页面上重新找到segs 字段里面的那个k,也就是$P2
就可以重新得到下载地址了
http://f.youku.com/player/getFlvPath/sid/00_00/st/flv/fileid/030002010050A7A3B61B2900E68D4764E53244-6197-A048-82D6-950E5328B47E?K=(放到这个位
置)
10 其实上面这个视频我是找了个小的,如果是大视频的话,他的分段比较多,比如一些电影常常会有七八个分段,但是不管怎么样,只是$P2的值在变,你只需
要改一下$P2即可
有些网站可能没有,那你可以去硕鼠上下http://www.flvcd.com/
对于程序员来说就要从根本上了解了。
ok,那就举个优酷的具体例子。时间:2012-11-19,如果有一天这个方法不行了,那是优酷改算法了....
首先你要找到你想下载的视频的播放页面
如:http://v.youku.com/v_show/id_XNDc2Mzc1MTU2.html //(布兰妮)
2 将上面id_XNDc2Mzc1MTU2.html 的XNDc2Mzc1MTU2 放到下面的地址里
http://v.youku.com/player/getPlayList/VideoIDS/
组合为:http://v.youku.com/player/getPlayList/VideoIDS/XNDc2Mzc1MTU2
3 ok,在浏览器里面打开上面的网址
会看到下面一大堆代码(你在本地看的时候最大化这个文本文档)
{"data":[{"ct":"f","cs":"2124|2232|2125","logo":"http:\/\/g1.ykimg.com\/1100641F4650A7A9B0385400E68D47ED32E247-01C1-BB97-442B-
74F5E03E4534","seed":6344,"tags":["\u5e03\u5170\u59ae","Britney","Spears","CHER","ADELE","Darkness","MV","\u6df7
\u97f3"],"categories":"95","videoid":"119093789","vidEncoded":"XNDc2Mzc1MTU2","username":"\u7334\u59c6","userid":"15109447","title":"\u3010
\u7334\u59c6\u72ec\u5bb6\u3011\u5e03\u5170\u59ae\u3001Cher\u3001Adele\u3001The Darkness\u5de8\u597d\u542c\u6df7
\u97f3mv\uff01","up":142,"down":14,"ts":"NpdKxziap0I5epCpAfdzpgc","tsup":"NpdO7Tuap0I5epCpAt13pgc","key1":"b3460bb4","key2":"9245d1c8e7e32933
","tt":"0","videoSource":"1","seconds":"276.55","streamfileids":
{"hd2":"14*0*14*14*14*41*14*41*14*14*64*14*49*28*49*56*49*20*41*20*12*56*14*14*8*9*58*26*51*28*9*51*8*64*0*12*51*51*1*9*41*56*28*1*49*14*51*5
8*1*58*12*26*9*1*56*64*14*8*64*0*12*58*20*51*28*8*","mp4":"14*0*14*14*14*58*14*41*14*14*64*14*49*28*49*28*56*58*41*20*12*56*14*14*8*9*58*26*5
1*28*9*51*8*64*0*12*51*51*1*9*41*56*28*1*49*14*51*58*1*58*12*26*9*1*56*64*14*8*64*0*12*58*20*51*28*8*","flv":"14*0*14*14*14*12*14*41*14*14*64
*14*49*28*49*0*20*9*41*20*12*56*14*14*8*9*58*26*51*28*9*51*8*64*0*12*51*51*1*9*41*56*28*1*49*14*51*58*1*58*12*26*9*1*56*64*14*8*64*0*12*58*20
*51*28*8*"},"segs":{"hd2":[{"no":0,"size":"41588469","seconds":"277","k":"2d7095f6398c7a8a282826e4","k2":"19f87ff924a26ece3"}],"mp4":
[{"no":0,"size":"19022745","seconds":"277","k":"83f2d20acdbe2f03282826e4","k2":"1ebc63639b671b482"}],"flv":
[{"no":0,"size":"9932910","seconds":"277","k":"4be592cfae8eea21282826e4","k2":"167f8074bfb7bdca7"}]},"streamsizes":
{"hd2":"41588469","mp4":"19022745","flv":"9932910"},"stream_ids":{"hd2":"96664057","mp4":"96662457","flv":"96659445"},"streamlogos":
{"hd2":"1","mp4":"1","flv":"1"},"streamtypes":["hd2","mp4","flv"],"streamtypes_o":["hd2","flvhd","mp4"]}],"user":{"id":0},"controller":
{"search_count":true,"mp4_restrict":1,"stream_mode":2,"share_disabled":false,"download_disabled":false,"video_capture":true,"area_code":31000
0,"dma_code":4812,"continuous":1,"playmode":"normal","circle":false}}
4 下面从里面找到几个关键的信息// 可以使用ctrl+f 查找一下
"seed":6344 //程序中用来计算key的时间种子
"key1":"b3460bb4"
"key2":"9245d1c8e7e32933" //两个key 这个key1 key2 在以前的优酷上是有用的,现在可以不使用了
"streamfileids":// 可以看到 这里面分为hd2 mp4 flv,不是每个视频都有这三种格式的{
"hd2":"14*0*14*14*14*41*14*41*14*14*64*14*49*28*49*56*49*20*41*20*12*56*14*14*8*9*58*26*51*28*9*51*8*64*0*12*51*51*1*9*41*56*28*1*49*14*51*58*1*58*12*26*9*1*56*64*14*8*64*0*12*58*20*51*28*8*",
"mp4":"14*0*14*14*14*58*14*41*14*14*64*14*49*28*49*28*56*58*41*20*12*56*14*14*8*9*58*26*51*28*9*51*8*64*0*12*51*51*1*9*41*56*28*1*49*14*51*58*1*58*12*26*9*1*56*64*14*8*64*0*12*58*20*51*28*8*",
"flv":"14*0*14*14*14*12*14*41*14*14*64*14*49*28*49*0*20*9*41*20*12*56*14*14*8*9*58*26*51*28*9*51*8*64*0*12*51*51*1*9*41*56*28*1*49*14*51*58*1*58*12*26*9*1*56*64*14*8*64*0*12*58*20*51*28*8*"}
"segs"://这里面也分为hd2 mp4 flv,你会发现hd2的size最大,所以如果想下最清晰的请选择hd2,其次mp4,最后flv"hd2":[{"no":0,"size":"41588469","seconds":"277","k":"2d7095f6398c7a8a282826e4","k2":"19f87ff924a26ece3"}],
"mp4":[{"no":0,"size":"19022745","seconds":"277","k":"83f2d20acdbe2f03282826e4","k2":"1ebc63639b671b482"}],
"flv":[{"no":0,"size":"9932910","seconds":"277","k":"4be592cfae8eea21282826e4","k2":"167f8074bfb7bdca7"}]}
5 组合下载地址
现在的优酷下载地址比起以前来已经简单了其实只有两部分数据 我用$P1、$P2 来代表,另外类型不同 地址也不同 我以flv为例
得到$P1 $P2 把他们放到下面的地址里面
http://f.youku.com/player/getFlvPath/sid/00_00/st/flv/fileid/ $P1?K=$P2
上面地址里有st/flv 如果你下载的是其他的类型,如mp4 只要改为st/mp4就可以了
6 下面我重点说下 如何得到$P1 、$P2
$P1是由算法得到的
下面这个是c#版本的,c/c++版本的不便透漏,可以自己试着改下,不难
调用getFileID
参数说明:
fileid//即为"streamfiledids" 里面相应类型的那一串
如flv的
"14*0*14*14*14*12*14*41*14*14*64*14*49*28*49*0*20*9*41*20*12*56*14*14*8*9*58*26*51*28*9*51*8*64*0*12*51*51*1*9*41*56*28*1*49*14*51*58*1*58*12*26*9*1*56*64*14*8*64*0*12*58*20*51*28*8*"
seed 就是上面的"seed":6344
返回值:即为$P1 = 030002010050A7A3B61B2900E68D4764E53244-6197-A048-82D6-950E5328B47E
public static String getFileID(String fileid, double seed)
{
String mixed = getFileIDMixString(seed);
String[] ids = fileid.Split('*');
StringBuilder realId = new StringBuilder();
int idx;
for (int i = 0; i < ids.Length - 1; i++)
{
idx = int.Parse(ids[i]);
realId.Append(mixed[idx]);
}
//Console.Write(realId.ToString());
return realId.ToString();
}
public static String getFileIDMixString(double seed)
{
StringBuilder mixed = new StringBuilder();
StringBuilder source = new StringBuilder("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ/\\:._-1234567890");
int index, len = source.Length;
for (int i = 0; i < len; ++i)
{
seed = (seed * 211 + 30031) % 65536;
index = (int)Math.Floor(seed / 65536 * source.Length);
mixed.Append(source[index]);
source.Remove(index, 1);
}
return mixed.ToString();
}
7 $P2的来源
看到segs字段了么,如flv的
"flv":[{"no":0,"size":"9932910","seconds":"277","k":"4be592cfae8eea21282826e4","k2":"167f8074bfb7bdca7"}]}
可以在这里面看到"k":"4be592cfae8eea21282826e4" OK,这个就是$P2了,也就是key,注意k2是没法用的
以前网上流传的算法其实都是通过key1 key2通过算法得到的key,现在不知道为什么优酷直接显示出来了。
8 ok,既然$P1 $P2都已经找到了,那么下载地址也就找到了
根据:http://f.youku.com/player/getFlvPath/sid/00_00/st/flv/fileid/ $P1?K=$P2
得到:http://f.youku.com/player/getFlvPath/sid/00_00/st/flv/fileid/030002010050A7A3B61B2900E68D4764E53244-6197-A048-82D6-950E5328B47E?
K=4be592cfae8eea21282826e4
9 当你看到我给出的这个下载地址的时候,或许你会蠢蠢欲动了,想去直接下载下试试,呵呵 ,告诉你,除非你在我发帖的一个小时内看到。
优酷的这个下载地址的key是1个小时左右变化一次,所以你看到的时候应该已经无法下载了。Don't worry, 你如果想下载这个视频 重新在浏览器里面输入
http://v.youku.com/player/getPlayList/VideoIDS/XNDc2Mzc1MTU2 对,没错就是它,第2步里面的那个地址
输入后在页面上重新找到segs 字段里面的那个k,也就是$P2
就可以重新得到下载地址了
http://f.youku.com/player/getFlvPath/sid/00_00/st/flv/fileid/030002010050A7A3B61B2900E68D4764E53244-6197-A048-82D6-950E5328B47E?K=(放到这个位
置)
10 其实上面这个视频我是找了个小的,如果是大视频的话,他的分段比较多,比如一些电影常常会有七八个分段,但是不管怎么样,只是$P2的值在变,你只需
要改一下$P2即可
11 Ok,打完收工....
捐赠支持:如果觉得这篇文章对您有帮助,请“扫一扫”鼓励作者!
相关文章
本文无需标签!