Exemple #1
0
        public static ZipsList ListZips(string accessToken)
        {
            string url = $"{_baseURL}list?oauth_token={accessToken}";

            using (putSharpWebClient client = new putSharpWebClient())
            {
                string json = client.DownloadString(url);

                return(ZipListParser(json));
            }
        }
Exemple #2
0
        public static Zip GetZip(string accessToken, long zipID)
        {
            string url = $"{_baseURL}{zipID}?oauth_token={accessToken}";

            using (putSharpWebClient client = new putSharpWebClient())
            {
                string json = client.DownloadString(url);

                return(ZipParser(json));
            }
        }
Exemple #3
0
        public static Feed Get(string accessToken, long id)
        {
            string url = $"{_baseURL}{id}?oauth_token={accessToken}";

            using (putSharpWebClient client = new putSharpWebClient())
            {
                string json = client.DownloadString(url);

                return(FeedParser(json));
            }
        }
Exemple #4
0
        public static string Delete(string accessToken, long id)
        {
            string url = $"{_baseURL}{id}/delete?oauth_token={accessToken}";

            using (putSharpWebClient client = new putSharpWebClient())
            {
                string json = client.UploadString(url, "");

                return(StatusParser(json));
            }
        }
Exemple #5
0
        public static FriendList FriendRequests(string accessToken)
        {
            string url = $"{_baseURL}waiting-requests?oauth_token={accessToken}";

            using (putSharpWebClient client = new putSharpWebClient())
            {
                string json = client.DownloadString(url);

                return(FriendListParser(json));
            }
        }
Exemple #6
0
        public static string Approve(string accessToken, string userName)
        {
            string url = $"{_baseURL}{userName}/approve?oauth_token={accessToken}";

            using (putSharpWebClient client = new putSharpWebClient())
            {
                string json = client.UploadString(url, "");

                return(StatusParser(json));
            }
        }
Exemple #7
0
        public static AccountSettings Settings(string accessToken)
        {
            string url = $"{_baseURL}settings?oauth_token={accessToken}";

            using (putSharpWebClient client = new putSharpWebClient())
            {
                string json = client.DownloadString(url);

                return(AccountSettingsParser(json));
            }
        }
Exemple #8
0
        public static string Clean(string accessToken)
        {
            string url = $"{_baseURL}clean?oauth_token={accessToken}";

            using (putSharpWebClient client = new putSharpWebClient())
            {
                byte[] jsonBytes = client.UploadValues(url, new NameValueCollection());
                string json      = Encoding.ASCII.GetString(jsonBytes);

                return(json);
            }
        }
Exemple #9
0
        public static void Retry(string accessToken, long id)
        {
            string url = $"{_baseURL}retry?oauth_token={accessToken}";

            NameValueCollection par = new NameValueCollection();

            par.Add("id", id.ToString());

            using (putSharpWebClient client = new putSharpWebClient())
            {
                byte[] jsonBytes = client.UploadValues(url, par);
                string json      = Encoding.ASCII.GetString(jsonBytes);
            }
        }
Exemple #10
0
        public static string UpdateSettings(string accessToken, Dictionary <string, object> settingsValues)
        {
            string url = $"{_baseURL}settings?oauth_token={accessToken}";

            NameValueCollection par = new NameValueCollection();

            foreach (KeyValuePair <string, object> setting in settingsValues)
            {
                par.Add(setting.Key, setting.Value.ToString().ToLower());
            }

            using (putSharpWebClient client = new putSharpWebClient())
            {
                byte[] jsonBytes = client.UploadValues(url, par);
                return(Encoding.ASCII.GetString(jsonBytes));
            }
        }
Exemple #11
0
        public static Transfer Add(string accessToken, string magnetURL, long parentID = 0, string callbackURL = "")
        {
            string url = $"{_baseURL}add?oauth_token={accessToken}";

            NameValueCollection par = new NameValueCollection();

            par.Add("url", magnetURL);
            par.Add("save_parent_id", parentID.ToString());

            if (!string.IsNullOrEmpty(callbackURL))
            {
                par.Add("callback_url", callbackURL);
            }

            using (putSharpWebClient client = new putSharpWebClient())
            {
                byte[] jsonBytes = client.UploadValues(url, par);
                string json      = Encoding.ASCII.GetString(jsonBytes);

                return(SingleTransferParser(json));
            }
        }
Exemple #12
0
        public static CreatedZip CreateZip(string accessToken, IEnumerable <long> IDs)
        {
            string url = $"{_baseURL}create?oauth_token={accessToken}";

            string idString = "";

            foreach (long id in IDs)
            {
                idString += id + ",";
            }
            idString = idString.Substring(0, idString.Length - 1);

            NameValueCollection par = new NameValueCollection();

            par.Add("file_ids", idString);

            using (putSharpWebClient client = new putSharpWebClient())
            {
                byte[] jsonBytes = client.UploadValues(url, par);
                string json      = Encoding.ASCII.GetString(jsonBytes);

                return(CreatedZipParser(json));
            }
        }
Exemple #13
0
        public static Feed Create(string accessToken, string title, string rssSourceURL, long parentDirID, bool deleteOldFiles = false,
                                  bool dontProcessWholeFeed             = false, IEnumerable <string> keywords = null,
                                  IEnumerable <string> unwantedKeywords = null, bool paused                    = false)
        {
            string url = $"{_baseURL}create?oauth_token={accessToken}";

            string keywordString = "";

            foreach (string keyword in keywords)
            {
                keywordString += keyword + ",";
            }
            keywordString = keywordString.Substring(0, keywordString.Length - 1);

            string unKeywordString = "";

            foreach (string keyword in unwantedKeywords)
            {
                unKeywordString += keyword + ",";
            }
            unKeywordString = unKeywordString.Substring(0, unKeywordString.Length - 1);

            NameValueCollection par = new NameValueCollection();

            par.Add("title", title);
            par.Add("rss_source_url", rssSourceURL);
            par.Add("parent_dir_id", parentDirID.ToString());

            if (deleteOldFiles)
            {
                par.Add("delete_old_files", "true");
            }
            else
            {
                par.Add("delete_old_files", "false");
            }

            if (dontProcessWholeFeed)
            {
                par.Add("dont_process_whole_feed", "true");
            }
            else
            {
                par.Add("dont_process_whole_feed", "false");
            }

            par.Add("keyword", keywordString);
            par.Add("unwanted_keywords", unKeywordString);

            if (paused)
            {
                par.Add("paused", "true");
            }
            else
            {
                par.Add("paused", "false");
            }

            using (putSharpWebClient client = new putSharpWebClient())
            {
                byte[] jsonBytes = client.UploadValues(url, par);
                string json      = Encoding.ASCII.GetString(jsonBytes);

                return(FeedParser(json));
            }
        }