11package org .schabi .newpipe .extractor .services .peertube ;
22
3+ import static org .schabi .newpipe .extractor .StreamingService .ServiceInfo .MediaCapability .COMMENTS ;
4+ import static org .schabi .newpipe .extractor .StreamingService .ServiceInfo .MediaCapability .VIDEO ;
5+ import static java .util .Arrays .asList ;
6+
37import org .schabi .newpipe .extractor .StreamingService ;
48import org .schabi .newpipe .extractor .channel .ChannelExtractor ;
59import org .schabi .newpipe .extractor .comments .CommentsExtractor ;
610import org .schabi .newpipe .extractor .exceptions .ExtractionException ;
7- import org .schabi .newpipe .extractor .kiosk .KioskExtractor ;
811import org .schabi .newpipe .extractor .kiosk .KioskList ;
9- import org .schabi .newpipe .extractor .linkhandler .*;
12+ import org .schabi .newpipe .extractor .linkhandler .LinkHandler ;
13+ import org .schabi .newpipe .extractor .linkhandler .LinkHandlerFactory ;
14+ import org .schabi .newpipe .extractor .linkhandler .ListLinkHandler ;
15+ import org .schabi .newpipe .extractor .linkhandler .ListLinkHandlerFactory ;
16+ import org .schabi .newpipe .extractor .linkhandler .SearchQueryHandler ;
17+ import org .schabi .newpipe .extractor .linkhandler .SearchQueryHandlerFactory ;
1018import org .schabi .newpipe .extractor .playlist .PlaylistExtractor ;
1119import org .schabi .newpipe .extractor .search .SearchExtractor ;
12- import org .schabi .newpipe .extractor .services .peertube .extractors .*;
13- import org .schabi .newpipe .extractor .services .peertube .linkHandler .*;
20+ import org .schabi .newpipe .extractor .services .peertube .extractors .PeertubeAccountExtractor ;
21+ import org .schabi .newpipe .extractor .services .peertube .extractors .PeertubeChannelExtractor ;
22+ import org .schabi .newpipe .extractor .services .peertube .extractors .PeertubeCommentsExtractor ;
23+ import org .schabi .newpipe .extractor .services .peertube .extractors .PeertubePlaylistExtractor ;
24+ import org .schabi .newpipe .extractor .services .peertube .extractors .PeertubeSearchExtractor ;
25+ import org .schabi .newpipe .extractor .services .peertube .extractors .PeertubeStreamExtractor ;
26+ import org .schabi .newpipe .extractor .services .peertube .extractors .PeertubeSuggestionExtractor ;
27+ import org .schabi .newpipe .extractor .services .peertube .extractors .PeertubeTrendingExtractor ;
28+ import org .schabi .newpipe .extractor .services .peertube .linkHandler .PeertubeChannelLinkHandlerFactory ;
29+ import org .schabi .newpipe .extractor .services .peertube .linkHandler .PeertubeCommentsLinkHandlerFactory ;
30+ import org .schabi .newpipe .extractor .services .peertube .linkHandler .PeertubePlaylistLinkHandlerFactory ;
31+ import org .schabi .newpipe .extractor .services .peertube .linkHandler .PeertubeSearchQueryHandlerFactory ;
32+ import org .schabi .newpipe .extractor .services .peertube .linkHandler .PeertubeStreamLinkHandlerFactory ;
33+ import org .schabi .newpipe .extractor .services .peertube .linkHandler .PeertubeTrendingLinkHandlerFactory ;
1434import org .schabi .newpipe .extractor .stream .StreamExtractor ;
1535import org .schabi .newpipe .extractor .subscription .SubscriptionExtractor ;
1636import org .schabi .newpipe .extractor .suggestion .SuggestionExtractor ;
1737
1838import java .util .List ;
1939
20- import static java .util .Arrays .asList ;
21- import static org .schabi .newpipe .extractor .StreamingService .ServiceInfo .MediaCapability .COMMENTS ;
22- import static org .schabi .newpipe .extractor .StreamingService .ServiceInfo .MediaCapability .VIDEO ;
23-
2440public class PeertubeService extends StreamingService {
2541
2642 private PeertubeInstance instance ;
2743
28- public PeertubeService (int id ) {
29- this (id , PeertubeInstance .defaultInstance );
44+ public PeertubeService (final int id ) {
45+ this (id , PeertubeInstance .DEFAULT_INSTANCE );
3046 }
3147
32- public PeertubeService (int id , PeertubeInstance instance ) {
48+ public PeertubeService (final int id , final PeertubeInstance instance ) {
3349 super (id , "PeerTube" , asList (VIDEO , COMMENTS ));
3450 this .instance = instance ;
3551 }
@@ -60,13 +76,10 @@ public ListLinkHandlerFactory getCommentsLHFactory() {
6076 }
6177
6278 @ Override
63- public SearchExtractor getSearchExtractor (SearchQueryHandler queryHandler ) {
79+ public SearchExtractor getSearchExtractor (final SearchQueryHandler queryHandler ) {
6480 final List <String > contentFilters = queryHandler .getContentFilters ();
65- boolean external = false ;
66- if (!contentFilters .isEmpty () && contentFilters .get (0 ).startsWith ("sepia_" )) {
67- external = true ;
68- }
69- return new PeertubeSearchExtractor (this , queryHandler , external );
81+ return new PeertubeSearchExtractor (this , queryHandler ,
82+ !contentFilters .isEmpty () && contentFilters .get (0 ).startsWith ("sepia_" ));
7083 }
7184
7285 @ Override
@@ -80,7 +93,7 @@ public SubscriptionExtractor getSubscriptionExtractor() {
8093 }
8194
8295 @ Override
83- public ChannelExtractor getChannelExtractor (ListLinkHandler linkHandler )
96+ public ChannelExtractor getChannelExtractor (final ListLinkHandler linkHandler )
8497 throws ExtractionException {
8598
8699 if (linkHandler .getUrl ().contains ("/video-channels/" )) {
@@ -91,19 +104,19 @@ public ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler)
91104 }
92105
93106 @ Override
94- public PlaylistExtractor getPlaylistExtractor (ListLinkHandler linkHandler )
107+ public PlaylistExtractor getPlaylistExtractor (final ListLinkHandler linkHandler )
95108 throws ExtractionException {
96109 return new PeertubePlaylistExtractor (this , linkHandler );
97110 }
98111
99112 @ Override
100- public StreamExtractor getStreamExtractor (LinkHandler linkHandler )
113+ public StreamExtractor getStreamExtractor (final LinkHandler linkHandler )
101114 throws ExtractionException {
102115 return new PeertubeStreamExtractor (this , linkHandler );
103116 }
104117
105118 @ Override
106- public CommentsExtractor getCommentsExtractor (ListLinkHandler linkHandler )
119+ public CommentsExtractor getCommentsExtractor (final ListLinkHandler linkHandler )
107120 throws ExtractionException {
108121 return new PeertubeCommentsExtractor (this , linkHandler );
109122 }
@@ -117,34 +130,31 @@ public PeertubeInstance getInstance() {
117130 return this .instance ;
118131 }
119132
120- public void setInstance (PeertubeInstance instance ) {
133+ public void setInstance (final PeertubeInstance instance ) {
121134 this .instance = instance ;
122135 }
123136
124137 @ Override
125138 public KioskList getKioskList () throws ExtractionException {
126- KioskList .KioskExtractorFactory kioskFactory = new KioskList .KioskExtractorFactory () {
127- @ Override
128- public KioskExtractor createNewKiosk (StreamingService streamingService ,
129- String url ,
130- String id )
131- throws ExtractionException {
132- return new PeertubeTrendingExtractor (PeertubeService .this ,
133- new PeertubeTrendingLinkHandlerFactory ().fromId (id ), id );
134- }
135- };
136-
137- KioskList list = new KioskList (this );
139+ final KioskList .KioskExtractorFactory kioskFactory = (streamingService , url , id ) ->
140+ new PeertubeTrendingExtractor (
141+ PeertubeService .this ,
142+ new PeertubeTrendingLinkHandlerFactory ().fromId (id ),
143+ id
144+ );
145+
146+ final KioskList list = new KioskList (this );
138147
139148 // add kiosks here e.g.:
140149 final PeertubeTrendingLinkHandlerFactory h = new PeertubeTrendingLinkHandlerFactory ();
141150 try {
142151 list .addKioskEntry (kioskFactory , h , PeertubeTrendingLinkHandlerFactory .KIOSK_TRENDING );
143- list .addKioskEntry (kioskFactory , h , PeertubeTrendingLinkHandlerFactory .KIOSK_MOST_LIKED );
152+ list .addKioskEntry (kioskFactory , h ,
153+ PeertubeTrendingLinkHandlerFactory .KIOSK_MOST_LIKED );
144154 list .addKioskEntry (kioskFactory , h , PeertubeTrendingLinkHandlerFactory .KIOSK_RECENT );
145155 list .addKioskEntry (kioskFactory , h , PeertubeTrendingLinkHandlerFactory .KIOSK_LOCAL );
146156 list .setDefaultKiosk (PeertubeTrendingLinkHandlerFactory .KIOSK_TRENDING );
147- } catch (Exception e ) {
157+ } catch (final Exception e ) {
148158 throw new ExtractionException (e );
149159 }
150160
0 commit comments