2018-09-01 13:48:12 +00:00
<!DOCTYPE html>
<!-- [if IE 8]><html class="no - js lt - ie9" lang="en" > <![endif] -->
<!-- [if gt IE 8]><! --> < html class = "no-js" lang = "en" > <!-- <![endif] -->
< head >
< meta charset = "utf-8" >
< meta http-equiv = "X-UA-Compatible" content = "IE=edge" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
< link rel = "shortcut icon" href = "../img/favicon.ico" >
< title > Concept of LinkHandler - NewPipe Documentation< / title >
2018-09-08 17:06:35 +00:00
<!-- local fonts -->
2018-09-01 13:48:12 +00:00
< link rel = "stylesheet" href = "../css/local_fonts.css" type = "text/css" / >
< link rel = "stylesheet" href = "../css/theme.css" type = "text/css" / >
< link rel = "stylesheet" href = "../css/theme_extra.css" type = "text/css" / >
2018-09-08 17:06:35 +00:00
<!-- local code syntax highlighting -->
< link rel = "stylesheet" href = "../css/github.min.css" type = "text/css" / >
2018-09-01 13:48:12 +00:00
< link rel = "stylesheet" href = "../css/highlight.css" type = "text/css" / >
< script >
// Current page data
var mkdocs_page_name = "Concept of LinkHandler";
var mkdocs_page_input_path = "02_Concept_of_LinkHandler.md";
var mkdocs_page_url = null;
< / script >
< script src = "../js/jquery-2.1.1.min.js" defer > < / script >
< script src = "../js/modernizr-2.8.3.min.js" defer > < / script >
2018-09-08 17:06:35 +00:00
< script src = "../js/highlight.min.js" > < / script >
2018-09-01 13:48:12 +00:00
< script > hljs . initHighlightingOnLoad ( ) ; < / script >
< / head >
< body class = "wy-body-for-nav" role = "document" >
< div class = "wy-grid-for-nav" >
< nav data-toggle = "wy-nav-shift" class = "wy-nav-side stickynav" >
< div class = "wy-side-nav-search" >
< a href = ".." class = "icon icon-home" > NewPipe Documentation< / a >
< div role = "search" >
< form id = "rtd-search-form" class = "wy-form" action = "../search.html" method = "get" >
< input type = "text" name = "q" placeholder = "Search docs" title = "Type search term here" / >
< / form >
< / div >
< / div >
< div class = "wy-menu wy-menu-vertical" data-spy = "affix" role = "navigation" aria-label = "main navigation" >
< ul class = "current" >
< li class = "toctree-l1" >
< a class = "" href = ".." > Welcome to the NewPipe Documentaiton.< / a >
< / li >
< li class = "toctree-l1" >
< a class = "" href = "../00_Prepare_everything/" > Prepare everything< / a >
< / li >
< li class = "toctree-l1" >
< a class = "" href = "../01_Concept_of_the_extractor/" > Concept of the Extractor< / a >
< / li >
< li class = "toctree-l1 current" >
< a class = "current" href = "./" > Concept of LinkHandler< / a >
< ul class = "subnav" >
< li class = "toctree-l2" > < a href = "#concept-of-linkhandler" > Concept of LinkHandler< / a > < / li >
2018-09-08 17:06:35 +00:00
< ul >
< li > < a class = "toctree-l3" href = "#importand-notes-about-linkhandler" > Importand notes about LinkHandler:< / a > < / li >
< li > < a class = "toctree-l3" href = "#usage" > Usage< / a > < / li >
< li > < a class = "toctree-l3" href = "#implementation" > Implementation< / a > < / li >
< li > < a class = "toctree-l3" href = "#listlinkhandler-and-querylinkhandler" > ListLinkHandler and QueryLinkHandler< / a > < / li >
< / ul >
2018-09-01 13:48:12 +00:00
< / ul >
< / li >
< / ul >
< / div >
< / nav >
< section data-toggle = "wy-nav-shift" class = "wy-nav-content-wrap" >
< nav class = "wy-nav-top" role = "navigation" aria-label = "top navigation" >
< i data-toggle = "wy-nav-top" class = "fa fa-bars" > < / i >
< a href = ".." > NewPipe Documentation< / a >
< / nav >
< div class = "wy-nav-content" >
< div class = "rst-content" >
< div role = "navigation" aria-label = "breadcrumbs navigation" >
< ul class = "wy-breadcrumbs" >
< li > < a href = ".." > Docs< / a > » < / li >
< li > Concept of LinkHandler< / li >
< li class = "wy-breadcrumbs-aside" >
< / li >
< / ul >
< hr / >
< / div >
< div role = "main" >
< div class = "section" >
< h1 id = "concept-of-linkhandler" > Concept of LinkHandler< / h1 >
2018-09-08 17:06:35 +00:00
< p > < a href = "https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/linkhandler/LinkHandler.html" > LinkHandler< / a >
represent Links to resources like videos, search requests, channels, etc.
The idea behind them is that a video can have multiple links pointig to it, but it has
one unique id that represents it, like this example:< / p >
< p > < a href = "https://www.youtube.com/watch?v=oHg5SJYRHA0" > oHg5SJYRHA0< / a > can be represented as:< / p >
< ul >
< li > https://www.youtube.com/watch?v=oHg5SJYRHA0 (default url for youtube)< / li >
< li > https://youtu.be/oHg5SJYRHA0< / li >
< li > https://m.youtube.com/watch?v=oHg5SJYRHA0< / li >
< / ul >
< h3 id = "importand-notes-about-linkhandler" > Importand notes about LinkHandler:< / h3 >
< ul >
< li > A simple < code > LinkHandler< / code > will contain the default URL, the ID and the original url.< / li >
< li > < code > LinkHandler< / code > are ReadOnly< / li >
< li > LinkHandler are also used to determine which part of the extractor can handle a certain link.< / li >
< li > In order to get one you must either call
< a href = "https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/linkhandler/LinkHandlerFactory.html#fromUrl-java.lang.String-" > fromUrl()< / a > or < a href = "https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/linkhandler/LinkHandlerFactory.html#fromId-java.lang.String-" > fromId()< / a > of the the coresponding < code > LinkHandlerFactory< / code > .< / li >
< li > Every type of Type of Resource has its own LinkHandlerFactory. Eg. YoutubeStreamLinkHandler, YoutubeChannelLinkHandler, etc.< / li >
< / ul >
< h3 id = "usage" > Usage< / h3 >
< p > So the typical Usage for getting a LinkHandler would look like this.< / p >
< pre > < code class = "java" > LinkHandlerFactory myLinkHandlerFactory = new MyStreamLinkHandlerFactory();
LinkHandler myVideo = myLinkHandlerFactory.fromUrl(" https://my.service.com/the_video" );
< / code > < / pre >
< h3 id = "implementation" > Implementation< / h3 >
< p > In order to Use LinkHandler for your service you must override the apropriate LinkHandlerFactory. eg:< / p >
< pre > < code class = "java" > class MyStreamLinkHandlerFactory extends LinkHandlerFactory {
@Override
public String getId(String url) throws ParsingException {
// Return the ID based on the url.
}
@Override
public String getUrl(String id) throws ParsingException {
// Return the url based on the id given.
}
@Override
public boolean onAcceptUrl(String url) throws ParsingException {
// Return true if this LinkHanlderFactory can handle this type of link
}
}
< / code > < / pre >
< h3 id = "listlinkhandler-and-querylinkhandler" > ListLinkHandler and QueryLinkHandler< / h3 >
< p > List based resources like channels and playlists can be sorted, for example by date, name, or by a certain name.
Therefore these type of resources don't just use a LinkHandler, but an extention called
< a href = "https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/linkhandler/ListLinkHandler.html" > ListLinkHandler< / a > < / p >
2018-09-01 13:48:12 +00:00
< / div >
< / div >
< footer >
< div class = "rst-footer-buttons" role = "navigation" aria-label = "footer navigation" >
< a href = "../01_Concept_of_the_extractor/" class = "btn btn-neutral" title = "Concept of the Extractor" > < span class = "icon icon-circle-arrow-left" > < / span > Previous< / a >
< / div >
< hr / >
< div role = "contentinfo" >
<!-- Copyright etc -->
< / div >
Built with < a href = "http://www.mkdocs.org" > MkDocs< / a > using a < a href = "https://github.com/snide/sphinx_rtd_theme" > theme< / a > provided by < a href = "https://readthedocs.org" > Read the Docs< / a > .
< / footer >
< / div >
< / div >
< / section >
< / div >
< div class = "rst-versions" role = "note" style = "cursor: pointer" >
< span class = "rst-current-version" data-toggle = "rst-current-version" >
< span > < a href = "../01_Concept_of_the_extractor/" style = "color: #fcfcfc;" > « Previous< / a > < / span >
< / span >
< / div >
< script > var base _url = '..' ; < / script >
< script src = "../js/theme.js" defer > < / script >
< script src = "../search/main.js" defer > < / script >
< / body >
< / html >