// retrieves info from Moving Pictures protected override bool GrabFileDetails() { try { browser = MovingPicturesCore.Browser; selectedMovie = browser.SelectedMovie; List<DBLocalMedia> localMedia = selectedMovie.LocalMedia; _mediaDetail = new BasicMediaDetail(); _mediaDetail.Title = selectedMovie.Title; _mediaDetail.Year = selectedMovie.Year; _mediaDetail.ImdbID = selectedMovie.ImdbID; _mediaDetail.Thumb = selectedMovie.CoverThumbFullPath; _mediaDetail.FanArt = selectedMovie.BackdropFullPath; _mediaDetail.Files = new List<FileInfo>(); foreach (DBLocalMedia localMediaItem in localMedia) { _mediaDetail.Files.Add(new FileInfo(localMediaItem.FullPath)); } return true; } catch (Exception e) { logger.ErrorException(string.Format("Unexpected error when pulling data from Moving Pictures{0}", Environment.NewLine), e); return false; } }
protected override bool GrabFileDetails() { try { selectedMovie = MyFilmsDetail.GetCurrentMovie(); _mediaDetail = new BasicMediaDetail(); _mediaDetail.Title = selectedMovie.Title; _mediaDetail.Year = selectedMovie.Year; _mediaDetail.ImdbID = selectedMovie.IMDBNumber; _mediaDetail.Thumb = selectedMovie.Picture; _mediaDetail.FanArt = selectedMovie.Fanart; _mediaDetail.Files = new List<FileInfo>(); string[] files = selectedMovie.File.Trim().Split(new Char[] { ';' }); foreach (string file in files) { _mediaDetail.Files.Add(new FileInfo(file)); } return true; } catch (Exception e) { logger.ErrorException(string.Format("Unexpected error when pulling data from MyFilms{0}", Environment.NewLine), e); return false; } }
public override void Clear() { _pluginName = Localization.ManualSearch; _ID = -2; _mediaDetail = new BasicMediaDetail(); _isModified = false; }
protected override bool GrabFileDetails() { try { GUIVideoTitle videoTitleWindow = GUIWindowManager.GetWindow(ID) as GUIVideoTitle; GUIListItem videoTitleSelectedItem = null; IMDBMovie videoTitleMovie = null; string videoTitleMovieThumb = string.Empty; if (videoTitleWindow != null) { videoTitleSelectedItem = videoTitleWindow.GetSelectedItem(); } if (videoTitleSelectedItem != null && !videoTitleSelectedItem.IsFolder) { videoTitleMovie = videoTitleSelectedItem.AlbumInfoTag as IMDBMovie; videoTitleMovieThumb = videoTitleSelectedItem.ThumbnailImage; } if (videoTitleMovie != null && videoTitleMovie.ID > 0) { _mediaDetail = new BasicMediaDetail(); _mediaDetail.Title = videoTitleMovie.Title; _mediaDetail.Year = videoTitleMovie.Year > 1900 ? videoTitleMovie.Year : 0; _mediaDetail.ImdbID = videoTitleMovie.IMDBNumber; _mediaDetail.Thumb = videoTitleMovieThumb; string fanart = string.Empty; MediaPortal.Util.FanArt.GetFanArtfilename(videoTitleMovie.Title, 0, out fanart); _mediaDetail.FanArt = fanart; ArrayList files = new ArrayList(); VideoDatabase.GetFilesForMovie(videoTitleMovie.ID, ref files); _mediaDetail.Files = new List<FileInfo>(); foreach (string file in files) { _mediaDetail.Files.Add(new FileInfo(file)); } if (_mediaDetail.Files.Count < 1) { _mediaDetail.Files.Add(new FileInfo(videoTitleMovie.File)); } return true; } return false; } catch (Exception e) { logger.ErrorException(string.Format("Unexpected error when pulling data from My Videos (Title){0}", Environment.NewLine), e); return false; } }
public override void Clear() { _pluginName = ""; _ID = -1; _mediaDetail = new BasicMediaDetail(); }
private List<SubtitleItem> QueryDownloaders(BasicMediaDetail mediaDetail, Dictionary<string, CustomSubtitleDownloader> downloaders, ref List<SubtitleItem> allResults) { SubtitleDownloader.Core.EpisodeSearchQuery episodeQuery = null; SubtitleDownloader.Core.SearchQuery movieQuery = null; SubtitleDownloader.Core.ImdbSearchQuery queryIMDB = null; logger.Info("Searching for subtitles..."); SubtitlesSearchType subtitlesSearchType = _searchType; //SubCentralUtils.getSubtitlesSearchTypeFromMediaDetail(mediaDetail); switch (subtitlesSearchType) { case SubtitlesSearchType.IMDb: logger.Debug("...using IMDb query: '{0}'", mediaDetail.ImdbID); queryIMDB = new SubtitleDownloader.Core.ImdbSearchQuery(mediaDetail.ImdbID); queryIMDB.LanguageCodes = _languageCodes.ToArray(); if (SubCentralUtils.canSearchMediaDetailWithType(mediaDetail, SubtitlesSearchType.MOVIE)) { logger.Debug(" ...additional movie query: '{0} ({1})'", mediaDetail.Title, mediaDetail.Year); movieQuery = new SubtitleDownloader.Core.SearchQuery(mediaDetail.Title); movieQuery.Year = mediaDetail.Year; movieQuery.LanguageCodes = _languageCodes.ToArray(); } break; case SubtitlesSearchType.TVSHOW: logger.Debug("...using TV show query: '{0} {1}x{2:00} TvdbId: {3}", mediaDetail.Title, mediaDetail.SeasonProper, mediaDetail.EpisodeProper, mediaDetail.TvdbId); episodeQuery = new SubtitleDownloader.Core.EpisodeSearchQuery(mediaDetail.Title, mediaDetail.SeasonProper, mediaDetail.EpisodeProper, mediaDetail.TvdbId); episodeQuery.LanguageCodes = _languageCodes.ToArray(); break; case SubtitlesSearchType.MOVIE: logger.Debug("...using movie query: '{0} ({1})'", mediaDetail.Title, mediaDetail.Year); movieQuery = new SubtitleDownloader.Core.SearchQuery(mediaDetail.Title); movieQuery.Year = mediaDetail.Year; movieQuery.LanguageCodes = _languageCodes.ToArray(); break; case SubtitlesSearchType.NONE: return allResults; } int providerCount = 1; foreach (KeyValuePair<string, CustomSubtitleDownloader> kvp in downloaders) { if (IsCanceled()) { //allResults.Clear(); break; } SubtitleDownloader.Core.ISubtitleDownloader subsDownloader = kvp.Value.downloader; string providerName = kvp.Value.downloaderTitle; subtitlesSearchType = _searchType; //reset search type //testing SearchTimeout subsDownloader.SearchTimeout = SettingsManager.Properties.GeneralSettings.SearchTimeout; List<SubtitleDownloader.Core.Subtitle> resultsFromDownloader = null; int percent = (100 / downloaders.Count) * providerCount; logger.Debug("Searching site {0}...", providerName); OnProgress(Localization.QueryingProviders + " (" + Convert.ToString(providerCount) + "/" + Convert.ToString(downloaders.Count) + "):", providerName, Localization.FoundSubtitles + ": " + Convert.ToString(allResults.Count), percent); try { switch (subtitlesSearchType) { case SubtitlesSearchType.IMDb: bool shouldThrowNotSupportedException = false; try { resultsFromDownloader = subsDownloader.SearchSubtitles(queryIMDB); if (resultsFromDownloader.Count == 0 && movieQuery != null) { List<SubtitleDownloader.Core.Subtitle> resultsFromDownloaderForMovieQuery = subsDownloader.SearchSubtitles(movieQuery); if (resultsFromDownloaderForMovieQuery.Count > 0) { // means that the site does not support imdb queries, should throw later logger.Error("Site {0} does not support IMDb ID search, got the results using regular movie search", providerName); resultsFromDownloader.AddRange(resultsFromDownloaderForMovieQuery); shouldThrowNotSupportedException = true; } } } catch (Exception e) { if (e is NotImplementedException || e is NotSupportedException) { if (movieQuery != null) { logger.Error("Site {0} does not support IMDb ID search, will try regular movie search", providerName); try { resultsFromDownloader = subsDownloader.SearchSubtitles(movieQuery); } catch (Exception e1) { // if the error happens now, we're probably searching some sites that support only tv shows? // so instead of returning not supported, we're gonna return no results // perhaps in the future, new exception type should be thrown to indicade that site does not support movie search // 19.06.2010, SE: it's the future! :) if (e1 is NotImplementedException || e1 is NotSupportedException) { subtitlesSearchType = SubtitlesSearchType.MOVIE; throw new NotSupportedException(string.Format("Site {0} does not support movie search!", providerName)); } else { throw e1; } } } else { //logger.Error("Site {0} does not support IMDb ID search", providerName); throw new NotSupportedException(string.Format("Site {0} does not support IMDb ID search!", providerName)); } } else { // throw it! throw e; } } if (shouldThrowNotSupportedException) { // meh, do not throw, since we already have results and it's logged //throw new NotSupportedException("Site {0} does not support IMDb ID search"); } break; case SubtitlesSearchType.TVSHOW: try { resultsFromDownloader = subsDownloader.SearchSubtitles(episodeQuery); } catch (Exception e) { if (e is NotImplementedException || e is NotSupportedException) { throw new NotSupportedException(string.Format("Site {0} does not support TV Show search!", providerName)); } else { throw e; } } break; case SubtitlesSearchType.MOVIE: try { resultsFromDownloader = subsDownloader.SearchSubtitles(movieQuery); } catch (Exception e) { if (e is NotImplementedException || e is NotSupportedException) { throw new NotSupportedException(string.Format("Site {0} does not support movie search!", providerName)); } else { throw e; } } break; } } catch (ThreadAbortException e) { throw e; } catch (Exception e) { if (e.InnerException != null && e.InnerException is ThreadAbortException) { throw e.InnerException; } if (e is NotSupportedException) { logger.Error(e.Message); } else { logger.ErrorException(string.Format("Error while querying site {0}{1}", providerName, Environment.NewLine), e); } if (OnProviderSearchErrorEvent != null) { if (GUIGraphicsContext.form.InvokeRequired) { OnProviderSearchErrorDelegate d = OnProviderSearchErrorEvent; GUIGraphicsContext.form.Invoke(d, mediaDetail, subtitlesSearchType, e); } else { OnProviderSearchErrorEvent(mediaDetail, subtitlesSearchType, e); } } } if (resultsFromDownloader != null && resultsFromDownloader.Count > 0) { foreach (SubtitleDownloader.Core.Subtitle subtitle in resultsFromDownloader) { if (!subtitle.FileName.IsNullOrWhiteSpace() && !string.IsNullOrEmpty(subtitle.LanguageCode)) { SubtitleItem subItem = new SubtitleItem(); subItem.Downloader = subsDownloader; subItem.Subtitle = subtitle; subItem.ProviderTitle = kvp.Key; subItem.LanguageName = subtitle.LanguageCode; if (!string.IsNullOrEmpty(SubCentralUtils.SubsLanguages[subtitle.LanguageCode])) subItem.LanguageName = SubCentralUtils.SubsLanguages[subtitle.LanguageCode]; allResults.Add(subItem); } } } providerCount++; } return allResults; }
public TagRank(BasicMediaDetail mediaDetail) { MediaDetail = mediaDetail; }
public static bool canSearchMediaDetailWithType(BasicMediaDetail basicMediaDetail, SubtitlesSearchType subtitlesSearchType) { bool useImdbMovieQuery = !(string.IsNullOrEmpty((basicMediaDetail.ImdbID))); bool useTitle = !(string.IsNullOrEmpty((basicMediaDetail.Title))); bool useMovieQuery = useTitle && !(string.IsNullOrEmpty((basicMediaDetail.YearStr))); bool useEpisodeQuery = useTitle && ( (basicMediaDetail.AbsoluteNumbering && string.IsNullOrEmpty(basicMediaDetail.SeasonStr) && !string.IsNullOrEmpty(basicMediaDetail.EpisodeStr)) || (!basicMediaDetail.AbsoluteNumbering && !string.IsNullOrEmpty(basicMediaDetail.SeasonStr) && !string.IsNullOrEmpty(basicMediaDetail.EpisodeStr)) ); switch (subtitlesSearchType) { case SubtitlesSearchType.IMDb: return useImdbMovieQuery; case SubtitlesSearchType.TVSHOW: return useEpisodeQuery; case SubtitlesSearchType.MOVIE: return useMovieQuery; default: return false; } }
public void SearchForSubtitles(BasicMediaDetail mediaDetail) { if (IsCanceled()) Kill(); if (_subtitlesDownloaderThread != null && _subtitlesDownloaderThread.IsAlive) return; _isCanceled = false; _status = ThreadStatus.StatusEnded; _subtitlesDownloaderThread = new Thread(SearchSubtitlesAsync); _subtitlesDownloaderThread.IsBackground = true; _subtitlesDownloaderThread.Name = "Subtitles Downloader Thread"; _subtitlesDownloaderThread.Start(mediaDetail); }
public void DownloadSubtitle(SubtitleItem subtitleItem, BasicMediaDetail mediaDetail, FolderSelectionItem folderSelectionItem, SubtitlesSearchType searchType, bool skipDefaults) { if (IsCanceled()) Kill(); if (_subtitlesDownloaderThread != null && _subtitlesDownloaderThread.IsAlive) return; _isCanceled = false; _status = ThreadStatus.StatusEnded; DownloadData downloadData = new DownloadData { SubtitleItem = subtitleItem, MediaDetail = mediaDetail, FolderSelectionItem = folderSelectionItem, SearchType = searchType, SkipDefaults = skipDefaults, StatusList = new List<SubtitleDownloadStatus>() }; _subtitlesDownloaderThread = new Thread(DownloadSubtitleAsync); _subtitlesDownloaderThread.IsBackground = true; _subtitlesDownloaderThread.Name = "Subtitles Downloader Thread"; _subtitlesDownloaderThread.Start(downloadData); }
private SubtitlesSearchType getRealCurrentSearchSearchType(BasicMediaDetail mediaDetail) { SubtitlesSearchType searchType = SubCentralUtils.getSubtitlesSearchTypeFromMediaDetail(mediaDetail); if (ModifySearchSearchType != SubtitlesSearchType.NONE) { if (ModifySearchSearchType == SubtitlesSearchType.TVSHOW && SubCentralUtils.canSearchMediaDetailWithType(mediaDetail, ModifySearchSearchType)) searchType = SubtitlesSearchType.TVSHOW; else if (ModifySearchSearchType == SubtitlesSearchType.MOVIE && SubCentralUtils.canSearchMediaDetailWithType(mediaDetail, SubtitlesSearchType.IMDb)) searchType = SubtitlesSearchType.IMDb; else if (ModifySearchSearchType == SubtitlesSearchType.MOVIE && SubCentralUtils.canSearchMediaDetailWithType(mediaDetail, SubtitlesSearchType.MOVIE)) searchType = SubtitlesSearchType.MOVIE; else searchType = SubtitlesSearchType.NONE; } return searchType; }
private BasicMediaDetail CopyMediaDetail(BasicMediaDetail mediaDetail) { List<FileInfo> fileList = new List<FileInfo>(); if (mediaDetail.Files != null && mediaDetail.Files.Count > 0) { foreach (FileInfo fileInfo in CurrentHandler.MediaDetail.Files) { try { FileInfo fi = new FileInfo(fileInfo.FullName); fileList.Add(fi); } catch { } } } BasicMediaDetail newMediaDetail = new BasicMediaDetail(); newMediaDetail.ImdbID = CurrentHandler.MediaDetail.ImdbID; newMediaDetail.Title = CurrentHandler.MediaDetail.Title; newMediaDetail.Year = CurrentHandler.MediaDetail.Year; newMediaDetail.AbsoluteNumbering = CurrentHandler.MediaDetail.AbsoluteNumbering; newMediaDetail.Season = CurrentHandler.MediaDetail.Season; newMediaDetail.Episode = CurrentHandler.MediaDetail.Episode; newMediaDetail.EpisodeAbs = CurrentHandler.MediaDetail.EpisodeAbs; newMediaDetail.Thumb = CurrentHandler.MediaDetail.Thumb; newMediaDetail.FanArt = CurrentHandler.MediaDetail.FanArt; newMediaDetail.Files = fileList; return newMediaDetail; }
void retriever_OnSubtitleDownloadedToTempEvent(BasicMediaDetail mediaDetail, List<FileInfo> subtitleFiles) { //HideWaitCursor(); }
private void retriever_OnSubtitleDownloadedEvent(BasicMediaDetail mediaDetail, List<SubtitleDownloadStatus> statusList) { //HideWaitCursor(); string heading = string.Empty; switch (getRealCurrentSearchSearchType(mediaDetail)) { case SubtitlesSearchType.TVSHOW: heading = string.Format("{0} S{1}E{2}", mediaDetail.Title, mediaDetail.SeasonStr, mediaDetail.EpisodeStr); break; case SubtitlesSearchType.MOVIE: heading = string.Format("{0} ({1})", mediaDetail.Title, mediaDetail.YearStr); break; case SubtitlesSearchType.IMDb: heading = string.IsNullOrEmpty(mediaDetail.Title) ? mediaDetail.ImdbIDStr : string.Format("{0} ({1})", mediaDetail.Title, mediaDetail.ImdbIDStr); break; } if (statusList == null || statusList.Count < 1) { if (statusList != null) { GUIUtils.ShowNotifyDialog(heading, string.Format(Localization.NoSubtitlesDownloaded, Localization.NoSubtitlesInChosen), GUIUtils.NoSubtitlesLogoThumbPath); } return; } int mediaCount = statusList.Count; int succesful, canceled, errors; countDownloads(statusList, out succesful, out canceled, out errors); if (succesful == mediaCount) { // all succesful if (succesful == 1) GUIUtils.ShowNotifyDialog(heading, Localization.SubtitlesDownloaded, GUIUtils.SubtitlesLogoThumbPath); else GUIUtils.ShowNotifyDialog(heading, string.Format(Localization.AllSubtitlesDownloaded, succesful), GUIUtils.SubtitlesLogoThumbPath); } else if (errors == mediaCount) { // all errors GUIUtils.ShowNotifyDialog(heading, Localization.ErrorWhileDownloadingSubtitles, GUIUtils.NoSubtitlesLogoThumbPath); return; } else if (canceled == mediaCount) { // all canceled /* if (canceled == 1) GUIUtils.ShowNotifyDialog(heading, Localization.CanceledDownload, GUIUtils.NoSubtitlesLogoThumbPath); else GUIUtils.ShowNotifyDialog(heading, string.Format(Localization.AllSubtitlesCanceledDownload, canceled), GUIUtils.NoSubtitlesLogoThumbPath); */ return; } else { // some are ok, some not List<string> notifyList = new List<string>(); if (succesful > 0) notifyList.Add(string.Format(Localization.SubtitlesDownloadedCount, succesful)); if (errors > 0) notifyList.Add(string.Format(Localization.SubtitlesDownloadErrorCount, errors)); if (canceled > 0) notifyList.Add(string.Format(Localization.SubtitlesDownloadCanceledCount, canceled)); string notifyListString = string.Empty; foreach (string notify in notifyList) { notifyListString = notifyListString + (string.IsNullOrEmpty(notifyListString) ? notify : "\n" + notify); } if (!string.IsNullOrEmpty(notifyListString)) GUIUtils.ShowNotifyDialog(heading, notifyListString); } // checking if (statusList.Count == 0) return; if (mediaDetail.Files == null || mediaDetail.Files.Count == 0) return; PluginHandler properHandler = _backupHandler != null ? _backupHandler : CurrentHandler; if (properHandler == null) return; foreach (SubtitleDownloadStatus sds in statusList) { if (sds.Index >= 0 && mediaDetail.Files.Count > sds.Index && (sds.Status == SubtitleDownloadStatusStatus.Succesful || sds.Status == SubtitleDownloadStatusStatus.AlreadyExists) ) { properHandler.SetHasSubtitles(mediaDetail.Files[sds.Index].FullName, true); _checkMediaForSubtitlesOnOpenDone = false; } } if (SettingsManager.Properties.GeneralSettings.AfterDownload == OnAfterDownload.BackToOriginalPlugin && properHandler.GetHasSubtitles(true)) { GUIWindowManager.ShowPreviousWindow(); } }
void retriever_OnProviderSearchErrorEvent(BasicMediaDetail mediaDetail, SubtitlesSearchType subtitlesSearchType, Exception e) { retriever.OnProviderSearchErrorEvent -= retriever_OnProviderSearchErrorEvent; //HideWaitCursor(); if (e is NotImplementedException || e is NotSupportedException) { switch (subtitlesSearchType) { case SubtitlesSearchType.IMDb: GUIUtils.ShowNotifyDialog(Localization.Error, Localization.SiteDoesNotSupportIMDbIDSearch, GUIUtils.NoSubtitlesLogoThumbPath); break; case SubtitlesSearchType.MOVIE: GUIUtils.ShowNotifyDialog(Localization.Error, Localization.SiteDoesNotSupportMovieSearch, GUIUtils.NoSubtitlesLogoThumbPath); break; case SubtitlesSearchType.TVSHOW: GUIUtils.ShowNotifyDialog(Localization.Error, Localization.SiteDoesNotSupportTVShowSearch, GUIUtils.NoSubtitlesLogoThumbPath); break; default: GUIUtils.ShowNotifyDialog(Localization.Error, string.Format(Localization.ErrorWhileRetrievingSubtitlesWithReason, e.Message), GUIUtils.NoSubtitlesLogoThumbPath, 10); //GUIUtils.ShowNotifyDialog(Localization.Error, Localization.ErrorWhileRetrievingSubtitles, GUIUtils.NoSubtitlesLogoThumbPath); break; } } else if (e is System.Net.WebException && ((System.Net.WebException)e).Status == System.Net.WebExceptionStatus.Timeout) { GUIUtils.ShowNotifyDialog(Localization.Error, Localization.TimedOutWhileRetrievingSubtitles, GUIUtils.NoSubtitlesLogoThumbPath); } else { GUIUtils.ShowNotifyDialog(Localization.Error, string.Format(Localization.ErrorWhileRetrievingSubtitlesWithReason, e.Message), GUIUtils.NoSubtitlesLogoThumbPath, 10); //GUIUtils.ShowNotifyDialog(Localization.Error, Localization.ErrorWhileRetrievingSubtitles, GUIUtils.NoSubtitlesLogoThumbPath); } _notificationDone = true; }
protected override bool GrabFileDetails() { try { episode = WindowPlugins.GUITVSeries.TVSeriesPlugin.m_SelectedEpisode; if (episode == null) return false; series = Helper.getCorrespondingSeries(episode[DBEpisode.cSeriesID]); if (series == null) return false; string seriesTitle = series[DBOnlineSeries.cOriginalName]; string seasonIdx = episode[DBEpisode.cSeasonIndex]; string episodeIdx = episode[DBEpisode.cEpisodeIndex]; string episodeIdxAbs = episode[DBOnlineEpisode.cAbsoluteNumber]; bool absolute = false; if (series[DBOnlineSeries.cChosenEpisodeOrder] == "Absolute" && !string.IsNullOrEmpty(episodeIdxAbs)) { absolute = true; } int seasonIdxInt = -1; int.TryParse(seasonIdx, out seasonIdxInt); int episodeIdxInt = -1; int.TryParse(episodeIdx, out episodeIdxInt); int episodeIdxAbsInt = -1; int.TryParse(episodeIdxAbs, out episodeIdxAbsInt); string thumb = ImageAllocator.GetSeriesPosterAsFilename(series); string fanart = Fanart.getFanart(episode[DBEpisode.cSeriesID]).FanartFilename; string episodeFileName = episode[DBEpisode.cFilename]; _mediaDetail = new BasicMediaDetail(); _mediaDetail.Title = seriesTitle; _mediaDetail.AbsoluteNumbering = absolute; _mediaDetail.Season = seasonIdxInt; _mediaDetail.Episode = episodeIdxInt; _mediaDetail.EpisodeAbs = episodeIdxAbsInt; _mediaDetail.Thumb = thumb; _mediaDetail.FanArt = fanart; _mediaDetail.Files = new List<FileInfo>(); if (!string.IsNullOrEmpty(episodeFileName)) _mediaDetail.Files.Add(new FileInfo(episodeFileName)); _mediaDetail.TvdbId = series[DBSeries.cID]; return true; } catch (Exception e) { logger.ErrorException(string.Format("Unexpected error when pulling data from TVSeries{0}", Environment.NewLine), e); return false; } }
private void OnSubtitlesDownloaded(BasicMediaDetail mediaDetail, List<SubtitleDownloadStatus> statusList) { _status = ThreadStatus.StatusStartedWithoutWaitCursor; if (OnSubtitleDownloadedEvent != null) { if (GUIGraphicsContext.form.InvokeRequired) { OnSubtitleDownloadedDelegate d = OnSubtitleDownloadedEvent; GUIGraphicsContext.form.Invoke(d, mediaDetail, statusList); } else { OnSubtitleDownloadedEvent(mediaDetail, statusList); } } }
private void OnSubtitlesDownloadedToTemp(BasicMediaDetail mediaDetail, List<FileInfo> subtitleFiles) { if (OnSubtitleDownloadedToTempEvent != null) { if (GUIGraphicsContext.form.InvokeRequired) { OnSubtitleDownloadedToTempDelegate d = OnSubtitleDownloadedToTempEvent; GUIGraphicsContext.form.Invoke(d, mediaDetail, subtitleFiles); } else { OnSubtitleDownloadedToTempEvent(mediaDetail, subtitleFiles); } } }
public static SubtitlesSearchType getSubtitlesSearchTypeFromMediaDetail(BasicMediaDetail basicMediaDetail) { SubtitlesSearchType result = SubtitlesSearchType.NONE; bool useImdbMovieQuery = !(string.IsNullOrEmpty((basicMediaDetail.ImdbID))); bool useTitle = !(string.IsNullOrEmpty((basicMediaDetail.Title))); bool useMovieQuery = useTitle && !(string.IsNullOrEmpty((basicMediaDetail.YearStr))); bool useEpisodeQuery = useTitle && ( (basicMediaDetail.AbsoluteNumbering && string.IsNullOrEmpty(basicMediaDetail.SeasonStr) && !string.IsNullOrEmpty(basicMediaDetail.EpisodeStr)) || (!basicMediaDetail.AbsoluteNumbering && !string.IsNullOrEmpty(basicMediaDetail.SeasonStr) && !string.IsNullOrEmpty(basicMediaDetail.EpisodeStr)) ); if (useEpisodeQuery) { result = SubtitlesSearchType.TVSHOW; } if (useImdbMovieQuery) { result = SubtitlesSearchType.IMDb; } else if (useMovieQuery) { result = SubtitlesSearchType.MOVIE; } return result; }
private static void AddTemporaryCustomPluginHandler(int ID, List<string> pluginData) { TemporaryCustomPluginHandler customTemporaryPluginHandler = SubCentralCore.Instance.PluginHandlers[PluginHandlerType.CUSTOM] as TemporaryCustomPluginHandler; logger.Debug("Adding temporary handler for plugin ID {0} from sent data", ID); // we have to get our custom provider and data from the provider should be 9 or more // plugin_name, imdb, title, year, season, episode, thumb, fanart, filename1, filename2, ... if (customTemporaryPluginHandler != null && pluginData.Count >= 9) { string pluginName = pluginData[0].Trim(); int pluginID = ID; string imdbID = pluginData[1].Trim(); string title = pluginData[2].Trim(); int year = -1; int.TryParse(pluginData[3].Trim(), out year); int season = -1; int.TryParse(pluginData[4].Trim(), out season); int episode = -1; int.TryParse(pluginData[5].Trim(), out episode); string thumb = pluginData[6].Trim(); string fanart = pluginData[7].Trim(); List<FileInfo> fileList = new List<FileInfo>(); for (int i = 8; i < pluginData.Count; i++) { if (!string.IsNullOrEmpty(pluginData[i].Trim())) { try { FileInfo fi = new FileInfo(pluginData[i].Trim()); fileList.Add(fi); } catch { } } } List<string> validBoolValues = new List<string> { "1", "yes", "true" }; string absoluteS = pluginData[9].Trim(); bool absolute = validBoolValues.Contains(absoluteS.ToLowerInvariant()); if (string.IsNullOrEmpty(pluginName) || fileList.Count == 0) return; BasicMediaDetail mediaDetail = new BasicMediaDetail(); mediaDetail.ImdbID = imdbID; mediaDetail.Title = title; if (SubCentralUtils.isYearCorrect(year.ToString())) mediaDetail.Year = year; mediaDetail.AbsoluteNumbering = absolute; mediaDetail.Season = 0; if (SubCentralUtils.isSeasonOrEpisodeCorrect(season.ToString(), false)) mediaDetail.Season = season; mediaDetail.Episode = 0; mediaDetail.EpisodeAbs = 0; if (absolute && SubCentralUtils.isSeasonOrEpisodeCorrect(episode.ToString(), absolute)) mediaDetail.EpisodeAbs = episode; else if (!absolute && SubCentralUtils.isSeasonOrEpisodeCorrect(episode.ToString(), absolute)) mediaDetail.Episode = episode; mediaDetail.Thumb = thumb; mediaDetail.FanArt = fanart; mediaDetail.Files = fileList; if (SubCentralUtils.getSubtitlesSearchTypeFromMediaDetail(mediaDetail) == SubtitlesSearchType.NONE) return; // all ok! customTemporaryPluginHandler.ID = pluginID; customTemporaryPluginHandler.PluginName = pluginName; customTemporaryPluginHandler.MediaDetail = mediaDetail; } }