private void RefreshTvEpisodesLibrary()
        {
            Logger.Instance().Log("FrontView+", "Start Refresh : TvEpisodes");
            var res = _remote.VideoLibrary.GetTvEpisodes();
            Logger.Instance().Log("FrontView+", "Remote TvEpisodes : " + res.Count);

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

            _database.SetBulkInsert(true);
            _database.BeginTransaction();
            _database.DeleteRemoteTvEpisodes(_remoteInfo.Id);
            foreach (var apiTvEpisode in res)
            {
                long oldFavorite = 0;
                foreach (var episode in oldData)
                {
                    if (episode.IdEpisode == apiTvEpisode.IdEpisode)
                        oldFavorite = episode.IsFavorite;
                }
                var tvEpisode = new Yatse2TvEpisode(apiTvEpisode) {IdRemote = _remoteInfo.Id, IsFavorite = oldFavorite};
                _database.InsertTvEpisode(tvEpisode);
            }
            _database.CommitTransaction();
            _database.SetBulkInsert(false);
            Logger.Instance().Log("FrontView+", "End Refresh : TvEpisodes");
        }
        /**

        private void RefreshTvSeasonLibrary()
        {
            Logger.Instance().Log("FrontView+", "Start Refresh : TvSeasons");
            var res = _remote.VideoLibrary.GetTvSeasons();
            Logger.Instance().Log("FrontView+", "Remote TvSeasons : " + res.Count);

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

            _database.SetBulkInsert(true);
            _database.BeginTransaction();
            _database.DeleteRemoteTvSeasons(_remoteInfo.Id);
            foreach (var apiTvSeason in res)
            {
                long oldFavorite = 0;
                foreach (var show in oldData)
                {
                    if (show.IdShow == apiTvSeason.IdShow)
                        oldFavorite = show.IsFavorite;
                }
                var tvSeason = new Yatse2TvSeason(apiTvSeason) {IdRemote = _remoteInfo.Id, IsFavorite = oldFavorite};
                _database.InsertTvSeason(tvSeason);
            }


            _database.CommitTransaction();
            _database.SetBulkInsert(false);
            Logger.Instance().Log("FrontView+", "End Refresh : TvSeasons");
        }
    */
        private void QuickRefreshTvEpisodesLibrary()
        {
            Logger.Instance().Log("FrontView+", "Start QUICK Refresh : TvEpisodes");
            var res = _remote.VideoLibrary.GetTvEpisodesRefresh();
            Logger.Instance().Log("FrontView+", "Remote QUICK REFRESH TvEpisodes : " + res.Count);

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

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

            var notfound = true;
            foreach (var apiTvEpisode in res)
            {
                notfound = true;  
                foreach (var episode in oldData)
                {
                    if (episode.IdEpisode == apiTvEpisode.IdEpisode)
                    {
                        notfound = false;
                        Logger.Instance().Log("FrontView+", "Episode IDomovie ID" + episode.IdEpisode + " apiTvEpisode.Id:" + apiTvEpisode.IdEpisode);
                    }
                        
                }

                if (notfound == true)
                {
                    Logger.Instance().Log("FrontView+", "Inserting TVEpisode:"+apiTvEpisode.ShowTitle+": Episode ID"+apiTvEpisode.IdEpisode +" Id Show:"+apiTvEpisode.IdShow);
                    var tvEpisode = new Yatse2TvEpisode(apiTvEpisode) { IdRemote = _remoteInfo.Id };
                    _database.InsertTvEpisode(tvEpisode);
                }
            }
            
            _database.CommitTransaction();
            _database.SetBulkInsert(false);
            Logger.Instance().Log("FrontView+", "End QUICK Refresh : TvEpisodes");
        }
Beispiel #3
0
        public long InsertTvEpisode(Yatse2TvEpisode episode)
        {
            if (episode == null)
                return 0;
            var sqlCmd = _dbConnection.CreateCommand();
            sqlCmd.CommandText =
                @"INSERT INTO `TvEpisodes` ( IdRemote ,IdEpisode,IdFile,IdShow,Title,ShowTitle,Rating,Plot,Director,Date,Mpaa,Studio,Season,Episode,FileName,Path,PlayCount,Hash,Thumb,Fanart,IsStack,IsFavorite ) 
                  VALUES ( ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?);";
            sqlCmd.Parameters.AddWithValue("a1", episode.IdRemote);
            sqlCmd.Parameters.AddWithValue("a2", episode.IdEpisode);
            sqlCmd.Parameters.AddWithValue("a3", episode.IdFile);
            sqlCmd.Parameters.AddWithValue("a4", episode.IdShow);
            sqlCmd.Parameters.AddWithValue("a5", episode.Title);
            sqlCmd.Parameters.AddWithValue("a6", episode.ShowTitle);
            sqlCmd.Parameters.AddWithValue("a7", episode.Rating);
            sqlCmd.Parameters.AddWithValue("a8", episode.Plot);
            sqlCmd.Parameters.AddWithValue("a9", episode.Director);
            sqlCmd.Parameters.AddWithValue("a10", episode.Date);
            sqlCmd.Parameters.AddWithValue("a11", episode.Mpaa);
            sqlCmd.Parameters.AddWithValue("a12", episode.Studio);
            sqlCmd.Parameters.AddWithValue("a13", episode.Season);
            sqlCmd.Parameters.AddWithValue("a14", episode.Episode);
            sqlCmd.Parameters.AddWithValue("a15", episode.FileName);
            sqlCmd.Parameters.AddWithValue("a16", episode.Path);
            sqlCmd.Parameters.AddWithValue("a17", episode.PlayCount);
            sqlCmd.Parameters.AddWithValue("a18", episode.Hash);
            sqlCmd.Parameters.AddWithValue("a19", episode.Thumb);
            sqlCmd.Parameters.AddWithValue("a20", episode.Fanart);
            sqlCmd.Parameters.AddWithValue("a21", episode.IsStack);
            sqlCmd.Parameters.AddWithValue("a22", episode.IsFavorite);

            return QueryInsert(sqlCmd);
        }
Beispiel #4
0
        public bool UpdateTvEpisode(Yatse2TvEpisode episode)
        {
            if (episode == null)
                return false;
            var sqlCmd = _dbConnection.CreateCommand();
            sqlCmd.CommandText =
                @"UPDATE `TvEpisodes` SET IdRemote = ?,IdEpisode = ?,IdFile = ?,IdShow = ?,Title = ?,ShowTitle = ?,Rating = ?,Plot = ?,Director = ?,Date = ?,Mpaa = ?,Studio = ?,Season = ?,Episode = ?,FileName = ?,Path = ?,PlayCount = ?,Hash = ?,Thumb = ?,Fanart = ?,IsStack = ?,IsFavorite = ? WHERE Id = @Id;";
            sqlCmd.Parameters.AddWithValue("a1", episode.IdRemote);
            sqlCmd.Parameters.AddWithValue("a2", episode.IdEpisode);
            sqlCmd.Parameters.AddWithValue("a3", episode.IdFile);
            sqlCmd.Parameters.AddWithValue("a4", episode.IdShow);
            sqlCmd.Parameters.AddWithValue("a5", episode.Title);
            sqlCmd.Parameters.AddWithValue("a6", episode.ShowTitle);
            sqlCmd.Parameters.AddWithValue("a7", episode.Rating);
            sqlCmd.Parameters.AddWithValue("a8", episode.Plot);
            sqlCmd.Parameters.AddWithValue("a9", episode.Director);
            sqlCmd.Parameters.AddWithValue("a10", episode.Date);
            sqlCmd.Parameters.AddWithValue("a11", episode.Mpaa);
            sqlCmd.Parameters.AddWithValue("a12", episode.Studio);
            sqlCmd.Parameters.AddWithValue("a13", episode.Season);
            sqlCmd.Parameters.AddWithValue("a14", episode.Episode);
            sqlCmd.Parameters.AddWithValue("a15", episode.FileName);
            sqlCmd.Parameters.AddWithValue("a16", episode.Path);
            sqlCmd.Parameters.AddWithValue("a17", episode.PlayCount);
            sqlCmd.Parameters.AddWithValue("a18", episode.Hash);
            sqlCmd.Parameters.AddWithValue("a19", episode.Thumb);
            sqlCmd.Parameters.AddWithValue("a20", episode.Fanart);
            sqlCmd.Parameters.AddWithValue("a21", episode.IsStack);
            sqlCmd.Parameters.AddWithValue("a22", episode.IsFavorite);
            sqlCmd.Parameters.AddWithValue("@Id", episode.Id);

            return Query(sqlCmd);
        }
Beispiel #5
0
 private Collection<Yatse2TvEpisode> QueryTvEpisode(SQLiteCommand query)
 {
     var tvEpisodes = new Collection<Yatse2TvEpisode>();
     if (!_connected) return tvEpisodes;
     try
     {
         LogQuery(query);
         var sqldReader = query.ExecuteReader();
         while (sqldReader.Read())
         {
             var episode = new Yatse2TvEpisode
             {
                 Id = GetLong(sqldReader, "Id"),
                 IdRemote = GetLong(sqldReader, "IdRemote"),
                 IdEpisode = GetLong(sqldReader, "IdEpisode"),
                 IdFile = GetLong(sqldReader, "IdFile"),
                 IdShow = GetLong(sqldReader, "IdShow"),
                 Title = GetString(sqldReader, "Title"),
                 ShowTitle = GetString(sqldReader, "ShowTitle"),
                 Rating = GetString(sqldReader, "Rating"),
                 Plot = GetString(sqldReader, "Plot"),
                 Director = GetString(sqldReader, "Director"),
                 Date = GetString(sqldReader, "Date"),
                 Mpaa = GetString(sqldReader, "Mpaa"),
                 Studio = GetString(sqldReader, "Studio"),
                 Season = GetLong(sqldReader, "Season"),
                 Episode = GetLong(sqldReader, "Episode"),
                 FileName = GetString(sqldReader, "FileName"),
                 Path = GetString(sqldReader, "Path"),
                 PlayCount = GetLong(sqldReader, "PlayCount"),
                 Hash = GetString(sqldReader, "Hash"),
                 Thumb = GetString(sqldReader, "Thumb"),
                 Fanart = GetString(sqldReader, "Fanart"),
                 IsStack = GetLong(sqldReader, "IsStack"),
                 IsFavorite = GetLong(sqldReader, "IsFavorite")
             };
             tvEpisodes.Add(episode);
         }
         sqldReader.Dispose();
         query.Dispose();
     }
     catch (SQLiteException e)
     {
         Log(e.Message);
     }
     return tvEpisodes;
 }