public static vServiceKind UsingParserCk(string u) { vServiceKind attribute = default(vServiceKind); if ((Evaltool.Evaluation(u, "http(s)?://(www\\.)?youtube\\.com/watch\\?.*", Evaltool.evalStrategy.RegularExpression)) || Evaltool.Evaluation(u, "http://youtu\\.be/\\w+")) { attribute = vServiceKind.Youtube; } else if (Evaltool.Evaluation(u, "http://(www\\.)?nicovideo\\.jp/watch/[sn][mo]\\d+", Evaltool.evalStrategy.RegularExpression)) { attribute = vServiceKind.Niconico; } else if (Evaltool.Evaluation(u, "(?<=http://v.youku.com/v_show/id_)\\w+(?=\\.html)", Evaltool.evalStrategy.RegularExpression)) { attribute = vServiceKind.Youku; } else if (Evaltool.Evaluation(u, "http://www.dailymotion.com/*ideo/*", Evaltool.evalStrategy.WildCard)) { attribute = vServiceKind.Dailymotion; } else { attribute = vServiceKind.No; } return(attribute); }
public static Dictionary <int, Tuple <string, Uri, string> > Dailymotion(string url) { //Dim fObj As IEnumerable(Of Fiddler.Session) //With myOrbit.getFiddlerLog() // fObj = .Reverse(). // TakeWhile(Function(item, i) i < _dmCountLimit AndAlso item.fullUrl Like _dmUriPattern). // Reverse //End With string m = url; if (Evaltool.Evaluation(m, "http://www.dailymotion.com/video/???????_*")) { m = m.Substring(0, m.IndexOf('_')); } m.Remove(m.IndexOf('_')); HttpWebRequest req = WebRequest.CreateHttp(m.Replace("/video/", "/embed/video/")); WebResponse _with1 = req.GetResponse(); using (StreamReader r = new StreamReader(_with1.GetResponseStream())) { m = r.ReadToEnd(); } _with1.Close(); m = m.Substring(m.IndexOf("var info = ") + "var info = ".Length); Debug.Print(m); m = m.Remove(m.IndexOf("," + Environment.NewLine)); Newtonsoft.Json.Linq.JObject j = Newtonsoft.Json.Linq.JObject.Parse(m); qList.Reverse(); List <Tuple <string, Uri, string> > rList = new List <Tuple <string, Uri, string> >(); qList.AsParallel().AsOrdered().ForAll((s) => { string realUrl = j[s].ToString(); if (string.IsNullOrEmpty(realUrl)) { return; } string savename = realUrl.Remove(realUrl.IndexOf('?')); savename = savename.Substring(savename.LastIndexOf('/') + 1); rList.Add(Tuple.Create <string, Uri, string>(savename, new Uri(realUrl, UriKind.Absolute), "")); }); SortedDictionary <int, string> d = new SortedDictionary <int, string>(); int ind = -1; return(rList.ToDictionary <Tuple <string, Uri, string>, int>((item) => { ind += 1; return ind; })); #endregion }