public IEnumerable <MyRecordingInfo> GetRecordings(CancellationToken cancellationToken) { var pluginPath = Plugin.Instance.ConfigurationFilePath.Remove(Plugin.Instance.ConfigurationFilePath.Length - 4); var localPath = String.Format("{0}", Configuration.LocalFilePath); var remotePath = String.Format("{0}", Configuration.RemoteFilePath); var genreMapper = new GenreMapper(Plugin.Instance.Configuration); var lastName = string.Empty; var schedules = GetFromService <Timers>(cancellationToken, typeof(Timers), "api/timerlist.html?utf8=2"); var response = GetFromService <Recordings>(cancellationToken, typeof(Recordings), "api/recordings.html?utf8=1&images=1"); Plugin.Logger.Info("Found overall Recordings: {0} ", response.Recording.Count()); return(response.Recording.Select(r => { var recording = new MyRecordingInfo() { Id = r.Id, Name = r.Name, EpisodeTitle = r.EpisodeTitle, EpisodeNumber = r.EpisodeNumber, SeasonNumber = r.SeasonNumber, Year = r.Year, Overview = r.Overview, EitContent = r.EitContent, SeriesTimerId = r.Series, ChannelId = r.ChannelId, ChannelName = r.ChannelName, ChannelType = ChannelType.TV, StartDate = DateTime.ParseExact(r.Start, "yyyyMMddHHmmss", CultureInfo.InvariantCulture).ToUniversalTime(), EndDate = DateTime.ParseExact(r.Start, "yyyyMMddHHmmss", CultureInfo.InvariantCulture).Add(TimeSpan.ParseExact(r.Duration, "hhmmss", CultureInfo.InvariantCulture)).ToUniversalTime(), Path = r.File, }; if (!String.IsNullOrEmpty(r.EitContent) || !String.IsNullOrEmpty(r.Overview)) { genreMapper.PopulateRecordingGenres(recording); } if (recording.IsMovie) { recording.Name = r.MovieName; } if ((recording.StartDate <= DateTime.Now.ToUniversalTime()) && (recording.EndDate >= DateTime.Now.ToUniversalTime())) { var timers = schedules.Timer.Where(t => GeneralExtensions.GetScheduleTime(t.Date, t.Start).AddMinutes(t.PreEPG) == recording.StartDate && t.Recording == "-1").FirstOrDefault(); if (timers != null) { recording.Status = RecordingStatus.InProgress; } } else { recording.Status = RecordingStatus.Completed; if (!String.IsNullOrEmpty(r.Image)) { recording.ImageUrl = _wssProxy.GetRecordingImage(r.Image); } } if (Configuration.RequiresPathSubstitution) { recording.Path = r.File.Replace(localPath, remotePath); } if (Configuration.EnableTmdbLookup) { if (recording.Name != lastName) { _tmdbLookup.GetTmdbPoster(cancellationToken, recording); } lastName = recording.Name; } if (File.Exists(Path.Combine(pluginPath, "recordingposters", String.Join("", recording.Name.Split(Path.GetInvalidFileNameChars())) + ".jpg"))) { recording.TmdbPoster = Path.Combine(pluginPath, "recordingposters", String.Join("", recording.Name.Split(Path.GetInvalidFileNameChars())) + ".jpg"); } Plugin.Logger.Info("Found Recording: {0} - {1}, Series: {2}, Id: {3}, status: {4}", r.Name, r.EpisodeTitle, r.Series, r.Id, recording.Status); return recording; })); }
public IEnumerable <MyRecordingInfo> GetRecordings(CancellationToken cancellationToken) { var pluginPath = Plugin.Instance.ConfigurationFilePath.Remove(Plugin.Instance.ConfigurationFilePath.Length - 4); var localPath = String.Format("{0}", Configuration.LocalFilePath); var remotePath = String.Format("{0}", Configuration.RemoteFilePath); var genreMapper = new GenreMapper(Plugin.Instance.Configuration); var lastName = string.Empty; var recordings = GetFromService <List <Recording> >(cancellationToken, "GetRecordings").Select(r => { var recording = new MyRecordingInfo() { Id = r.Id, Name = r.Title, EpisodeTitle = r.EpisodeName, EpisodeNumber = r.EpisodeNumber, SeasonNumber = r.SeasonNumber, Overview = r.Description, Year = r.Year, Genres = new List <String>(), TimerId = r.ScheduleId.ToString(CultureInfo.InvariantCulture), ChannelId = r.ChannelId.ToString(CultureInfo.InvariantCulture), ChannelName = r.ChannelName, ChannelType = ChannelType.TV, StartDate = r.StartTime, EndDate = r.EndTime, Status = (r.IsRecording) ? RecordingStatus.InProgress : RecordingStatus.Completed, Path = r.FileName, }; //recording.IsSeries = true; //is set by genreMapper if (!String.IsNullOrEmpty(r.Genre)) { recording.Genres.Add(r.Genre); genreMapper.PopulateRecordingGenres(recording); } if (recording.IsMovie) { recording.Name = r.MovieName; } if (r.IsRecording) { var schedule = GetSchedule(cancellationToken, r.ScheduleId.ToString()); recording.EndDate = schedule.EndTime + TimeSpan.FromMinutes(schedule.PostRecordInterval); } if (!r.IsRecording) { recording.ImageUrl = _wssProxy.GetRecordingImage(r.Id); } if (Configuration.RequiresPathSubstitution) { recording.Path = r.FileName.Replace(localPath, remotePath); } if (Configuration.EnableTmdbLookup) { if (recording.Name != lastName) { _tmdbLookup.GetTmdbPoster(cancellationToken, recording); } lastName = recording.Name; } if (File.Exists(Path.Combine(pluginPath, "recordingposters", String.Join("", recording.Name.Split(Path.GetInvalidFileNameChars())) + ".jpg"))) { recording.TmdbPoster = Path.Combine(pluginPath, "recordingposters", String.Join("", recording.Name.Split(Path.GetInvalidFileNameChars())) + ".jpg"); } return(recording); }).ToList(); Plugin.Logger.Info("Found recordings: {0} ", recordings.Count()); return(recordings); }