Youku real video address resolution, video resolution

Source: Internet
Author: User

Youku real video address resolution, video resolution
Analysis of Youku's real video address-November October 7, 2014

Sequence: Youku updated the algorithm (long ago, haha ...), Therefore, many blog parsing algorithms are no longer available. Many Daniel has updated the new parsing method. I am also writing an article on the parsing process here. (The language used in this article is C #)

Due to the time limit on the youku video address, the following link may have expired when you access this article. Sorry.

Example: http://v.youku.com/v_show/id _XNzk2NTI0MzMy. Html

1: Get the video vid

Mark the red part in the video url. A regular expression can be obtained.

1 string getVid(string url)2 {3     string strRegex = "(?<=id_)(\\w+)";4     Regex reg = new Regex(strRegex);5     Match match = reg.Match(url);6     return match.ToString();7 }
2: Get video metadata

Http://v.youku.com/player/getPlayList/VideoIDS/XNzk2NTI0MzMy/Pf/4/ctype/12/ev/1

Embed the preceding vid in the above url to access the video information file. Because the video information is too long, not all content is posted here. Below are some important content. (The retrieved file is a json file and can be parsed directly)

 1 { "data": [ { 2             "ip": 1991941296, 3             "ep": "MwXRTAsbJLnb0PbJ8uJxAdSivUU11wnKXxc=", 4             "segs": { 5                 "hd2": [ 6                     { 7                         "no": "0", 8                         "size": "34602810", 9                         "seconds": 205,10                         "k": "248fe14b4c1b37302411f67a",11                         "k2": "1c8e113cecad924c5"12                     },13                     {14                         "no": "1",15                     },] }, } ],}

 

The content shown above will be used later. WhereSegs includes hd3, hd2, flv, mp4, and 3gpAnd each format is divided into several segments. High Definition hd2 (Video Format: flv)

3: splicing m3u8 addresses

Http://pl.youku.com/playlist/m3u8? Ctype = 12 & ep = {0} & ev = 1 & keyframe = 1 & oip = {1} & sid = {2} & token = {3} & type = {4} & vid = {5}

There are 6 parameters in total, of which the vid and oip have been obtained, respectively, the ip fields in the previous vid and json file, namely (XNzk2NTI0MzMyAnd1991941296), But the ep, sid, token needs to be re-calculated (the ep value in the json file cannot be used directly ). Type is relatively simple and will be discussed later.

3.1 calculate ep, sid, token

The calculation method is purely mathematical calculation. The following describes the calculation functions. The three parameters can be calculated at one time. Which involves Base64 encoding and decoding knowledge, click to view.

 1      private static string myEncoder(string a, byte[] c, bool isToBase64) 2         { 3             string result = ""; 4             List<Byte> bytesR = new List<byte>(); 5             int f = 0, h = 0, q = 0; 6             int[] b = new int[256]; 7             for (int i = 0; i < 256; i++) 8                     b[i] = i; 9             while (h < 256)10             {11                 f = (f + b[h] + a[h % a.Length]) % 256;12                 int temp = b[h];13                 b[h] = b[f];14                 b[f] = temp;15                 h++;16             }17             f = 0; h = 0; q = 0;18             while (q < c.Length)19             {20                 h = (h + 1) % 256;21                 f = (f + b[h]) % 256;22                 int temp = b[h];23                 b[h] = b[f];24                 b[f] = temp;25                 byte[] bytes = new byte[] { (byte)(c[q] ^ b[(b[h] + b[f]) % 256]) };26                 bytesR.Add(bytes[0]);27                 result += System.Text.ASCIIEncoding.ASCII.GetString(bytes);28                 q++;29             }30             if (isToBase64)31             {32                 Byte[] byteR = bytesR.ToArray();33                 result = Convert.ToBase64String(byteR);34             }35             return result;36         }37         public static void getEp(string vid, string ep, ref string pNew, ref string token, ref string sid)38         {39             string template1 = "becaf9be";40             string template2 = "bf7e5f01";41             byte[] bytes = Convert.FromBase64String(ep);42             ep = ystem.Text.ASCIIEncoding.ASCII.GetString(bytes);43             string temp = myEncoder(template1, bytes, false);44             string[] part = temp.Split('_');45             sid = part[0];46             token = part[1];47             string whole = string.Format("{0}_{1}_{2}", sid, vid, token);48             byte[] newbytes = System.Text.ASCIIEncoding.ASCII.GetBytes(whole);49             epNew = myEncoder(template2, newbytes, true);50         }

 

The calculated ep, token, and sid are diaVGE + IVMwB5CXXjz8bNHi0cCEHXJZ0vESH/7 YbAMZuNaHQnT/Wzw ==, 4178,441 265221168712cdf4f8. Note: At this time, ep cannot be directly spliced into the url. You need to encode the url ToUrlEncode (ep ). Eventually ep is diaVGE % 2bIVMwB5CXXjz8bNHi0cCEHXJZ0vESH % 2f7YbAMZuNaHQnT % 2 fWzw % 3d % 3d

3.2 computing type

The Type value is closely related to the selected segs. For example, the hd2 and type selected in this article are flv. The following is a comparison between segs, type and definition.

"Segs", "type", "Definition" "hd3", "flv", "1080 P" "hd2", "flv", "UHD" "mp4 ", "mp4", "HD" "flvhd", "flv", "HD" flv "," flv "," SD "3 gphd", "3gp ", "HD"
3.3 splicing address

The last m3u8 address is

Http://pl.youku.com/playlist/m3u8? Ctype = 12 & ep = diaVGE % %2f7ybamzunahqnt % 2 fWzw % 3d % 3d & ev = 1 & keyframe = 1 & oip = 1991941296 & sid = 441265221168712cdf4f8 & token = 4178 & type = flv & vid = XNzk2NTI0MzMy

4. Get the video address

After downloading the above m3u8 file, the content is the real address, but you need to handle it a little bit. Part of the content is as follows:

 1 #EXTM3U 2 #EXT-X-TARGETDURATION:12 3 #EXT-X-VERSION:3 4 #EXTINF:6, 5 http://59.108.137.14/696CD107FE4D821FFBF173EB3/03000208005430B01849631468DEFEC61C5678-3A78-37BA-1971-21A0D4EEA0E7.flv?ts_start=0&ts_end=5.9&ts_seg_no=0&ts_keyframe=1 6 #EXTINF:5.533, 7 http://59.108.137.14/696CD107FE4D821FFBF173EB3/03000208005430B01849631468DEFEC61C5678-3A78-37BA-1971-21A0D4EEA0E7.flv?ts_start=5.9&ts_end=11.433&ts_seg_no=1&ts_keyframe=1 8 #EXTINF:5.467, 9 http://59.108.137.14/696CD107FE4D821FFBF173EB3/03000208005430B01849631468DEFEC61C5678-3A78-37BA-1971-21A0D4EEA0E7.flv?ts_start=11.433&ts_end=16.9&ts_seg_no=2&ts_keyframe=110 #EXTINF:9.267,

Each url contains only videos of about 6 s, but the actual length can be obtained by removing the parameters in the url. However, after each entry is removed, the same url needs to be merged. For example, the url segment can be obtained from the list above.

Http: // 59.108.137.14/696cd1_fe4d821ffbf173eb3/03000208005430B01849631468DEFEC61C5678-3A78-37BA-1971-21A0D4EEA0E7.flv

Download all the URLs in m3u8.

 


Youku FLV's real absolute address ????

Youku seems to have no idea. Even if the analyzed website is 127.0.0.1: 8909/... F2.flv
Actually equivalent:
61.55.175.26/... F2.flv
This kind of website is not your so-called real address, but has a validity period.

The following Youku address is immutable:
F.youku.com/player/getflvpath/...the background is pseudo-static...

Websites such as Youku do not share flv online, which seriously affects their competitiveness. They only share swf with their own players online...
However, video websites like popcorn can extract real video addresses.

Q: How can I obtain the real address of youku video based on Youku's address?

Click share to copy the address. (You can change the addresses below if they are not suitable .)
Hope to help you.




Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.