public bool MakeRequest(string movieTitle, string requestMessage) { this.CheckAppKey(); this.CheckLoggedIn(); if (string.IsNullOrWhiteSpace(movieTitle)) { throw new ArgumentException("Movie title cannot be null or empty."); } else if (string.IsNullOrWhiteSpace(requestMessage)) { throw new ArgumentException("Request message cannot be null or empty."); } else { try { var req = YifyAPI.GetMakeRequestReqeust(this.appKey, this.userKey, movieTitle, requestMessage); var res = YifyAPI.SendPostRequest(req); var xDoc = _parser.ToResponse(res); return(true); } catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); } } }
public int MakeComment(int movieID, string commentText) { this.CheckAppKey(); this.CheckLoggedIn(); if (movieID < 0) { throw new ArgumentException("Movie id should be greater than 0."); } else if (string.IsNullOrWhiteSpace(commentText)) { throw new ArgumentException("Comment text cannot be null or empty."); } else { var req = YifyAPI.GetMakeCommentReqeust(this.appKey, this.userKey, movieID, commentText); var res = YifyAPI.SendPostRequest(req); int parsed = _parser.ParseMakeCommentResponse(res); try { var xDoc = _parser.ToResponse(res); return(-1); } catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); } } }
public Profile GetProfile() { this.CheckLoggedIn(); var url = YifyAPI.GetUserProfileURI(this.userKey); string res = YifyAPI.SendGetRequest(url); return(_parser.ParseGetProfileRequest(res)); }
public List <BookmarkedMovie> BookmarkedMovies(bool withRtRatings) { this.CheckLoggedIn(); try { var req = YifyAPI.GetMovieBookmarksURI(this.userKey, withRtRatings); var res = YifyAPI.SendGetRequest(req); return(_parser.ParseGetBookmarkedMoviesResponse(res)); } catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); } }
public User GetUserDetails(int userID) { try { var uri = YifyAPI.GetUserDetailsURI(userID, true); var res = YifyAPI.SendGetRequest(uri); return(_parser.ParseGetUserDetailsResponse(res)); } catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); } }
public List <ParentalGuide> GetMovieParentalGuide(int movieID) { try { var uri = YifyAPI.GetMovieParentalGuideURI(movieID); var res = YifyAPI.SendGetRequest(uri); return(_parser.ParseGetMovieParentalGuideResponse(res)); } catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); } }
/// <summary> /// Get movie details for a particular movie /// </summary> /// <param name="movieID">YTS movie id</param> /// <param name="includeCast">If true cast information will be included</param> /// <param name="includeImages">If true movie images will be included</param> /// <returns>Movie object containing the movie result</returns> public Movie GetMovie(int movieID, bool includeCast = true, bool includeImages = true) { try { var uri = YifyAPI.GetMovieURI(movieID, includeCast, includeImages); var res = YifyAPI.SendGetRequest(uri); return(_parser.ParseGetMovieResponse(res)); } catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); } }
public string Login(string username, string password) { this.CheckAppKey(); try { var req = YifyAPI.GetUserKeyRequest(username, password, appKey, false); var res = YifyAPI.SendPostRequest(req); string ukey = _parser.ParseGetUserKeyResponse(res); this.userKey = ukey; return(ukey); } catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); } }
public override object ToResponse(string response) { if (string.IsNullOrEmpty(response)) { throw new YifyException("Empty response received"); } else { XDocument doc = response.ToXDoc(); if (YifyAPI.IsYifyError(doc)) { throw new YifyException(YifyAPI.GetStatusMessage(doc)); } else { return doc; } } }
public bool ResetUserPassword(string resetCode, string newPassword) { this.CheckAppKey(); if (!resetCode.HasValue() || !newPassword.HasValue()) { throw new ArgumentException("Reset Code or New Password cannot be empty."); } else { try { var req = YifyAPI.GetResetUserPasswordRequest(this.appKey, resetCode, newPassword); var res = YifyAPI.SendPostRequest(req); var xDoc = _parser.ToResponse(res); return(true); } catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); } } }
/// <summary> /// Send a password recovery request to Yify torrent. If the email is valid Yify torrent will email a /// password rest code which can be used on <code>ResetUserPassword</code> function. /// </summary> /// <param name="email">Email of a registered account</param> /// <returns>True if the request is successful</returns> /// <exception cref="YifyLib.YifyMissingAppKeyException">If application key is missing</exception> /// <exception cref="ArgumentException">If Email is empty or null</exception> /// <exception cref="YifyLib.YifyException">If any errors occurred YTS process</exception> public bool ForgotUserPassword(string email) { this.CheckAppKey(); if (!email.HasValue()) { throw new ArgumentException("Email cannot be empty."); } else { try { var req = YifyAPI.GetForgotUserPasswordRequest(this.appKey, email); var res = YifyAPI.SendPostRequest(req); var xDoc = _parser.ToResponse(res); return(true); } catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); } } }
public RegisterUser RegisterUser(string userName, string password, string email) { this.CheckAppKey(); if (!userName.HasValue() || !password.HasValue() || !email.HasValue()) { throw new ArgumentException("Username, Password or Email cannot be empty."); } else { try { var req = YifyAPI.GetRegisterUserRequest(this.appKey, userName, password, email); var res = YifyAPI.SendPostRequest(req); var rgu = _parser.ParseRegisterUserResponse(res); this.userKey = rgu.UserKey; return(rgu); } catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); } } }
public Profile EditUserSettings(string aboutText = "", string newPassword = "", string avatarImagePath = "") { this.CheckAppKey(); this.CheckLoggedIn(); try { var req = YifyAPI.GetEditUserSettingsRequest(this.userKey, this.appKey, aboutText, newPassword, avatarImagePath); string res = Task <string> .Factory.StartNew(() => { return(YifyAPI.SendPostRequestAsync(req).Result); }).Result; return(_parser.ParseGetProfileRequest(res)); } catch (FileNotFoundException) { throw; } catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); } }
public bool DeleteComment(int commentID) { this.CheckAppKey(); this.CheckLoggedIn(); if (commentID < 0) { throw new ArgumentException("Comment id should be greater than 0."); } else { try { var req = YifyAPI.GetDeleteCommentReqeust(this.appKey, this.userKey, commentID); var res = YifyAPI.SendPostRequest(req); var xDoc = _parser.ToResponse(res); return(true); } catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); } } }
/// <summary> /// Search or list movies in YTS /// </summary> /// <param name="queryTerm">Term to search</param> /// <param name="quality">Quality of the release Ex: 720p, 1080p, 3D</param> /// <param name="genre">Genre of the movie (See http://www.imdb.com/genre/ for full list)</param> /// <param name="minimumRating">Minimum rating of the movie. Ex: 0 to 9</param> /// <param name="limit">The limit of results per page. Ex: 20</param> /// <param name="page">Page number to view the movies Ex: Limit 15 and Page 2 will show you movies 15 to 30</param> /// <param name="sortBy">Sorts the results by chosen field</param> /// <param name="orderBy">Order of the results in Ascending or Descending order</param> /// <returns>Collection of ListMovie class objects</returns> /// <exception cref="YifyLib.YifyException">If any errors occurred YTS process</exception> public List <ListMovie> ListMovies( string queryTerm = "", string quality = "All", string genre = "", uint minimumRating = 0, uint limit = 20, uint page = 1, SearchResultSort sortBy = SearchResultSort.DateAdded, SortOrder orderBy = SortOrder.Desc) { try { var uri = YifyAPI.GetListMovieURI(queryTerm, quality, genre, minimumRating, limit, page, sortBy, orderBy); var res = YifyAPI.SendGetRequest(uri); return(_parser.ParseListMovieResponse(res)); } catch (Exception ex) { throw new YifyException("An error occurred. See inner exception for more details", ex); } }