Skip to content

Commit 9e53cf0

Browse files
committed
Fix parameter reassignment and other style issues
Also remove left-behind debug statement
1 parent 3fe55b3 commit 9e53cf0

4 files changed

Lines changed: 17 additions & 18 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/StreamingService.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,18 +279,18 @@ public CommentsExtractor getCommentsExtractor(String url) throws ExtractionExcep
279279
* @param url the url on which it should be decided of which link type it is
280280
* @return the link type of url
281281
*/
282-
public final LinkType getLinkTypeByUrl(String url) throws ParsingException {
283-
url = Utils.followGoogleRedirectIfNeeded(url);
282+
public final LinkType getLinkTypeByUrl(final String url) throws ParsingException {
283+
final String polishedUrl = Utils.followGoogleRedirectIfNeeded(url);
284284

285285
final LinkHandlerFactory sH = getStreamLHFactory();
286286
final LinkHandlerFactory cH = getChannelLHFactory();
287287
final LinkHandlerFactory pH = getPlaylistLHFactory();
288288

289-
if (sH != null && sH.acceptUrl(url)) {
289+
if (sH != null && sH.acceptUrl(polishedUrl)) {
290290
return LinkType.STREAM;
291-
} else if (cH != null && cH.acceptUrl(url)) {
291+
} else if (cH != null && cH.acceptUrl(polishedUrl)) {
292292
return LinkType.CHANNEL;
293-
} else if (pH != null && pH.acceptUrl(url)) {
293+
} else if (pH != null && pH.acceptUrl(polishedUrl)) {
294294
return LinkType.PLAYLIST;
295295
} else {
296296
return LinkType.NONE;

extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandlerFactory.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,10 @@ public String getUrl(String id, String baseUrl) throws ParsingException {
4949
* @param url the url to extract path and id from
5050
* @return a {@link LinkHandler} complete with information
5151
*/
52-
public LinkHandler fromUrl(String url) throws ParsingException {
53-
if (url == null) throw new IllegalArgumentException("url can not be null");
54-
url = Utils.followGoogleRedirectIfNeeded(url);
55-
final String baseUrl = Utils.getBaseUrl(url);
56-
return fromUrl(url, baseUrl);
52+
public LinkHandler fromUrl(final String url) throws ParsingException {
53+
final String polishedUrl = Utils.followGoogleRedirectIfNeeded(url);
54+
final String baseUrl = Utils.getBaseUrl(polishedUrl);
55+
return fromUrl(polishedUrl, baseUrl);
5756
}
5857

5958
/**

extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/ListLinkHandlerFactory.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ public String getUrl(String id, List<String> contentFilter, String sortFilter, S
3131
///////////////////////////////////
3232

3333
@Override
34-
public ListLinkHandler fromUrl(String url) throws ParsingException {
35-
url = Utils.followGoogleRedirectIfNeeded(url);
36-
final String baseUrl = Utils.getBaseUrl(url);
37-
return fromUrl(url, baseUrl);
34+
public ListLinkHandler fromUrl(final String url) throws ParsingException {
35+
final String polishedUrl = Utils.followGoogleRedirectIfNeeded(url);
36+
final String baseUrl = Utils.getBaseUrl(polishedUrl);
37+
return fromUrl(polishedUrl, baseUrl);
3838
}
3939

4040
@Override

extractor/src/main/java/org/schabi/newpipe/extractor/utils/Utils.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -181,15 +181,15 @@ public static String removeUTF8BOM(String s) {
181181
return s;
182182
}
183183

184-
public static String getBaseUrl(String url) throws ParsingException {
184+
public static String getBaseUrl(final String url) throws ParsingException {
185185
try {
186186
final URL uri = stringToURL(url);
187187
return uri.getProtocol() + "://" + uri.getAuthority();
188-
} catch (MalformedURLException e) {
188+
} catch (final MalformedURLException e) {
189189
final String message = e.getMessage();
190190
if (message.startsWith("unknown protocol: ")) {
191-
System.out.println(message.substring(18));
192-
return message.substring(18); // return just the protocol (e.g. vnd.youtube)
191+
// return just the protocol (e.g. vnd.youtube)
192+
return message.substring("unknown protocol: ".length());
193193
}
194194

195195
throw new ParsingException("Malformed url: " + url, e);

0 commit comments

Comments
 (0)