Ejemplo n.º 1
0
        public string ProxyUrl(MBTrailers.ITunesTrailer trailer)
        {
            Uri         uri         = new Uri(trailer.RealPath);
            ProxyInfo   proxyInfo   = new ProxyInfo(uri.Host, uri.PathAndQuery, ProxyInfo.ITunesUserAgent, uri.Port);
            TrailerInfo trailerInfo = new TrailerInfo(TrailerType.Remote, proxyInfo.LocalFilename, trailer.ParentalRating, trailer.Genres);

            using (ChannelFactory <ITrailerProxy> factory = new ChannelFactory <ITrailerProxy>(new NetNamedPipeBinding(), "net.pipe://localhost/mbtrailers"))
            {
                ITrailerProxy proxyServer = factory.CreateChannel();
                try
                {
                    proxyServer.SetProxyInfo(proxyInfo);
                    proxyServer.SetTrailerInfo(trailerInfo);
                }
                catch (Exception e)
                {
                    Logger.ReportException("Error setting proxy info", e);
                    Logger.ReportError("Inner Exception: " + e.InnerException.Message);
                }
                finally
                {
                    (proxyServer as ICommunicationObject).Close();
                }
            }

            var target = Path.Combine(cacheDir, proxyInfo.LocalFilename);

            return(File.Exists(target) ? target : string.Format("http://localhost:{0}/{1}", this.port, proxyInfo.LocalFilename));
        }
Ejemplo n.º 2
0
        public override void ValidateChildren()
        {
            System.Threading.Thread.Sleep(5000); //wait to be sure the service process is up...

            //only validate once per day or when forced or on service refresh
            if (Kernel.LoadContext == MBLoadContext.Service || Plugin.PluginOptions.Instance.Changed || DateTime.Now > lastUpdated.AddHours(23))
            {
                Logger.ReportInfo("MBTrailers validating MyTrailers " + lastUpdated);
                Plugin.PluginOptions.Instance.Changed = false;
                Plugin.PluginOptions.Save();
                lastUpdated = DateTime.Now;
                base.ValidateChildren();
                Kernel.Instance.ItemRepository.SaveItem(this);
            }
            else
            {
                //just go through our existing children and be sure the proxy has them in the list
                using (ChannelFactory <ITrailerProxy> factory = new ChannelFactory <ITrailerProxy>(new NetNamedPipeBinding(), "net.pipe://localhost/mbtrailers"))
                {
                    ITrailerProxy proxyServer = factory.CreateChannel();
                    try
                    {
                        foreach (Movie item in this.Children)
                        {
                            var trailerInfo = new TrailerInfo(TrailerType.Local, item.Path.ToLower(), item.ParentalRating, item.Genres);
                            proxyServer.SetTrailerInfo(trailerInfo);
                        }
                    }
                    catch (Exception e)
                    {
                        Logger.ReportException("Error setting trailer info", e);
                        Logger.ReportError("Inner Exception: " + e.InnerException.Message);
                    }
                    finally
                    {
                        (proxyServer as ICommunicationObject).Close();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public void SetTrailerInfo(MediaBrowser.Library.Entities.Show trailer)
        {
            TrailerInfo trailerInfo = new TrailerInfo(TrailerType.Local, trailer.Path.ToLower(), trailer.ParentalRating, trailer.Genres);

            using (ChannelFactory <ITrailerProxy> factory = new ChannelFactory <ITrailerProxy>(new NetNamedPipeBinding(), "net.pipe://localhost/mbtrailers"))
            {
                ITrailerProxy proxyServer = factory.CreateChannel();
                try
                {
                    proxyServer.SetTrailerInfo(trailerInfo);
                }
                catch (Exception e)
                {
                    Logger.ReportException("Error setting trailer info", e);
                    Logger.ReportError("Inner Exception: " + e.InnerException.Message);
                }
                finally
                {
                    (proxyServer as ICommunicationObject).Close();
                }
            }
        }