protected override bool ProcessVisualSection(string relLink, MovieInfo movieInfo, string id) { return(false); }
public MoviesheetsUpdateManagerParams(string bg, string f1, string f2, string f3, MovieInfo movieinfo, string cover, string preview) { BackgroundPath = bg; Fanart1Path = f1; Fanart2Path = f2; Fanart3Path = f3; nfo = movieinfo; CoverPath = cover; PreviewPath = preview; }
public void ThreadPoolCallback() { try { try { Loggy.Logger.Debug(string.Format("Entering Thread {0}", Thread.CurrentThread.ManagedThreadId)); Loggy.Logger.Factory.Flush(); try { MovieItem _movieItem = FileManager.GetMovieByFilePath(this.MoviePath); FileManager.SetMovieItemStatus(_movieItem, MovieItemStatus.Querying); } catch { } MoviesheetsUpdateManager _man = new MoviesheetsUpdateManager(this.MetadataFile, this.MoviePath); MoviesheetInfo _metadataInfo = _man.GetMetadataInfo(); string _ext = _metadataInfo != null && !string.IsNullOrEmpty(_metadataInfo.CoverExtension) ? _metadataInfo.CoverExtension : ".jpg"; string _tmpCoverPath = Helpers.GetUniqueFilename(_ext); _ext = _metadataInfo != null && !string.IsNullOrEmpty(_metadataInfo.BackgroundExtension) ? _metadataInfo.BackgroundExtension : ".jpg"; string _tmpBackgroundPath = Helpers.GetUniqueFilename(_ext); _ext = _metadataInfo != null && !string.IsNullOrEmpty(_metadataInfo.Fanart1Extension) ? _metadataInfo.Fanart1Extension : ".jpg"; string _tmpFanart1Path = Helpers.GetUniqueFilename(_ext); _ext = _metadataInfo != null && !string.IsNullOrEmpty(_metadataInfo.Fanart2Extension) ? _metadataInfo.Fanart2Extension : ".jpg"; string _tmpFanart2Path = Helpers.GetUniqueFilename(_ext); _ext = _metadataInfo != null && !string.IsNullOrEmpty(_metadataInfo.Fanart3Extension) ? _metadataInfo.Fanart3Extension : ".jpg"; string _tmpFanart3Path = Helpers.GetUniqueFilename(_ext); MovieInfo _movieinfo = _man.GetMovieInfo(); MediaInfoData _mediainfo = _movieinfo != null ? _movieinfo.MediaInfo : null; Action ExtractImagesIfNeeded = new Action(delegate { if (!File.Exists(_tmpCoverPath)) { _man.GetImage(MoviesheetsUpdateManager.COVER_STREAM_NAME, _tmpCoverPath); } if (!File.Exists(_tmpBackgroundPath)) { _man.GetImage(MoviesheetsUpdateManager.BACKGROUND_STREAM_NAME, _tmpBackgroundPath); } if (!File.Exists(_tmpFanart1Path)) { _man.GetImage(MoviesheetsUpdateManager.FANART1_STREAM_NAME, _tmpFanart1Path); } if (!File.Exists(_tmpFanart2Path)) { _man.GetImage(MoviesheetsUpdateManager.FANART2_STREAM_NAME, _tmpFanart2Path); } if (!File.Exists(_tmpFanart3Path)) { _man.GetImage(MoviesheetsUpdateManager.FANART3_STREAM_NAME, _tmpFanart3Path); } }); try { foreach (UpdateItem _item in Items) { // if cancellation was approved, jump out if (CancelProcessing.WaitOne(20)) { return; } switch (_item.ItemType) { case UpdateItemType.Moviesheet: case UpdateItemType.Extrasheet: case UpdateItemType.ParentFoldersheet: if (_item.Template != null) { SheetType _sheetType = _item.ItemType == UpdateItemType.Extrasheet ? SheetType.Extra : _item.ItemType == UpdateItemType.ParentFoldersheet ? SheetType.Spare : SheetType.Main; MovieSheetsGenerator _Generator = new MovieSheetsGenerator(_sheetType, this.MoviePath); _Generator.SelectedTemplate = _item.Template; // call the Action responsible to extract images if missing ExtractImagesIfNeeded.Invoke(); // try to get latest IMDB rating for the movie if (_movieinfo != null && FileManager.Configuration.Options.UpdateIMDbRating) { try { string _newRating = new IMDBMovieInfo().GetIMDbRating(_movieinfo.IMDBID); if (!string.IsNullOrEmpty(_newRating)) { _movieinfo.Rating = _newRating; try { // update back the metadata (as the rating is needed for playlists) using (MemoryStream _ms = new MemoryStream()) { _movieinfo.Save(_ms, this.MoviePath, true); _man.AddPart(NFO_STREAM_NAME, _ms); } } catch (Exception ex) { Loggy.Logger.DebugException("Updating Rating into .tgmd.", ex); } } } catch { } } // set items _Generator.MovieInfo = _movieinfo; _Generator.MediaInfo = _mediainfo; _Generator.UpdateCover(_tmpCoverPath); _Generator.UpdateBackdrop(MoviesheetImageType.Background, _tmpBackgroundPath); _Generator.UpdateBackdrop(MoviesheetImageType.Fanart1, _tmpFanart1Path); _Generator.UpdateBackdrop(MoviesheetImageType.Fanart2, _tmpFanart2Path); _Generator.UpdateBackdrop(MoviesheetImageType.Fanart3, _tmpFanart3Path); _Generator.RenderAndReplicateMoviesheet(_item.TargetPath, true); _Generator.Dispose(); _Generator.MovieInfo = null; _Generator.MediaInfo = null; _Generator.SelectedTemplate = null; _Generator = null; } break; case UpdateItemType.Thumbnail: if (!File.Exists(_tmpCoverPath)) { _man.GetImage(MoviesheetsUpdateManager.COVER_STREAM_NAME, _tmpCoverPath); } Helpers.CreateThumbnailImage(_tmpCoverPath, _item.TargetPath, FileManager.Configuration.Options.KeepAspectRatio); break; case UpdateItemType.ExtraThumbnail: if (!File.Exists(_tmpCoverPath)) { _man.GetImage(MoviesheetsUpdateManager.COVER_STREAM_NAME, _tmpCoverPath); } Helpers.CreateExtraThumbnailImage(_tmpCoverPath, _item.TargetPath); break; case UpdateItemType.Nfo: if (_movieinfo != null) { nfoHelper.GenerateNfoFile(_item.MoviePath, _movieinfo, _movieinfo.MediaInfo != null ? _movieinfo.MediaInfo : null); } break; case UpdateItemType.ImagesExport: Executor _executor = new Executor(_item.MoviePath); // make sure the images are extracted to their temp locations (as maybe no sheet needs to be generated, only export is wanted ExtractImagesIfNeeded.Invoke(); // export images (that are required) _executor.ExportCover(_tmpCoverPath); _executor.ExportBackdrop(_tmpBackgroundPath, MoviesheetImageType.Background); _executor.ExportBackdrop(_tmpFanart1Path, MoviesheetImageType.Fanart1); _executor.ExportBackdrop(_tmpFanart2Path, MoviesheetImageType.Fanart2); _executor.ExportBackdrop(_tmpFanart3Path, MoviesheetImageType.Fanart3); break; } } // foreach try { MovieItem _movieItem = FileManager.GetMovieByFilePath(this.MoviePath); _movieItem.MovieItemStatus = MovieItemStatus.Done; } catch (Exception ex) { Loggy.Logger.DebugException("Set movieitem status:", ex); } _man = null; } finally { Helpers.RemoveFile(_tmpCoverPath); Helpers.RemoveFile(_tmpBackgroundPath); Helpers.RemoveFile(_tmpFanart1Path); Helpers.RemoveFile(_tmpFanart2Path); Helpers.RemoveFile(_tmpFanart3Path); } } catch (Exception ex) { try { MovieItem _movieItem = FileManager.GetMovieByFilePath(this.MoviePath); FileManager.SetMovieItemStatus(_movieItem, MovieItemStatus.Exception); Loggy.Logger.DebugException(string.Format("Processing file {0}", this.MoviePath), ex); } catch { } } } finally { if (this.DoneEvent != null) { this.DoneEvent.Set(); } } }
public IMDBMovieInfoCacheItem(string countryCode, MovieInfo info) { MovieInfo = info; CountryCode = countryCode; }
private void SetCurrentEpisodeRelatedInfo(int _id, MovieInfo info) { if (info != null) { string _episode = m_EpisodeData.Episode; if (!string.IsNullOrEmpty(_episode)) { XmlDocument _doc = new XmlDocument(); if (CurrentSeriesHelper.GetEpisodesData.ContainsKey(_id)) { try { _doc.LoadXml(CurrentSeriesHelper.GetEpisodesData[_id]); } catch { } } // get EpisodesList //string _order = null; string _clause = null; string _episodeField = null; string _seasonField = null; string _query = null; switch (m_EpisodeData.Type) { default: case EpisodeType.AiredOrder: //_order = "default"; _clause = string.Format("[SeasonNumber='{0}']", m_EpisodeData.Season); _episodeField = "EpisodeNumber"; _seasonField = "SeasonNumber"; _query = string.Format("//Episode[SeasonNumber='{0}' and EpisodeNumber='{1}']", m_EpisodeData.Season, m_EpisodeData.Episode); break; case EpisodeType.DVDOrder: //_order = "dvd"; _clause = string.Format("[DVD_season='{0}']", m_EpisodeData.Season); _episodeField = "DVD_episodenumber"; _seasonField = "DVD_season"; _query = string.Format("//Episode[(DVD_season='{0}' or DVD_season='{0}.0') and (DVD_episodenumber='{1}' or DVD_episodenumber='{1}.0')]", m_EpisodeData.Season, m_EpisodeData.Episode); break; case EpisodeType.Absolute: //_order = "absolute"; _clause = string.Empty; _episodeField = "absolute_number"; _seasonField = string.Empty; _query = string.Format("//Episode[absolute_number='{0}']", m_EpisodeData.Episode); break; } XmlNodeList _episodes = _doc.SelectNodes(string.Format("//Episode{0}", _clause)); if (_episodes != null && _episodes.Count != 0) { SortedDictionary <int, string> _dict = new SortedDictionary <int, string>(); foreach (XmlNode _ep in _episodes) { string _number = TrimValue(Helpers.GetValueFromXmlNode(_ep, _episodeField)); string _name = HttpUtility.HtmlDecode(Helpers.GetValueFromXmlNode(_ep, "EpisodeName")); _name = string.IsNullOrEmpty(_name) ? "" : _name; int _nr = 0; if (Int32.TryParse(_number, out _nr) && !_dict.ContainsKey(_nr)) { _dict.Add(_nr, _name); } else // no episode number, add it at the beginning { info.Episodes.Add(string.IsNullOrEmpty(_number) ? "" : _number); info.EpisodesNames.Add(_name); } } foreach (KeyValuePair <int, string> _pair in _dict) { info.Episodes.Add(_pair.Key.ToString()); info.EpisodesNames.Add(_pair.Value); } } // string _episodeUrl = string.Format("{0}{1}/{2}/{3}/{4}/{5}.xml", BaseUrl, _id, _order, m_EpisodeData.Season, _episode, FileManager.Configuration.Options.MovieSheetsOptions.TVShowsLanguage); // MemoryStream _stream = SendRequest(_episodeUrl); // if (_stream == null || _stream.Length == 0) // { // _episodeUrl = string.Format("{0}{1}/{2}/{3}/{4}/", BaseUrl, _id, _order, m_EpisodeData.Season, _episode); // _stream = SendRequest(_episodeUrl); // } // if (_stream != null && _stream.Length > 0) // { // _stream.Position = 0; // try // { // _doc.Load(_stream); // } // catch { } // } XmlElement _episodeNode = _doc.SelectSingleNode(_query) as XmlElement; if (_episodeNode != null) { info.Season = string.IsNullOrEmpty(_seasonField) ? string.Empty : Helpers.GetValueFromXmlNode(_episodeNode, _seasonField); info.Episode = TrimValue(Helpers.GetValueFromXmlNode(_episodeNode, _episodeField)); info.EpisodeName = HttpUtility.HtmlDecode(Helpers.GetValueFromXmlNode(_episodeNode, "EpisodeName")); info.EpisodePlot = HttpUtility.HtmlDecode(Helpers.GetValueFromXmlNode(_episodeNode, "Overview")); info.SetEpisodeReleaseDate(this.GetFormattedDate(Helpers.GetValueFromXmlNode(_episodeNode, "FirstAired"))); info.Rating = Helpers.GetValueFromXmlNode(_episodeNode, "Rating"); string _director = Helpers.GetValueFromXmlNode(_episodeNode, "Director"); if (!string.IsNullOrEmpty(_director)) { info.Director = _director.Split('|', ',').ToTrimmedList().ToListWithoutEmptyItems(); } string _writers = Helpers.GetValueFromXmlNode(_episodeNode, "Writer"); if (!string.IsNullOrEmpty(_writers)) { info.Writers = _writers.Split('|', ',').ToTrimmedList().ToListWithoutEmptyItems(); } string _guests = Helpers.GetValueFromXmlNode(_episodeNode, "GuestStars"); if (!string.IsNullOrEmpty(_guests)) { info.GuestStars = _guests.Split('|', ',').ToTrimmedList().ToListWithoutEmptyItems(); } } } } }
private static void SaveNfo(string movieFilename, MovieInfo movie, MediaInfoData mediainfo, string targetFile) { if (movie != null) { if (mediainfo != null) { movie.MediaInfo = mediainfo; } movie.Filename = Path.GetFileName(movieFilename); // autotranslating items to English if (FileManager.Configuration.Options.MovieSheetsOptions.AutotranslateGenre && movie.Genre.Count != 0) { Translator.TranslatorManager _tm = new Translator.TranslatorManager(); List <string> _glist = new List <string>(); TextInfo _ti = new CultureInfo("en").TextInfo; foreach (string _g in movie.Genre) { string _ss = _tm.Translate(_g); if (!string.IsNullOrEmpty(_ss)) { _ss = _ti.ToTitleCase(_ss); _glist.Add(_ss); } } movie.Genre = _glist; } string _folder = Path.GetDirectoryName(targetFile); Directory.CreateDirectory(_folder); try { if (FileManager.Configuration.Options.ExportNfoAsTvixie) // Tvixie format { XmlSerializer _xs = new XmlSerializer(typeof(MovieInfo)); using (MemoryStream _ms = new MemoryStream()) { XmlTextWriter _tw = new XmlTextWriter(_ms, Encoding.UTF8); _tw.Formatting = Formatting.Indented; _xs.Serialize(_tw, movie); _ms.Position = 0; MemoryStream _res = Helpers.XslTransformEmbededStream(TVIXIE_EXPORT_XSL, _ms, null); using (FileStream _fs = new FileStream(targetFile, FileMode.Create, FileAccess.ReadWrite)) { _res.CopyTo(_fs); } if (_res != null) { _res.Dispose(); } } } else if (FileManager.Configuration.Options.ExportNfoAsWDTVHUB) // WDTV Live Hub format { XmlSerializer _xs = new XmlSerializer(typeof(MovieInfo)); using (MemoryStream _ms = new MemoryStream()) { XmlTextWriter _tw = new XmlTextWriter(_ms, Encoding.UTF8); _tw.Formatting = Formatting.Indented; _xs.Serialize(_tw, movie); _ms.Position = 0; Dictionary <string, string> _params = new Dictionary <string, string>(); _params.Add("IsEpisode", EpisodeData.IsEpisodeFile(movieFilename) ? "1" : "0"); _params.Add("ExportBackdropsType", ((int)FileManager.Configuration.Options.NamingOptions.ExportBackdropType).ToString()); MemoryStream _res = Helpers.XslTransformEmbededStream(WDTVHUB_EXPORT_XSL, _ms, _params); // format the xml _res.Position = 0; XmlReader _xr = XmlReader.Create(_res); XDocument _doc = XDocument.Load(_xr); try { _res.Dispose(); _res = new MemoryStream(); XmlWriterSettings _set = new XmlWriterSettings(); _set.Indent = true; XmlWriter _xw = XmlWriter.Create(_res, _set); _doc.Save(_xw); _xw.Close(); } catch { } // stupid patch for & _res.Position = 0; var str = PatchAmpersandAnd(Encoding.UTF8.GetString(_res.ToArray())); using (var sw = new StreamWriter(targetFile)) { sw.Write(str); } // Old way, before patching the & //using (FileStream _fs = new FileStream(targetFile, FileMode.Create, FileAccess.ReadWrite)) //{ // _res.Position = 0; // _res.CopyTo(_fs); //} _res.Dispose(); } } else if (FileManager.Configuration.Options.ExportNfoAsWDTVHUB_V2) // WDTV Live Hub format (new firmware) { XmlSerializer _xs = new XmlSerializer(typeof(MovieInfo)); using (MemoryStream _ms = new MemoryStream()) { XmlTextWriter _tw = new XmlTextWriter(_ms, Encoding.UTF8); _tw.Formatting = Formatting.Indented; _xs.Serialize(_tw, movie); _ms.Position = 0; Dictionary <string, string> _params = new Dictionary <string, string>(); _params.Add("IsEpisode", EpisodeData.IsEpisodeFile(movieFilename) ? "1" : "0"); _params.Add("ExportBackdropsType", ((int)FileManager.Configuration.Options.NamingOptions.ExportBackdropType).ToString(CultureInfo.InvariantCulture)); MemoryStream _res = Helpers.XslTransformEmbededStream(WDTVHUB_EXPORT_XSL_V2, _ms, _params); // format the xml _res.Position = 0; XmlReader _xr = XmlReader.Create(_res); XDocument _doc = XDocument.Load(_xr); try { _res.Dispose(); _res = new MemoryStream(); XmlWriterSettings _set = new XmlWriterSettings(); _set.Indent = true; XmlWriter _xw = XmlWriter.Create(_res, _set); _doc.Save(_xw); _xw.Close(); } catch { } // stupid patch for & _res.Position = 0; var str = PatchAmpersandAnd(Encoding.UTF8.GetString(_res.ToArray())); using (var sw = new StreamWriter(targetFile)) { sw.Write(str); } // Old way, before patching the & //using (FileStream _fs = new FileStream(targetFile, FileMode.Create, FileAccess.ReadWrite)) //{ // _res.Position = 0; // _res.CopyTo(_fs); //} _res.Dispose(); } } else if (FileManager.Configuration.Options.ExportNfoAsXBMC) // XBMC format { XmlSerializer _xs = new XmlSerializer(typeof(MovieInfo)); using (MemoryStream _ms = new MemoryStream()) { XmlTextWriter _tw = new XmlTextWriter(_ms, Encoding.UTF8); _tw.Formatting = Formatting.Indented; _xs.Serialize(_tw, movie); _ms.Position = 0; MemoryStream _res = Helpers.XslTransformEmbededStream(XBMC_EXPORT_XSL, _ms, null); _res.Position = 0; XmlReader _xr = XmlReader.Create(_res); XDocument _doc = XDocument.Load(_xr); try { // patch trailer if (!string.IsNullOrEmpty(movie.Trailer)) { Match m = Regex.Match(movie.Trailer, "watch\\?v=(?<ID>.*)", RegexOptions.Singleline | RegexOptions.IgnoreCase); string id = m.Success ? m.Groups["ID"].Value.Trim() : null; if (!string.IsNullOrEmpty(id)) { XElement trailerNode = _doc.Descendants("trailer").FirstOrDefault(); if (trailerNode == null) { trailerNode = new XElement("trailer"); } trailerNode.Value = string.Format("plugin://plugin.video.youtube/?action=play_video&videoid={0}", id); _doc.Element("movie").Add(trailerNode); } } // patch mediainfo if (mediainfo != null) { Match _m = Regex.Match(mediainfo.VideoResolution, "(?<Width>\\d+)x(?<Height>\\d+)", RegexOptions.Singleline | RegexOptions.IgnoreCase); string _width = _m.Success ? _m.Groups["Width"].Value : "0"; string _height = _m.Success ? _m.Groups["Height"].Value : "0"; XElement _fileInfo = new XElement("fileinfo"); _doc.Element("movie").Add(_fileInfo); XElement _streamDetails = new XElement("streamdetails", new XElement("audio", new XElement("channels", mediainfo.AudioChannels), new XElement("codec", mediainfo.AudioCodec != null ? mediainfo.AudioCodec.Replace("-", "") : mediainfo.AudioCodec)), new XElement("video", new XElement("aspect", mediainfo.AspectRatio), new XElement("duration", mediainfo.Duration), new XElement("codec", mediainfo.VideoCodec), new XElement("height", _height), new XElement("width", _width)) ); _fileInfo.Add(_streamDetails); List <string> _subsList = MediaInfoManager.GetAllDistinctSubtitles(mediainfo.GetSubtitlesList(true, mediainfo.EmbeddedSubtitles), mediainfo.GetSubtitlesList(true, mediainfo.ExternalSubtitlesList)); foreach (string _sub in _subsList) { XElement _s = new XElement("subtitle", new XElement("language"), new XElement("longlanguage", _sub) ); _streamDetails.Add(_s); } } // end patch mediainfo _res.Dispose(); _res = new MemoryStream(); XmlWriterSettings _set = new XmlWriterSettings(); _set.Indent = true; XmlWriter _xw = XmlWriter.Create(_res, _set); _doc.Save(_xw); _xw.Close(); } catch { } using (FileStream _fs = new FileStream(targetFile, FileMode.Create, FileAccess.ReadWrite)) { _res.Position = 0; _res.CopyTo(_fs); } if (_res != null) { _res.Dispose(); } } } else // ThumbGen's format { using (FileStream _fs = new FileStream(targetFile, FileMode.Create, FileAccess.ReadWrite)) { XmlSerializer _xs = new XmlSerializer(typeof(MovieInfo)); XmlTextWriter _tw = new XmlTextWriter(_fs, Encoding.UTF8); _tw.Formatting = Formatting.Indented; _xs.Serialize(_tw, movie); } if (FileManager.Configuration.Options.PutFullMediaInfoToExportedNfo) { try { MediaInfoManager.AppendFullMediaInfoToNfoFile(targetFile, movieFilename); } catch { } } } } catch (Exception ex) { Loggy.Logger.DebugException("Gen nfo", ex); } } }
public static void GenerateNfoFile(string movieFilename, MovieInfo movie, MediaInfoData mediainfo) { GenerateNfoFile(movieFilename, movie, mediainfo, FileManager.Configuration.GetMovieInfoPath(movieFilename, true, MovieinfoType.Export)); // always generate respecting the naming convention for Export! }
public override bool GetResults(string keywords, string imdbID, bool skipImages) { bool _result = false; HttpWebRequest _req = (HttpWebRequest)WebRequest.Create(string.Format("{0}/ricerca/", Host)); // Set values for the request back //_req.Method = "GET"; _req.ContentType = "application/x-www-form-urlencoded"; _req.UserAgent = "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; .NET4.0C; .NET4.0E)"; // Do the request to get the response string _strResponse = null; _strResponse = Helpers.GetPage(string.Format("{0}/ricerca/film/{1}", Host, string.Format("?q={0}&submit.x=21&submit.y=11", keywords))); if (!string.IsNullOrEmpty(_strResponse)) { // get the request id (eg. http://www.movieplayer.it/ricerca/dGhlIHlvdW5nIHZpY3Rvcmlh/1/ ) string _reqId = _req.Address.OriginalString; if (!string.IsNullOrEmpty(_reqId)) { _reqId = _reqId.Replace("http://www.movieplayer.it/ricerca/", "").Replace("/1/", ""); //if (!string.IsNullOrEmpty(_reqId)) { // requery just for the movies page _strResponse = string.IsNullOrEmpty(_reqId) ? _strResponse : Helpers.GetPage(string.Format("{0}/ricerca/film/{1}/", Host, _reqId)); if (!string.IsNullOrEmpty(_strResponse)) { Regex _reg = new Regex("<a href=\"(?<RelLink>/film/(?<Id>[^/]*)/[^\"]*)\">(?<Title>[^\"]+)</a>[^\"]*<em>trama:</em>(?<Plot>.*?)(<|\\[)", RegexOptions.IgnoreCase); if (_reg.IsMatch(_strResponse)) { List <string> _IDs = new List <string>(); foreach (Match _match in _reg.Matches(_strResponse)) { if (FileManager.CancellationPending) { return(ResultsList.Count != 0); } try { string _id = _match.Groups["Id"].Value; if (_IDs.Contains(_id)) { continue; // avoid duplicates } _IDs.Add(_id); string _relLink = _match.Groups["RelLink"].Value; string _title = HttpUtility.HtmlDecode(_match.Groups["Title"].Value).Replace("\n\t", "").Replace("</strong>", "").Replace("<strong>", "").Trim(); string _year = string.Empty; Regex _yearEx = new Regex("\\(([0-9]*)\\)", RegexOptions.IgnoreCase); if (_yearEx.IsMatch(_title)) { _year = _yearEx.Matches(_title)[0].Groups[1].Value; } if (!IsValidYear(_year)) { continue; } _title = _yearEx.Replace(_title, "").Trim(new char[] { '\r', '\n', ' ' }); _title = _title.Replace("<strong>", "").Replace("</strong>", ""); string _plot = HttpUtility.HtmlDecode(_match.Groups["Plot"].Value).Trim().Replace("<strong>", "").Replace("</strong>", ""); string _moviePageLink = string.Format("{0}{1}", Host, _relLink); // load the gallery and check if u can find some posters string _moviePage = Helpers.GetPage(_moviePageLink); if (!string.IsNullOrEmpty(_moviePage)) { MovieInfo _movieInfo = GetMovieInfo(_moviePage); _movieInfo.Name = _title; if (string.IsNullOrEmpty(_movieInfo.Year)) { _movieInfo.Year = _year; } _movieInfo.Overview = _plot; if (skipImages) { if (!string.IsNullOrEmpty(_title)) { ResultMovieItem _movieItem = new ResultMovieItem(_id, _title, null, this.CollectorName); _movieItem.CollectorMovieUrl = _moviePageLink; _movieItem.MovieInfo = _movieInfo; ResultsList.Add(_movieItem); _result = true; } } else { string _imageUrl = GetCoverLink(_moviePage); if (!string.IsNullOrEmpty(_imageUrl)) { _imageUrl = _imageUrl.Replace("_medium", ""); } if (!string.IsNullOrEmpty(_title)) { ResultMovieItem _movieItem = new ResultMovieItem(_id, _title, _imageUrl, this.CollectorName); _movieItem.CollectorMovieUrl = _moviePageLink; _movieItem.MovieInfo = _movieInfo; ResultsList.Add(_movieItem); _result = true; } } } } catch { } } } } } } } return(_result); }
protected override MovieInfo GetMovieInfo(string input) { MovieInfo _result = new MovieInfo(); if (!string.IsNullOrEmpty(input)) { // imdbid _result.IMDBID = nfoHelper.ExtractIMDBId(input); Regex _reg; //original title string _otitle = Helpers.GetSubstringBetweenStrings(input, ">Originaltitel:", "class=\"Normal\">"); if (!string.IsNullOrEmpty(_otitle)) { _reg = new Regex("<b>([^<]*)</b>", RegexOptions.IgnoreCase); if (_reg.IsMatch(_otitle)) { _result.OriginalTitle = HttpUtility.HtmlDecode(_reg.Matches(_otitle)[0].Groups[1].Value.Trim()); } } // country string _country = Helpers.GetSubstringBetweenStrings(input, ">Herstellungsland:", "class=\"Normal\">"); if (!string.IsNullOrEmpty(_country)) { _reg = new Regex("Land&Text=([^\"]*)", RegexOptions.IgnoreCase); if (_reg.IsMatch(_country)) { foreach (Match _m in _reg.Matches(_country)) { _result.Countries.Add(HttpUtility.UrlDecode(HttpUtility.HtmlDecode(_m.Groups[1].Value.Trim()))); } } } // director string _director = Helpers.GetSubstringBetweenStrings(input, ">Regie:", "class=\"Normal\">"); if (!string.IsNullOrEmpty(_director)) { _reg = new Regex(">([^<]+)</span", RegexOptions.IgnoreCase); if (_reg.IsMatch(_director)) { _result.Director.Add(HttpUtility.HtmlDecode(_reg.Matches(_director)[0].Groups[1].Value.Trim())); } } // cast string _cast = Helpers.GetSubstringBetweenStrings(input, ">Darsteller:", "class=\"Normal\">"); if (!string.IsNullOrEmpty(_cast)) { _reg = new Regex(">([^<]+)</span", RegexOptions.IgnoreCase); if (_reg.IsMatch(_director)) { foreach (Match _m in _reg.Matches(_cast)) { string _actor = HttpUtility.HtmlDecode(_m.Groups[1].Value.Trim()); if (!_actor.Contains("[mehr]")) { _result.Cast.Add(_actor); } } } } // rating _reg = new Regex("<br>Note: ([0-9.]*) ", RegexOptions.IgnoreCase); if (_reg.IsMatch(input)) { _result.Rating = _reg.Matches(input)[0].Groups[1].Value; } // genres string _genres = Helpers.GetSubstringBetweenStrings(input, ">Genre(s):", "class=\"Normal\">"); if (!string.IsNullOrEmpty(_genres)) { _reg = new Regex(">([^<]+)</span", RegexOptions.IgnoreCase); if (_reg.IsMatch(_genres)) { foreach (Match _m in _reg.Matches(_genres)) { string _genre = HttpUtility.HtmlDecode(_m.Groups[1].Value.Trim()); if (!_genre.Contains("[mehr]")) { _result.Genre.Add(_genre); } } } } // plot string _plotArea = Helpers.GetSubstringBetweenStrings(input, "<b>Inhalt:</", "<b>[mehr]</b"); if (!string.IsNullOrEmpty(_plotArea)) { _reg = new Regex("<a href=\"([^\"]*)", RegexOptions.IgnoreCase); if (_reg.IsMatch(_plotArea)) { string _relLink = HttpUtility.HtmlDecode(_reg.Matches(_plotArea)[0].Groups[1].Value.Trim()); if (!string.IsNullOrEmpty(_relLink)) { string _linkToPlot = string.Format("{0}/{1}", Host, _relLink); string _plotPage = Helpers.GetPage(_linkToPlot); if (!string.IsNullOrEmpty(_plotPage)) { string _area = Helpers.GetSubstringBetweenStrings(_plotPage, "gelesen</b></", "</font></p>"); if (!string.IsNullOrEmpty(_area)) { _reg = new Regex("gelesen</b></b>([\\W\\w]+)", RegexOptions.IgnoreCase); if (_reg.IsMatch(_area)) { _result.Overview = HttpUtility.HtmlDecode(_reg.Matches(_area)[0].Groups[1].Value.Replace("<br>", "").Replace("<br />", "").Replace("<br/>", "").Replace("</font>", "").Trim()); } } } } } } // certification _reg = new Regex("(FSK [0-9]+)", RegexOptions.IgnoreCase); if (_reg.IsMatch(input)) { _result.Certification = _reg.Matches(input)[0].Groups[1].Value.Trim(); } } return(_result); }
public override bool GetResults(string keywords, string imdbID, bool skipImages) { bool _result = false; keywords = keywords.Replace(" ", "+"); string input = Helpers.GetPage(string.Format("http://alpacine.com/buscar/?buscar={0}", keywords)); if (!string.IsNullOrEmpty(input)) { string _reg = "href=\"(?<Link>/pelicula/[^\"]*?)\">(?<Title>.*?)</"; Regex regex = new Regex(_reg); if (regex.IsMatch(input)) { int count = regex.Matches(input).Count; foreach (Match match in regex.Matches(input)) { if (FileManager.CancellationPending) { return(ResultsList.Count != 0); } string sUrl = match.Groups["Link"].Value; if (sUrl != "") { string _id = sUrl.Substring(10, sUrl.Length - 10 - 1); string _title = match.Groups["Title"].Value; _title = Helpers.StripHTML(_title); if (!string.IsNullOrEmpty(_title)) { // get movie info MovieInfo _movieInfo = GetMovieInfo(_id); if (!IsValidYear(_movieInfo.Year)) { continue; } if (skipImages) { if (!string.IsNullOrEmpty(_title)) { ResultMovieItem _movieItem = new ResultMovieItem(_id, _title, null, CollectorName); _movieItem.CollectorMovieUrl = string.Format("{0}{1}", Host, sUrl); _movieItem.MovieInfo = _movieInfo; ResultsList.Add(_movieItem); _result = true; } } else { string _gallery = Helpers.GetPage(string.Format("{0}{1}carteles/", Host, sUrl)); if (!string.IsNullOrEmpty(_gallery)) { string _reg2 = "<a\\shref=\"(?<1>/cartel/.*?)\"\\starget"; Regex _regex2 = new Regex(_reg2); if (_regex2.IsMatch(_gallery)) { foreach (Match _galleryMatch in _regex2.Matches(_gallery)) { string _cartel = _galleryMatch.Groups["1"].Value; string _coverPage = Helpers.GetPage(string.Format("{0}{1}", Host, _cartel)); if (!string.IsNullOrEmpty(_coverPage)) { string _reg3 = "imagen\"\\ssrc=\"(?<1>.*?)\""; Regex _regex3 = new Regex(_reg3); if (_regex3.IsMatch(_coverPage)) { string _imageUrl = _regex3.Match(_coverPage).Groups["1"].Value; if (!string.IsNullOrEmpty(_title) && !string.IsNullOrEmpty(_imageUrl)) { ResultMovieItem _movieItem = new ResultMovieItem(_id, _title, _imageUrl, CollectorName); _movieItem.CollectorMovieUrl = string.Format("{0}{1}", Host, sUrl); _movieItem.MovieInfo = _movieInfo; ResultsList.Add(_movieItem); _result = true; } } } } } } } } } } } } return(_result); }
protected override MovieInfo GetMovieInfo(string id) { MovieInfo _result = new MovieInfo(); // title -> description"\scontent="(?<1>.*?)\s-\s // OriginalTitle -> tulo\soriginal:</span>\s(?<1>.*?)</div> // Year -> \s\(([0-9]*)\)\s-\s // Runtime -> uraci.n:</span>\s(?<1>.*?)\sm // Plot -> inopsis:</div><.*?>([^<]*)< // Genres, Country, Director, Cast -> /">([^\<]*)</a> // Rating -> voto">[\s\t\n\r]*?(\d.*)[\s|\t|\n|\r|\v|\f] string _page = Helpers.GetPage(string.Format("{0}/pelicula/{1}/", Host, id)); if (!string.IsNullOrEmpty(_page)) { // title Regex _reg = new Regex("description\"\\scontent=\"(.*)\\s-\\s", RegexOptions.IgnoreCase); if (_reg.IsMatch(_page)) { _result.Name = HttpUtility.HtmlDecode(_reg.Matches(_page)[0].Groups[1].Value); } // original title _reg = new Regex("tulo\\soriginal:</span>\\s(.*)</div>", RegexOptions.IgnoreCase); if (_reg.IsMatch(_page)) { _result.OriginalTitle = HttpUtility.HtmlDecode(_reg.Matches(_page)[0].Groups[1].Value); } // year _reg = new Regex("\\s\\(([0-9]*)\\)\\s-\\s", RegexOptions.IgnoreCase); if (_reg.IsMatch(_page)) { _result.Year = _reg.Matches(_page)[0].Groups[1].Value; } // runtime _reg = new Regex("n:</span>\\s(.*)\\sm", RegexOptions.IgnoreCase); if (_reg.IsMatch(_page)) { _result.Runtime = _reg.Matches(_page)[0].Groups[1].Value; } // plot _reg = new Regex("inopsis:</div><.*?>([^<]*)<", RegexOptions.IgnoreCase); if (_reg.IsMatch(_page)) { _result.Overview = HttpUtility.HtmlDecode(_reg.Matches(_page)[0].Groups[1].Value); } // rating _reg = new Regex("voto\">[\\s\\t\\n\\r]*?(\\d.*)[\\s|\\t|\\n|\\r|\\v|\\f]", RegexOptions.IgnoreCase); if (_reg.IsMatch(_page)) { _result.Rating = _reg.Matches(_page)[0].Groups[1].Value; } // genres string _genres = Helpers.GetSubstringBetweenStrings(_page, "titulo\">Género", "titulo\">Pa"); if (!string.IsNullOrEmpty(_genres)) { _reg = new Regex("/\">([^\\<]*)</a>", RegexOptions.IgnoreCase); if (_reg.IsMatch(_genres)) { foreach (Match _m in _reg.Matches(_genres)) { _result.Genre.Add(HttpUtility.HtmlDecode(_m.Groups[1].Value)); } } } // countries string _countries = Helpers.GetSubstringBetweenStrings(_page, ">País:</span>", "titulo\">Durac"); if (!string.IsNullOrEmpty(_countries)) { _reg = new Regex("/\">([^\\<]*)</a>", RegexOptions.IgnoreCase); if (_reg.IsMatch(_countries)) { foreach (Match _m in _reg.Matches(_countries)) { _result.Countries.Add(HttpUtility.HtmlDecode(_m.Groups[1].Value)); } } } // director string _director = Helpers.GetSubstringBetweenStrings(_page, "titulo\">Direcc", "titulo\">Interpretaci"); if (!string.IsNullOrEmpty(_director)) { _reg = new Regex("/\">([^\\<]*)</a>", RegexOptions.IgnoreCase); if (_reg.IsMatch(_director)) { foreach (Match _m in _reg.Matches(_director)) { _result.Director.Add(HttpUtility.HtmlDecode(_m.Groups[1].Value)); } } } // cast string _cast = Helpers.GetSubstringBetweenStrings(_page, "titulo\">Interpretaci", "titulo\">Sinopsis"); if (!string.IsNullOrEmpty(_cast)) { _reg = new Regex("/\">([^\\<]*)</a>", RegexOptions.IgnoreCase); if (_reg.IsMatch(_cast)) { foreach (Match _m in _reg.Matches(_cast)) { _result.Cast.Add(HttpUtility.HtmlDecode(_m.Groups[1].Value)); } } } } return(_result); }
private bool ProcessPage(string input, string inputIMDBID, bool skipImages) { bool _result = false; if (!string.IsNullOrEmpty(input)) { string _imdbid = nfoHelper.ExtractIMDBId(input); if (!string.IsNullOrEmpty(inputIMDBID) && !string.IsNullOrEmpty(_imdbid) && string.Compare(_imdbid, inputIMDBID) != 0) { return(_result); } if (!string.IsNullOrEmpty(inputIMDBID) && string.IsNullOrEmpty(_imdbid)) { return(_result); } if (!string.IsNullOrEmpty(inputIMDBID) && !string.IsNullOrEmpty(_imdbid) && string.Compare(_imdbid, inputIMDBID) == 0) { m_MatchedByIMDBId = true; } MovieInfo _info = new MovieInfo(); Match _match = null; string _regex = @"<title>(?<Title>[^/^\(]*)/? (?<OriginalTitle>[^\(]*)"; _info.Name = GetItem(input, _regex, "Title"); if (!string.IsNullOrEmpty(_info.Name)) { _info.OriginalTitle = GetItem(input, _regex, "OriginalTitle"); if (string.IsNullOrEmpty(_info.OriginalTitle)) { _match = Regex.Match(input, @"/flag_[^>]+>.*?<h3>(?<1>[^<]+)", RegexOptions.IgnoreCase | RegexOptions.Singleline); if (_match.Success) { _info.OriginalTitle = _match.Groups[1].Value; } } _info.Year = GetItem(input, ", (?<Year>\\d{4}),", "Year"); if (string.IsNullOrEmpty(_info.Year)) { _match = Regex.Match(input, @",\s(?<1>\d{4}),", RegexOptions.IgnoreCase | RegexOptions.Multiline); if (_match.Success) { _info.Year = _match.Groups[1].Value; } } _match = Regex.Match(input, "<h2 class=\"average\">(?<Rating>[0-9]+)%</h2>", RegexOptions.Multiline | RegexOptions.IgnoreCase); if (_match.Success) { string _r = _match.Groups["Rating"].Value.Replace(",", ".").Trim(); double _dr = 0d; if (!string.IsNullOrEmpty(_r) && Double.TryParse(_r, out _dr)) { _info.Rating = (_dr / 10).ToString("F2"); } } _match = Regex.Match(input, @",\s\d{4},\s(?<1>\d*?)\smin", RegexOptions.Multiline | RegexOptions.IgnoreCase); if (_match.Success) { _info.Runtime = _match.Groups[1].Value; } _match = Regex.Match(input, "alt=\"Odrážka\"\\s+class=\"[^\"]+\"/>(?<1>.*?)<", RegexOptions.IgnoreCase | RegexOptions.Singleline); if (_match.Success) { _info.Overview = _match.Groups[1].Value.Replace("<p>", "").Replace("<strong>", "").Replace("</strong>", "").Replace("<br />", ""). Replace("</p>", "").Replace("<span class=\"source\">", "").Replace("</span>", "").Replace(" ", "").Trim('\n').Trim('\t'); } string[] _genres = null; _match = Regex.Match(input, "<p class=\"genre\">(?<Genre>[^<]+)</p", RegexOptions.IgnoreCase | RegexOptions.Multiline); if (_match.Success) { _genres = _match.Groups[1].Value.Split('/'); if (_genres != null && _genres.Count() != 0) { _info.Genre = _genres.ToTrimmedList(); } } string _imageUrl = null; _match = Regex.Match(input, "(?<Cover>http://img\\.csfd\\.cz/posters/\\d+/\\d+[^\\.]+.jpg)", RegexOptions.IgnoreCase | RegexOptions.Multiline); if (_match.Success) { _imageUrl = _match.Groups[1].Value; } _info.IMDBID = _imdbid; string _id = null; _match = Regex.Match(input, "href=\"/film/(?<1>[0-9]*)-", RegexOptions.IgnoreCase | RegexOptions.Multiline); if (_match.Success) { _id = _match.Groups[0].Value; } if (string.IsNullOrEmpty(_id)) { _id = Helpers.GetUniqueFilename(""); } if (!IsValidYear(_info.Year)) { return(false); } if (!string.IsNullOrEmpty(_info.Name)) { ResultMovieItem _movieItem = new ResultMovieItem(_id, _info.Name, _imageUrl, this.CollectorName); _movieItem.MovieInfo = _info; _movieItem.MovieInfo.Name = _info.Name; if (string.IsNullOrEmpty(_movieItem.MovieInfo.IMDBID)) { _movieItem.MovieInfo.IMDBID = inputIMDBID; } ResultsList.Add(_movieItem); _result = true; } } } return(_result); }
public void CreateMovieInfoFile(MediaInfoData mediainfo, MovieInfo movieinfo) { MediaInfoData _mediainfo = mediainfo == null?MediaInfoManager.GetMediaInfoData(MoviePath) : mediainfo; nfoHelper.GenerateNfoFile(MoviePath, movieinfo, _mediainfo); }
public MovieInfo GetMovieInfo(string imdbId, string countryCode) { MovieInfo _result = new MovieInfo(); if (!string.IsNullOrEmpty(imdbId)) { MovieInfo _originalInfo = new MovieInfo(); if (this.Language != "com") { _originalInfo = new IMDBMovieInfo("com").GetMovieInfo(imdbId, countryCode); } string _moviePage = Helpers.GetPage(string.Format("{0}/title/{1}/", m_CountryFactory.TargetHost, imdbId), null, m_CountryFactory.GetEncoding, "", true, false, m_CountryFactory.Language); if (!string.IsNullOrEmpty(_moviePage)) { _result.IMDBID = imdbId; _result.Name = GetTitle(_moviePage); _result.Name = string.IsNullOrEmpty(_result.Name) ? _originalInfo.Name : _result.Name; _result.OriginalTitle = GetOriginalTitle(_moviePage); _result.OriginalTitle = string.IsNullOrEmpty(_result.OriginalTitle) ? (string.IsNullOrEmpty(_originalInfo.OriginalTitle) ? _result.Name : _originalInfo.OriginalTitle) : _result.OriginalTitle; _result.Year = GetYear(_moviePage); _result.Year = string.IsNullOrEmpty(_result.Year) ? _originalInfo.Year : _result.Year; _result.Runtime = GetRunTime(_moviePage); _result.Runtime = string.IsNullOrEmpty(_result.Runtime) ? _originalInfo.Runtime : _result.Runtime; DateTimeFormatInfo _dtfi = new DateTimeFormatInfo() { DateSeparator = " ", ShortDatePattern = "dd MMMM yyyy" }; if (string.IsNullOrEmpty(_originalInfo.ReleaseDate)) { _result.SetReleaseDate(Helpers.GetFormattedDate(GetReleaseDate(imdbId), _dtfi)); } else { _result.ReleaseDate = _originalInfo.ReleaseDate; } DateTime _out = DateTime.MinValue; if (DateTime.TryParse(_result.ReleaseDate, out _out) && _out != DateTime.MinValue) { _result.ReleaseDate = Helpers.GetFormattedDate(_out); } _result.Rating = GetRating(_moviePage); _result.Rating = string.IsNullOrEmpty(_result.Rating) ? _originalInfo.Rating : _result.Rating; _result.MPAA = GetMPAA(_moviePage); _result.MPAA = string.IsNullOrEmpty(_result.MPAA) ? _originalInfo.MPAA : _result.MPAA; _result.Tagline = GetTagline(_moviePage); _result.Tagline = string.IsNullOrEmpty(_result.Tagline) ? _originalInfo.Tagline : _result.Tagline; _result.Metascore = GetMetascore(_moviePage); _result.Metascore = string.IsNullOrEmpty(_result.Metascore) ? _originalInfo.Metascore : _result.Metascore; _result.Trailer = GetTrailerLink(_moviePage); _result.Trailer = string.IsNullOrEmpty(_result.Trailer) ? _originalInfo.Trailer : _result.Trailer; if (!string.IsNullOrEmpty(_result.Trailer) && !_result.Trailer.StartsWith("http")) { _result.Trailer = "http://www.imdb.com" + _result.Trailer; } _result.Overview = GetOverview(imdbId); if (string.IsNullOrEmpty(_result.Overview)) { _result.Overview = GetPlot(_moviePage); } _result.Overview = string.IsNullOrEmpty(_result.Overview) ? _originalInfo.Overview : _result.Overview; _result.Genre = GetGenres(_moviePage); _result.Genre = _result.Genre.Count == 0 ? _originalInfo.Genre : _result.Genre; _result.Cast = GetActors(_moviePage).ToTrimmedList(); _result.Cast = _result.Cast.Count == 0 ? _originalInfo.Cast : _result.Cast; _result.Director = GetDirectors(_moviePage); _result.Director = _result.Director.Count == 0 ? _originalInfo.Director : _result.Director; _result.Countries = GetCountries(_moviePage); _result.Countries = _result.Countries.Count == 0 ? _originalInfo.Countries : _result.Countries; _result.Certification = GetCertification(countryCode, _moviePage, imdbId); _result.Certification = string.IsNullOrEmpty(_result.Certification) ? _originalInfo.Certification : _result.Certification; _result.Studios = GetCompanies(_moviePage); _result.Studios = _result.Studios.Count == 0 ? _originalInfo.Studios : _result.Studios; } } return(_result); }
private MovieInfo GetMovieInfo(XmlNode movieNode) { MovieInfo _result = new MovieInfo(); if (movieNode != null) { XmlNodeList _castingList = movieNode.SelectNodes("casting/person"); if (_castingList.Count != 0) { foreach (XmlNode _actor in _castingList) { string _d = HttpUtility.HtmlDecode(Helpers.GetAttributeFromXmlNode(_actor, "name")); if (!string.IsNullOrEmpty(_d)) { _result.Cast.Add(_d); } } } //_result.Certification XmlNodeList _countriesList = movieNode.SelectNodes("countries/country"); if (_countriesList.Count != 0) { foreach (XmlNode _country in _countriesList) { string _d = HttpUtility.HtmlDecode(Helpers.GetValueFromXmlNode(_country)); if (!string.IsNullOrEmpty(_d)) { _result.Countries.Add(_d); } } } XmlNodeList _directorsList = movieNode.SelectNodes("directors/director"); if (_directorsList.Count != 0) { foreach (XmlNode _director in _directorsList) { string _d = HttpUtility.HtmlDecode(Helpers.GetValueFromXmlNode(_director)); if (!string.IsNullOrEmpty(_d)) { _result.Director.Add(_d); } } } XmlNodeList _genresList = movieNode.SelectNodes("genres/genre"); if (_genresList.Count != 0) { foreach (XmlNode _genre in _genresList) { string _d = HttpUtility.HtmlDecode(Helpers.GetValueFromXmlNode(_genre)); if (!string.IsNullOrEmpty(_d)) { _result.Genre.Add(_d); } } } _result.IMDBID = Helpers.GetValueFromXmlNode(movieNode, "id_imdb").PadLeft(7, '0'); if (!string.IsNullOrEmpty(_result.IMDBID) && !_result.IMDBID.StartsWith("t")) { _result.IMDBID = "tt" + _result.IMDBID; } _result.Name = HttpUtility.HtmlDecode(Helpers.GetValueFromXmlNode(movieNode, "title")); _result.OriginalTitle = HttpUtility.HtmlDecode(Helpers.GetValueFromXmlNode(movieNode, "originaltitle")); _result.Overview = HttpUtility.HtmlDecode(Helpers.GetValueFromXmlNode(movieNode, "plot")); _result.Rating = Helpers.GetValueFromXmlNode(movieNode.SelectSingleNode("//ratings/rating[@type='imdb']")); if (string.IsNullOrEmpty(_result.Rating)) { _result.Rating = Helpers.GetValueFromXmlNode(movieNode.SelectSingleNode("//ratings/rating[@type='allocine']")); } //_result.ReleaseDate _result.Runtime = Helpers.GetValueFromXmlNode(movieNode, "runtime"); XmlNodeList _studiosList = movieNode.SelectNodes("studios/studio"); if (_studiosList.Count != 0) { foreach (XmlNode _studio in _studiosList) { string _d = HttpUtility.HtmlDecode(Helpers.GetValueFromXmlNode(_studio)); if (!string.IsNullOrEmpty(_d)) { _result.Studios.Add(_d); } } } _result.Year = Helpers.GetValueFromXmlNode(movieNode, "year"); } return(_result); }
public ResultItemBase() { MovieInfo = new MovieInfo(); }
private bool GetMovieDetails(string movieId, bool onlyInfo, out MovieInfo movieInfo) { bool _result = false; movieInfo = null; if (!string.IsNullOrEmpty(movieId)) { XmlDocument _docDetails = new XmlDocument(); try { _docDetails.Load(this.GetInfoUrl(movieId)); } catch { } XmlNode _movie = _docDetails.SelectSingleNode("//movie"); if (_movie != null) { MovieInfo _movieInfo = GetMovieInfo(_movie); movieInfo = _movieInfo; if (!onlyInfo) { // get posters if (_movie != null) { XmlNodeList _images = _movie.SelectNodes("//image[@type='Poster' and @size='original']"); if (_images.Count != 0) { foreach (XmlNode _image in _images) { string _imageUrl = Helpers.GetAttributeFromXmlNode(_image, "url"); ResultMovieItem _movieItem = new ResultMovieItem(movieId, _movieInfo.Name, _imageUrl, this.CollectorName); _movieItem.CollectorMovieUrl = Helpers.GetValueFromXmlNode(_movie, "url"); _movieItem.MovieInfo = _movieInfo; ResultsList.Add(_movieItem); _result = true; } } else { ResultMovieItem _movieItem = new ResultMovieItem(movieId, _movieInfo.Name, null, this.CollectorName); _movieItem.CollectorMovieUrl = Helpers.GetValueFromXmlNode(_movie, "url"); _movieItem.MovieInfo = _movieInfo; ResultsList.Add(_movieItem); _result = true; } // get fanart/backdrops XmlNodeList _fanarts = _movie.SelectNodes("//image[@type='Fanart' and @size='preview']"); if (_fanarts.Count != 0) { foreach (XmlNode _fanart in _fanarts) { string _fanartId = Helpers.GetAttributeFromXmlNode(_fanart, "id"); if (!string.IsNullOrEmpty(_fanartId)) { string _thumbUrl = Helpers.GetAttributeFromXmlNode(_movie.SelectSingleNode(string.Format("//image[@id='{0}' and @size='preview']", _fanartId)), "url"); XmlNode _originalNode = _movie.SelectSingleNode(string.Format("//image[@id='{0}' and @size='original']", _fanartId)); string _originalUrl = Helpers.GetAttributeFromXmlNode(_originalNode, "url"); string _width = _originalNode != null ? _originalNode.Attributes["width"].Value : null; string _height = _originalNode != null ? _originalNode.Attributes["height"].Value : null; if (!string.IsNullOrEmpty(_thumbUrl) && !string.IsNullOrEmpty(_originalUrl)) { BackdropItem _bi = new BackdropItem(movieId, _movieInfo.IMDBID, this.CollectorName, _thumbUrl, _originalUrl); _bi.SetSize(_width, _height); this.BackdropsList.Add(_bi); } } } } } } } } return(_result); }
protected override MovieInfo GetMovieInfo(string mmid) { MovieInfo _movieInfo = null; try { if (!string.IsNullOrEmpty(mmid)) { int _filmId = Int32.Parse(mmid); FilmDetail _details = m_apiProxy.RetrieveDetails(getSessionKey(), _filmId); if (_details != null) { _movieInfo = new MovieInfo(); foreach (MovieMeterHelper.FilmDetail.Actor _actor in _details.actors) { _movieInfo.Cast.Add(_actor.name); } foreach (MovieMeterHelper.FilmDetail.Country _country in _details.countries) { _movieInfo.Countries.Add(_country.name); } foreach (MovieMeterHelper.FilmDetail.Director _director in _details.directors) { _movieInfo.Director.Add(_director.name); } foreach (string _genre in _details.genres) { _movieInfo.Genre.Add(_genre); } if (!string.IsNullOrEmpty(_details.imdb)) { _movieInfo.IMDBID = "tt" + _details.imdb; } _movieInfo.OriginalTitle = _details.title; if (_details.alternative_titles.Count() != 0) { _movieInfo.Name = _details.alternative_titles[_details.alternative_titles.Count() - 1].title; } if (string.IsNullOrEmpty(_movieInfo.Name)) { _movieInfo.Name = _movieInfo.OriginalTitle; } _movieInfo.Overview = _details.plot; _movieInfo.Rating = _details.average; try { if (!string.IsNullOrEmpty(_movieInfo.Rating)) { _movieInfo.Rating = (2 * _movieInfo.dRating).ToString(); } } catch { } if (_details.dates_cinema.Count() != 0) { _movieInfo.ReleaseDate = _details.dates_cinema[0].date; } _movieInfo.Runtime = _details.duration; _movieInfo.Year = _details.year; } } } catch { } return(_movieInfo); }
public static MovieInfo LoadNfoFile(string movieFilename, string nfoFilePath, out nfoFileType nfofiletype) { MovieInfo _result = new MovieInfo(); nfofiletype = nfoFileType.Unknown; string _nfoFilename = nfoFilePath; // if there's no nfo specified if (string.IsNullOrEmpty(_nfoFilename)) { // first try to load from target movieinfo path _nfoFilename = GetNfoFilename(movieFilename, false); if (string.IsNullOrEmpty(_nfoFilename) || !File.Exists(_nfoFilename)) { // try also near the movie _nfoFilename = GetNfoFilename(movieFilename, true); } } if (File.Exists(_nfoFilename)) { using (FileStream _fs = new FileStream(_nfoFilename, FileMode.Open, FileAccess.Read)) { // check first if it is a valid XML XmlDocument _doc = new XmlDocument(); try { _doc.Load(_fs); } catch { // no valid xml, safely jump out return(_result); } bool _loaded = false; // check if it is an ember one _result = TryParse(new EmberNfoHelper(), _nfoFilename, out _loaded, out nfofiletype); // check if maybe it is a xbmc nfo file if (!_loaded) { _result = TryParse(new XBMCNfoHelper(), _nfoFilename, out _loaded, out nfofiletype); } // check if maybe it is a mymovies.dk nfo file if (!_loaded) { _result = TryParse(new MyMoviesNfoHelper(), _nfoFilename, out _loaded, out nfofiletype); } // check if maybe it is a TViXiE nfo file if (!_loaded) { _result = TryParse(new TvixieNfoHelper(), _nfoFilename, out _loaded, out nfofiletype); } if (!_loaded) { try { _fs.Position = 0; XmlSerializer _xs = new XmlSerializer(typeof(MovieInfo)); _result = _xs.Deserialize(_fs) as MovieInfo; nfofiletype = nfoFileType.ThumbGen; } catch (Exception ex) { Loggy.Logger.DebugException("Cannot deserialize nfo:" + _nfoFilename, ex); } } } } return(_result); }
private bool GetSeries(string keywords) { m_Series.Clear(); MemoryStream _stream = null; XmlDocument _doc = new XmlDocument(); // if we are processing same series then use cache if (IsSameSeriesBeingProcessed()) { try { _doc.LoadXml(CurrentSeriesHelper.GetSeriesDataXML); } catch { } } else { // if u have imdbid then USE IT!! if (!string.IsNullOrEmpty(m_IMDbId)) { // sample: http://thetvdb.com/api/GetSeriesByRemoteID.php?imdbid=tt0411008 string _seriesUrl = string.Format("{0}/api/GetSeriesByRemoteID.php?imdbid={1}&language={2}", m_MirrorPath, m_IMDbId, FileManager.Configuration.Options.MovieSheetsOptions.TVShowsLanguage); _stream = SendRequest(_seriesUrl); if (_stream == null || _stream.Length == 0) { _seriesUrl = string.Format("{0}/api/GetSeriesByRemoteID.php?imdbid={1}", m_MirrorPath, m_IMDbId); _stream = SendRequest(_seriesUrl); } } else // no imdbid, use keywords { string _seriesUrl = string.Format("{0}/api/GetSeries.php?seriesname={1}&language={2}", m_MirrorPath, keywords, FileManager.Configuration.Options.MovieSheetsOptions.TVShowsLanguage); _stream = SendRequest(_seriesUrl); if (_stream == null || _stream.Length == 0) { _seriesUrl = string.Format("{0}/api/GetSeries.php?seriesname={1}", m_MirrorPath, keywords); _stream = SendRequest(_seriesUrl); } } if (_stream != null && _stream.Length > 0) { _stream.Position = 0; try { _doc.Load(_stream); _stream.Dispose(); _stream = null; } catch { } } } XmlNodeList _series = _doc.SelectNodes("//Series"); if (_series.Count != 0) { foreach (XmlNode _item in _series) { int _id = Convert.ToInt32(Helpers.GetValueFromXmlNode(_item, "seriesid")); string _title = HttpUtility.HtmlDecode(Helpers.GetValueFromXmlNode(_item, "SeriesName")); string _imdb = Helpers.GetValueFromXmlNode(_item, "IMDB_ID"); string _year = GetSeriesYear(_item); if (string.IsNullOrEmpty(_imdb) && !IsValidYear(_year)) { continue; } // if I have an imdbid and it is not matching the found one, skip this series if (!string.IsNullOrEmpty(m_IMDbId) /*&& !string.IsNullOrEmpty(_imdb)*/ && m_IMDbId.ToLowerInvariant() != _imdb.ToLowerInvariant()) { // this series does not match the provided imdbid continue; } bool _addIt = true; if (IsSameSeriesBeingProcessed()) { // if we have series data, we use it for filtering if (!string.IsNullOrEmpty(CurrentSeriesHelper.SeriesID) && (string.Compare(CurrentSeriesHelper.SeriesID, _id.ToString(), true) != 0)) { // different ID do not add it _addIt = false; } } else { // we are not anymore in the same series RootFolder, reset CurrentSeriesHelper data CurrentSeriesHelper.Reset(); // remember the new series root CurrentSeriesHelper.SeriesRootFolder = GetCurrentSeriesRootFolder(); // cache result of the current GetSeriesData CurrentSeriesHelper.GetSeriesDataXML = _doc.OuterXml.ToString(); } if (_addIt) { MovieInfo _movieInfo = GetMovieInfo(_item, _id.ToString()); if (!m_Series.ContainsKey(_id)) { TheTVDBSerieItem _new = new TheTVDBSerieItem(_id, _title, _imdb); _new.MovieInfo = _movieInfo; m_Series.Add(_id, _new); } } } } return(m_Series.Count != 0); }
public static void GenerateNfoFile(string movieFilename, MovieInfo movie, MediaInfoData mediainfo, string targetPath) { SaveNfo(movieFilename, movie, mediainfo, targetPath); }
protected override MovieInfo GetMovieInfo(string input) { MovieInfo _result = base.GetMovieInfo(input); if (!string.IsNullOrEmpty(input)) { Regex _reg; // rating // must multiply rating by 2 to reach x/10 (they have only 5 stars) try { _result.Rating = string.Format("{0:0.#}", 2 * _result.dRating); } catch { } // country _result.Countries.Clear(); _reg = new Regex("<b>País:</b> ([^<]*)<br />", RegexOptions.IgnoreCase); if (_reg.IsMatch(input)) { _result.Countries.AddRange(_reg.Matches(input)[0].Groups[1].Value.Split(new char[] { ',' }).ToTrimmedList()); } // genres _result.Genre.Clear(); _reg = new Regex("<b>Género:</b>([^<]*)", RegexOptions.IgnoreCase); if (_reg.IsMatch(input)) { _result.Genre.AddRange(_reg.Matches(input)[0].Groups[1].Value.Split(new char[] { ',' }).ToTrimmedList()); } // runtime _reg = new Regex("<b>Duração:</b>([0-9 ]*)", RegexOptions.IgnoreCase); if (_reg.IsMatch(input)) { _result.Runtime = _reg.Matches(input)[0].Groups[1].Value.Trim(); } // director string _directorArea = Helpers.GetSubstringBetweenStrings(input, "<b>Realização:</b>", "<b>Intérpretes:"); if (!string.IsNullOrEmpty(_directorArea)) { _reg = new Regex("href=\"/pessoas/[0-9]*\">([^<]*)", RegexOptions.IgnoreCase); if (_reg.IsMatch(_directorArea)) { _result.Director.Add(_reg.Matches(input)[0].Groups[1].Value.Trim()); } else { _reg = new Regex("<b>Realização:</b><br />([^<]*)", RegexOptions.IgnoreCase); if (_reg.IsMatch(_directorArea)) { _result.Director.Add(_reg.Matches(input)[0].Groups[1].Value.Trim()); } } } // cast string _castArea = Helpers.GetSubstringBetweenStrings(input, "<b>Intérpretes:</b><br", "<br"); if (!string.IsNullOrEmpty(_castArea)) { _reg = new Regex("href=\"/pessoas/[0-9]*\">([^<]*)</a>", RegexOptions.IgnoreCase); if (_reg.IsMatch(_castArea)) { foreach (Match _match in _reg.Matches(_castArea)) { _result.Cast.Add(_match.Groups[1].Value.Trim()); } } } // plot _result.Overview = _result.Overview.Trim(); // classification _reg = new Regex("<b>Classificação:</b>([^<]*)", RegexOptions.IgnoreCase); if (_reg.IsMatch(input)) { _result.Certification = _reg.Matches(input)[0].Groups[1].Value.Trim(); } } return(_result); }