コード例 #1
0
        private DBOnlineSeries getSeriesFromSelected(DataGridViewRow row)
        {
            DBOnlineSeries chosenSeries = null;
            var            cell         = row.Cells[ColIndexOf(colOSeries)] as DataGridViewComboBoxCell;
            var            seriesList   = cell.Tag as List <DBOnlineSeries>;

            if (seriesList != null)
            {
                string toMatch = cell.Value as string;
                chosenSeries = seriesList.FirstOrDefault(s => toMatch == getDisplayStringForSeries(s));
            }
            return(chosenSeries);
        }
コード例 #2
0
        public static string GetLanguageOverride(String sSeriesID)
        {
            string       sqlCon = string.Empty;
            SQLCondition cond   = new SQLCondition();

            sqlCon = "id = " + sSeriesID;
            cond.AddCustom(sqlCon);

            // Get the language that the user has selected for the serie
            List <DBValue> seriesLanguage = DBOnlineSeries.GetSingleField(DBOnlineSeries.cLanguage, cond, new DBOnlineSeries());

            if ((seriesLanguage.Count > 0) && (seriesLanguage[0] != ""))
            {
                return(seriesLanguage[0]);
            }
            else
            {
                //If there is no language prefered for the series, the fallback is SelLanguageAsString (en).
                return(SelLanguageAsString);
            }
        }
コード例 #3
0
        private Dictionary <string, UserInputResultSeriesActionPair> getApprovedResults()
        {
            var pageResult = new Dictionary <string, UserInputResultSeriesActionPair>();

            foreach (DataGridViewRow row in dataGridViewIdentifySeries.Rows)
            {
                string         inputSeriesName = row.Cells[ColIndexOf(colSeries)].Value as string;
                var            requestedAction = getActionFromRow(row);
                DBOnlineSeries chosenSeries    = null;

                // else we dont even care
                if (requestedAction == UserInputResults.SeriesAction.Approve)
                {
                    chosenSeries = getSeriesFromSelected(row);
                }

                MPTVSeriesLog.Write(string.Format("Series \"{0}\" {1} {2}", inputSeriesName, requestedAction.ToString(), chosenSeries == null ? string.Empty : this.getDisplayStringForSeries(chosenSeries)));

                pageResult.Add(inputSeriesName, new UserInputResultSeriesActionPair(requestedAction, chosenSeries));
            }

            return(pageResult);
        }
コード例 #4
0
 private string getDisplayStringForSeries(DBOnlineSeries series)
 {
     return(string.Format("{0} ({1})", series[DBOnlineSeries.cPrettyName], series[DBOnlineSeries.cID]));
 }
コード例 #5
0
        public void GetSeries()
        {
            Log.Instance().Print("Pulling series list from MP-TVSeries started");
            List <DBOnlineSeries> myseries = DBOnlineSeries.getAllSeries();

            foreach (DBOnlineSeries tvshow in myseries)
            {
                DBSeries mytv = Helper.getCorrespondingSeries(tvshow[DBOnlineSeries.cID]);
                if (mytv != null)
                {
                    string ishidden = mytv[DBSeries.cHidden];
                    if (ishidden != "1")
                    {
                        Series s = new Series();
                        s.ID           = (tvshow[DBOnlineSeries.cID]);
                        s.Name         = tvshow[DBOnlineSeries.cPrettyName];
                        s.OriginalName = tvshow[DBOnlineSeries.cOriginalName];
                        s.Description  = tvshow[DBOnlineSeries.cSummary];
                        s.Rating       = tvshow[DBOnlineSeries.cRating];
                        s.Genres       = tvshow[DBOnlineSeries.cGenre];
                        s.Poster       = Config.GetFolder(Config.Dir.Thumbs) + @"\" + "MPTVSeriesBanners" + @"\" + tvshow[DBOnlineSeries.cCurrentBannerFileName].ToString().Replace("/", @"\");

                        DBEpisode lastlocal    = null;
                        DBEpisode firstunlocal = null;
                        DBSeries  series       = Helper.getCorrespondingSeries(tvshow[DBOnlineSeries.cID]);
                        //DownList.Add(todownload);
                        // get all episodes for the series
                        var conditions = new SQLCondition();
                        conditions.Add(new DBOnlineEpisode(), DBOnlineEpisode.cSeriesID, tvshow[DBOnlineSeries.cID], SQLConditionType.Equal);
                        var episodes = DBEpisode.Get(conditions, false);
                        episodes.Sort();
                        //first option - get all unlocal episodes
                        var           unLocalEpisodes = episodes.Where(e => !e.IsAvailableLocally).ToList();
                        StringBuilder sb = new StringBuilder();

                        foreach (DBEpisode e in unLocalEpisodes)
                        {
                            s.AllUnlocal += "S" + ((int)e[DBEpisode.cSeasonIndex]).ToString("00") + "E" + ((int)e[DBEpisode.cEpisodeIndex]).ToString("00") + "|";
                        }
                        //
                        //second option - get first unlocal episode
                        var localepisodes = episodes.Where(e => e.IsAvailableLocally);
                        try
                        {
                            lastlocal = localepisodes.Last();
                        }
                        catch
                        {
                            lastlocal = null;
                        }
                        int firstunlocalid = episodes.IndexOf(lastlocal) + 1;
                        try
                        {
                            firstunlocal   = episodes[firstunlocalid];
                            s.FirstUnlocal = "S" + ((int)firstunlocal[DBEpisode.cSeasonIndex]).ToString("00") + "E" + ((int)firstunlocal[DBEpisode.cEpisodeIndex]).ToString("00");
                        }
                        catch (Exception e)
                        {
                            firstunlocal   = null;
                            s.FirstUnlocal = "";
                        }
                        allseries.Add(s);
                    }
                }
            }

            Log.Instance().Print("Pulling series list from MP-TVSeries finished");
        }
コード例 #6
0
 private string getDisplayStringForSeries(DBOnlineSeries series)
 {
     return string.Format("{0} ({1})", series[DBOnlineSeries.cPrettyName], series[DBOnlineSeries.cID]);
 }