Exemple #1
0
 public void Add(DBTable table)
 {
     AddWhat(table);
     if (m_sFrom.Length > 0)
         m_sFrom += ", ";
     m_sFrom += table.m_tableName;
 }
Exemple #2
0
        public void AddWhat(DBTable table)
        {
            foreach (KeyValuePair<string, DBField> field in table.m_fields)
            {
                if (String.IsNullOrEmpty(m_sWhat))
                    m_sWhat += table.m_tableName + "." + field.Key;
                else
                    m_sWhat += ", " + table.m_tableName + "." + field.Key;
            }

        }
Exemple #3
0
 static void getTableFieldname(string what, out DBTable table, out string fieldname)
 {
     string sTable = string.Empty;
     fieldname = string.Empty;
     table = null;
     what = what.Replace("<", "").Replace(">", "").Trim();
     sTable = what.Split('.')[0];
     switch (sTable)
     {
         case "Series":
             if(new DBOnlineSeries().FieldNames.Contains(what.Split('.')[1]))
             {
                 table = new DBOnlineSeries();
                 fieldname = what.Split('.')[1];
             }
             else
             {
                 table = new DBSeries();
                 fieldname = what.Split('.')[1];
             }
             break;
         case "Season":
             table = new DBSeason();
             fieldname = what.Split('.')[1];
             break;
         case "Episode":
             if (new DBOnlineEpisode().FieldNames.Contains(what.Split('.')[1]))
             {
                 table = new DBOnlineEpisode();
                 fieldname = what.Split('.')[1];
             }
             else
             {
                 table = new DBEpisode();
                 fieldname = what.Split('.')[1];
             }
             break;
     }
 }
Exemple #4
0
 public SQLWhat(DBTable table)
 {
     Add(table);
 }
        private void Season_OnItemSelected(GUIListItem item)
        {
            if (m_bQuickSelect) return;

            m_SelectedEpisode = null;
            if (item == null || item.TVTag == null)
                return;

            setNewListLevelOfCurrView(m_CurrViewStep);

            DBSeason season = item.TVTag as DBSeason;
            if (season == null) return;

            m_SelectedSeason = season;

            // set watched/unavailable flag
            if (dummyIsWatched != null) dummyIsWatched.Visible = (int.Parse(season[DBOnlineSeries.cEpisodesUnWatched]) == 0);
            if (dummyIsAvailable != null) dummyIsAvailable.Visible = season[DBSeason.cHasLocalFiles];

            setGUIProperty(guiProperty.Title, FieldGetter.resolveDynString(m_sFormatSeasonTitle, season));
            setGUIProperty(guiProperty.Subtitle, FieldGetter.resolveDynString(m_sFormatSeasonSubtitle, season));
            setGUIProperty(guiProperty.Description, FieldGetter.resolveDynString(m_sFormatSeasonMain, season));

            // Delayed Image Loading of Season Banners
            string filename = ImageAllocator.GetSeasonBannerAsFilename(season);
            if (filename.Length == 0)
            {
                // Load Series Poster instead
                if (DBOption.GetOptions(DBOption.cSubstituteMissingArtwork) && m_SelectedSeries != null)
                {
                    filename = ImageAllocator.GetSeriesPosterAsFilename(m_SelectedSeries);
                }
            }
            seasonbanner.Filename = filename;

            setGUIProperty(guiProperty.Logos, localLogos.getLogos(ref season, logosHeight, logosWidth));

            clearGUIProperty(guiProperty.EpisodeImage);

            if (!m_CurrLView.stepHasSeriesBeforeIt(m_CurrViewStep))
            {
                // it is the case
                m_SelectedSeries = Helper.getCorrespondingSeries(season[DBSeason.cSeriesID]);
                if (m_SelectedSeries != null)
                {
                    seriesbanner.Filename = ImageAllocator.GetSeriesBannerAsFilename(m_SelectedSeries);
                    seriesposter.Filename = ImageAllocator.GetSeriesPosterAsFilename(m_SelectedSeries);
                }
                else
                {
                    clearGUIProperty(guiProperty.SeriesBanner);
                    clearGUIProperty(guiProperty.SeriesPoster);
                }
            }

            pushFieldsToSkin(m_SelectedSeason, "Season");

            // Load Fanart
            m_FanartItem = m_SelectedSeason;
            if (DBOption.GetOptions(DBOption.cFanartRandom))
            {
                // We should update fanart as soon as new series is selected or
                // if timer was disabled (e.g. fullscreen playback)
                if (m_SelectedSeries[DBSeries.cID].ToString() != m_prevSeriesID || m_bFanartTimerDisabled)
                    m_FanartTimer.Change(0, DBOption.GetOptions(DBOption.cRandomFanartInterval));
            }
            else
                loadFanart(m_FanartItem);

            // Remember last series, so we dont re-initialize random fanart timer
            m_prevSeriesID = m_SelectedSeries[DBSeries.cID];
        }
        public static void pushFieldsToSkin(DBTable item, string pre)
        {
            if (item == null) return;
            List<string> fieldsRequestedForPre = null;

            if (SkinSettings.SkinProperties.ContainsKey(pre))
            {
                fieldsRequestedForPre = SkinSettings.SkinProperties[pre];
                for (int i = 0; i < fieldsRequestedForPre.Count; i++)
                {
                    pushFieldToSkin(item, pre, fieldsRequestedForPre[i]);
                }
            }
        }
 private static void pushFieldToSkin(DBTable item, string pre, string field)
 {
     string t = pre + "." + field;
     setGUIProperty(t, FieldGetter.resolveDynString("<" + t + ">", item));
 }
 public static string resolveDynString(string what, DBTable item)
 {
     return(resolveDynString(what, item, true));
 }
Exemple #9
0
 public static void GlobalSet(DBTable obj, String sKey1, String sKey2, SQLCondition conditions)
 {
     if (obj.m_fields.ContainsKey(sKey1) && obj.m_fields.ContainsKey(sKey2))
     {
         String sqlQuery = "update " + obj.m_tableName + " SET " + sKey1 + " = " + sKey2 + conditions;
         SQLiteResultSet results = DBTVSeries.Execute(sqlQuery);
         if (dbUpdateOccured != null)
             dbUpdateOccured(obj.m_tableName);
     }
 }
Exemple #10
0
        public static void GlobalSet(DBTable obj, String sKey, DBValue Value, SQLCondition conditions)
        {
            if (obj.m_fields.ContainsKey(sKey))
            {
                String sqlQuery = "update " + obj.m_tableName + " SET " + sKey + "=";
                switch (obj.m_fields[sKey].Type)
                {
                    case DBField.cTypeInt:
                        sqlQuery += Value;
                        break;

                    case DBField.cTypeString:
                        sqlQuery += "'" + Value + "'";
                        break;
                }

                sqlQuery += conditions;
                SQLiteResultSet results = DBTVSeries.Execute(sqlQuery);
                if (dbUpdateOccured != null)
                    dbUpdateOccured(obj.m_tableName);
            }
        }
Exemple #11
0
 public SQLCondition(DBTable table, String sField, DBValue value, SQLConditionType type)
 {
     Add(table, sField, value, type);
 }
        private void OnRateItem(DBTable item, string value)
        {
            if (TraktSettings.AccountStatus != ConnectionState.Connected) return;

            TraktLogger.Info("Recieved rating event from tvseries");

            if (item is DBEpisode)
                RateEpisode(item as DBEpisode);
            else
                RateSeries(item as DBSeries);
        }
Exemple #13
0
        public static List <DBValue> GetSingleField(string field, SQLCondition conds, DBTable obj)
        {
            string         sql     = "select " + field + " from " + obj.m_tableName + conds + conds.orderString + conds.limitString;
            List <DBValue> results = new List <DBValue>();

            try
            {
                foreach (SQLiteResultSet.Row result in DBTVSeries.Execute(sql).Rows)
                {
                    results.Add(result.fields[0]);
                }
            }
            catch (Exception ex)
            {
                MPTVSeriesLog.Write("GetSingleField SQL method generated an error: " + ex.Message);
            }
            return(results);
        }
Exemple #14
0
        public static string resolveDynString(string what, DBTable item, bool splitFields, bool applyUserFormatting)
        {
            // apply userFormatting on the field's itself
            if (applyUserFormatting)
            {
                performUserFormattingReplacement(ref what);
            }

            Level        level      = levelOfItem(item);
            string       value      = what;
            List <Level> whatLevels = getLevel(what);

            _splitFields = splitFields;
            // the item needs to be the type corresponding to the level (we require the item to match the indicated level)
            if (level == Level.Episode) // we can do everything
            {
                if (whatLevels.Contains(Level.Episode))
                {
                    DBOnlineEpisode o = item as DBOnlineEpisode;
                    if (o == null)
                    {
                        value = replaceEpisodeTags(item as DBEpisode, value);
                    }
                    else
                    {
                        value = replaceEpisodeTags(o, value);
                    }
                }
                if (whatLevels.Contains(Level.Season))
                {
                    value = replaceSeasonTags(item[DBEpisode.cSeriesID], item[DBEpisode.cSeasonIndex], value);
                }
                if (whatLevels.Contains(Level.Series))
                {
                    value = replaceSeriesTags(item[DBEpisode.cSeriesID], value);
                }
            }
            else if (level == Level.Season && !whatLevels.Contains(Level.Episode)) // we can do season/series
            {
                if (whatLevels.Contains(Level.Season))
                {
                    value = replaceSeasonTags(item as DBSeason, value);
                }
                if (whatLevels.Contains(Level.Series))
                {
                    value = replaceSeriesTags(item[DBSeason.cSeriesID], value);
                }
            }
            else if (level == Level.Series && !whatLevels.Contains(Level.Episode) && !whatLevels.Contains(Level.Season)) // we can only do series
            {
                DBOnlineSeries o = item as DBOnlineSeries;
                if (o == null)
                {
                    value = replaceSeriesTags(item as DBSeries, value);
                }
                else
                {
                    value = replaceSeriesTags(item[DBSeries.cID], value);
                }
            }
            if (nonFormattingFields.Contains(what))
            {
                return(value);
            }
            value = doFormatting(value, what, item);

            value = MathParser.mathParser.TryParse(value);
            value = MathParser.mathParser.TranslateExpression(value);

            // apply userFormatting on the field's result
            if (applyUserFormatting)
            {
                bool replacementOccured = performUserFormattingReplacement(ref value);
                // because the replacement itself might be dynamic again, we resolve the result again
                if (replacementOccured)
                {
                    value = resolveDynString(value, item, splitFields, applyUserFormatting);
                }
            }
            return(System.Web.HttpUtility.HtmlDecode(value));
        }
Exemple #15
0
 public static string resolveDynString(string what, DBTable item, bool applyUserFormatting)
 {
     return(resolveDynString(what, item, true, applyUserFormatting));
 }
Exemple #16
0
        public void Add(DBTable table, String sField, DBValue value, SQLConditionType type)
        {
            if (table.m_fields.ContainsKey(sField))
            {
                String sValue = String.Empty;
                switch (table.m_fields[sField].Type)
                {
                    case DBField.cTypeInt:
                        sValue = value;
                        break;

                    case DBField.cTypeString:
                        if (type == SQLConditionType.Like || type == SQLConditionType.NotLike)
                            sValue = "'%" + ((String)value).Replace("'", "''") + "%'";
                        else
                            sValue = "'" + ((String)value).Replace("'", "''") + "'";
                        break;
                }
                AddCustom(table.m_tableName + "." + sField, sValue, type);
            }
        }
Exemple #17
0
        public void AddSubQuery(string field, DBTable table, SQLCondition innerConditions, DBValue value, SQLConditionType type)
        {
            string sValue;
            if (type == SQLConditionType.Like || type == SQLConditionType.NotLike)
                sValue = "'%" + ((String)value).Replace("'", "''") + "%'";
            else
                sValue = ((String)value).Replace("'", "''");

            AddCustom("( select " + field + " from " + table.m_tableName + innerConditions + innerConditions.orderString + innerConditions.limitString +  " ) ", sValue, type);
        }
Exemple #18
0
 public static void Clear(DBTable obj, SQLCondition conditions)
 {
     String sqlQuery = "delete from " + obj.m_tableName + conditions;
     SQLiteResultSet results = DBTVSeries.Execute(sqlQuery);
     if (dbUpdateOccured != null)
         dbUpdateOccured(obj.m_tableName);
 }
Exemple #19
0
        internal static void showRatingsDialog(DBTable item, bool auto)
        {
            if (item == null) return;
            MPTVSeriesLog.Write("Asking to rate", MPTVSeriesLog.LogLevel.Debug);

            GUIListItem pItem = null;
            Listlevel level = item is DBEpisode ? Listlevel.Episode : Listlevel.Series;

            string value = "0";
            string dlgHeading = (level == Listlevel.Episode ? Translation.RateEpisode : Translation.RateSeries);

            if (System.IO.File.Exists(GUIGraphicsContext.Skin + @"\TVSeries.RatingDialog.xml"))
            {
                GUIUserRating ratingDlg = (GUIUserRating)GUIWindowManager.GetWindow(GUIUserRating.ID);
                ratingDlg.Reset();
                ratingDlg.SetHeading((level == Listlevel.Episode ? Translation.RateEpisode : Translation.RateSeries));
                if (level == Listlevel.Series)
                {
                    ratingDlg.SetLine(1, string.Format(Translation.RateDialogLabel, item.ToString()));
                }
                else
                {
                    ratingDlg.SetLine(1, string.Format(Translation.RateDialogLabel, Translation.Episode));
                    ratingDlg.SetLine(2, item.ToString());
                }

                if (DBOption.GetOptions(DBOption.cRatingDisplayStars) == 10)
                {
                    ratingDlg.DisplayStars = GUIUserRating.StarDisplay.TEN_STARS;
                    ratingDlg.Rating = DBOption.GetOptions(DBOption.cDefaultRating);
                }
                else
                {
                    ratingDlg.DisplayStars = GUIUserRating.StarDisplay.FIVE_STARS;
                    ratingDlg.Rating = (int)(DBOption.GetOptions(DBOption.cDefaultRating) / 2);
                }

                ratingDlg.DoModal(ratingDlg.GetID);
                if (ratingDlg.IsSubmitted)
                {
                    if (ratingDlg.DisplayStars == GUIUserRating.StarDisplay.FIVE_STARS)
                        value = (ratingDlg.Rating * 2).ToString();
                    else
                        value = ratingDlg.Rating.ToString();
                }
                else return;
            }
            else
            {
                IDialogbox dlg = (IDialogbox)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_MENU);
                dlg.Reset();
                dlg.SetHeading(dlgHeading + ": " + item.ToString());

                // List Rating 1 Star to 10 Stars
                // Re-use existing menu labels to represent star value
                pItem = new GUIListItem(Translation.RatingStar);
                dlg.Add(pItem);
                pItem.ItemId = 1;

                for (int i = 2; i < 11; i++)
                {
                    pItem = new GUIListItem(Translation.RatingStars);
                    dlg.Add(pItem);
                    pItem.ItemId = i;
                }

                // Reset Rating (Rate = 0)
                pItem = new GUIListItem(Translation.ResetRating);
                dlg.Add(pItem);
                pItem.ItemId = 11;

                if (auto)
                {
                    pItem = new GUIListItem(Translation.DontAskToRate);
                    dlg.Add(pItem);
                    pItem.ItemId = 12;
                }

                dlg.DoModal(GUIWindowManager.ActiveWindow);

                if (dlg.SelectedId == -1 || dlg.SelectedId > 12) return; // cancelled
                if (dlg.SelectedLabelText == Translation.DontAskToRate && auto)
                {
                    DBOption.SetOptions(DBOption.cAskToRate, false);
                    return;
                }
                // Get Rating Value
                value = dlg.SelectedId.ToString();
                // Reset rating
                if (dlg.SelectedLabelText == Translation.ResetRating)
                    value = "0";
            }

            new Thread(delegate(object o)
            {
                DBTable tItem = ((KeyValuePair<DBTable, string>)o).Key;
                string tValue = ((KeyValuePair<DBTable, string>)o).Value;

                Listlevel tLevel = tItem is DBEpisode ? Listlevel.Episode : Listlevel.Series;
                string id = tItem[tLevel == Listlevel.Episode ? DBOnlineEpisode.cID : DBOnlineSeries.cID];

                // Submit rating online database
                int rating = -1;
                if (Int32.TryParse(tValue, out rating))
                {
                    Online_Parsing_Classes.OnlineAPI.SubmitRating(tLevel == Listlevel.Episode ? Online_Parsing_Classes.OnlineAPI.RatingType.episode : Online_Parsing_Classes.OnlineAPI.RatingType.series, id, rating);

                    if (level == Listlevel.Episode)
                        FollwitConnector.Rate((DBEpisode)item, rating);
                    else
                        FollwitConnector.Rate((DBSeries)item, rating);
                }

            })
            {
                IsBackground = true,
                Name = "tvdb rating sender"
            }.Start(new KeyValuePair<DBTable, string>(item, value));

            // Apply to local database
            item["myRating"] = value;

            // recalculate rating/votes
            double currRating = string.IsNullOrEmpty(item["Rating"]) ? 0.0 : (double)item["Rating"];
            double currCount = string.IsNullOrEmpty(item["RatingCount"]) ? 0.0 : (double)item["RatingCount"];
            item["Rating"] = ((currRating * currCount) + double.Parse(value)) / (currCount + 1);
            item["RatingCount"] = currCount + 1;

            // tell any listeners that user rated episode/series
            if (RateItem != null)
                RateItem(item, value);

            item.Commit();
        }
Exemple #20
0
        public static List<DBValue> GetSingleField(string field, SQLCondition conds, DBTable obj)
        {

            string sql = "select " + field + " from " + obj.m_tableName + conds + conds.orderString + conds.limitString;
            List<DBValue> results = new List<DBValue>();
            try
            {
                foreach (SQLiteResultSet.Row result in DBTVSeries.Execute(sql).Rows)
                {
                    results.Add(result.fields[0]);
                }
            }
            catch (Exception ex)
            {
                MPTVSeriesLog.Write("GetSingleField SQL method generated an error: " + ex.Message);
            }
            return results;
        }
Exemple #21
0
        private void Episode_OnItemSelected(GUIListItem item)
        {
            if (item == null || item.TVTag == null)
                return;

            setNewListLevelOfCurrView(m_CurrViewStep);

            DBEpisode episode = item.TVTag as DBEpisode;
            if (episode == null) return;

            // set watched/unavailable flag
            if (dummyIsWatched != null) dummyIsWatched.Visible = episode[DBOnlineEpisode.cWatched];
            if (dummyIsAvailable != null) dummyIsAvailable.Visible = episode[DBEpisode.cFilename].ToString().Length > 0;

            m_SelectedEpisode = episode;
            setGUIProperty(guiProperty.Logos, localLogos.getLogos(ref episode, logosHeight, logosWidth));
            setGUIProperty(guiProperty.EpisodeImage, ImageAllocator.GetEpisodeImage(m_SelectedEpisode));
            setGUIProperty(guiProperty.Title, FieldGetter.resolveDynString(m_sFormatEpisodeTitle, episode));
            setGUIProperty(guiProperty.Subtitle, FieldGetter.resolveDynString(m_sFormatEpisodeSubtitle, episode));
            setGUIProperty(guiProperty.Description, FieldGetter.resolveDynString(m_sFormatEpisodeMain, episode));

            // with groups in episode view its possible the user never selected a series/season (flat view)
            // thus its desirable to display the series_banner and season banner on hover)
            if (!m_CurrLView.stepHasSeriesBeforeIt(m_CurrViewStep) || m_bUpdateBanner)
            {
                // it is the case
                m_SelectedSeason = Helper.getCorrespondingSeason(episode[DBEpisode.cSeriesID], episode[DBEpisode.cSeasonIndex]);
                m_SelectedSeries = Helper.getCorrespondingSeries(episode[DBEpisode.cSeriesID]);

                if (m_SelectedSeries != null)
                {
                    seriesbanner.Filename = ImageAllocator.GetSeriesBannerAsFilename(m_SelectedSeries);
                    seriesposter.Filename = ImageAllocator.GetSeriesPosterAsFilename(m_SelectedSeries);
                    pushFieldsToSkin(m_SelectedSeries, "Series");
                }
                else
                {
                    clearGUIProperty(guiProperty.SeriesBanner);
                    clearGUIProperty(guiProperty.SeriesPoster);
                }

                if (m_SelectedSeason != null)
                {
                    string filename = ImageAllocator.GetSeasonBannerAsFilename(m_SelectedSeason);
                    if (filename.Length == 0)
                    {
                        // Load Series Poster instead
                        if (DBOption.GetOptions(DBOption.cSubstituteMissingArtwork) && m_SelectedSeries != null)
                        {
                            filename = ImageAllocator.GetSeriesPosterAsFilename(m_SelectedSeries);
                        }
                    }
                    seasonbanner.Filename = filename;

                    pushFieldsToSkin(m_SelectedSeason, "Season");
                }
                else
                    clearGUIProperty(guiProperty.SeasonPoster);

                m_bUpdateBanner = false;
            }
            pushFieldsToSkin(m_SelectedEpisode, "Episode");

            // Load Fanart for Selected Series, might be in Episode Only View e.g. Recently Added, Latest
            if (m_SelectedSeries == null) return;

            m_FanartItem = m_SelectedSeries;
            if (DBOption.GetOptions(DBOption.cFanartRandom))
            {
                // We should update fanart as soon as new series is selected or
                // if timer was disabled (e.g. fullscreen playback)
                if (m_SelectedSeries[DBSeries.cID].ToString() != m_prevSeriesID || m_bFanartTimerDisabled)
                    m_FanartTimer.Change(0, DBOption.GetOptions(DBOption.cRandomFanartInterval));
            }
            else
                loadFanart(m_FanartItem);

            // Remember last series, so we dont re-initialize random fanart timer
            m_prevSeriesID = m_SelectedSeries[DBSeries.cID];
        }
Exemple #22
0
        static string getValuesOfType(DBTable item, string what, Regex matchRegex, string Identifier)
        {          
            string value = what;
            foreach (Match m in matchRegex.Matches(what))
            {            
                string result;
                // check if we have useredted column             
                string userEditedEquivalent = m.Value + DBTable.cUserEditPostFix;
                if (string.IsNullOrEmpty((result = item[userEditedEquivalent])))
                    result = item[m.Value];
                
                // Create pretty string for split fields e.g. |SCI-FI|ACTION| => SCI-FI, ACTION
                if (_splitFields) result = result.Trim('|').Replace("|", ", ");
                
                // Prefix specials with an 'S' when in-line sorting with episodes
                if (m.Value == "EpisodeIndex" && item["SeasonIndex"].ToString() == "0" && what.IndexOf("<SeasonIndex>",0) < 0)
                    result = "S" + item["EpisodeIndex"];
                
                // Localize Date Format
                if (_formatDates) {                    
                    DateTime date;
                    if (DateTime.TryParseExact(result, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.None, out date)) {
                        result = date.ToString(_dateFormat);
                    }
                }

                // remove regional info from number when applying formatting rules
                // the formatting rules expects decimal values with a dot seperator
                // Ratings could be inserted with comma seperator and are commonly used
                // in formatting rules to evaluate rating images
                // Note: this is probably not the best way to handle this, probably better off enforcing how we write to db!
                if (m.Value == "Rating" && what.IndexOf("Eval", 0) >= 0)
                    result = result.Replace(',', '.');

                value = value.Replace(Identifier + m.Value + ">", result);
            }            
            return value;
        }
Exemple #23
0
        private bool loadFanart(DBTable item)
        {
            if (FanartBackground == null)
            {
                // Fanart not supported by skin, exit now
                fanartSet = false;
                if (this.dummyIsFanartLoaded != null)
                    this.dummyIsFanartLoaded.Visible = false;

                return false;
            }

            try
            {
                Fanart fanart = currSeriesFanart;
                DBSeries series = item as DBSeries;

                // Get a Fanart for selected series from Database
                if (series != null)
                {
                    if (fanart == null || fanart.SeriesID != series[DBSeries.cID])
                    {
                        // Get a Fanart object for currently selected series
                        fanart = Fanart.getFanart(series[DBSeries.cID]);
                    }
                }
                else
                {
                    // Get Season Fanart if it exists, otherwise return Series fanart
                    DBSeason season = item as DBSeason;
                    if (season != null)
                        fanart = Fanart.getFanart(season[DBSeason.cSeriesID], season[DBSeason.cIndex]);
                }

                if (fanart == null)
                {
                    // This shouldn't happen
                    MPTVSeriesLog.Write("Fanart is unavailable, disabling", MPTVSeriesLog.LogLevel.Debug);
                    DisableFanart();
                    return false;
                }

                // Reset Fanart Selection for next time
                fanart.ForceNewPick();
                currSeriesFanart = fanart;

                // set current fanart property so can be used outside of imageswapper
                string fanartFile = fanart.FanartFilename;
                setGUIProperty("#TVSeries.Current.Fanart", fanartFile);

                // disable fanart if the skin tells us so
                if (!CheckSkinFanartSettings())
                {
                    DisableFanart();
                    return false;
                }

                // Activate Backdrop in Image Swapper
                if (!backdrop.Active) backdrop.Active = true;

                // Assign Fanart filename to Image Loader
                // Will display fanart in backdrop or reset to default background
                backdrop.Filename = fanartFile;

                if (fanart.Found)
                    MPTVSeriesLog.Write(string.Format("Fanart found and loaded for series {0}, loading: {1}", Helper.getCorrespondingSeries(fanart.SeriesID).ToString(), backdrop.Filename), MPTVSeriesLog.LogLevel.Debug);
                else
                    MPTVSeriesLog.Write(string.Format("Fanart not found for series {0}", Helper.getCorrespondingSeries(fanart.SeriesID).ToString()));

                // I don't think we can support these anymore with dbfanart now
                //if (this.dummyIsLightFanartLoaded != null)
                //    this.dummyIsLightFanartLoaded.Visible = f.RandomPickIsLight;
                //if (this.dummyIsDarkFanartLoaded != null)
                //    this.dummyIsDarkFanartLoaded.Visible = !f.RandomPickIsLight;

                if (fanart.HasColorInfo)
                {
                    System.Drawing.Color[] fanartColors = fanart.Colors;
                    setGUIProperty("FanArt.Colors.LightAccent", Fanart.RGBColorToHex(fanartColors[0]));
                    setGUIProperty("FanArt.Colors.DarkAccent", Fanart.RGBColorToHex(fanartColors[1]));
                    setGUIProperty("FanArt.Colors.Neutral Midtone", Fanart.RGBColorToHex(fanartColors[2]));
                }
                else
                {
                    setGUIProperty("FanArt.Colors.LightAccent", string.Empty);
                    setGUIProperty("FanArt.Colors.DarkAccent", string.Empty);
                    setGUIProperty("FanArt.Colors.Neutral Midtone", string.Empty);
                }

                if (this.dummyIsFanartColorAvailable != null)
                    this.dummyIsFanartColorAvailable.Visible = fanart.HasColorInfo;

                if (this.dummyIsFanartLoaded != null)
                    this.dummyIsFanartLoaded.Visible = true;

                return fanartSet = true;
            }
            catch (Exception ex)
            {
                MPTVSeriesLog.Write("Failed to load Fanart: " + ex.Message, MPTVSeriesLog.LogLevel.Normal);
                return fanartSet = false;
            }
        }
Exemple #24
0
 public static string resolveDynString(string what, DBTable item)
 {
     return resolveDynString(what, item, true);
 }
Exemple #25
0
        private void Series_OnItemSelected(GUIListItem item)
        {
            if (m_bQuickSelect) return;

            m_SelectedSeason = null;
            m_SelectedEpisode = null;
            if (item == null || item.TVTag == null || !(item.TVTag is DBSeries))
                return;

            setNewListLevelOfCurrView(m_CurrViewStep);

            DBSeries series = item.TVTag as DBSeries;
            if (series == null) return;

            m_SelectedSeries = series;

            // set watched/unavailable flag
            if (dummyIsWatched != null) dummyIsWatched.Visible = (int.Parse(series[DBOnlineSeries.cEpisodesUnWatched]) == 0);
            if (dummyIsAvailable != null) dummyIsAvailable.Visible = series[DBSeason.cHasLocalFiles];

            clearGUIProperty(guiProperty.EpisodeImage);
            seasonbanner.Filename = "";

            setGUIProperty(guiProperty.Title, FieldGetter.resolveDynString(m_sFormatSeriesTitle, series));
            setGUIProperty(guiProperty.Subtitle, FieldGetter.resolveDynString(m_sFormatSeriesSubtitle, series));
            setGUIProperty(guiProperty.Description, FieldGetter.resolveDynString(m_sFormatSeriesMain, series));

            // Delayed Image Loading of Series Banners/Posters
            seriesbanner.Filename = ImageAllocator.GetSeriesBannerAsFilename(series);
            seriesposter.Filename = ImageAllocator.GetSeriesPosterAsFilename(series);

            setGUIProperty(guiProperty.Logos, localLogos.getLogos(ref series, logosHeight, logosWidth));

            pushFieldsToSkin(m_SelectedSeries, "Series");

            // Load Fanart
            // Re-initialize timer for random fanart
            m_FanartItem = m_SelectedSeries;
            if (DBOption.GetOptions(DBOption.cFanartRandom))
            {
                // We should update fanart as soon as new series is selected or
                // if timer was disabled (e.g. fullscreen playback)
                if (m_SelectedSeries[DBSeries.cID].ToString() != m_prevSeriesID || m_bFanartTimerDisabled)
                    m_FanartTimer.Change(0, DBOption.GetOptions(DBOption.cRandomFanartInterval));
            }
            else
                loadFanart(m_FanartItem);

            // Remember last series, so we dont re-initialize random fanart timer
            m_prevSeriesID = m_SelectedSeries[DBSeries.cID];
        }
Exemple #26
0
 public static string resolveDynString(string what, DBTable item, bool applyUserFormatting)
 {
     return resolveDynString(what, item, true, applyUserFormatting);
 }
Exemple #27
0
        public static string resolveDynString(string what, DBTable item, bool splitFields, bool applyUserFormatting)
        {
             // apply userFormatting on the field's itself
            if (applyUserFormatting) performUserFormattingReplacement(ref what);

            Level level = levelOfItem(item);
            string value = what;
            List<Level> whatLevels = getLevel(what);
            _splitFields = splitFields;
            // the item needs to be the type corresponding to the level (we require the item to match the indicated level)
            if (level == Level.Episode) // we can do everything
            {
                if (whatLevels.Contains(Level.Episode))
                {
                    DBOnlineEpisode o = item as DBOnlineEpisode;
                    if (o == null) value = replaceEpisodeTags(item as DBEpisode, value);
                    else value = replaceEpisodeTags(o, value);
                }
                if (whatLevels.Contains(Level.Season))
                    value = replaceSeasonTags(item[DBEpisode.cSeriesID], item[DBEpisode.cSeasonIndex], value);
                if (whatLevels.Contains(Level.Series))
                    value = replaceSeriesTags(item[DBEpisode.cSeriesID], value);
            }
            else if (level == Level.Season && !whatLevels.Contains(Level.Episode)) // we can do season/series
            {
                if (whatLevels.Contains(Level.Season))
                    value = replaceSeasonTags(item as DBSeason, value);
                if (whatLevels.Contains(Level.Series))
                    value = replaceSeriesTags(item[DBSeason.cSeriesID], value);
            }
            else if (level == Level.Series && !whatLevels.Contains(Level.Episode) && !whatLevels.Contains(Level.Season)) // we can only do series
            {
                DBOnlineSeries o = item as DBOnlineSeries;
                if (o == null) value = replaceSeriesTags(item as DBSeries, value);
                else value = replaceSeriesTags(item[DBSeries.cID], value);
            }            
            if (nonFormattingFields.Contains(what))
            {
                return value;
            }
            value = doFormatting(value, what, item);

            value = MathParser.mathParser.TryParse(value);
            value = MathParser.mathParser.TranslateExpression(value);

            // apply userFormatting on the field's result
            if (applyUserFormatting)
            {
                bool replacementOccured = performUserFormattingReplacement(ref value);
                // because the replacement itself might be dynamic again, we resolve the result again
                if(replacementOccured) value = resolveDynString(value, item, splitFields, applyUserFormatting);
            }
            return value;
        }
Exemple #28
0
 static Level levelOfItem(DBTable item)
 {
     Type p = item.GetType();
     if (p == typeof(DBSeries) || p == typeof(DBOnlineSeries)) return Level.Series;
     if (p == typeof(DBSeason)) return Level.Season;
     if (p == typeof(DBEpisode) || p==typeof(DBOnlineEpisode)) return Level.Episode;
     return Level.Series;
 }
Exemple #29
0
 static string getQTableNameFromUnknownType(DBTable table, string field)
 {
     return (string)table.GetType().InvokeMember("Q", System.Reflection.BindingFlags.InvokeMethod, null, table, new object[1] { field });
 }
Exemple #30
0
        static string getValuesOfType(DBTable item, string what, Regex matchRegex, string Identifier)
        {          
            string value = what;
            foreach (Match m in matchRegex.Matches(what))
            {            
                string result;
                // check if we have useredted column             
                string userEditedEquivalent = m.Value + DBTable.cUserEditPostFix;
                if (string.IsNullOrEmpty((result = item[userEditedEquivalent])))
                    result = item[m.Value];
                
                // Create pretty string for split fields e.g. |SCI-FI|ACTION| => SCI-FI, ACTION
                if (_splitFields) result = result.Trim('|').Replace("|", ", ");
                
                // Prefix specials with an 'S' when in-line sorting with episodes
                if (m.Value == "EpisodeIndex" && item["SeasonIndex"].ToString() == "0" && what.IndexOf("<SeasonIndex>",0) < 0)
                    result = "S" + item["EpisodeIndex"];
                
                // Localize Date Format
                if (_formatDates) {                    
                    DateTime date;
                    if (DateTime.TryParseExact(result, "yyyy-MM-dd", System.Globalization.CultureInfo.CurrentCulture, System.Globalization.DateTimeStyles.None, out date)) {
                        result = date.ToString(_dateFormat);
                    }
                }

                value = value.Replace(Identifier + m.Value + ">", result);
            }            
            return value;
        }
Exemple #31
0
        private string replaceDynamicFields(string value, DBTable item)
        {
            string result = value;

            Regex matchRegEx = new Regex(@"\<[a-zA-Z\.]+\>");
            foreach (Match m in matchRegEx.Matches(value))
            {
                string resolvedValue = FieldGetter.resolveDynString(m.Value, item, false);
                result = result.Replace(m.Value, resolvedValue);
            }

            return result;
        }
Exemple #32
0
 static string doFormatting(string input, string fieldname, DBTable item)
 {
     foreach (formatingRule fr in formatingRules)
         if (fr.Format(input, fieldname, item))
             input = fr.Result;
     return input;
 }
Exemple #33
0
 public SQLCondition(DBTable table, String sField, DBValue value, SQLConditionType type)
 {
     Add(table, sField, value, type);
 }
Exemple #34
0
 public bool Format(string input, string field, DBTable item)
 {
     this.input = input;
     this.field = field;
     this.item = item;
     if (Applies)
     {
         result = doAction(input, field, item);
         return true;
     }
     return false;
 }
        private void OnRateItem(DBTable item, string value)
        {
            if (TraktSettings.AccountStatus != ConnectionState.Connected) return;

            if (item is DBEpisode)
                RateEpisode(item as DBEpisode);
            else
                RateSeries(item as DBSeries);
        }
Exemple #36
0
 public SQLWhat(DBTable table)
 {
     Add(table);
 }