Example #1
0
        public static bool CanPerformSubtitleDownload(string strFile, int duration)
        {
            if (duration < ProTONEConfig.SubtitleMinimumMovieDuration * 60)
            {
                // Movie is too short
                Logger.LogTrace("This movie does not have a subtitle but is shorter than {0} minutes. Not starting download.", 20);
                return(false);
            }
            if (!ProTONEConfig.SubtitleDownloadEnabled)
            {
                // Subtitle download not enabled
                Logger.LogTrace("This movie does not have a subtitle but online subtitle download is disabled.");
                return(false);
            }
            if (!NetworkInterface.GetIsNetworkAvailable())
            {
                // Subtitle download not enabled
                Logger.LogTrace("This movie does not have a subtitle but there is no available network connection to use for download.");
                return(false);
            }
            if (SubtitleDownloadProcessor.IsFileOnDownloadList(strFile))
            {
                // Already on download list
                Logger.LogTrace("This movie has the subtitle already on download list.");
                return(false);
            }

            return(true);
        }
Example #2
0
        public static void TryFindSubtitle(string strFile, int duration, bool askToOverwrite)
        {
            try
            {
                if (SubtitleDownloadProcessor.TestForExistingSubtitle(strFile))
                {
                    if (!askToOverwrite || MessageDisplay.Query(Translator.Translate("TXT_OVERWRITE_SUBTITLE"),
                                                                Translator.Translate("TXT_CONFIRM_OVERWRITE_SUBTITLE"), MessageBoxIcon.Information) != DialogResult.Yes)
                    {
                        return;
                    }
                }

                if (SubtitleDownloadProcessor.CanPerformSubtitleDownload(strFile, duration))
                {
                    // We should display a subtitle but we don't have one.
                    // Try to grab one from internet.
                    ThreadPool.QueueUserWorkItem(
                        new WaitCallback(SubtitleDownloadProcessor.AttemptDownload), strFile);
                }
            }
            finally
            {
                // This is for enforcing playlist refresh
                EventDispatch.DispatchEvent(LocalEvents.UpdatePlaylistNames, false);
            }
        }