public async Task <List <JSON_Entry> > ChangesHistory() { var parameters = new AuthDictionary() { { "fileid", FileID.ToString() } }; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { using (HttpResponseMessage response = await localHttpClient.GetAsync(new pUri("/getfilehistory", parameters), HttpCompletionOption.ResponseContentRead).ConfigureAwait(false)) { string result = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.OK && JObject.Parse(result).Value <int>("result").Equals(0)) { return(JsonConvert.DeserializeObject <List <JSON_Entry> >(JObject.Parse(result).SelectToken("entries").ToString(), JSONhandler)); } else { ShowError(result); return(null); } } } }
public static async Task <JSON_GetVideoDirectLink> VideoDirectLink(string VideoID) { using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { var RequestUri = new Uri($"https://www.dailymotion.com/embed/video/{VideoID}"); HttpResponseMessage ResPonse = await localHttpClient.GetAsync(RequestUri).ConfigureAwait(false); var result = await ResPonse.Content.ReadAsStringAsync(); if (ResPonse.StatusCode == System.Net.HttpStatusCode.OK) { string partONE = "var config = {"; string partTWO = "};"; var ExtractTheDlink = Between(result, partONE, partTWO); ExtractTheDlink = string.Concat("{", ExtractTheDlink, "}"); var TheRsult = JsonConvert.DeserializeObject <JSON_GetVideoDirectLink>(ExtractTheDlink, JSONhandler); if (TheRsult.metadata.qualities.auto == null) { throw new DailymotionException("video maybe private or password protected", (int)ResPonse.StatusCode); } TheRsult.VideoResolutionUrls = await FormatDirectLnks(TheRsult.metadata.qualities.auto[0].url); return(TheRsult); } else { throw new DailymotionException(ResPonse.ReasonPhrase, (int)ResPonse.StatusCode); } } }
public async Task <JSON_ListPushes> ListContinue(string Cursor, int Limit) { var parameters = new Dictionary <string, string>() { { "active", "true" }, { "limit", Limit.ToString() }, { "cursor", Cursor } }; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { var RequestUri = new pUri("pushes", parameters); using (HttpResponseMessage resPonse = await localHttpClient.GetAsync(RequestUri).ConfigureAwait(false)) { string result = await resPonse.Content.ReadAsStringAsync(); if (resPonse.StatusCode == HttpStatusCode.OK) { var FinRes = JsonConvert.DeserializeObject <JSON_ListPushes>(result, JSONhandler); // FinRes.ApiLimits = GetApiLimits(resPonse) return(FinRes); } else { ShowError(result); } return(null); } } }
public async Task <JSON_FileMetadata> UploadRemote(string UrlToUP, string Filename = null) { var parameters = new AuthDictionary { { "url", UrlToUP }, { "folderid", FolderID.ToString() }, { "target", Filename } }; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { using (HttpResponseMessage response = await localHttpClient.GetAsync(new pUri("/downloadfile", parameters), HttpCompletionOption.ResponseContentRead).ConfigureAwait(false)) { string result = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.OK && JObject.Parse(result).Value <int>("result").Equals(0)) { return(JObject.Parse(result).Value <JSON_FileMetadata>("metadata")); } else { ShowError(result); return(null); } } } }
public async Task <bool> UnCompressTaskProgress(string JobID) { IClient clint = new PClient(Username, Password, ConnectionSetting); var TheDomin = (await clint.Account().GetCurrentServer()).hostname; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { using (HttpResponseMessage response = await localHttpClient.GetAsync(new Uri(string.Format("https://{0}/extractarchiveprogress", TheDomin) + AsQueryString(new AuthDictionary() { { "progresshash", JobID } })), System.Net.Http.HttpCompletionOption.ResponseContentRead).ConfigureAwait(false)) { string result = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.OK && JObject.Parse(result).Value <int>("result").Equals(0)) { return(Convert.ToBoolean(JObject.Parse(result).SelectToken("finished").ToString())); } else { ShowError(result); return(false); } } } }
public async Task <JSON_JobProgress> CompressTaskProgress(string JobID) { IClient client = new PClient(Username, Password, ConnectionSetting); var TheDomin = (await client.Account().GetCurrentServer()).hostname; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { using (HttpResponseMessage response = await localHttpClient.GetAsync(new Uri(string.Format("https://{0}/savezipprogress", TheDomin) + AsQueryString(new AuthDictionary() { { "progresshash", JobID } })), HttpCompletionOption.ResponseContentRead).ConfigureAwait(false)) { string result = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.OK && JObject.Parse(result).Value <int>("result").Equals(0)) { return(JsonConvert.DeserializeObject <JSON_JobProgress>(result, JSONhandler)); } else { ShowError(result); return(null); } } } }
public async Task <bool> UploadRemoteMultiple(List <string> UrlsToUP) { var parameters = new AuthDictionary { { "url", string.Join(" ", UrlsToUP) }, { "folderid", FolderID.ToString() } }; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { using (HttpResponseMessage response = await localHttpClient.GetAsync(new pUri("/downloadfile", parameters), HttpCompletionOption.ResponseContentRead).ConfigureAwait(false)) { string result = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.OK && JObject.Parse(result).Value <int>("result").Equals(0)) { return(true); } else { ShowError(result); return(false); } } } }
public async Task <List <json_VideoResolutionUrls> > VideosDirectUrls(int Limit = 100, int OffSet = 1, IProgress <ReportStatus> ReportCls = null, CancellationToken token = default) { ReportCls = ReportCls ?? new Progress <ReportStatus>(); var parameters = new Dictionary <string, string> { { "id", PlaylistID }, { "fields", string.Join(",", new List <string>() { FieldsVideo.title.ToString(), FieldsVideo.id.ToString() }) }, { "limit", Limit.ToString() }, { "page", OffSet.ToString() }, { "sort", VideoSortEnum.recent.ToString() } }; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { HttpResponseMessage ResPonse = await localHttpClient.GetAsync(new pUri($"/playlist/{PlaylistID}/videos", parameters)).ConfigureAwait(false); string result = await ResPonse.Content.ReadAsStringAsync(); if (ResPonse.IsSuccessStatusCode) { var fin = JsonConvert.DeserializeObject <JSON_ListVideos>(result, JSONhandler); List <json_VideoResolutionUrls> vUrlz = new List <json_VideoResolutionUrls>(); foreach (JSON_VideoMetadata vid in fin.VideoList) { if (token.IsCancellationRequested) { return(vUrlz); } DClient client = new DClient(accessToken: authToken, Settings: ConnectionSetting); JSON_GetVideoDirectLink vurl = await client.Mine.Video(vid.id).DirectLink(); vurl.VideoResolutionUrls.Name = vurl.metadata.title; vUrlz.Add(vurl.VideoResolutionUrls); int current = Convert.ToInt32(fin.VideoList.IndexOf(vid)); ReportCls.Report(new ReportStatus() { ProgressPercentage = current / fin.VideoList.Count * 100, BytesTransferred = current, TotalBytes = fin.VideoList.Count, TextStatus = $"Generating Links for {vid.name}..." }); } return(vUrlz); } else { ShowError(result); return(null); } } }
private async Task <JSON_GetUploadUrl> GetUploadUrl() { using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { HttpResponseMessage ResPonse = await localHttpClient.GetAsync(new pUri("/file/upload")).ConfigureAwait(false); string result = await ResPonse.Content.ReadAsStringAsync(); return(ResPonse.IsSuccessStatusCode ? JsonConvert.DeserializeObject <JSON_GetUploadUrl>(result, JSONhandler) : throw ShowError(result)); } }
public async Task <bool> Exists(string VideoID) { using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { HttpResponseMessage ResPonse = await localHttpClient.GetAsync(new pUri($"/user/me/watchlater/{VideoID}")).ConfigureAwait(false); var result = await ResPonse.Content.ReadAsStringAsync(); return(ResPonse.IsSuccessStatusCode ? JObject.Parse(result).SelectToken("list").ToList().Count > 0 : throw ShowError(result)); } }
public async Task <JSON_CheckAccessToken> RevokeAccessToken() { using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { HttpResponseMessage ResPonse = await localHttpClient.GetAsync(new pUri("/logout")).ConfigureAwait(false); var result = await ResPonse.Content.ReadAsStringAsync(); return(ResPonse.IsSuccessStatusCode ? JsonConvert.DeserializeObject <JSON_CheckAccessToken>(result, JSONhandler) : throw ShowError(result)); } }
public async Task <JSON_GetToken> UserInfo() { using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { using (System.Net.Http.HttpResponseMessage response = await localHttpClient.GetAsync(new pUri("user/profile", new AuthDictionary())).ConfigureAwait(false)) { string result = await response.Content.ReadAsStringAsync(); return(result.CheckStatus() ? JsonConvert.DeserializeObject <JSON_GetToken>(result, JSONhandler) : throw ShowError(result)); } } }
public async Task <JSON_ImageMetadata> ImageMetadata(string ImagePath) { using (HtpClient localHtpClient = new HtpClient(new HCHandler { })) { using (HttpResponseMessage response = await localHtpClient.GetAsync(new pUri("get?" + string.Format("name={0}", ImagePath.Slash())), HttpCompletionOption.ResponseContentRead).ConfigureAwait(false)) { string result = await response.Content.ReadAsStringAsync(); return(response.StatusCode == HttpStatusCode.OK ? JsonConvert.DeserializeObject <JSON_ImageMetadata>(result, JSONhandler) : throw ShowError(result)); } } }
public async Task <JSON_FolderList> FolderList(string FolderPath) { using (HtpClient localHtpClient = new HtpClient(new HCHandler { })) { using (HttpResponseMessage response = await localHtpClient.GetAsync(new pUri("listfolder?" + string.Format("path={0}", FolderPath.Trim('/'))), HttpCompletionOption.ResponseContentRead).ConfigureAwait(false)) { string result = await response.Content.ReadAsStringAsync(); return(response.StatusCode == HttpStatusCode.OK ? JsonConvert.DeserializeObject <JSON_FolderList>(result, JSONhandler) : throw ShowError(result)); } } }
public async Task <JSON_FolderMetadata> CreateNewFolder(string FolderName) { using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { using (HttpResponseMessage response = await localHttpClient.GetAsync(new pUri("folder/add", new AuthDictionary() { { "name", FolderName } })).ConfigureAwait(false)) { string result = await response.Content.ReadAsStringAsync(); return(result.CheckStatus() ? JsonConvert.DeserializeObject <JSON_FolderMetadata>(result.Jobj().SelectToken("data").ToString(), JSONhandler) : throw ShowError(result)); } } }
public async Task <bool> Exists(string VideoID) { var parameters = new Dictionary <string, string>(); // parameters.Add("fields", String.Join(",", utilitiez.GetStringsFromClassConstants(GetType(FieldsVideo)))) using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { HttpResponseMessage ResPonse = await localHttpClient.GetAsync(new pUri($"/user/me/history/{VideoID}", parameters)).ConfigureAwait(false); string result = await ResPonse.Content.ReadAsStringAsync(); return(ResPonse.IsSuccessStatusCode ? JObject.Parse(result).SelectToken("list").ToList().Count > 0 : throw ShowError(result)); } }
public async Task <JSON_PlayListMetadata> Metadata() { var parameters = new Dictionary <string, string> { { "fields", string.Join(",", GetStringsFromClassConstants(typeof(FieldsPlaylist))) } }; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { var RequestUri = new pUri($"/playlist/{PlaylistID}", parameters); HttpResponseMessage ResPonse = await localHttpClient.GetAsync(RequestUri).ConfigureAwait(false); var result = await ResPonse.Content.ReadAsStringAsync(); return(ResPonse.IsSuccessStatusCode ? JsonConvert.DeserializeObject <JSON_PlayListMetadata>(result, JSONhandler) : throw ShowError(result)); } }
public static async Task <JSON_VideoMetadata> VideoMetadata(string VideoID, string Fields) { var parameters = new Dictionary <string, string>() { { "fields", Fields } }; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { HttpResponseMessage ResPonse = await localHttpClient.GetAsync(new pUri($"/video/{VideoID}", parameters)).ConfigureAwait(false); var result = await ResPonse.Content.ReadAsStringAsync(); return(ResPonse.IsSuccessStatusCode ? JsonConvert.DeserializeObject <JSON_VideoMetadata>(result, JSONhandler) : throw ShowError(result)); } }
public static async Task <JSON_GetToken> Token(string Username, string Password) { ServicePointManager.Expect100Continue = true; ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12 | SecurityProtocolType.Ssl3; var parameters = new Dictionary <string, string>() { { "login", Username }, { "password", Password } }; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { using (HttpResponseMessage response = await localHttpClient.GetAsync(new pUri("user/login", parameters)).ConfigureAwait(false)) { string result = await response.Content.ReadAsStringAsync(); return(result.CheckStatus() ? JsonConvert.DeserializeObject <JSON_GetToken>(result, JSONhandler) : throw ShowError(result)); } } }
public static async Task <JSON_ListPlaylists> ListPlaylists(string UserID, string Fields, PlaylistSortEnum Sort = PlaylistSortEnum.recent, int Limit = 100, int OffSet = 1) { var parameters = new Dictionary <string, string> { { "fields", Fields }, { "limit", Limit.ToString() }, { "page", OffSet.ToString() }, { "sort", Sort.ToString() } }; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { HttpResponseMessage ResPonse = await localHttpClient.GetAsync(new pUri($"/user/{UserID}/playlists", parameters)).ConfigureAwait(false); string result = await ResPonse.Content.ReadAsStringAsync(); return(ResPonse.IsSuccessStatusCode ? JsonConvert.DeserializeObject <JSON_ListPlaylists>(result, JSONhandler) : throw ShowError(result)); } }
public async Task <JSON_ListChannels> GetChannelsList() { var parameters = new Dictionary <string, string> { { "fields", string.Join(",", GetStringsFromClassConstants(typeof(FieldsChannels))) }, { "limit", "100" }, { "page", "1" }, { "sort", ChannelSortEnum.alpha.ToString() } }; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { HttpResponseMessage ResPonse = await localHttpClient.GetAsync(new pUri("/channels", parameters)).ConfigureAwait(false); var result = await ResPonse.Content.ReadAsStringAsync(); return(ResPonse.IsSuccessStatusCode ? JsonConvert.DeserializeObject <JSON_ListChannels>(result, JSONhandler) : throw ShowError(result)); } }
public static async Task <JSON_ListVideos> SearchForAVideo(string UserID, string Fields, string Keyword, VideoSortEnum Sort = VideoSortEnum.recent, int Limit = 100, int OffSet = 1) { var parameters = new Dictionary <string, string> { { "fields", Fields }, { "search", Keyword },// { "search", SearchType == SearchTypesEnum.Contains ? Keyword : string.Concat("\"", Keyword.Replace(" ", "+"), "\"") }, { "limit", Limit.ToString() }, { "page", OffSet.ToString() }, { "sort", Sort.ToString() } }; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { HttpResponseMessage ResPonse = await localHttpClient.GetAsync(new pUri($"/user/{UserID}/videos", parameters)).ConfigureAwait(false); string result = await ResPonse.Content.ReadAsStringAsync(); return(ResPonse.IsSuccessStatusCode ? JsonConvert.DeserializeObject <JSON_ListVideos>(result, JSONhandler) : throw ShowError(result)); } }
public async Task <JSON_GetCurrentServer> GetCurrentServer() { using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { using (HttpResponseMessage response = await localHttpClient.GetAsync(new pUri("/currentserver", new AuthDictionary()), HttpCompletionOption.ResponseContentRead).ConfigureAwait(false)) { string result = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.OK && JObject.Parse(result).Value <int>("result").Equals(0)) { return(JsonConvert.DeserializeObject <JSON_GetCurrentServer>(result, JSONhandler)); } else { ShowError(result); return(null); } } } }
public async Task <bool> ResendActivationMail() { using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { using (HttpResponseMessage response = await localHttpClient.GetAsync(new pUri("/sendverificationemail", new AuthDictionary()), HttpCompletionOption.ResponseContentRead).ConfigureAwait(false)) { string result = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.OK && JObject.Parse(result).Value <int>("result").Equals(0)) { return(true); } else { ShowError(result); return(false); } } } }
public async Task <JSON_ListUsers> SearchForAUser(string Keyword, SearchTypesEnum SearchType, UsersSortEnum Sort = UsersSortEnum.popular, int Limit = 100, int OffSet = 1) { var parameters = new Dictionary <string, string> { { "fields", string.Join(",", GetStringsFromClassConstants(typeof(FieldsUsers))) }, { "search", SearchType == SearchTypesEnum.Contains ? Keyword : string.Concat("\"", Keyword.Replace(" ", "+"), "\"") }, { "limit", Limit.ToString() }, { "page", OffSet.ToString() }, { "sort", Sort.ToString() } }; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { HttpResponseMessage ResPonse = await localHttpClient.GetAsync(new pUri("/users", parameters)).ConfigureAwait(false); string result = await ResPonse.Content.ReadAsStringAsync(); return(ResPonse.IsSuccessStatusCode ? JsonConvert.DeserializeObject <JSON_ListUsers>(result, JSONhandler) : throw ShowError(result)); } }
public async Task <List <JSON_InviteMetadata> > ListInvites() { using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { using (HttpResponseMessage response = await localHttpClient.GetAsync(new pUri("/userinvites", new AuthDictionary()), HttpCompletionOption.ResponseContentRead).ConfigureAwait(false)) { string result = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.OK && JObject.Parse(result).Value <int>("result").Equals(0)) { return(JsonConvert.DeserializeObject <List <JSON_InviteMetadata> >(JObject.Parse(result).SelectToken("invites").ToString(), JSONhandler)); } else { ShowError(result); return(null); } } } }
public async Task <Uri> GetRegistrationPageUrl() { using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { using (HttpResponseMessage response = await localHttpClient.GetAsync(new pUri("/invite", new AuthDictionary()), HttpCompletionOption.ResponseContentRead).ConfigureAwait(false)) { string result = await response.Content.ReadAsStringAsync(); if (response.StatusCode == HttpStatusCode.OK && JObject.Parse(result).Value <int>("result").Equals(0)) { return(new Uri(JObject.Parse(result).SelectToken("url").ToString())); } else { ShowError(result); return(null); } } } }
public async Task <JSON_ListVideos> ListFavorites(VideoSortEnum Sort = VideoSortEnum.recent, int Limit = 10, int OffSet = 1) { var parameters = new Dictionary <string, string> { { "fields", string.Join(",", GetStringsFromClassConstants(typeof(FieldsVideo))) }, { "limit", Limit.ToString() }, { "page", OffSet.ToString() }, { "sort", Sort.ToString() } }; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { var RequestUri = new pUri(string.Format("/user/me/favorites"), parameters); HttpResponseMessage ResPonse = await localHttpClient.GetAsync(RequestUri).ConfigureAwait(false); var result = await ResPonse.Content.ReadAsStringAsync(); return(ResPonse.IsSuccessStatusCode ? JsonConvert.DeserializeObject <JSON_ListVideos>(result, JSONhandler) : throw ShowError(result)); } }
public async Task <JSON_ListVideos> ListVideosInSubscriptedChannels(ChannelsEnum Channel, int?DurationShorterOrEqual_inMins = null, VideoSortEnum Sort = VideoSortEnum.recent, int Limit = 10, int OffSet = 1) { var parameters = new Dictionary <string, string> { { "shorter_than", DurationShorterOrEqual_inMins.HasValue ? DurationShorterOrEqual_inMins.Value.ToString() : null }, { "channel", Channel.ToString() }, { "fields", string.Join(",", GetStringsFromClassConstants(typeof(FieldsVideo))) }, { "limit", Limit.ToString() }, { "page", OffSet.ToString() }, { "sort", Sort.ToString() } }; using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { HttpResponseMessage ResPonse = await localHttpClient.GetAsync(new pUri("/user/me/subscriptions", parameters)).ConfigureAwait(false); string result = await ResPonse.Content.ReadAsStringAsync(); return(ResPonse.IsSuccessStatusCode ? JsonConvert.DeserializeObject <JSON_ListVideos>(result, JSONhandler) : throw ShowError(result)); } }
public async Task <JSON_Youtube> GetYoutubeDownloadUrls(string YoutubeVideoUrl) { using (HtpClient localHttpClient = new HtpClient(new HCHandler())) { HttpResponseMessage ResPonse = await localHttpClient.GetAsync(new Uri(string.Format("https://www.youtube.com/get_video_info?video_id={0}&el=embedded&ps=default&eurl=&gl=US&hl=en", Utilitiez.TryParseVideoId(YoutubeVideoUrl)))).ConfigureAwait(false); var result = await ResPonse.Content.ReadAsStringAsync(); if (ResPonse.IsSuccessStatusCode) { result = WebUtility.UrlDecode(result); var theTxt = string.Concat(Utilitiez.Between(result, "player_response=", "}}}&"), "}}}"); return(JsonConvert.DeserializeObject <JSON_Youtube>(theTxt, JSONhandler)); } else { ShowError(result); return(null); } } }