Youku has a unique ID for each video. This ID can be obtained when you view the source file on the page,
The following uses videoid = 4579646 as an example.
1. After the flvplayer load is complete, it will request the playback list of this ID from the background. The request address is as follows:
Http://v.youku.com/player/getPlayList/VideoIDS/4579646
Modify videoid to obtain the playback list of any video.
This request returns a JSON object that stores the video playback list and video address decryption method.
2. video address decryption parameters in the JSON object
"Seed": 6064,
"Fileid ": "34*56*56*31*34*32*67*7*34*34*6*31*4*67*46*32*0*29*56*4*32*10*34*34*29*67*3*10*29*29*31*10*29*4*34*56*7*62*18*5*31*34*6*18*56*62*4*32*18*5*55*32*0*18*46*31*55*67*46*3*4*62*34*10*62*56 *"
"Key1": "bd7e2210 ",
"Key2": "a4b19712badcd042"
The following is the "look" of the video address ":
Http://f.youku.com/player/getFlvPath/sid/123122029188218825571_00
/ST/FLV/fileid/02006401004962dc0f6102007fc5984715ce4e-d1fc-1363-8681-abdc115158da? K = 206c9dcb7e2eb9a614fa7e0
The red part varies according to the video and request time.
The blue part indicates the sequence number of the video file (hexadecimal). If a video file is divided into 11 parts, you only need to change the blue part from 00 to 0a.
Sid:Java code
- Private string getsid (){
- String SID = new date (). gettime () + ""
- + (1000 + new random (). nextint (999) + ""
- + (New random (). nextint (9000) + 1000 );
- Return Sid;
- }
Private string getsid () {string SID = new date (). gettime () + "" + (1000 + new random (). nextint (999) + "" + (new random (). nextint (9000) + 1000); Return Sid ;}
The first half of the Sid is obtained, and the sequence number of the video file is added.
Fileid:
Java code
- /*
- The fileid seed parameter is provided in the preceding JSON object.
- */
- Private string getfileid (string fileid, int seed ){
- String mixed = getmixstring (SEED );
- String [] IDs = fileid. Split ("\\*");
- String realid = "";
- For (INT I = 0; I <IDs. length; ++ I ){
- Int idx = integer. parseint (IDs [I]);
- Realid + = mixed. charat (idx );
- }
- Return realid;
- }
- Private string getmixstring (INT seed ){
- String mixed = "";
- String source = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz/\:. _-1234567890 ";
- Int Len = source. Length ();
- For (INT I = 0; I <Len; ++ I ){
- Seed = (seed * 211 + 30031) % 65536;
- Int Index = (INT) (seed/65536d * Source. Length ());
- Char c = source. charat (INDEX );
- Mixed = mixed + C;
- Source = source. Replace (C + "","");
- }
- Return mixed;
- }
/* The fileid seed parameter is provided for the JSON object mentioned above. */Private string getfileid (string fileid, int seed) {string mixed = getmixstring (SEED); string [] IDs = fileid. split ("\ *"); string realid = ""; for (INT I = 0; I <IDs. length; ++ I) {int idx = integer. parseint (IDs [I]); realid + = mixed. charat (idx);} return realid;} private string getmixstring (INT seed) {string mixed = ""; string source = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz /\\:. _-1234567890 "; int Len = source. length (); For (INT I = 0; I <Len; ++ I) {seed = (seed * 211 + 30031) % 65536; int Index = (INT) (seed/65536d * Source. length (); char c = source. charat (INDEX); mixed = mixed + C; Source = source. replace (C + "", "");} return mixed ;}
Then, change the 9-and 10-bit (non-array-bit) values of the obtained fileid to the video file sequence number (same as the suffix of seed ).
Key:Java code
- Private string getkey (string key1, string key2 ){
- Int appendkey = util. hexstring2int (key1 );
- Appendkey ^ = 0xa55aa5a5;
- Return key2 + integer. tohexstring (appendkey );
- }