From b3d1bbc44d1b2cbc9d2b4f66b52bd531e8f69e86 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Thu, 22 Feb 2018 19:17:23 +0100 Subject: [PATCH] add basic extractor/collector pattern --- ...Everything.md => 00_Prepare_everything.md} | 6 ++-- docs/01_Basic_concept_of_the_extractor.md | 33 +++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) rename docs/{00_PrepareEverything.md => 00_Prepare_everything.md} (90%) create mode 100644 docs/01_Basic_concept_of_the_extractor.md diff --git a/docs/00_PrepareEverything.md b/docs/00_Prepare_everything.md similarity index 90% rename from docs/00_PrepareEverything.md rename to docs/00_Prepare_everything.md index d3eaf0c..ac09540 100644 --- a/docs/00_PrepareEverything.md +++ b/docs/00_Prepare_everything.md @@ -1,8 +1,8 @@ # Prepare everything -Welcome to the NewPipe tutorial. This tutorial will guide you through the process of creating your own NewPipeExtractor service -with which NewPipe will gain support for a dedicated streaming service like YouTube, Vimeo or SournCloud. -Let's dive right. ;D +Welcome to the NewPipe tutorial. This tutorial will guide you through the process of creating your own NewPipeExtractor +service with which NewPipe will gain support for a dedicated streaming service like YouTube, Vimeo or SournCloud. Let's +dive right. ;D ## Setup your dev environment diff --git a/docs/01_Basic_concept_of_the_extractor.md b/docs/01_Basic_concept_of_the_extractor.md new file mode 100644 index 0000000..7bfb1f6 --- /dev/null +++ b/docs/01_Basic_concept_of_the_extractor.md @@ -0,0 +1,33 @@ +# Basic Concept of the Extractor + +## Collector/Extractor pattern + +Before we can start coding our own service we need to understand the basic concept of the extractor. There is a pattern +you will find all over the code. It is called to __extractor/collector__ pattern. The idea behind this pattern is that +the [extractor](https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/Extractor.html) +would produce single peaces of data, and the collector would take it and form usable data for the front end out of it. +The collector also controls the parsing process, and takes care about error handling. So if the extractor fails at any +point the collector will decide weather it should continue parsing or not. This requires the extractor to be made out of +many small methods. One method for every data field the collector wants to have. The collectors are provided by NewPipe. +You need to take care of the extractors. + +### Usage in the front end + +So typical call for retrieving data from a website would look like this: +```java +Info info; +try { + Extractor extractor = new Extractor(ome_meta_info); // Create a new Extractor with a given context provided as parameter. + info = Info.getInfo(extractor); // Retrieves the data form extractor and builds info package. +} catch(Exception e) { + // handler errors when collector decided to break up extraction +} +``` + + + + + + + +