Vevo videos are not playing

Dec 31, 2013 at 1:38 PM
First of all good job on keeping this project alive on your free time ;)

Today while testing it i found out that some videos just don't work then i tried to debug the code and see what's going on. The first thing i noticed was the missing signature and after checking your code i saw that you use "key = 'sig'" to add the signature. For some reasons some videos doesn't contain the key "sig" but instead "s" only so i promptly changed that and voila! the signature is back(something you could fix in future versions). However even having the signature the link still doesn't work. I even went as far as comparing it to a working one and everything should be fine but for some reasons the link is just dead... i tried youtube and it works there without any problems.

Here is the video i'm trying to play:
http://www.youtube.com/watch?v=MwpMEbgC7DA

What could it be??? wondering if there is something new that we now have to add on those videos. Thanks in advance!
Jan 12, 2014 at 1:50 AM
I think YouTube changed the response again for some videos. When I look at the response it doesn't seem that the "url_encoded_fmt_stream_map" contains a "\u0026url=". Not sure why yet.
Mar 6, 2014 at 12:51 AM
hi
is there any solution for this? vevo videos are not playing :(
Coordinator
Mar 9, 2014 at 11:29 PM
I tried to find a way for this problem, but couldnt find a way to get the MP4 link, maybe the logic is integrated into the flash content? Are Vevo videos working without flash?
Mar 10, 2014 at 10:40 PM
seems like you mentioned that vevo videos working fine in other thread https://mytoolkit.codeplex.com/discussions/476808 ?
Mar 13, 2014 at 2:47 AM
checked latest sample on svn. VEVO videos are not working. no they don't require flash to run.
Mar 14, 2014 at 2:52 AM
So I found solution in VB.NET from code project. I converted to C#. it works. here it is if someone needs it.
public static List<string> GetUrl(string PageURL)
        {
             
            string HTML = new WebClient().DownloadString(PageURL);
            string temp = "\"\\\\/\\\\/s.ytimg.com\\\\/yts\\\\/jsbin\\\\/html5player-(.+?)\\.js\"";
            Match m = Regex.Match(HTML, temp);
            Group g = m.Groups[1];
            string Player_Version = g.ToString();
            temp = "http://s.ytimg.com/yts/jsbin/" + "html5player-" + Player_Version + ".js";
            string Player_Code = new WebClient().DownloadString(temp);
            temp = "\"url_encoded_fmt_stream_map\":\\s+\"(.+?)\"";
            HTML = Uri.UnescapeDataString(Regex.Match(HTML, temp, RegexOptions.Singleline).Groups[1].ToString());
        
            MatchCollection Streams = Regex.Matches(HTML, "(^url=|(\\\\u0026url=|,url=))(.+?)(\\\\u0026|,|$)");
            MatchCollection Signatures = Regex.Matches(HTML, "(^s=|(\\\\u0026s=|,s=))(.+?)(\\\\u0026|,|$)");
            List<string> URLs = new List<string>();
            for(int i=0; i < Streams.Count-1; i++)
            {
                string URL = Streams[i].Groups[3].ToString();
                if(Signatures.Count > 0)
                {
                    string sign = Sign_Decipher(Signatures[i].Groups[3].ToString(), Player_Code);
                    URL += "&signature=" + sign;
                }
                URLs.Add(URL.Trim());
            }

            return URLs;
        }

        private static string Sign_Decipher(string s, string code)
        {
            string Function_Name = Regex.Match(code, "signature=(\\w+)\\(\\w+\\)").Groups[1].ToString();
            Match Function_Match = Regex.Match(code, "function " + Function_Name + "\\((\\w+)\\)\\{(.+?)\\}", RegexOptions.Singleline);
            string var = Function_Match.Groups[1].ToString();
            string Decipher = Function_Match.Groups[2].ToString();
            string[] Lines = Decipher.Split(';');
            for(int i=0; i < Lines.Length; i++)
            {
                string Line = Lines[i].Trim();
                if(Regex.IsMatch(Line, var + "=" + var + "\\.reverse\\(\\)"))
                {
                    char[] charArray = s.ToCharArray();
                    Array.Reverse( charArray );
                    s = new string( charArray );
                }
                else if(Regex.IsMatch(Line, var + "=" + var + "\\.slice\\(\\d+\\)"))
                {
                    s = Slice(s, Convert.ToInt32(Regex.Match(Line, var + "=" + var + "\\.slice\\((\\d+)\\)").Groups[1].ToString()));
                }
                else if (Regex.IsMatch(Line, var + "=\\w+\\(" + var + ",\\d+\\)")) 
                {
                    s = Swap(s, Convert.ToInt32(Regex.Match(Line, var + "=\\w+\\(" + var + ",(\\d+)\\)").Groups[1].ToString()));
                }
                else if (Regex.IsMatch(Line, var + "\\[0\\]=" + var + "\\[\\d+%" + var + "\\.length\\]"))
                {
                    s = Swap(s, Convert.ToInt32(Regex.Match(Line, var + "\\[0\\]=" + var + "\\[(\\d+)%" + var + "\\.length\\]").Groups[1].ToString()));
                }
            }
            return s;
        }
      
        private static string Slice(string input, int length)
        {
            return input.Substring(length);
        }

        private static string Swap(string input, int position)
        {
            StringBuilder Str = new StringBuilder(input);
            char SwapChar = Str[position];
            Str[position] = Str[0];
            Str[0] = SwapChar;
            return Str.ToString();
        }
Coordinator
Mar 15, 2014 at 4:16 PM
So in general you are downloading the page's js file and parse it? I can use this code as fallback to the current method!?
Coordinator
Mar 15, 2014 at 4:57 PM
Just tested your code... it works. Working on integrating it into the current code..
Coordinator
Mar 15, 2014 at 6:00 PM
Ok, ive updated everything, now the code is much cleaner and your extension has been integrated... Please check out the SVN repo and the sample app in it. A new nuget package will be released soon.

Thank you very much.
Coordinator
Mar 15, 2014 at 6:18 PM
Ok nuget package available (v2.1.0).