public void LoadingTest() { var feed = OpdsFeed.Load(new XmlTextReader("http://m.gutenberg.org/ebooks/?format=opds")); Assert.IsNotNull(feed); Assert.IsInstanceOfType(feed, typeof(OpdsFeed)); }
public void LoadingDetailPageTest() { var feed = OpdsFeed.Load(new XmlTextReader("http://m.gutenberg.org/ebooks/22945.opds")); Assert.IsNotNull(feed); Assert.IsInstanceOfType(feed, typeof(OpdsFeed)); Assert.IsInstanceOfType(feed.Items.First(), typeof(OpdsItem)); }
public void FindLinkTest() { var feed = OpdsFeed.Load(new XmlTextReader("http://m.gutenberg.org/ebooks/?format=opds")); Assert.AreEqual("/ebooks.opds/", feed.FindLink("self").Uri.ToString()); Assert.AreEqual("http://m.gutenberg.org/catalog/osd-books.xml", feed.FindLink("search").Uri.ToString()); feed = OpdsFeed.Load(new XmlTextReader("http://m.gutenberg.org/ebooks/search.opds/?sort_order=downloads")); Assert.AreEqual("/ebooks/search.opds/?sort_order=downloads&start_index=26", feed.FindLink("next").Uri.ToString()); }
private void OnOpdsLoaderDoWork(object sender, DoWorkEventArgs e) { try { e.Result = OpdsFeed.Load(new XmlTextReader(e.Argument as string)); } catch (XmlException) { e.Result = new OpdsFeed(new[] { OpdsItem.Load(new XmlTextReader(e.Argument as string)) }); } }
public void FacetGroupTest() { var feed = OpdsFeed.Load(new XmlTextReader("http://www.feedbooks.com/books/catalog.atom")); var facetGroups = feed.FacetGroups.ToList(); Assert.IsTrue(facetGroups.Count > 1); foreach (var group in facetGroups) { Assert.IsNotNull(group.Key); Assert.IsTrue(group.Count() > 0); } }
/// <summary> /// /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult Search(string id) { var request = new FSSearchRequest(MvcApplication.Current.FileSystemBookFolder) { PageIndex = 1, PageSize = 10, OrderDirection = true, OrderBy = "LastUpdatedTime", KeyWord = String.Format("*{0}*", id), }; var feed = new OpdsFeed(MvcApplication.Current.OpdsDataConverter.GetItems(request.Process()).Items.Select(i => i.Value)); return(Content(feed.ToXml(), "text/xml")); }
public void LoadFeedWithBase64EncodedImage() { var feed = OpdsFeed.Load(new XmlTextReader("http://m.gutenberg.org/ebooks/search.opds/?sort_order=downloads&start_index=1")); Assert.IsTrue(feed.Items.Count() > 0); var entry = feed.Items.FirstOrDefault(); Assert.IsNotNull(entry); Assert.IsTrue(entry.Links.Count > 0); var link = entry.Links.FirstOrDefault(l => l.RelationshipType == OpdsRelations.Thumbnail); Assert.IsNotNull(link); Assert.AreEqual("http", link.Uri.Scheme); }
/// <summary> /// /// </summary> /// <returns></returns> public ActionResult Category(string id) { var request = new DataItemsRequest() { Id = id, PageIndex = 1, PageSize = 10, }; var items = DbOpdsData.GetItems(request).Items.OrderByDescending(i => i.Value.LastUpdatedTime); var feed = new OpdsFeed(items.Select(i => i.Value)); feed.SearchUri = WebRequestHelper.CurrentHostUri + "/Opds/Search/{keyword}"; return(Content(feed.ToXml(), "text/xml")); }
/// <summary> /// /// </summary> /// <returns></returns> public ActionResult Category(string id) { var request = new FSCategoryRequest(MvcApplication.Current.FileSystemBookFolder) { Id = id, PageIndex = 1, PageSize = 10, OrderDirection = true, OrderBy = "LastUpdatedTime", }; var feed = new OpdsFeed(MvcApplication.Current.OpdsDataConverter.GetItems(request.Process()).Items.Select(i => i.Value)); feed.SearchUri = WebRequestHelper.CurrentHostUri + "/FS/Search/{keyword}"; return(Content(feed.ToXml(), "text/xml")); }
/// <summary> /// Gets a feed from a Uri. /// </summary> private void GetFeed(bool withCache = true, bool withHistory = true) { try { IsLoading = true; if (withCache && opdsManager.CanFromCache(_CurrentUrl)) { OpdsFeed temp = null; Task.Factory.StartNew(() => { temp = opdsManager.ConvertFeed(_CurrentUrl); }).ContinueWith(ant => { Content = temp; IsLoading = false; if (withHistory) { _History.Add(_CurrentUrl); HistoryView.MoveCurrentTo(_CurrentUrl); } //updates UI no problem as we are using correct SynchronizationContext }, TaskScheduler.FromCurrentSynchronizationContext()); } else { WebClient client = CreateWebClient(); client.OpenReadCompleted += new OpenReadCompletedEventHandler(Client_OpenReadCompleted); client.OpenReadAsync(_CurrentUrl, new AsyncFeedParam() { currentUri = _CurrentUrl, withHisto = withHistory, clientWeb = client }); } } catch (Exception err) { LogHelper.Manage("FeedViewModel.GetFeed", err); } }