public List<SubtitleInfo> GetSubtitles(string fileName) { List<SubtitleInfo> retVal = new List<SubtitleInfo>(); NativeFileInfo nfi = new NativeFileInfo(fileName, true); if (nfi.IsValid) { string hashCode = FileHash.ToHexadecimal(FileHash.ComputeHash(fileName)); VideoInfo ovi = new VideoInfo(); ovi.imdbid = string.Empty; ovi.moviehash = hashCode; ovi.moviebytesize = nfi.Size.GetValueOrDefault(); ovi.sublanguageid = "all"; #region GetSubtitles Commented code - DEBUG PURPOSE ONLY // Name the movie "fringe 4x03.avi" //ovi.moviehash = "18379ac9af039390"; //ovi.moviebytesize = 366876694; #endregion List<SubtitleInfo> response = DoGetSubtitles(ovi); string[] fileNameParts = nfi.Name.ToLowerInvariant().Split(" -.][(){}".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); if (fileNameParts.Length > 0) { List<string> fileNamePartsList = new List<string>(fileNameParts); foreach (SubtitleInfo osf in response) { if (CheckMatch(osf.MovieName, fileNamePartsList)) { retVal.Add(osf); } else if (CheckMatch(osf.MovieNameEng, fileNamePartsList)) { retVal.Add(osf); } else if (CheckMatch(osf.MovieReleaseName, fileNamePartsList)) { retVal.Add(osf); } else if (CheckMatch(osf.SubFileName, fileNamePartsList)) { retVal.Add(osf); } } } } return retVal; }
private void tvImportPath_AfterSelect(object sender, TreeViewEventArgs e) { (BkgTask as Task).SourcePath = tvImportPath.SelectedNodePath; NativeFileInfo nfi = new NativeFileInfo((BkgTask as Task).SourcePath, false); Wizard.CanFinish = nfi.IsValid; if (Directory.Exists((BkgTask as Task).SourcePath)) { string label = string.Empty; string sernum = Kernel32.GetVolumeInformation(Path.GetPathRoot((BkgTask as Task).SourcePath), ref label); txtEntryDesc.Text = string.Format("{0}:{1}", label, sernum); } }
public override void ShowProperties(List<string> strItems, object additionalData) { List<object> lofi = new List<object>(); foreach (string item in strItems) { NativeFileInfo ofi = new NativeFileInfo(item, false); if (ofi.IsValid) { lofi.Add(ofi); } } FileAttributesBrowser.ProcessObjectAttributes(lofi); pgProperties.SelectedObjects = lofi.ToArray(); }
private void DisplaySourcePath() { tvImportPath.InitOPMShellTreeView(); if (!string.IsNullOrEmpty((BkgTask as Task).SourcePath)) { NativeFileInfo nfi = new NativeFileInfo((BkgTask as Task).SourcePath, false); if (nfi.IsValid) { tvImportPath.Select(); tvImportPath.Focus(); tvImportPath.DrillToFolder(nfi.Path); Wizard.CanFinish = true; } } txtEntryDesc.Text = (BkgTask as Task).EntryDescription; }
public List<SubtitleInfo> GetSubtitles(string fileName) { try { NativeFileInfo nfi = new NativeFileInfo(fileName, true); if (nfi.IsValid) { if (_session == null) { _session = SubtitleServerSession.Create(_serverType, _serverUrl, _userName, _password); } if (_session != null) { return _session.GetSubtitles(fileName); } } } catch (Exception ex) { Logger.LogException(ex); } return null; }
private void DisplayCatalogContents(object state) { Catalog cat = null; try { ShowWaitDialog("TXT_WAIT_LOADING_CATALOG"); string path = (BkgTask as Task).CatalogPath; NativeFileInfo nfi = new NativeFileInfo(path, false); if (nfi.IsValid) { cat = new Catalog(path); } else if (!string.IsNullOrEmpty(path)) { cat = new Catalog(); cat.Save(path); } } catch (Exception ex) { Logger.LogException(ex); } finally { if (cat != null && cat.IsValid) { DisplayCatalog(cat); } CloseWaitDialog(); } }