Example #1
0
        List <Channel> DownloadPart(int dayNr, int dayPart, DateTime now)
        {
            var epgData = new List <Channel>();

            try
            {
                _logger.Debug($"Download EPG data for day {dayNr+1} part {dayPart+1}");
                var zip = DownloadEpgfile(now, dayNr, dayPart);
                if (_stop())
                {
                    return(null);
                }
                var file      = _compression.Decompress(zip);
                var epgString = Encoding.Default.GetString(file);
                var data      = ParseEpgData(epgString);
                epgData = _channelList.FilterOnSelectedChannels(data);
                DownloadDetails(epgData);
                _logger.Info($"Downloaded EPG data for {epgData.SelectMany(channel => channel.Programs).Count()} programs for day {dayNr+1} (part {dayPart+1})");
            }
            catch (Exception ex)
            {
                _logger.Warn($"Failed during download day {dayNr} part {dayPart}", ex);
            }
            return(epgData);
        }
Example #2
0
        private List <Channel> DownloadEpgData(DateTime start, DateTime end, bool nocache = false)
        {
            var epgString = DownloadEpgJson(start, end, nocache);

            if (_stop())
            {
                return(new List <Channel>());
            }
            var jsonData = JsonConvert.DeserializeObject <ItvOnlineJson>(epgString);
            var data     = ConvertToChannelList(jsonData);

            return(_channelList.FilterOnSelectedChannels(data));
        }
Example #3
0
        public string Download(Func <bool> stopProcessing)
        {
            var pipedEpg = _downloader.DownloadEpgData(stopProcessing);

            if (stopProcessing())
            {
                return(string.Empty);
            }
            var channelsWithEpg = ConvertToChannels(pipedEpg, stopProcessing);

            if (stopProcessing())
            {
                return(string.Empty);
            }
            _channelList.LoadChannelsFromDisk();
            channelsWithEpg = _channelList.FilterOnSelectedChannels(channelsWithEpg);
            if (stopProcessing())
            {
                return(string.Empty);
            }
            return(GenerateXmlTv(channelsWithEpg));
        }