public override bool GetResults(string keywords, string imdbID, bool skipImages) { bool _result = false; // Start with a connection m_apiProxy = (IMMApi)XmlRpcProxyGen.Create(typeof(IMMApi)); try { string _mmId = null; if (!string.IsNullOrEmpty(imdbID)) { // get MovieMeter ID from imdb id try { _mmId = m_apiProxy.RetrieveByImdb(getSessionKey(), imdbID.Replace("tt", "")); } catch { } if (!string.IsNullOrEmpty(_mmId)) { if (GetMovie(_mmId)) { _result = true; } } } else { // search by keywords Film[] _filmlist = null; try { _filmlist = m_apiProxy.Search(getSessionKey(), keywords); } catch { } if (_filmlist != null && _filmlist.Count() != 0) { foreach (Film _f in _filmlist) { //loop trough the filmlist if (GetMovie(_f.filmId)) { _result = true; } } } } } finally { //m_apiProxy.CloseSession(m_sessionKey); } return(_result); }
/// <summary> /// Requests for a new sessionkey of it's not initialized yet or not valid anymore /// otherwise the known sessionkey will be used /// </summary> /// <returns>String with a valid sessionkey</returns> private static string getSessionKey() { if ((new DateTime(1970, 1, 1)).AddSeconds(sessionValidTill) < DateTime.Now.ToUniversalTime()) { apiProxy = (IMMApi)XmlRpcProxyGen.Create(typeof(IMMApi)); ApiStartSession s = apiProxy.StartSession(Settings.ConstSettings.Application.MovieMeterApi); sessionKey = s.session_key; sessionValidTill = s.valid_till; } return(sessionKey); }
private string getSessionKey() { try { //sessionValidTill: Seconds since the Unix Epoch, can be used for about 30 minutes if ((new DateTime(1970, 1, 1)).AddSeconds(m_sessionValidTill) < DateTime.Now.ToUniversalTime()) { m_apiProxy = (IMMApi)XmlRpcProxyGen.Create(typeof(IMMApi)); ApiStartSession s = m_apiProxy.StartSession(m_apiKey); m_sessionKey = s.session_key; m_sessionValidTill = s.valid_till; } } catch { } return(m_sessionKey); }
public override MovieInfo QueryMovieInfo(string imdbId) { MovieInfo _result = null; if (!string.IsNullOrEmpty(imdbId)) { m_apiProxy = (IMMApi)XmlRpcProxyGen.Create(typeof(IMMApi)); try { string _mmId = null; try { _mmId = m_apiProxy.RetrieveByImdb(getSessionKey(), imdbId.Replace("tt", "")); } catch { } if (!string.IsNullOrEmpty(_mmId)) { _result = GetMovieInfo(_mmId); } } finally { } } return(_result); }
/// <summary> /// Requests for a new sessionkey of it's not initialized yet or not valid anymore /// otherwise the known sessionkey will be used /// </summary> /// <returns>String with a valid sessionkey</returns> private static string getSessionKey() { if ((new DateTime(1970, 1, 1)).AddSeconds(sessionValidTill) < DateTime.Now.ToUniversalTime()) { apiProxy = (IMMApi)XmlRpcProxyGen.Create(typeof(IMMApi)); ApiStartSession s = apiProxy.StartSession(Settings.ConstSettings.Application.MovieMeterApi); sessionKey = s.session_key; sessionValidTill = s.valid_till; } return sessionKey; }