/// <summary>
        /// Marks the specified episode as seen.
        /// </summary>
        /// <param name="showid">The ID of the show.</param>
        /// <param name="file">The identified file.</param>
        public static void MarkAsSeen(int showid, ShowFile file)
        {
            var @new = false;
            var eps  = file.Episode.SecondEpisode.HasValue
                       ? Enumerable.Range(file.Episode.Episode, (file.Episode.SecondEpisode.Value - file.Episode.Episode + 1)).ToArray()
                       : new[] { file.Episode.Episode };

            foreach (var epnr in eps)
            {
                Episode ep;
                if (Database.TVShows[showid].EpisodeByID.TryGetValue(file.Episode.Season * 1000 + epnr, out ep))
                {
                    if (!ep.Watched)
                    {
                        @new = ep.Watched = true;
                    }
                }
            }

            if (@new)
            {
                Log.Debug("Marking " + file + " as seen.");
                Database.TVShows[showid].SaveTracking();
                PostToSocial(file);
            }

            MainWindow.Active.DataChanged();
        }
        public static void askUserForShow(string userInput)
        {
            string   showFilePath = "shows.csv";
            ShowFile showFile     = new ShowFile(showFilePath);

            // Add show
            Show   show      = new Show();
            string tempInput = "";

            // ask user to input show title
            System.Console.WriteLine("What is the show titled");
            show.showTitle = System.Console.ReadLine();

            // check if the title matches another title
            if (!showFile.hasSameTitle(show.showTitle))
            {
                System.Console.WriteLine("What Season?");
                show.showSeason = int.Parse(System.Console.ReadLine());

                System.Console.WriteLine("What Episode?");
                show.showEpisode = int.Parse(System.Console.ReadLine());

                do
                {
                    // ask user to enter a writer
                    System.Console.WriteLine("Enter a Writer. ('.' to stop) ");
                    tempInput = System.Console.ReadLine();

                    show.showWriters.Add(tempInput);
                } while (tempInput != ".");

                //show never gets created if the title matches another
                showFile.AddShow(show);
            }
        }
Exemple #3
0
        static void Main(string[] args)
        {
            //测试ListBox
            //TestListBox listbox = new TestListBox();
            //listbox.ShowDialog();
            //测试Check
            //TestCheckBox check = new TestCheckBox();
            //check.ShowDialog();

            //TestPanel panel = new TestPanel();
            //panel.ShowDialog();

            ShowFile file = new ShowFile();

            file.ShowDialog();
        }
Exemple #4
0
        public LinkDocumentForm()
        {
            InitializeComponent();

            string[]        files = Directory.GetFiles(DirectoryAndFileHelper.ClientDocumentsFolder);
            List <ShowFile> list  = new List <ShowFile>();

            foreach (string s in files)
            {
                ShowFile sf = new ShowFile()
                {
                    FileName = s.Split('\\')[s.Split('\\').Length - 1]
                };
                sf.GetImage();
                list.Add(sf);
            }
            dataGridView1.DataSource = list;
        }
 private void TextDB_Click(object sender, EventArgs e)
 {
     ShowFile.ShowDialog();
 }
        /// <summary>
        /// Updates the status message on configures social networks.
        /// </summary>
        /// <param name="file">The identified file.</param>
        public static void PostToSocial(ShowFile file)
        {
            if (Settings.Get("Post only recent", true) && (DateTime.Now - file.Airdate).TotalDays > 21)
            {
                return;
            }

            var listed = Settings.Get("Post restrictions list", new List<int>())
                                 .Contains(Database.TVShows.Values.First(x => x.Name == file.Show).ShowID);

            switch (Settings.Get("Post restrictions list type", "black"))
            {
                case "black":
                    if (listed)
                    {
                        return;
                    }
                    break;

                case "white":
                    if (!listed)
                    {
                        return;
                    }
                    break;
            }

            foreach (var engine in Extensibility.GetNewInstances<SocialEngine>())
            {
                if (!Settings.Get<bool>("Post to " + engine.Name))
                {
                    continue;
                }

                if (engine is OAuthEngine)
                {
                    var tokens = Settings.Get<List<string>>(engine.Name + " OAuth");

                    if (tokens != null && tokens.Count != 0)
                    {
                        ((OAuthEngine)engine).Tokens = tokens;
                    }
                    else
                    {
                        continue;
                    }
                }

                var format = Settings.Get(engine.Name + " Status Format", engine.DefaultStatusFormat);
                if (string.IsNullOrWhiteSpace(format))
                {
                    return;
                }

                try { engine.PostMessage(FileNames.Parser.FormatFileName(format, file)); } catch { }
            }
        }
        /// <summary>
        /// Marks the specified episode as seen.
        /// </summary>
        /// <param name="showid">The ID of the show.</param>
        /// <param name="file">The identified file.</param>
        public static void MarkAsSeen(int showid, ShowFile file)
        {
            var @new = false;
            var eps  = file.Episode.SecondEpisode.HasValue
                       ? Enumerable.Range(file.Episode.Episode, (file.Episode.SecondEpisode.Value - file.Episode.Episode + 1)).ToArray()
                       : new[] { file.Episode.Episode };

            foreach (var epnr in eps)
            {
                var epid = Database.GetEpisodeID(showid, file.Episode.Season, epnr);
                if (epid == int.MinValue)
                {
                    continue;
                }

                if (@new = (Database.Query("select * from tracking where showid = ? and episodeid = ?", showid, epid).Count == 0))
                {
                    Database.Execute("insert into tracking values (?, ?)", showid, epid);

                    Database.Trackings.Add(epid);
                    Database.Episodes.First(e => e.EpisodeID == epid).Watched = true;
                }
            }

            if (@new)
            {
                PostToSocial(file);
            }

            MainWindow.Active.DataChanged();
        }
        /// <summary>
        /// Updates the status message on configures social networks.
        /// </summary>
        /// <param name="file">The identified file.</param>
        public static void PostToSocial(ShowFile file)
        {
            if (Settings.Get("Post only recent", true) && (DateTime.Now - file.Airdate).TotalDays > 21)
            {
                Log.Debug("Not posting " + file + " to social networks because it is not a recent episode.");
                return;
            }

            var listed = Settings.Get("Post restrictions list", new List <int>())
                         .Contains(Database.TVShows.Values.First(x => x.Title == file.Show).ID);

            switch (Settings.Get("Post restrictions list type", "black"))
            {
            case "black":
                if (listed)
                {
                    Log.Debug("Not posting " + file + " to social networks because the show is blacklisted.");
                    return;
                }
                break;

            case "white":
                if (!listed)
                {
                    Log.Debug("Not posting " + file + " to social networks because the show is not whitelisted.");
                    return;
                }
                break;
            }

            foreach (var engine in Extensibility.GetNewInstances <SocialEngine>())
            {
                if (!Settings.Get <bool>("Post to " + engine.Name))
                {
                    continue;
                }

                if (engine is OAuthEngine)
                {
                    var tokens = Settings.Get <List <string> >(engine.Name + " OAuth");

                    if (tokens != null && tokens.Count != 0)
                    {
                        ((OAuthEngine)engine).Tokens = tokens;
                    }
                    else
                    {
                        Log.Debug("Not posting " + file + " to " + engine.Name + " because it required OAuth tokens are missing.");
                        continue;
                    }
                }


                var format = Settings.Get(engine.Name + " Status Format", engine.DefaultStatusFormat);
                if (string.IsNullOrWhiteSpace(format))
                {
                    return;
                }

                try
                {
                    engine.PostMessage(FileNames.Parser.FormatFileName(format, file));
                    Log.Debug("Successfully posted " + file + " to " + engine.Name + ".");
                }
                catch (Exception ex)
                {
                    Log.Warn("Unhandled exception while posting " + file + " to " + engine.Name + ".", ex);
                }
            }
        }
        /// <summary>
        /// Marks the specified episode as seen.
        /// </summary>
        /// <param name="showid">The ID of the show.</param>
        /// <param name="file">The identified file.</param>
        public static void MarkAsSeen(int showid, ShowFile file)
        {
            var @new = false;
            var eps  = file.Episode.SecondEpisode.HasValue
                       ? Enumerable.Range(file.Episode.Episode, (file.Episode.SecondEpisode.Value - file.Episode.Episode + 1)).ToArray()
                       : new[] { file.Episode.Episode };

            foreach (var epnr in eps)
            {
                Episode ep;
                if (Database.TVShows[showid].EpisodeByID.TryGetValue(file.Episode.Season * 1000 + epnr, out ep))
                {
                    if (!ep.Watched)
                    {
                        @new = ep.Watched = true;
                    }
                }
            }

            if (@new)
            {
                Database.TVShows[showid].SaveTracking();
                PostToSocial(file);
            }

            MainWindow.Active.DataChanged();
        }