Ejemplo n.º 1
0
        private static void ConvertSeriesTimeZones(TVDoc doc, TheTVDB tvdb)
        {
            //this is just to convert timezones in the TheTVDB into the TVDOC where they should be:
            //itshould only do anything the first time it is run and then be entirely begign
            //can be removed after 1/1/19

            foreach (ShowItem si in doc.Library.GetShowItems())
            {
                string newTimeZone = tvdb.GetSeries(si.TVDBCode)?.tempTimeZone;

                if (string.IsNullOrWhiteSpace(newTimeZone))
                {
                    continue;
                }
                if (newTimeZone == TimeZone.DefaultTimeZone())
                {
                    continue;
                }
                if (si.ShowTimeZone != TimeZone.DefaultTimeZone())
                {
                    continue;
                }

                si.ShowTimeZone = newTimeZone;
                doc.SetDirty();
                logger.Info("Copied timezone:{0} onto series {1}", newTimeZone, si.ShowName);
            }
        }
Ejemplo n.º 2
0
 private void frmTheTVDBTest_Load(object sender, EventArgs e)
 {
     api = new TheTVDB();
 }
Ejemplo n.º 3
0
    private void FetchTV() {

      var movieInfo= NFOFileReader.ReadMovieOrDefault(this.Item);
      if (movieInfo != null) {
        this.title = movieInfo.Title;
        this.description=movieInfo.Plot;
        this.duration = movieInfo.Duration;
        this.actors=movieInfo.Actors;
        this.director=movieInfo.Director;
        this.genre=movieInfo.Genres?.FirstOrDefault();
        this.isSeries = false;
        this._MarkMetaDataInitialized();
        return;
      }

      var episodeInfo = NFOFileReader.ReadEpisodeOrDefault(this.Item);
      if (episodeInfo != null) {
        var showInfo = NFOFileReader.ReadShowOrDefault(this.Item.Directory) ?? NFOFileReader.ReadShowOrDefault(this.Item.Directory?.Parent) ?? NFOFileReader.ReadShowOrDefault(this.Item.Directory?.Parent?.Parent);

        this.title = episodeInfo.Title;
        this.description = episodeInfo.Plot;
        this.duration = episodeInfo.Duration;
        this.actors = showInfo.Actors;
        this.director = episodeInfo.Director;
        this.genre = showInfo.Genres?.FirstOrDefault();
        this.episode = episodeInfo.Episode;
        this.season = episodeInfo.Season;
        this.seriesname = showInfo.Title?? episodeInfo.ShowTitle;
        this.isSeries = true;
        this._MarkMetaDataInitialized();
        return;
      }
      
      try {
        if (this.tvshowid == null || this.tvshowid == -1)
          this.tvshowid = TheTVDB.GetTVShowID(this.Path);

        var name = Directory.GetParent(this.Path).Name.GetNiceNameOrNull();
        if (name == null || name is Formatting.NiceSeriesName seriesName && seriesName.Episode == 0)
          name = base.Title.GetNiceNameOrNull();

        if (name == null)
          name = this.Item.Name.GetNiceNameOrNull();

        TVShowInfo tvinfo = null;

        if (this.tvshowid != null && this.tvshowid > 0) {
          tvinfo = TheTVDB.GetTVShowDetails(this.tvshowid.Value);
          this.Server.UpdateTVCache(tvinfo);
          this.seriesname = tvinfo.Name;
          this.isSeries = true;
        }

        switch (name) {
          case Formatting.NiceSeriesName showName: {
            this.isSeries = true;
            if (string.IsNullOrEmpty(this.seriesname))
              this.seriesname = showName.Name;

            if (showName.Episode > 0) {
              this.title =
                tvinfo != null
                ? tvinfo.Find(showName.Season, showName.Episode)
                : $"s{showName.Season}e{showName.Episode}"
                ;

              this.season = showName.Season;
              this.episode = showName.Episode;
            } else {
              this.title = base.Title;
            }

            if (!string.IsNullOrEmpty(name.Releaser))
              this.title = $"{this.title} ({name.Resolution},{name.Releaser})";

            break;
          }

          case Formatting.MovieName movieName: {
            this.seriesname = $"{movieName.Name} ({movieName.Year})";
            break;
          }

          default:
            this.seriesname = Directory.GetParent(this.Path).Name;
            break;
        }
      } catch (Exception exn) {
        if (exn is ArgumentNullException) { } else {
          this.tvshowid = TheTVDB.GetTVShowID(this.Path);
        }
      }
    }
Ejemplo n.º 4
0
    private static int Main(string[] args)
    {
        // Enabling Windows XP visual effects before any controls are created
        Application.EnableVisualStyles();
        Application.SetCompatibleTextRenderingDefault(false);

        // Sort out the command line arguments
        CommandLineArgs clargs = new CommandLineArgs(args);

        // see if we're already running
        bool createdNew = false;

        System.Threading.Mutex mutex = new System.Threading.Mutex(true, "TVRenameMutex", out createdNew);

        if (!createdNew)
        {
            // we're already running

            // tell the already running copy to come to the foreground
            IpcClientChannel clientChannel = new IpcClientChannel();
            ChannelServices.RegisterChannel(clientChannel, true);

            RemotingConfiguration.RegisterWellKnownClientType(typeof(IPCMethods), "ipc://TVRenameChannel/IPCMethods");

            IPCMethods ipc = new IPCMethods();

            // if we were already running, and no command line arguments, then bring application to the foreground
            // and we're done.
            if (args.Length == 0)
            {
                ipc.BringToForeground();
                return(0);
            }

            // Send command-line arguments to already running TVRename via IPC

            CommandLineArgs.MissingFolderBehaviour before = ipc.MissingBehaviour;
            bool renameBefore = ipc.RenameBehaviour;

            if (clargs.RenameCheck == false)
            {
                // Temporarily override behaviour for missing folders
                ipc.RenameBehaviour = false;
            }

            if (clargs.MissingFolder != CommandLineArgs.MissingFolderBehaviour.Ask)
            {
                // Temporarily override behaviour for missing folders
                ipc.MissingBehaviour = clargs.MissingFolder;
            }

            // TODO: Unify command line handling between here and in UI.cs (ProcessArgs).  Just send in clargs via IPC?

            if (clargs.Scan || clargs.DoAll) // doall implies scan
            {
                ipc.Scan();
            }

            if (clargs.DoAll)
            {
                ipc.DoAll();
            }

            if (clargs.Quit)
            {
                ipc.Quit();
                return(0);
            }

            ipc.RenameBehaviour  = renameBefore;
            ipc.MissingBehaviour = before;

            return(0);
        }

#if !DEBUG
        try
        {
#endif

        // Starting TVRename...

        // Check arguments for forced recover
        bool ok            = true;
        string recoverText = "";

        if (clargs.ForceRecover)
        {
            ok          = false; // force recover dialog
            recoverText = "Recover manually requested.";
        }

        // Load settings files
        TVDoc doc = null;
        try
        {
            if (!string.IsNullOrEmpty(clargs.UserFilePath))
            {
                PathManager.SetUserDefinedBasePath(clargs.UserFilePath);
            }
        }
        catch (System.Exception ex)
        {
            MessageBox.Show("Error while setting the User-Defined File Path:" + Environment.NewLine + ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            Environment.Exit(1);
        }

        FileInfo tvdbFile     = PathManager.TVDBFile;
        FileInfo settingsFile = PathManager.TVDocSettingsFile;

        do           // loop until no problems loading settings & tvdb cache files
        {
            if (!ok) // something went wrong last time around, ask the user what to do
            {
                RecoverXML rec = new RecoverXML(recoverText);
                if (rec.ShowDialog() == DialogResult.OK)
                {
                    tvdbFile     = rec.DBFile;
                    settingsFile = rec.SettingsFile;
                }
                else
                {
                    return(1);
                }
            }

            // try loading using current settings files, and set up the main
            // classes
            TheTVDB tvdb = new TheTVDB(tvdbFile, PathManager.TVDBFile, clargs);
            doc = new TVDoc(settingsFile, tvdb, clargs);

            if (!ok)
            {
                doc.SetDirty();
            }

            ok = doc.LoadOK;

            if (!ok)
            {
                recoverText = "";
                if (!doc.LoadOK && !String.IsNullOrEmpty(doc.LoadErr))
                {
                    recoverText += doc.LoadErr;
                }
                if (!tvdb.LoadOK && !String.IsNullOrEmpty(tvdb.LoadErr))
                {
                    recoverText += "\r\n" + tvdb.LoadErr;
                }
            }
        } while (!ok);

        // Show user interface
        UI theUI = new UI(doc);
        Application.Run(theUI);
        GC.KeepAlive(mutex);

#if !DEBUG
    }

    catch (Exception e)
    {
        ShowException se = new ShowException(e);
        se.ShowDialog();
    }
#endif

        return(0);
    }
Ejemplo n.º 5
0
        private void FetchTV()
        {
            try
            {
                if (tvshowid == null || tvshowid == -1)
                {
                    this.tvshowid = TheTVDB.GetTVShowID(this.Path);
                }
                var steszt = (System.IO.Directory.GetParent(base.Path).Name).TryGetName();
                if (steszt == null || (steszt is Formatting.NiceSeriesName && (steszt as Formatting.NiceSeriesName).Episode == 0))
                {
                    steszt = base.Title.TryGetName();
                }
                if (steszt == null)
                {
                    steszt = base.Item.Name.TryGetName();
                }
                TVShowInfo tvinfo = null;

                if (tvshowid != null && tvshowid > 0)
                {
                    tvinfo = TheTVDB.GetTVShowDetails(this.tvshowid.Value);
                    Server.UpdateTVCache(tvinfo);
                    this.seriesname = tvinfo.Name;
                    isSeries        = true;
                }

                if (steszt is Utilities.Formatting.NiceSeriesName)
                {
                    isSeries = true;
                    var steszt2 = steszt as Utilities.Formatting.NiceSeriesName;
                    if (String.IsNullOrEmpty(this.seriesname))
                    {
                        this.seriesname = steszt2.Name;
                    }

                    if (/*steszt2.Season > 0 &&*/ steszt2.Episode > 0)
                    {
                        if (tvinfo != null)
                        {
                            this.title = tvinfo.Find(steszt2.Season, steszt2.Episode);
                        }
                        else
                        {
                            this.title = String.Format("{0}x{1}", steszt2.Season, steszt2.Episode);
                        }
                        this.season  = steszt2.Season;
                        this.episode = steszt2.Episode;
                    }
                    else
                    {
                        this.title = base.Title;
                    }

                    if (!String.IsNullOrEmpty(steszt.Releaser))
                    {
                        this.title = String.Format("{0} ({1},{2})", this.title, steszt.Resolution, steszt.Releaser);
                    }
                }
                else if (steszt is Formatting.MovieName)
                {
                    var n = steszt as Formatting.MovieName;
                    this.seriesname = String.Format("{0} ({1})", n.Name, n.Year);
                }
                else
                {
                    this.seriesname = System.IO.Directory.GetParent(this.Path).Name;
                }
            }
            catch (Exception exn)
            {
                if (exn is System.ArgumentNullException)
                {
                }
                else
                {
                    this.tvshowid = TheTVDB.GetTVShowID(this.Path);
                }
            }
        }
Ejemplo n.º 6
0
        private void FetchTV2()
        {
            try
            {
                if (tvshowid == null || tvshowid == -1)
                {
                    this.tvshowid = TheTVDB.GetTVShowID(this.Path);
                }
                if (tvshowid != null && tvshowid > 0)
                {
                    var tvinfo = TheTVDB.GetTVShowDetails(this.tvshowid.Value);
                    Server.UpdateTVCache(tvinfo);
                    this.seriesname = tvinfo.Name;
                    isSeries        = true;

                    var steszt = base.Title.TryGetName();

                    if (steszt is Utilities.Formatting.NiceSeriesName)
                    {
                        var steszt2 = steszt as Utilities.Formatting.NiceSeriesName;
                        if (steszt2.Season > 0 && steszt2.Episode > 0)
                        {
                            var t = tvinfo.Find(steszt2.Season, steszt2.Episode);
                            this.title   = t;
                            this.season  = steszt2.Season;
                            this.episode = steszt2.Episode;
                        }
                        else
                        {
                            this.title = base.Title;
                        }
                    }
                    else
                    {
                        this.title = base.Title;
                    }
                }
            }
            catch (Exception exn)
            {
                if (exn is System.ArgumentNullException)
                {
                }
                else
                {
                    this.tvshowid = TheTVDB.GetTVShowID(this.Path);
                }
            }
            if (this.seriesname == null)
            {
                var trynice = base.Item.Name.TryGetName();

                if (trynice is Formatting.NiceSeriesName)
                {
                    isSeries = true;
                    var ttt = trynice as Formatting.NiceSeriesName;
                    var xx  = "-";
                    if (ttt.Episode > 0 && ttt.Season > 0)
                    {
                        xx = String.Format("{0}x{1}", ttt.Season, ttt.Episode);
                    }
                    else
                    {
                        if (ttt.Episode > 0)
                        {
                            xx = ttt.Episode.ToString();
                        }
                        else
                        {
                            xx = ttt.Season.ToString();
                        }
                    }
                    this.title      = xx;
                    this.seriesname = ttt.Name;
                }
                else if (trynice is Formatting.MovieName)
                {
                    var n = trynice as Formatting.MovieName;
                    isSeries        = false;
                    this.seriesname = String.Format("{0} ({1})", n.Name, n.Year);
                }
                else
                {
                    isSeries        = false;
                    this.seriesname = System.IO.Directory.GetParent(this.Path).Name;
                }
            }
        }