newpipe-documentation/docs/03_Implement_a_service.md

5.4 KiB

Implement a service

Services or better service connectors are the parts of NewPipe which communicative with an actual service like YouTube. This Page will describe how you can implement and add your own. Please make sure you red and understand the Concept of Extractors and the Concept of LinkHandler before implementing your own Service.

Allowed Libraries

The NewPipe Extractor already comes a long with a lot of usable tools and external libraries that should make extracting easy. For some specific (tiny) tasks regex is allowed. Here you can take a look at the Parser, which will give you a little help with that. Use Regex with care!!! Avoid it as often as possible. It's better to ask us to introduce a new library than start using regex to often.

If you need to introduce new libraries please tell us before you do it.

Head of Service

First of all if you want to create a new service you should create a new package below org.schabi.newpipe.services , with the name of your service as package name. Here you must put an implementation of these two classes:

StreamingService is a factory class that will return objects of all important parts of your service. Every extractor Kisok, Info type you add, and which should be part of your implementation must be instantiated using an instance of this class.

ServiceInfo will return some meta information about your service. Such as the name, the capabilities, and your name as well as your email address for further notice and maintenance issues. Remember, after extending this class you need to return an instance of it by through your implementation of StreamingService.getServiceInfo().

When these two classes are extended by you, you need to add them to the ServiceList of NewPipe. This way the will become an official part of the NewPipe Extractor. Every service has an ID, which will be set when this list gets created. You set this Id by entering it in the constructor. So when adding your service just give it the ID of the previously last service in the list incremented by one.

Stream

Channel

Playlist

Kiosk