Exemple #1
0
        private bool DownloadChannelLogos(ChannelLogos logos, IServiceSet serviceSet)
        {
            try
            {
                foreach (WebChannelBasic ch in channelLogosRequired)
                {
                    try
                    {
                        Stream logoStream = serviceSet.MASStream.GetImage(WebMediaType.TV, null, ch.Id.ToString());
                        logos.WriteToCacheDirectory(ch.Title, "png", logoStream);
                        Log.Debug("Downloaded logo for channel {0}", ch.Title);
                    }
                    catch (EndpointNotFoundException)
                    {
                        Log.Trace("Logo for channel {0} not available on server", ch.Title);
                    }
                }

                return true;
            }
            catch (MessageSecurityException)
            {
                return false;
            }
        }
        public override WebFileInfo GetFileInfo()
        {
            if ((MediaType == WebMediaType.TV || MediaType == WebMediaType.Recording) && FileType == WebFileType.Logo)
            {
                if (fileInfoCache != null)
                    return fileInfoCache;

                if (_logos == null)
                    _logos = new ChannelLogos();

                // get display name
                int idChannel = MediaType == WebMediaType.TV ?
                    Int32.Parse(Id) :
                    Connections.TAS.GetRecordingById(Int32.Parse(Id)).ChannelId;
                var channel = Connections.TAS.GetChannelBasicById(idChannel);
                string location = _logos.FindLocation(channel.Title);
                if(location == null)
                {
                    Log.Debug("Did not find tv logo for channel {0} with id {1}", channel.Title, idChannel);
                    fileInfoCache = new WebFileInfo() { Exists = false };
                    return fileInfoCache;
                }

                // great, return it
                fileInfoCache = new WebFileInfo(location);
                return fileInfoCache;
            }

            return path != null ? new WebFileInfo(path) : base.GetFileInfo();
        }
        public override WebFileInfo GetFileInfo()
        {
            if (fileInfoCache != null)
                return fileInfoCache;

            if (path != null)
            {
                fileInfoCache = new WebFileInfo(path);
                return fileInfoCache;
            }

            if ((MediaType == WebMediaType.TV || MediaType == WebMediaType.Recording || MediaType == WebMediaType.Radio) && FileType == WebFileType.Logo)
            {
                if (_logos == null)
                    _logos = new ChannelLogos();

                // get display name
                int idChannel = MediaType == WebMediaType.TV || MediaType == WebMediaType.Radio ?
                    Int32.Parse(Id) :
                    Connections.TAS.GetRecordingById(Int32.Parse(Id)).ChannelId;
                var channel = Connections.TAS.GetChannelBasicById(idChannel);
                string location = _logos.FindLocation(channel.Title);
                if(location == null)
                {
                    Log.Debug("Did not find tv logo for channel {0} with id {1}", channel.Title, idChannel);
                    fileInfoCache = new WebFileInfo() { Exists = false };
                    return fileInfoCache;
                }

                // great, return it
                fileInfoCache = new WebFileInfo(location);
                return fileInfoCache;
            }

            if (Offset < 0)
            {
                var artwork = Connections.MAS.GetArtwork(Provider, MediaType, Id);
                var preferedItem = artwork.Where(x => x.Type == FileType)
                                          .OrderByDescending(x => x.Rating)
                                          .Skip(-1 - Offset)
                                          .FirstOrDefault();
                if (preferedItem == null)
                {
                    Log.Debug("Requested prefered artwork item for provider={0} mediatype={1} filetype={2} id={3}, but no artwork found",
                        Provider, MediaType, FileType, Id);
                    fileInfoCache = new WebFileInfo()
                    {
                        Exists = false
                    };
                    return fileInfoCache;
                }

                fileInfoCache = Connections.MAS.GetFileInfo(Provider, MediaType, FileType, Id, preferedItem.Offset);
                return fileInfoCache;
            }

            return base.GetFileInfo();
        }
Exemple #4
0
        private void Init()
        {
            // don't do anything if we don't have a TVE connection
            if (!TVAccessService.Instance.TestConnectionToTVService())
                return;

            // exit if we already got all logos
            logos = new ChannelLogos();
            ScanForRequiredLogos();
            if (channelLogosRequired.Count == 0)
            {
                Log.Trace("All channel logos already available, not downloading any...");
                return;
            }

            // try downloading them on starting and exit if successful
            if (PerformCheck())
            {
                return;
            }

            // setup timer
            backgroundTimer = new Timer()
            {
                AutoReset = true,
                Interval = 60 * 60 * 1000,
            };
            backgroundTimer.Elapsed += new ElapsedEventHandler(TimerElapsed);
            backgroundTimer.Start();
        }
        private void Init()
        {
            // load list of channel logos that we don't have yet
            logos = new ChannelLogos();
            ITVAccessService tas = TVAccessService.Instance;
            if (!tas.TestConnectionToTVService())
                return;
            channelLogosRequired = tas.GetChannelsBasic()
                .Where(ch => logos.FindLocation(ch.Title) == null)
                .ToList();

            // exit if we already got all logos
            if (channelLogosRequired.Count == 0)
            {
                Log.Trace("All channel logos already available, not downloading any...");
                return;
            }

            // try downloading them on starting and exit if successful
            if (PerformCheck())
            {
                return;
            }

            // setup timer
            backgroundTimer = new Timer()
            {
                AutoReset = true,
                Interval = 60 * 60 * 1000,
            };
            backgroundTimer.Elapsed += new ElapsedEventHandler(TimerElapsed);
            backgroundTimer.Start();
        }