Example #1
0
        private async void FetchContributors(XElement episode, ReduxEntities data, string pid)
        {
            XNamespace ion          = "http://bbc.co.uk/2008/iplayer/ion";
            var        contributors = episode.Elements(ion + "blocklist")
                                      .Elements(ion + "episode_detail")
                                      .Elements(ion + "contributors")
                                      .Elements(ion + "contributor");
            var ctx = new ReduxEntities();

            foreach (var contributor in contributors)
            {
                var ct = new contributor
                {
                    character_name = contributor.Element(ion + "character_name").Value,
                    family_name    = contributor.Element(ion + "family_name").Value,
                    given_name     = contributor.Element(ion + "given_name").Value,
                    role           = contributor.Element(ion + "role").Value,
                    role_name      = contributor.Element(ion + "role_name").Value,
                    type           = contributor.Element(ion + "type").Value,
                    contributor_id = Convert.ToInt32(contributor.Element(ion + "id").Value),
                    pid            = pid
                };
                Debug.WriteLine("{0} {1} {2} {3} {4} {5} {6}", ct.character_name, ct.contributor_id, ct.family_name, ct.given_name, ct.role, ct.role_name, ct.type);
                ctx.contributors.AddObject(ct);
            }
            ctx.SaveChanges();
            //data.SaveChanges();
        }
Example #2
0
        private void FetchContributors(XElement episode, ReduxEntities data, string pid)
        {
            XNamespace ion          = "http://bbc.co.uk/2008/iplayer/ion";
            var        contributors = episode.Elements(ion + "blocklist")
                                      .Elements(ion + "episode_detail")
                                      .Elements(ion + "contributors")
                                      .Elements(ion + "contributor");

            foreach (var contributor in contributors)
            {
                var ct = new contributor
                {
                    character_name = contributor.Element(ion + "character_name").Value,
                    family_name    = contributor.Element(ion + "family_name").Value,
                    given_name     = contributor.Element(ion + "given_name").Value,
                    role           = contributor.Element(ion + "role").Value,
                    role_name      = contributor.Element(ion + "role_name").Value,
                    type           = contributor.Element(ion + "type").Value,
                    contributor_id = Convert.ToInt32(contributor.Element(ion + "id").Value),
                    pid            = pid
                };
                data.AddObject("contributors", ct);
            }
            //data.SaveChanges();
        }
Example #3
0
        private async Task FetchItemGenreAndIonAsync(scan_pips_contributors item, Thumbnail thumbnail, IProgress progress, bool isTags, bool isIonContributors, bool isCategories)
        {
            if (progress.IsCancelled)
            {
                return;
            }
            thumbnail.ShowImage("http://node2.bbcimg.co.uk/iplayer/images/episode/" + item.pid + "_314_176.jpg");

            try
            {
                if (isTags || isIonContributors)
                {
                    WebClient client = new WebClient();
                    string    result = await client.DownloadStringTaskAsync("http://www.bbc.co.uk/iplayer/ion/episodedetail/episode/" + item.pid + "/format/xml");

                    XElement   episode = XElement.Parse(result);
                    XNamespace ion     = "http://bbc.co.uk/2008/iplayer/ion";
                    if (isIonContributors)
                    {
                        await TaskEx.Run(() =>
                        {
                            var contributors = episode.Elements(ion + "blocklist")
                                               .Elements(ion + "episode_detail")
                                               .Elements(ion + "contributors")
                                               .Elements(ion + "contributor");
                            var data = new ReduxEntities();
                            foreach (var contributor in contributors)
                            {
                                var ct = new contributor
                                {
                                    character_name = contributor.Element(ion + "character_name").Value,
                                    family_name    = contributor.Element(ion + "family_name").Value,
                                    given_name     = contributor.Element(ion + "given_name").Value,
                                    role           = contributor.Element(ion + "role").Value,
                                    role_name      = contributor.Element(ion + "role_name").Value,
                                    type           = contributor.Element(ion + "type").Value,
                                    contributor_id = Convert.ToInt32(contributor.Element(ion + "id").Value),
                                    pid            = item.pid
                                };
                                data.AddObject("contributors", ct);
                            }
                            data.SaveChanges();
                        });
                    }
                    if (isTags)
                    {
                        await TaskEx.Run(() =>
                        {
                            var tags = episode.Elements(ion + "blocklist")
                                       .Elements(ion + "episode_detail")
                                       .Elements(ion + "tag_schemes")
                                       .Elements(ion + "tag_scheme")
                                       .Elements(ion + "tags")
                                       .Elements(ion + "tag");
                            var data = new ReduxEntities();
                            foreach (var tag in tags)
                            {
                                var tg = new tag
                                {
                                    tag_id = tag.Element(ion + "id").Value,
                                    name   = tag.Element(ion + "name").Value,
                                    value  = tag.Element(ion + "value").Value,
                                    pid    = item.pid
                                };
                                data.AddObject("tags", tg);
                            }
                            data.SaveChanges();
                        });
                    }
                }
                if (isCategories)
                {
                    WebClient catClient = new WebClient();
                    var       catresult = await catClient.DownloadStringTaskAsync("http://www.bbc.co.uk/programmes/" + item.pid + ".xml");

                    var root = XElement.Parse(catresult);

                    await TaskEx.Run(() =>
                    {
                        var cats = from cat in root.XPathSelectElements("categories/category[@type != 'genre']")
                                   select new category()
                        {
                            pid    = item.pid,
                            type   = cat.Attribute("type").Value,
                            catkey = cat.Attribute("key").Value,
                            title  = cat.Element("title").Value
                        };
                        var db = new ReduxEntities();
                        foreach (var c in cats)
                        {
                            db.AddObject("categories", c);
                        }
                        db.SaveChanges();
                    });
                }
                item.scanned = true;
            }
            catch (WebException wex)
            {
                MessageBox.Show("Can't find programme " + item.pid);
                //throw new Exception("Couldn't find programme " + item.pid, wex);
            }
        }