public void ValidateUser() { WebclientX client = new WebclientX(); NameValueCollection ps = new NameValueCollection(); ps.Add("session_id", session_id); string content = client.PostMethod(AppConst.SERVER_ADDRESS + "/validate", ps); if (content.Trim() != "1") callback.ValidateUserFailed(); }
public void RequestToServer() { WebclientX client = new WebclientX(); NameValueCollection ps = new NameValueCollection(); ps.Add("action", "system_user"); ps.Add("watching_id", PlayingChannelId); ps.Add("machine_key", SystemUserCheck.GetMachineKey()); string content = client.PostMethod(AppConst.ServerURL, ps); deFinishedGetSystemUser.Invoke(content); }
public static string CheckVersion(string isQuiet) { WebclientX client = new WebclientX(); NameValueCollection pars = new NameValueCollection(); pars.Add("action", "version"); pars.Add("quiet", isQuiet); pars.Add("version", Utility.EncodeTo64(AppConst.Version)); pars.Add("type", AppConst.appType.ToString()); pars.Add("register", Utility.md5String(Utility.ReadAppRegistry("TVKing2", "email"))); string res = client.PostMethod("http://tvking.tv/tvking_services.php", pars); return res.Trim(); }
public void SearchYoutube(string cate_id, string sort_id, string uploaded_id, string key) { WebclientX client = new WebclientX(); List<YoutubeObject> youtube_videos = new List<YoutubeObject>(); string category = ""; string sort = ""; string uploaded = ""; if (cate_id != "") { category = "search_category=" + cate_id + "&"; } if (sort_id != "") { sort = "search_sort=" + sort_id + "&"; } if (uploaded_id != "") { uploaded = "uploaded=" + uploaded_id + "&"; } string search_link = "http://www.youtube.com/results?" + sort + uploaded + category + "search_query=" + Utility.URLEncode(key) + "&page="; YoutubeSearch.last_query = search_link; callback.IYS_BeginSearching(); for (int i = 1; i <= max_page; i++) { YoutubeSearch.last_page = i; callback.IYS_ProgressSearching(i * 100 / max_page); if (stoping) { callback.IYS_Stop(); return; } //string search_content = Utility.ReadFile(@"C:\Users\Hoang\Desktop\results.htm");//client.GetMethod(search_link + i); string search_content = client.GetMethod(search_link + i); youtube_videos.AddRange(GetListYoutubeVD(search_content)); } callback.IYS_FinishedSearching(youtube_videos); //callbackYoutubeForm.Invoke(youtube_videos); }
//public DeFinishedSearchYoutube callbackYoutubeForm; public void ContinueSearching() { List<YoutubeObject> youtube_videos = new List<YoutubeObject>(); WebclientX client = new WebclientX(); callback.IYS_BeginSearching(); YoutubeSearch.last_page++; string search_content = client.GetMethod(last_query + YoutubeSearch.last_page); youtube_videos.AddRange(GetListYoutubeVD(search_content)); //for (int i = last_page + 1; i < last_page + max_page; i++) //{ // if (stoping) // { // callback.IYS_Stop(); // return; // } // callback.IYS_ProgressSearching((i + 1) * 100 / (last_page + max_page)); // string search_content = client.GetMethod(last_query + i); // youtube_videos.AddRange(GetListYoutubeVD(search_content)); //} //YoutubeSearch.last_page = last_page + max_page; callback.IYS_FinishedSearching(youtube_videos); //return youtube_videos; }
internal static string GetYoutubeStreamingURL(string youtubeid) { WebclientX client = new WebclientX(); youtubeid = Utility.SimpleRegexSingle("v=([0-9a-zA-Z_-]*)", youtubeid, 1); string youtubeinfo = client.GetMethod("http://www.youtube.com/get_video_info?video_id=" + youtubeid); if (youtubeinfo.IndexOf("errorcode=150") > 0) { youtubeinfo = client.GetMethod("http://www.youtube.com/watch?v=" + youtubeid); youtubeinfo = Utility.SimpleRegexSingle("flashvars=\"([^\"]*)\"", youtubeinfo, 1); } string content = Utility.SimpleRegexSingle("fmt_stream_map=([^&]+)", youtubeinfo, 1); content = Utility.URLDecode(content); List<string> video_links = Utility.SimpleRegex(@"url=.*?(?=type=)[^,]*", content, 0); string youtube_mp4_file = ""; foreach (string vl in video_links) { if (vl.IndexOf("video%2Fmp4") > 0) { youtube_mp4_file = Utility.URLDecode(Utility.SimpleRegexSingle("url=([^&]*)", vl, 1)); } } return youtube_mp4_file; }
public static bool RegisterUser(string email, string key) { WebclientX client = new WebclientX(); if (email == "" || key == "") { return false; //return true;//testing } NameValueCollection ps = new NameValueCollection(); ps.Add("email", email); ps.Add("key", key); string content = client.PostMethod(AppConst.SERVER_ADDRESS + "/register", ps); string temp_session_id = content.Trim(); if (temp_session_id == "" || temp_session_id.Length != 15) { Utility.WriteAppRegistry("settv", "ru_email", ""); Utility.WriteAppRegistry("settv", "ru_key", ""); return false; } session_id = temp_session_id; Utility.WriteAppRegistry("settv", "ru_email", email); Utility.WriteAppRegistry("settv", "ru_key", key); return true; }
public bool Register3(string email) { WebclientX client = new WebclientX(); NameValueCollection pars = new NameValueCollection(); pars.Add("action", "free_register"); pars.Add("id", Utility.EncodeTo64(email)); string res = client.PostMethod("http://tvking.tv/tvking_services.php", pars); if (res.Trim() == "1") { resetSetTime(); RegistryKey key = Registry.LocalMachine.CreateSubKey(keyLocation); key.SetValue(keyName, register_str); return true; } return false; }
public void ReportChannelViolation(string email, string channel, string message) { NameValueCollection prms = new NameValueCollection(); prms.Add("email", email); prms.Add("channel", channel); prms.Add("message", message); prms.Add("action", "copyright_violation"); WebclientX client = new WebclientX(); client.PostMethod(AppConst.ServerURL, prms); }
internal void SubmitUrl(string url, string country) { NameValueCollection prms = new NameValueCollection(); string email = Utility.ReadAppRegistry("TVKing2", "email"); prms.Add("user_email", email); prms.Add("submit_url", url); prms.Add("country", country); prms.Add("action", "user_submit_channel"); WebclientX client = new WebclientX(); client.PostMethod(AppConst.ServerURL, prms); }
public void GetYoutube() { List<Channel> list = new List<Channel>(); WebclientX client = new WebclientX(); string category = ""; string sort = ""; string uploaded = ""; if (uploaded != "") { category = "search_category=" + uploaded + "&"; } if (youtube_sort_id != "") { sort = "search_sort=" + youtube_sort_id + "&"; } if (youtube_uploaded_id != "") { uploaded = "uploaded=" + youtube_uploaded_id + "&"; } string search_link = "http://www.youtube.com/results?" + sort + uploaded + category + "search_query=" + Utility.URLEncode(seaching_keyword) + "&page="; for (int i = 1; i <= youtube_max_page; i++) { string search_content = client.GetMethod(search_link + i); List<Channel> items = GetListYoutubeVD(search_content); list.AddRange(items); } callback.FinishedLoadChannel(list); }
public void runAppStore() { client = new WebclientX(); myDataConnection = new OleDbConnection(connectionString); myDataConnection.Open(); nonqueryCommand = myDataConnection.CreateCommand(); nonqueryCommand.CommandText = "DELETE FROM review WHERE review.appid IN (SELECT app.appid FROM app WHERE store='appstore')"; nonqueryCommand.ExecuteNonQuery(); nonqueryCommand.Dispose(); nonqueryCommand = myDataConnection.CreateCommand(); nonqueryCommand.CommandText = "DELETE FROM app WHERE store='appstore'"; nonqueryCommand.ExecuteNonQuery(); nonqueryCommand.Dispose(); stop = false; string region_code = ""; if (region == "US") { region_code = "us/"; region = ""; } else if (region == "HongKong") { region_code = "hk/"; } else if (region == "UK") { region_code = "gb/"; } string letters = "QWERTYUIOPASDFGHJKLZXCVBNM#"; JObject json; for (int i = 0; i < letters.Length; i++) { if (stop == true) break; string l = letters.Substring(i, 1); int page = 1; while (true) { if (stop == true) break; List<string> app_links = new List<string>(); List<string> app_ids = new List<string>(); string content = ""; content = Utility.ReadFileString("as_app_dir/letter_" + region+l + "_" + page + ".txt"); if (content == "") { content = client.GetMethod("https://itunes.apple.com/" + region_code + "genre/ios-travel/id6003?mt=8&letter=" + l + "&page=" + page); Utility.WriteFile("as_app_dir/letter_" + region+l + "_" + page + ".txt", content, false); } page++; app_links = Utility.SimpleRegex("https://itunes.apple.com/" + region_code + "app/[a-z\\-]*/id([0-9]{7,})\\?mt=8", content, 0, System.Text.RegularExpressions.RegexOptions.Singleline); app_ids = Utility.SimpleRegex("https://itunes.apple.com/" + region_code + "app/[a-z\\-]*/id([0-9]{7,})\\?mt=8", content, 1); main.Log("Found " + app_links.Count + " apps in page " + page + " at letter " + l); for (int j = 0; j < app_links.Count; j++) { if (stop == true) break; try { string applink = app_links[j]; string appid = app_ids[j]; client.Headers.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.97 Safari/537.11"); content = Utility.ReadFileString("as_app/" + region + appid + ".txt"); if (content == "") { content = client.GetMethod(applink); Utility.WriteFile("as_app/" +region+ appid + ".txt", content, false); } client.Headers.Add("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"); string title = Utility.SimpleRegexSingle("class=\"intro\\s*\">\\s*<div class=\"left\">\\s*<h1>([^<]*)", content, 1); main.Log("Scraping app \"" + title + "\""); string description = Utility.SimpleRegexSingle("<h4>\\s*Description\\s*</h4>\\s*<p>(.*?)(?=</p>)", content, 1); description = description.Replace("|", " "); description = description.Replace("\n", " "); description = description.Replace("\r", " "); string price = Utility.SimpleRegexSingle("class=\"price\">([^<]*)", content, 1); string released_date = Utility.SimpleRegexSingle(">Released:\\s*</span>([^<]*)", content, 1); string update_date = Utility.SimpleRegexSingle(">Updated:\\s*</span>([^<]*)", content, 1); string developer = Utility.SimpleRegexSingle(">Developer:\\s*</span>([^<]*)", content, 1); developer = developer.Replace("|", " "); string seller = Utility.SimpleRegexSingle(">Seller:\\s*</span>([^<]*)", content, 1); seller = seller.Replace("|", " "); string version = Utility.SimpleRegexSingle(">Version:\\s*</span>([^<]*)", content, 1); client.Headers.Add("User-Agent", "iTunes/11.0 (Windows; Microsoft Windows 7 x64 Ultimate Edition Service Pack 1 (Build 7601)) AppleWebKit/536.27.1"); content = Utility.ReadFileString("as_review/review_main_" + appid + ".txt"); if (content == "") { content = client.GetMethod("https://itunes.apple.com/" + region_code + "customer-reviews/id" + appid + "?dataOnly=true&displayable-kind=11&appVersion=all"); Utility.WriteFile("as_review/review_main_" + appid + ".txt", content, false); } json = JObject.Parse(content); string rating_count = "0"; string average_rate = "0"; string rate1 = "0"; string rate2 = "0"; string rate3 = "0"; string rate4 = "0"; string rate5 = "0"; int totalNumberOfReviews = (int)json["totalNumberOfReviews"]; if (totalNumberOfReviews != 0) { rating_count = (string)json["ratingCount"]; average_rate = (string)json["ratingAverage"]; rate1 = (string)json["ratingCountList"][0]; rate2 = (string)json["ratingCountList"][1]; rate3 = (string)json["ratingCountList"][2]; rate4 = (string)json["ratingCountList"][3]; rate5 = (string)json["ratingCountList"][4]; } nonqueryCommand = myDataConnection.CreateCommand(); nonqueryCommand.CommandText = "INSERT INTO app (appid, title,description,price,released_date,update_date,developer,seller,version,rating_count,average_rate,rate1,rate2,rate3,rate4,rate5,store,region) VALUES (@appid, @title,@description,@price,@released_date,@update_date,@developer,@seller,@version,@rating_count,@average_rate,@rate1,@rate2,@rate3,@rate4,@rate5,'appstore',@region)"; nonqueryCommand.Parameters.AddWithValue("appid", appid); nonqueryCommand.Parameters.AddWithValue("title", title); nonqueryCommand.Parameters.AddWithValue("description", description); nonqueryCommand.Parameters.AddWithValue("price", price); nonqueryCommand.Parameters.AddWithValue("released_date", released_date); nonqueryCommand.Parameters.AddWithValue("update_date", update_date); nonqueryCommand.Parameters.AddWithValue("developer", developer); nonqueryCommand.Parameters.AddWithValue("seller", seller); nonqueryCommand.Parameters.AddWithValue("version", version); nonqueryCommand.Parameters.AddWithValue("rating_count", rating_count); nonqueryCommand.Parameters.AddWithValue("average_rate", average_rate); nonqueryCommand.Parameters.AddWithValue("rate1", rate1); nonqueryCommand.Parameters.AddWithValue("rate2", rate2); nonqueryCommand.Parameters.AddWithValue("rate3", rate3); nonqueryCommand.Parameters.AddWithValue("rate4", rate4); nonqueryCommand.Parameters.AddWithValue("rate5", rate5); nonqueryCommand.Parameters.AddWithValue("region", region); nonqueryCommand.ExecuteNonQuery(); nonqueryCommand.Dispose(); int from = 0; int to = 100; int count_review = 1; int review_count = 0; while (true && totalNumberOfReviews > 0) { if (stop == true) break; client.Headers.Add("User-Agent", "iTunes/11.0 (Windows; Microsoft Windows 7 x64 Ultimate Edition Service Pack 1 (Build 7601)) AppleWebKit/536.27.1"); content = Utility.ReadFileString("as_review/review_" + region+appid + "_" + count_review + ".txt"); if (content == "") { content = client.GetMethod("https://itunes.apple.com/WebObjects/MZStore.woa/wa/userReviewsRow?id=" + appid + "&displayable-kind=11&startIndex=" + from + "&endIndex=" + to + "&sort=1"); //("https://itunes.apple.com/WebObjects/MZStore.woa/wa/userReviewsRow?id=581264644&displayable-kind=11&startIndex=0&endIndex=2&sort=1&appVersion=all");// Utility.WriteFile("as_review/review_" + region+appid + "_" + count_review + ".txt", content, false); } count_review++; json = JObject.Parse(content); if (json["userReviewList"].Count() == 0) break; int userReviewList = json["userReviewList"].Count(); main.Log("Found " + userReviewList + " reviews"); for (int k = 0; k < userReviewList; k++) { if (stop == true) break; string rate_title = (string)json["userReviewList"][k]["title"]; rate_title = rate_title.Replace("|", " "); string rate_rate = (string)json["userReviewList"][k]["rating"]; string rate_by = (string)json["userReviewList"][k]["name"]; rate_by = rate_by.Replace("|", " "); string rate_date = (string)json["userReviewList"][k]["date"]; string rate_content = (string)json["userReviewList"][k]["body"]; rate_content = rate_content.Replace("|", " "); rate_content = rate_content.Replace("\n", " "); rate_content = rate_content.Replace("\r", " "); string rate_vote_count = (string)json["userReviewList"][k]["voteCount"]; string rate_vote_sum = (string)json["userReviewList"][k]["voteSum"]; nonqueryCommand = myDataConnection.CreateCommand(); nonqueryCommand.CommandText = "INSERT INTO review (appid, app_title, title, rate,rate_by,rate_date,content,vote_count,vote_sum,version) VALUES (@appid, @app_title, @title, @rate,@rate_by,@rate_date,@content,@vote_count,@vote_sum,@version)"; nonqueryCommand.Parameters.AddWithValue("@appid", appid); nonqueryCommand.Parameters.AddWithValue("@app_title", title); nonqueryCommand.Parameters.AddWithValue("@title", rate_title); nonqueryCommand.Parameters.AddWithValue("@rate", rate_rate); nonqueryCommand.Parameters.AddWithValue("@rate_by", rate_by); nonqueryCommand.Parameters.AddWithValue("@rate_date", rate_date); nonqueryCommand.Parameters.AddWithValue("@content", rate_content); nonqueryCommand.Parameters.AddWithValue("@vote_count", rate_vote_count); nonqueryCommand.Parameters.AddWithValue("@vote_sum", rate_vote_sum); nonqueryCommand.Parameters.AddWithValue("@version", ""); nonqueryCommand.ExecuteNonQuery(); nonqueryCommand.Dispose(); review_count++; } from = to + 1; to += 50; }//loop comments nonqueryCommand = myDataConnection.CreateCommand(); nonqueryCommand.CommandText = "UPDATE app SET review_count=@review_count WHERE appid=@appid"; nonqueryCommand.Parameters.AddWithValue("review_count", review_count); nonqueryCommand.Parameters.AddWithValue("appid", appid); nonqueryCommand.ExecuteNonQuery(); nonqueryCommand.Dispose(); } catch (Exception ex) { Utility.WriteLog(ex.Message); Utility.WriteLog(ex.StackTrace); } }//for (int j = 0; j < app_links.Count; j++) if (app_links.Count < 10) break; }//loop pages }//loop letters myDataConnection.Close(); myDataConnection.Dispose(); stop = true; main.Finished(); }
public void runGooglePlay() { client = new WebclientX(); myDataConnection = new OleDbConnection(connectionString); myDataConnection.Open(); nonqueryCommand = myDataConnection.CreateCommand(); nonqueryCommand.CommandText = "DELETE FROM review WHERE review.appid IN (SELECT app.appid FROM app WHERE store='googleplay')"; nonqueryCommand.ExecuteNonQuery(); nonqueryCommand.Dispose(); nonqueryCommand = myDataConnection.CreateCommand(); nonqueryCommand.CommandText = "DELETE FROM app WHERE store='googleplay'"; nonqueryCommand.ExecuteNonQuery(); nonqueryCommand.Dispose(); stop = false; client.Headers.Add("User-Agent", "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)"); for (int i = 0; i <= 480; i += 24) { if (stop == true) break; string content = ""; while (content == "") { client.SetProxyFile(proxy_file); content = Utility.ReadFileString("gp_app_dir/paid_page_" + i + ".txt"); if (content == "") { content = client.GetMethod("https://play.google.com/store/apps/category/TRAVEL_AND_LOCAL/collection/topselling_paid?start=" + i + "&num=24"); Utility.WriteFile("gp_app_dir/paid_page_" + i + ".txt", content, false); } } ParseGPItem(content); content = ""; while (content == "") { client.SetProxyFile(proxy_file); content = Utility.ReadFileString("gp_app_dir/free_page_" + i + ".txt"); if (content == "") { content = client.GetMethod("https://play.google.com/store/apps/category/TRAVEL_AND_LOCAL/collection/topselling_free?start=" + i + "&num=24"); Utility.WriteFile("gp_app_dir/page_" + i + ".txt", content, false); } } ParseGPItem(content); } myDataConnection.Close(); myDataConnection.Dispose(); stop = true; main.Finished(); }
static public bool DownloadFile(string url, string fn) { WebclientX Client = new WebclientX(); try { Client.DownloadFile(url, fn); } catch (Exception ex) { WriteLog(ex.Message); return false; } return true; }
private void play_youtube_channel() { ShowYoutubeControl(); if (current_youtubeid >= max_youtubeid) { return; } if (_youtube_videos.Count < current_youtubeid) return; string title = ""; if (Utility.HtmlDecode(_youtube_videos[current_youtubeid].title).Length > 35) { title = Utility.HtmlDecode(_youtube_videos[current_youtubeid].title).Substring(0, 34); } else title = Utility.HtmlDecode(_youtube_videos[current_youtubeid].title); barText.Text = "Loading channel " + title + " ..."; barText.Visible = true; barProgress.Visible = true; pnStatus.Visible = true; isShownAds = false; pbFullScreen.Visible = true; pbErrorBG.Visible = false; lbErrorPlayer.Visible = false; WebclientX client = new WebclientX(); string youtubeid = _youtube_videos[current_youtubeid].youtube_url; youtubeid = Utility.SimpleRegexSingle("v=([0-9a-zA-Z_-]*)", youtubeid, 1); txtTitle.Text = title; string youtubeinfo = client.GetMethod("http://www.youtube.com/get_video_info?video_id=" + youtubeid); if (youtubeinfo.IndexOf("errorcode=150") > 0) { youtubeinfo = client.GetMethod("http://www.youtube.com/watch?v=" + youtubeid); youtubeinfo = Utility.SimpleRegexSingle("flashvars=\"([^\"]*)\"", youtubeinfo, 1); } string content = Utility.SimpleRegexSingle("fmt_stream_map=([^&]+)", youtubeinfo, 1); content = Utility.URLDecode(content); List<string> video_links = Utility.SimpleRegex(@"url=.*?(?=type=)[^,]*", content, 0); string youtube_mp4_file = ""; foreach (string vl in video_links) { if (vl.IndexOf("video%2Fmp4") > 0) { youtube_mp4_file = Utility.URLDecode(Utility.SimpleRegexSingle("url=([^&]*)", vl, 1)); } } if (youtube_mp4_file != "") { isVideoPlaying = false; if (currentPlayingChannel != null && currentPlayingChannel.channel_type == AppConst.STREAM_TYPE_FLASH) player_flash.Movie = "http://"; player_wmp.Visible = true; player_flash.Visible = false; player_flash.Movie = "http://"; player_wmp.URL = youtube_mp4_file; playingYoutube = true; //timerFixWplayerBug.Enabled = true; } else { current_youtubeid++; play_youtube_channel(); } }