|
18 | 18 | import org.schabi.newpipe.extractor.search.SearchExtractor; |
19 | 19 | import org.schabi.newpipe.extractor.stream.StreamExtractor; |
20 | 20 | import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor; |
| 21 | +import org.schabi.newpipe.extractor.utils.Localization; |
21 | 22 |
|
22 | 23 | public abstract class StreamingService { |
23 | 24 | public static class ServiceInfo { |
@@ -83,56 +84,115 @@ public String toString() { |
83 | 84 | //////////////////////////////////////////// |
84 | 85 | // Extractor |
85 | 86 | //////////////////////////////////////////// |
86 | | - public abstract SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler, String contentCountry); |
87 | | - public abstract SuggestionExtractor getSuggestionExtractor(); |
| 87 | + public abstract SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler, Localization localization); |
| 88 | + public abstract SuggestionExtractor getSuggestionExtractor(Localization localization); |
88 | 89 | public abstract SubscriptionExtractor getSubscriptionExtractor(); |
89 | | - public abstract KioskList getKioskList() throws ExtractionException; |
| 90 | + public abstract KioskList getKioskList(Localization localization) throws ExtractionException; |
| 91 | + |
| 92 | + public abstract ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler, |
| 93 | + Localization localization) throws ExtractionException; |
| 94 | + public abstract PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler, |
| 95 | + Localization localization) throws ExtractionException; |
| 96 | + public abstract StreamExtractor getStreamExtractor(LinkHandler linkHandler, |
| 97 | + Localization localization) throws ExtractionException; |
| 98 | + public abstract CommentsExtractor getCommentsExtractor(ListLinkHandler linkHandler, |
| 99 | + Localization localization) throws ExtractionException; |
| 100 | + //////////////////////////////////////////// |
| 101 | + // Extractor with default localization |
| 102 | + //////////////////////////////////////////// |
90 | 103 |
|
91 | | - public abstract ChannelExtractor getChannelExtractor(ListLinkHandler urlIdHandler) throws ExtractionException; |
92 | | - public abstract PlaylistExtractor getPlaylistExtractor(ListLinkHandler urlIdHandler) throws ExtractionException; |
93 | | - public abstract StreamExtractor getStreamExtractor(LinkHandler UIHFactory) throws ExtractionException; |
94 | | - public abstract CommentsExtractor getCommentsExtractor(ListLinkHandler urlIdHandler) throws ExtractionException; |
95 | | - public abstract boolean isCommentsSupported(); |
| 104 | + public SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler) { |
| 105 | + return getSearchExtractor(queryHandler, NewPipe.getLocalization()); |
| 106 | + } |
| 107 | + |
| 108 | + public SuggestionExtractor getSuggestionExtractor() { |
| 109 | + return getSuggestionExtractor(NewPipe.getLocalization()); |
| 110 | + } |
| 111 | + |
| 112 | + public KioskList getKioskList() throws ExtractionException { |
| 113 | + return getKioskList(NewPipe.getLocalization()); |
| 114 | + } |
| 115 | + |
| 116 | + public ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler) throws ExtractionException { |
| 117 | + return getChannelExtractor(linkHandler, NewPipe.getLocalization()); |
| 118 | + } |
| 119 | + |
| 120 | + public PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler) throws ExtractionException { |
| 121 | + return getPlaylistExtractor(linkHandler, NewPipe.getLocalization()); |
| 122 | + } |
| 123 | + |
| 124 | + public StreamExtractor getStreamExtractor(LinkHandler linkHandler) throws ExtractionException { |
| 125 | + return getStreamExtractor(linkHandler, NewPipe.getLocalization()); |
| 126 | + } |
96 | 127 |
|
97 | | - public SearchExtractor getSearchExtractor(String query, List<String> contentFilter, String sortFilter, String contentCountry) throws ExtractionException { |
98 | | - return getSearchExtractor(getSearchQHFactory().fromQuery(query, contentFilter, sortFilter), contentCountry); |
| 128 | + public CommentsExtractor getCommentsExtractor(ListLinkHandler urlIdHandler) throws ExtractionException { |
| 129 | + return getCommentsExtractor(urlIdHandler, NewPipe.getLocalization()); |
| 130 | + } |
| 131 | + |
| 132 | + //////////////////////////////////////////// |
| 133 | + // Extractor without link handler |
| 134 | + //////////////////////////////////////////// |
| 135 | + |
| 136 | + public SearchExtractor getSearchExtractor(String query, |
| 137 | + List<String> contentFilter, |
| 138 | + String sortFilter, |
| 139 | + Localization localization) throws ExtractionException { |
| 140 | + return getSearchExtractor(getSearchQHFactory() |
| 141 | + .fromQuery(query, |
| 142 | + contentFilter, |
| 143 | + sortFilter), |
| 144 | + localization); |
99 | 145 | } |
100 | 146 |
|
101 | | - public ChannelExtractor getChannelExtractor(String id, List<String> contentFilter, String sortFilter) throws ExtractionException { |
102 | | - return getChannelExtractor(getChannelLHFactory().fromQuery(id, contentFilter, sortFilter)); |
| 147 | + public ChannelExtractor getChannelExtractor(String id, |
| 148 | + List<String> contentFilter, |
| 149 | + String sortFilter, |
| 150 | + Localization localization) throws ExtractionException { |
| 151 | + return getChannelExtractor(getChannelLHFactory().fromQuery(id, contentFilter, sortFilter), localization); |
103 | 152 | } |
104 | 153 |
|
105 | | - public PlaylistExtractor getPlaylistExtractor(String id, List<String> contentFilter, String sortFilter) throws ExtractionException { |
106 | | - return getPlaylistExtractor(getPlaylistLHFactory().fromQuery(id, contentFilter, sortFilter)); |
| 154 | + public PlaylistExtractor getPlaylistExtractor(String id, |
| 155 | + List<String> contentFilter, |
| 156 | + String sortFilter, |
| 157 | + Localization localization) throws ExtractionException { |
| 158 | + return getPlaylistExtractor(getPlaylistLHFactory() |
| 159 | + .fromQuery(id, |
| 160 | + contentFilter, |
| 161 | + sortFilter), |
| 162 | + localization); |
107 | 163 | } |
108 | 164 |
|
109 | | - public SearchExtractor getSearchExtractor(String query, String contentCountry) throws ExtractionException { |
110 | | - return getSearchExtractor(getSearchQHFactory().fromQuery(query), contentCountry); |
| 165 | + //////////////////////////////////////////// |
| 166 | + // Short extractor without localization |
| 167 | + //////////////////////////////////////////// |
| 168 | + |
| 169 | + public SearchExtractor getSearchExtractor(String query) throws ExtractionException { |
| 170 | + return getSearchExtractor(getSearchQHFactory().fromQuery(query), NewPipe.getLocalization()); |
111 | 171 | } |
112 | 172 |
|
113 | 173 | public ChannelExtractor getChannelExtractor(String url) throws ExtractionException { |
114 | | - return getChannelExtractor(getChannelLHFactory().fromUrl(url)); |
| 174 | + return getChannelExtractor(getChannelLHFactory().fromUrl(url), NewPipe.getLocalization()); |
115 | 175 | } |
116 | 176 |
|
117 | 177 | public PlaylistExtractor getPlaylistExtractor(String url) throws ExtractionException { |
118 | | - return getPlaylistExtractor(getPlaylistLHFactory().fromUrl(url)); |
| 178 | + return getPlaylistExtractor(getPlaylistLHFactory().fromUrl(url), NewPipe.getLocalization()); |
119 | 179 | } |
120 | 180 |
|
121 | 181 | public StreamExtractor getStreamExtractor(String url) throws ExtractionException { |
122 | | - return getStreamExtractor(getStreamLHFactory().fromUrl(url)); |
| 182 | + return getStreamExtractor(getStreamLHFactory().fromUrl(url), NewPipe.getLocalization()); |
123 | 183 | } |
124 | 184 |
|
125 | 185 | public CommentsExtractor getCommentsExtractor(String url) throws ExtractionException { |
126 | 186 | ListLinkHandlerFactory llhf = getCommentsLHFactory(); |
127 | 187 | if(null == llhf) { |
128 | 188 | return null; |
129 | 189 | } |
130 | | - return getCommentsExtractor(llhf.fromUrl(url)); |
| 190 | + return getCommentsExtractor(llhf.fromUrl(url), NewPipe.getLocalization()); |
131 | 191 | } |
132 | 192 |
|
| 193 | + public abstract boolean isCommentsSupported(); |
133 | 194 |
|
134 | 195 |
|
135 | | - |
136 | 196 |
|
137 | 197 | /** |
138 | 198 | * figure out where the link is pointing to (a channel, video, playlist, etc.) |
|
0 commit comments