public void Save(StreamingProvider streamingProvider)
        {
            var streamingProviderModel = new StreamingProviderModel
            {
                Id   = streamingProvider.Identity.Id,
                Type = streamingProvider.Identity.Type.ToString()
            };

            foreach (var category in streamingProvider.Categories)
            {
                var categoryModel = new MediaCategoryModel
                {
                    Name = category.Name
                };

                foreach (var media in category.Media)
                {
                    var mediaModel = new MediaModel
                    {
                        Name        = media.Name,
                        DateAdded   = media.DateAdded,
                        RelativeUrl = media.RelativeUrl.Value
                    };

                    categoryModel.Media.Add(mediaModel);
                }

                streamingProviderModel.Categories.Add(categoryModel);
            }

            System.IO.File.WriteAllText(
                $"{streamingProviderModel.Type.ToLower()}-data.json",
                JsonConvert.SerializeObject(streamingProviderModel, Formatting.Indented));
        }
示例#2
0
 public virtual void Initialize(DataSource dataSource, StreamingProvider streamingProvider, OrderProcessor orderProcessor, IStatusReporter connectionStatus)
 {
     this.DataSource        = dataSource;
     this.StreamingProvider = streamingProvider;
     this.OrderProcessor    = orderProcessor;
     this.StatusReporter    = connectionStatus;
     this.AccountAutoPropagate.Initialize(this);
 }
示例#3
0
        public StreamingProvider Scrape()
        {
            Login();

            Thread.Sleep(2000);

            var streamingProviderIdentity = new StreamingProviderIdentity(StreamingProviderType.NowTv);
            var streamingProvider         = new StreamingProvider(streamingProviderIdentity);

            AddCategories(streamingProvider);

            return(streamingProvider);
        }
示例#4
0
        private void AddCategories(StreamingProvider streamingProvider)
        {
            var categoryPage = new CategoryPageModel(_webDriver, _settings.BaseUrl);

            categoryPage.NavigateTo();

            var categories = categoryPage.GetCategories();

            foreach (var category in categories)
            {
                var mediaCategory = categoryPage.GetCategory(category.Name);
                streamingProvider.AddCategory(mediaCategory);
            }
        }
        public void PopulateStaticStreamingBrokerListViewsFromDataSource()
        {
            if (base.IsDisposed)
            {
                string msg = "base.IsDisposed=true for DataSourceEditorForm::PopulateStaticStreamingBrokerListViewsFromDataSource()";
                Assembler.PopupException(msg);
                return;
            }

            this.lvStaticProviders.Items.Clear();
            foreach (StaticProvider staticProviderPrototype in StaticProvidersByName.Values)
            {
                try {
                    StaticProvider staticProviderEditingInstance = null;                        // staticProviderPrototype;
                    if (ds.StaticProvider != null && ds.StaticProvider.GetType().FullName == staticProviderPrototype.GetType().FullName)
                    {
                        staticProviderEditingInstance = ds.StaticProvider;
                    }
                    // I still want to get a new instance, so if user choses it, I'll Initialize() it and put into serialize-able DataSource
                    if (staticProviderEditingInstance == null)
                    {
                        staticProviderEditingInstance = (StaticProvider)Activator.CreateInstance(staticProviderPrototype.GetType());
                    }
                    ListViewItem lvi = new ListViewItem()
                    {
                        Text = staticProviderEditingInstance.Name,
                        Name = staticProviderEditingInstance.GetType().Name,
                        Tag  = staticProviderEditingInstance
                    };
                    if (staticProviderEditingInstance.Icon != null)
                    {
                        this.imglStaticProviders.Images.Add(staticProviderEditingInstance.Icon);
                        lvi.ImageIndex = this.imglStaticProviders.Images.Count - 1;
                    }
                    this.lvStaticProviders.Items.Add(lvi);
                } catch (Exception e) {
                    this.assemblerInstance.StatusReporter.PopupException(e);
                    return;
                }
            }

            this.lvStreamingProviders.Items.Clear();
            ListViewItem lviAbsentStreaming = new ListViewItem()
            {
                Text = StreamingProvider.NO_STREAMING_PROVIDER,
                Name = StreamingProvider.NO_STREAMING_PROVIDER,
            };

            this.lvStreamingProviders.Items.Add(lviAbsentStreaming);
            foreach (StreamingProvider streamingProviderPrototype in StreamingProvidersByName.Values)
            {
                try {
                    StreamingProvider streamingProviderInstance = null;                         // streamingProviderPrototype;
                    if (ds.StreamingProvider != null && ds.StreamingProvider.GetType().FullName == streamingProviderPrototype.GetType().FullName)
                    {
                        streamingProviderInstance = ds.StreamingProvider;
                    }
                    // I still want to get a new instance, so if user choses it, I'll Initialize() it and put into serialize-able DataSource
                    if (streamingProviderInstance == null)
                    {
                        streamingProviderInstance = (StreamingProvider)Activator.CreateInstance(streamingProviderPrototype.GetType());
                    }

                    if (streamingProviderInstance.EditorInstanceInitialized == false)
                    {
                        try {
                            streamingProviderInstance.StreamingEditorInitialize(this);
                        } catch (Exception e) {
                            string msg = "can't initialize streamingProviderInstance[" + streamingProviderInstance + "]";
                            this.assemblerInstance.StatusReporter.PopupException(new Exception(msg, e));
                            return;
                        }
                    }

                    ListViewItem lvi = new ListViewItem()
                    {
                        Text = streamingProviderInstance.Name,
                        Name = streamingProviderInstance.GetType().Name,
                        Tag  = streamingProviderInstance
                    };
                    if (streamingProviderInstance.Icon != null)
                    {
                        this.imglStreamingProviders.Images.Add(streamingProviderInstance.Icon);
                        lvi.ImageIndex = this.imglStreamingProviders.Images.Count - 1;
                    }
                    this.lvStreamingProviders.Items.Add(lvi);
                } catch (Exception e) {
                    this.assemblerInstance.StatusReporter.PopupException(e);
                    return;
                }
            }

            this.lvBrokerProviders.Items.Clear();
            ListViewItem lviAbsentBroker = new ListViewItem()
            {
                Text = BrokerProvider.NO_BROKER_PROVIDER,
                Name = BrokerProvider.NO_BROKER_PROVIDER,
            };

            this.lvBrokerProviders.Items.Add(lviAbsentBroker);
            foreach (BrokerProvider brokerProviderPrototype in BrokerProvidersByName.Values)
            {
                try {
                    BrokerProvider brokerProviderInstance = null;                       // brokerProviderPrototype;
                    if (ds.BrokerProvider != null && ds.BrokerProvider.GetType().FullName == brokerProviderPrototype.GetType().FullName)
                    {
                        brokerProviderInstance = ds.BrokerProvider;
                    }
                    // I still want to get a new instance, so if user choses it, I'll Initialize() it and put into serialize-able DataSource
                    if (brokerProviderInstance == null)
                    {
                        brokerProviderInstance = (BrokerProvider)Activator.CreateInstance(brokerProviderPrototype.GetType());
                    }

                    if (brokerProviderInstance.EditorInstanceInitialized == false)
                    {
                        try {
                            brokerProviderInstance.BrokerEditorInitialize(this);
                        } catch (Exception e) {
                            string msg = "can't initialize brokerProviderInstance[" + brokerProviderInstance + "]";
                            this.assemblerInstance.StatusReporter.PopupException(new Exception(msg, e));
                            return;
                        }
                    }

                    //if (this.DataSource == null) return;	//changing market for ASCII DataProvider
                    //this.DataSource.DataSourceManager.DataSourceSaveTreeviewRefill(this.DataSource);


                    ListViewItem lvi = new ListViewItem()
                    {
                        Text = brokerProviderInstance.Name,
                        Name = brokerProviderInstance.GetType().Name,
                        Tag  = brokerProviderInstance
                    };
                    if (brokerProviderInstance.Icon != null)
                    {
                        this.imglBrokerProviders.Images.Add(brokerProviderInstance.Icon);
                        lvi.ImageIndex = this.imglBrokerProviders.Images.Count - 1;
                    }
                    this.lvBrokerProviders.Items.Add(lvi);
                } catch (Exception e) {
                    this.assemblerInstance.StatusReporter.PopupException(e);
                    return;
                }
            }
        }