Chinaunix首页 | 论坛 | 博客
  • 博客访问: 698440
  • 博文数量: 112
  • 博客积分: 2486
  • 博客等级: 大尉
  • 技术积分: 1541
  • 用 户 组: 普通用户
  • 注册时间: 2009-12-14 18:30
文章分类

全部博文(112)

文章存档

2012年(5)

2011年(48)

2010年(26)

2009年(33)

我的朋友

分类: LINUX

2010-11-30 18:06:42

(1)XMjI1MzUxNDg4.html     红色video_id
(2)根据(1)中的这个video_id构造下面的URL:
XMjI1MzUxNDg4/version/5/source/video?password=&ran=8704&n=3
注,除了红色部分,其余部分不变。
(3)请求(2)中的URL,服务器返回一个字符串:
{"data":[{"tt":"0","show":{"showid":"25132","paid":0,"show_paid":0,"copyright":1,"theaterid":0},"ct":"c","cs":"2043|2049|2056","logo":"http:\/\/g1.ykimg.com\/1100641F464C4139583D390031ED7945A228C8-15B1-8635-CFCC-51B398AF8663","seed":6296,"tags":["\u6b27\u7f8e","\u6218\u4e89"],"categories":"96","videoid":"56337872","vidEncoded":"XMjI1MzUxNDg4","list":[],"list_pre":{},"list_next":{},"username":"\u82e6\u74dc\u5976\u8336","userid":"43609124","title":"[\u6218\u4e89\u4e4b\u738b][\u9ad8\u6e05RMVB]","key1":"b14acf70","key2":"198bf247848cf72e","seconds":"7302.00","streamfileids":{"mp4":"6*9*6*6*6*65*20*37*6*6*5*17*5*20*12*65*9*47*66*54*65*66*6*6*9*20*14*47*46*12*32*32*32*6*9*6*47*46*40*6*5*66*12*40*20*65*37*32*40*6*6*9*9*40*66*9*14*9*61*61*5*37*5*9*65*37*","flv":"6*9*6*6*6*37*20*37*6*6*5*17*5*20*9*12*51*65*66*54*65*66*6*6*9*20*14*47*46*12*32*32*32*6*9*6*47*46*40*6*5*66*12*40*20*65*37*32*40*6*6*9*9*40*66*9*14*9*61*61*5*37*5*9*65*37*"},"segs":{"mp4":[{"no":"0","size":"37919316","seconds":"423"},{"no":"1","size":"28131965","seconds":"421"},{"no":"2","size":"31824362","seconds":"424"},{"no":"3","size":"33734220","seconds":"425"},{"no":"4","size":"25087737","seconds":"423"},{"no":"5","size":"23997683","seconds":"425"},{"no":"6","size":"23247420","seconds":"421"},{"no":"7","size":"31110684","seconds":"422"},{"no":"8","size":"20040773","seconds":"422"},{"no":"9","size":"22950277","seconds":"422"},{"no":"10","size":"26874202","seconds":"424"},{"no":"11","size":"18384418","seconds":"423"},{"no":"12","size":"16419055","seconds":"425"},{"no":"13","size":"22698918","seconds":"425"},{"no":"14","size":"33783183","seconds":"420"},{"no":"15","size":"16497061","seconds":"421"},{"no":"16","size":"38430270","seconds":"425"},{"no":"17","size":"10672371","seconds":"113"}],"flv":[{"no":"0","size":"13471496","seconds":"423"},{"no":"1","size":"14052710","seconds":"423"},{"no":"2","size":"13498051","seconds":"424"},{"no":"3","size":"12665361","seconds":"425"},{"no":"4","size":"13892859","seconds":"420"},{"no":"5","size":"13574914","seconds":"420"},{"no":"6","size":"13742905","seconds":"424"},{"no":"7","size":"14498988","seconds":"423"},{"no":"8","size":"11452915","seconds":"424"},{"no":"9","size":"14807438","seconds":"424"},{"no":"10","size":"13445929","seconds":"426"},{"no":"11","size":"12769193","seconds":"424"},{"no":"12","size":"13809426","seconds":"420"},{"no":"13","size":"14251918","seconds":"420"},{"no":"14","size":"15339423","seconds":"422"},{"no":"15","size":"10748628","seconds":"426"},{"no":"16","size":"17117101","seconds":"425"},{"no":"17","size":"3409612","seconds":"110"}]},"streamsizes":{"mp4":"461803915","flv":"236548867"},"streamtypes":["flvhd","mp4"],"streamtypes_o":["flvhd","mp4"]}],"user":{"id":0},"controller":{"search_count":true,"mp4_restrict":1,"stream_mode":1,"share_disabled":false,"download_disabled":false,"continuous":0}}

从这里面解析出下面几个值:
$seed, $key1, $key2, $fileId, $flv_no
$seed = 6296
$key1 = b14acf70
$key2 = 198bf247848cf72e
$fileId = 6*9*6*6*6*65*20*37*6*6*5*17*5*20*12*65*9*47*66*54*65*66*6*6*9*20*14*47*46*12*32*32*32*6*9*6*47*46*40*6*5*66*12*40*20*65*37*32*40*6*6*9*9*40*66*9*14*9*61*61*5*37*5*9*65*37*","flv":"6*9*6*6*6*37*20*37*6*6*5*17*5*20*9*12*51*65*66*54*65*66*6*6*9*20*14*47*46*12*32*32*32*6*9*6*47*46*40*6*5*66*12*40*20*65*37*32*40*6*6*9*9*40*66*9*14*9*61*61*5*37*5*9*65*37*

$flv_no = 0 1 2 。。。。17
注意,KEY1 KEY2的值是会变动的。
然后调用下面函数得到realId,
my $realId  = &getFileId($fileId, getMixString($seed));
sub getFileId {
 my ($fileId, $mixed) = @_;
 my $realId;
 my @ids = split(/\*/, $fileId);
 for (my $i = 0; $i < @ids; $i++) {
 $realId .= substr($mixed, $ids[$i], 1);
 }
 return $realId;
}

通过下面接口得到KEY值:
 my $key     = &getKey($key1, $key2);

sub getKey {
 my ($key1, $key2) = @_;
 my $appendkey = hex($key1);
 $appendkey ^= 0xA55AA5A5;
 return $key2 . sprintf("%x", $appendkey);
}

(4)得到最终我们需要的URL地址:
""
 . $Sid
 . "/st/flv/fileid/"
 . $realId
 . "?K="
 . $key;
如下:
00_00/st/flv/fileid/03000212004C413958F68F0031ED79AAA030D7-04F9-182A-0033-F3E3BB424382?K=198bf247848cf72e14106ad5

粗体00表示片段编号,如本部影片分成了18块7分钟长度的片段,则编号依次为00 01 02 。。。 16 17
阅读(2021) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~

chinaunix网友2010-12-15 17:52:19

my $realId = &getFileId($fileId, getMixString($seed)); sub getFileId { my ($fileId, $mixed) = @_; my $realId; my @ids = split(/\*/, $fileId); for (my $i = 0; $i < @ids; $i++) { $realId .= substr($mixed, $ids[$i], 1); } return $realId; } In PHP? Please help me...

chinaunix网友2010-12-01 15:00:03

很好的, 收藏了 推荐一个博客,提供很多免费软件编程电子书下载: http://free-ebooks.appspot.com