Ejemplo n.º 1
0
        private void RefreshTvShowLibrary()
        {
            Logger.Instance().Log("FrontView+", "Start Refresh : TvShows");
            var res = _remote.VideoLibrary.GetTvShows();
            Logger.Instance().Log("FrontView+", "Remote TvShows : " + res.Count);

            var oldData = _database.GetTvShowFavorites(_remoteInfo.Id);

            _database.SetBulkInsert(true);
            _database.BeginTransaction();
            _database.DeleteRemoteTvShows(_remoteInfo.Id);

            foreach (var apiTvShow in res)
            {
                long oldFavorite = 0;
                foreach (var show in oldData)
                {
                    if (show.IdShow == apiTvShow.IdShow)
                        oldFavorite = show.IsFavorite;
                }
                var tvShow = new Yatse2TvShow(apiTvShow) {IdRemote = _remoteInfo.Id, IsFavorite = oldFavorite};
                _database.InsertTvShow(tvShow);
            }
            _database.CommitTransaction();
            _database.SetBulkInsert(false);
            Logger.Instance().Log("FrontView+", "End Refresh : TvShows");
        }
Ejemplo n.º 2
0
        private void QuickRefreshTvShowLibrary()
        {
            Logger.Instance().Log("FrontView+", "Start Quick Refresh : TvShows");
            var res = _remote.VideoLibrary.GetTvShowsRefresh();
            Logger.Instance().Log("FrontView+", "Remote Quick Refresh TvShows : " + res.Count);

            var oldData = _database.GetTvShow(_remoteInfo.Id);

            _database.SetBulkInsert(true);
            _database.BeginTransaction();
          //  _database.DeleteRemoteTvShows(_remoteInfo.Id);

            var notfound = true;
            /**
            foreach (var apiTvShow in res)
            {
                Logger.Instance().Log("FrontView+", "res Data:" + apiTvShow.Title);
            }

            foreach (var show in oldData)
            {
                Logger.Instance().Log("FrontView+", "oldData Data:" + show.Title);
            }
            */
            


            foreach (var apiTvShow in res)
            {

      
            notfound = true;   
                foreach (var show in oldData)
                {
                   // Logger.Instance().Log("FrontView+", "In Loop:  oldData ShowName :" + show.Title);
                    if (show.IdShow == apiTvShow.IdShow)
                    {
                        notfound = false;
                        Logger.Instance().Log("FrontView+", "Quick Shows Check Id - Show Exists:" +show.Title +"  -  show.Idshow ID:" + show.IdShow + " apiTVShow.IdShow:" + apiTvShow.IdShow);
                        break;
                    }
                }
                if (notfound == true)
                {
                    Logger.Instance().Log("FrontView+", "Inserting TV Show :Show Name:" + apiTvShow.Title + ":ShowID:" + apiTvShow.IdShow);
                    var tvShow = new Yatse2TvShow(apiTvShow) { IdRemote = _remoteInfo.Id };
                    _database.InsertTvShow(tvShow);
                }
            }
            _database.CommitTransaction();
            _database.SetBulkInsert(false);
            Logger.Instance().Log("FrontView+", "End Quick Refresh : TvShows");
        }
Ejemplo n.º 3
0
        public long InsertTvShow(Yatse2TvShow show)
        {
            if (show == null)
                return 0;
            var sqlCmd = _dbConnection.CreateCommand();
            sqlCmd.CommandText =
                @"INSERT INTO `TvShows` ( IdRemote ,IdShow,IdScraper,Title,Plot,Premiered,Rating,Genre,Mpaa,Studio,Path,TotalCount,Hash,Thumb,Fanart,IsFavorite,Banner,Logo ) 
                  VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
            sqlCmd.Parameters.AddWithValue("a1", show.IdRemote);
            sqlCmd.Parameters.AddWithValue("a2", show.IdShow);
            sqlCmd.Parameters.AddWithValue("a3", show.IdScraper);
            sqlCmd.Parameters.AddWithValue("a4", show.Title);
            sqlCmd.Parameters.AddWithValue("a5", show.Plot);
            sqlCmd.Parameters.AddWithValue("a6", show.Premiered);
            sqlCmd.Parameters.AddWithValue("a7", show.Rating);
            sqlCmd.Parameters.AddWithValue("a8", show.Genre);
            sqlCmd.Parameters.AddWithValue("a9", show.Mpaa);
            sqlCmd.Parameters.AddWithValue("a10", show.Studio);
            sqlCmd.Parameters.AddWithValue("a11", show.Path);
            sqlCmd.Parameters.AddWithValue("a12", show.TotalCount);
            sqlCmd.Parameters.AddWithValue("a13", show.Hash);
            sqlCmd.Parameters.AddWithValue("a14", show.Thumb);
            sqlCmd.Parameters.AddWithValue("a15", show.Fanart);
            sqlCmd.Parameters.AddWithValue("a16", show.IsFavorite);
            sqlCmd.Parameters.AddWithValue("a17", show.Banner);
            sqlCmd.Parameters.AddWithValue("a18", show.Logo);

            return QueryInsert(sqlCmd);
        }
Ejemplo n.º 4
0
        public bool UpdateTvShow(Yatse2TvShow show)
        {
            if (show == null)
                return false;
            var sqlCmd = _dbConnection.CreateCommand();
            sqlCmd.CommandText =
                @"UPDATE `TvShows` SET IdRemote = ?,IdShow = ?,IdScraper = ?,Title = ?,Plot = ?,Premiered = ?,Rating = ?,Genre = ?,Mpaa = ?,Studio = ?,Path = ?,TotalCount = ?,Hash = ?,Thumb = ?,Fanart = ?,IsFavorite = ?, Banner = ?, Logo = ? WHERE Id = @Id;";
            sqlCmd.Parameters.AddWithValue("a1", show.IdRemote);
            sqlCmd.Parameters.AddWithValue("a2", show.IdShow);
            sqlCmd.Parameters.AddWithValue("a3", show.IdScraper);
            sqlCmd.Parameters.AddWithValue("a4", show.Title);
            sqlCmd.Parameters.AddWithValue("a5", show.Plot);
            sqlCmd.Parameters.AddWithValue("a6", show.Premiered);
            sqlCmd.Parameters.AddWithValue("a7", show.Rating);
            sqlCmd.Parameters.AddWithValue("a8", show.Genre);
            sqlCmd.Parameters.AddWithValue("a9", show.Mpaa);
            sqlCmd.Parameters.AddWithValue("a10", show.Studio);
            sqlCmd.Parameters.AddWithValue("a11", show.Path);
            sqlCmd.Parameters.AddWithValue("a12", show.TotalCount);
            sqlCmd.Parameters.AddWithValue("a13", show.Hash);
            sqlCmd.Parameters.AddWithValue("a14", show.Thumb);
            sqlCmd.Parameters.AddWithValue("a15", show.Fanart);
            sqlCmd.Parameters.AddWithValue("a16", show.IsFavorite);
            sqlCmd.Parameters.AddWithValue("a17", show.Banner);
            sqlCmd.Parameters.AddWithValue("a18", show.Logo);
            sqlCmd.Parameters.AddWithValue("@Id", show.Id);

            return Query(sqlCmd);
        }
Ejemplo n.º 5
0
        private Collection<Yatse2TvShow> QueryTvShow(SQLiteCommand query)
        {
            var tvShows = new Collection<Yatse2TvShow>();
            if (!_connected) return tvShows;
            try
            {
                LogQuery(query);
                var sqldReader = query.ExecuteReader();
                while (sqldReader.Read())
                {
                    var movie = new Yatse2TvShow
                    {
                        Id = GetLong(sqldReader, "Id"),
                        IdRemote = GetLong(sqldReader, "IdRemote"),
                        IdShow = GetLong(sqldReader, "IdShow"),
                        IdScraper = GetString(sqldReader, "IdScraper"),
                        Title = GetString(sqldReader, "Title"),
                        Plot = GetString(sqldReader, "Plot"),
                        Premiered = GetString(sqldReader, "Premiered"),
                        Rating = GetString(sqldReader, "Rating"),
                        Genre = GetString(sqldReader, "Genre"),
                        Mpaa = GetString(sqldReader, "Mpaa"),
                        Studio = GetString(sqldReader, "Studio"),
                        Path = GetString(sqldReader, "Path"),
                        TotalCount = GetLong(sqldReader, "TotalCount"),
                        Hash = GetString(sqldReader, "Hash"),
                        Thumb = GetString(sqldReader, "Thumb"),
                        Fanart = GetString(sqldReader, "Fanart"),
                        IsFavorite = GetLong(sqldReader, "IsFavorite"),
                        Banner = GetString(sqldReader, "Banner"),
                        Logo = GetString(sqldReader, "Logo")
                   
                    };
                    tvShows.Add(movie);
                    Log("SQL DATA::: Title:" + GetString(sqldReader, "Title") + "ID" + GetLong(sqldReader, "IdShow") + "Premiere:"+ GetString(sqldReader, "Premiered") +"Date: "+GetString(sqldReader, "Date"));
                }
                sqldReader.Dispose();
                query.Dispose();
            }
            catch (SQLiteException e)
            {
                Log(e.Message);
            }

            return tvShows;
        }