示例#1
0
        //Get movieinformation from database
        public MovieInformation GetMovieInformation(string sSession, int nFileID)
        {
            string sGlobalPath = MOTR_Settings.GetGlobalApplicationPath();

            //Get the path for the FileID
            string sPath = this.GetTemporaryVariable(sSession, "DrivePosition");
            string sFile = this.GetPathByID(sSession, nFileID);

            //No length, no go...
            if (sPath.Length == 0 || sFile.Length == 0)
            {
                return(null);
            }

            //Include full filename
            sPath += sFile;

            lock (_lockDbObjectMovies)
            {
                LiteDatabase m_db = new LiteDatabase(sGlobalPath + @"\MovieInformation.db");
                LiteCollection <MovieInformation> aDBValues = m_db.GetCollection <MovieInformation>("movieinfo");

                MovieInformation results = aDBValues.FindOne(x => x.Path == sPath);
                m_db.Dispose();
                if (results != null)
                {
                    return(results);
                }
                else
                {
                    return(null);
                }
            }
        }
示例#2
0
        public MOTR_Moviescraper(IWebSocketLogger logger)
        {
            //Set the settings for the scrapper
            MOTRScrapperSettings        = new MOTRMovieDbSettings();
            MOTRScrapperSettings.ApiKey = "73706c8ed57633aeb73e866cd896ff9c";
            MOTRScrapperSettings.ApiUrl = "http://api.themoviedb.org/3/";

            // registration with an implementation of IMovieDbSettings
            MovieDbFactory.RegisterSettings(MOTRScrapperSettings);

            //Store logger at startup
            _logger          = logger;
            movieInformation = null;
        }
示例#3
0
        //Store movieinformation in a database
        public bool StoreMovieInformation(string sSession, int nFileID, MovieInformation movieInformation)
        {
            string sGlobalPath = MOTR_Settings.GetGlobalApplicationPath();

            //Get the path for the FileID
            string sPath = this.GetTemporaryVariable(sSession, "DrivePosition");
            string sFile = this.GetPathByID(sSession, nFileID);

            //No length, no go...
            if (sPath.Length == 0 || sFile.Length == 0)
            {
                return(false);
            }

            //Include full filename
            sPath += sFile;

            //Store it in the class
            movieInformation.Path = sPath;

            lock (_lockDbObjectMovies)
            {
                LiteDatabase m_db = new LiteDatabase(sGlobalPath + @"\MovieInformation.db");
                LiteCollection <MovieInformation> aDBValues = m_db.GetCollection <MovieInformation>("movieinfo");

                // Use Linq to query documents
                var results = aDBValues.FindOne(x => x.Path == sPath);
                if (results != null)
                {
                    int ResultID = results._id;
                    results     = movieInformation;
                    results._id = ResultID;
                    aDBValues.Update(results);
                }
                else //Add new
                {
                    aDBValues.EnsureIndex(x => x.Path);
                    aDBValues.Insert(movieInformation);
                }

                m_db.Dispose();
            }

            return(true);
        }
示例#4
0
        public bool Select(int nIdInfo)
        {
            //No love if we select something that is not valid
            if (nIdInfo < 0 || nIdInfo >= apiSearchResponse.Results.Count)
            {
                return(false);
            }

            //Store the movieinformation selected
            movieInformation       = new MovieInformation(apiSearchResponse.Results[nIdInfo]);
            movieInformation.Added = DateTime.Now;

            //Now download posters
            this.DownloadImage(movieInformation.PosterPath);
            this.DownloadImage(movieInformation.BackdropPath);

            return(true);
        }