/// <summary> /// Download the user favorite list /// </summary> /// <param name="_userId"></param> /// <param name="_type"></param> /// <param name="_seriesId"></param> /// <returns></returns> internal List <int> DownloadUserFavoriteList(String _userId, Util.UserFavouriteAction _type, int _seriesId) { String xml = ""; String link = ""; try { link = TvdbLinkCreator.CreateUserFavouriteLink(_userId, _type, _seriesId); xml = m_webClient.DownloadString(link); } catch (XmlException ex) { Log.Error("Error parsing the xml file " + link + "\n\n" + xml, ex); throw new TvdbInvalidXmlException("Error parsing the xml file " + link + "\n\n" + xml); } catch (WebException ex) { Log.Warn("Request not successfull", ex); if (ex.Message.Equals("The remote server returned an error: (404) Not Found.")) { throw new TvdbInvalidApiKeyException("Couldn't connect to Thetvdb.com to retrieve favorite list for user " + _userId + ", you may use an invalid api key"); } else { throw new TvdbNotAvailableException("Couldn't connect to Thetvdb.com to retrieve favorite list for user " + _userId + ", check your internet connection and the status of http://thetvdb.com"); } } List <int> favList = m_xmlHandler.ExtractSeriesFavorites(xml); return(favList); }
/// <summary> /// Download the user favorite list /// </summary> /// <param name="_userId"></param> /// <param name="_type"></param> /// <param name="_seriesId"></param> /// <returns></returns> internal List <int> DownloadUserFavoriteList(String _userId, Util.UserFavouriteAction _type, int _seriesId) { String xml = m_webClient.DownloadString(TvdbLinks.CreateUserFavouriteLink(_userId, _type, _seriesId)); List <int> favList = m_xmlHandler.ExtractSeriesFavorites(xml); return(favList); }
/// <summary> /// Download the user favorite list /// </summary> /// <param name="_userId"></param> /// <param name="_type"></param> /// <param name="_seriesId"></param> /// <returns></returns> internal List <int> DownloadUserFavoriteList(String _userId, Util.UserFavouriteAction _type, int _seriesId) { String xml; try { xml = m_webClient.DownloadString(TvdbLinks.CreateUserFavouriteLink(_userId, _type, _seriesId)); } catch (WebException ex) { Log.Warn("Request not successfull", ex); if (ex.Message.Equals("The remote server returned an error: (404) Not Found.")) { throw new TvdbInvalidApiKeyException("Couldn't connect to Thetvdb.com to retrieve favorite list for user " + _userId + ", it seems like you use an invalid api key (" + m_apiKey + ")"); } else { throw new TvdbNotAvailableException("Couldn't connect to Thetvdb.com to retrieve favorite list for user " + _userId + ", check your internet connection and the status of http://thetvdb.com"); } } List <int> favList = m_xmlHandler.ExtractSeriesFavorites(xml); return(favList); }
/// <summary> /// Creates link which (depending on params) gets user favorites, adds a series to user /// favorites or removes a series from the favorite lis /// </summary> /// <param name="_identifier"></param> /// <param name="_type"></param> /// <param name="_seriesId"></param> /// <returns>Link</returns> internal static String CreateUserFavouriteLink(String _identifier, Util.UserFavouriteAction _type, int _seriesId) { String link = String.Format("{0}/api/User_Favorites.php?accountid={1}{2}", BASE_SERVER.Trim('/'), _identifier, ((_type == Util.UserFavouriteAction.none) ? "" : ("&type=" + _type + "&seriesid=" + _seriesId))); return(link); }
/// <summary> /// Creates link which (depending on params) gets user favorites, adds a series to user /// favorites or removes a series from the favorite lis /// </summary> /// <param name="_identifier"></param> /// <param name="_type"></param> /// <param name="_seriesId"></param> /// <returns></returns> internal static String CreateUserFavouriteLink(String _identifier, Util.UserFavouriteAction _type, int _seriesId) { return(TvdbLinks.BASE_SERVER + "/api/User_Favorites.php?accountid=" + _identifier + ((_type == Util.UserFavouriteAction.none) ? "" : ("&type=" + _type.ToString() + "&seriesid=" + _seriesId))); }