mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-14 22:30:33 +05:30
Fix parameter reassignment and other style issues
Also remove left-behind debug statement
This commit is contained in:
parent
3fe55b30ba
commit
9e53cf0b56
@ -279,18 +279,18 @@ public abstract class StreamingService {
|
|||||||
* @param url the url on which it should be decided of which link type it is
|
* @param url the url on which it should be decided of which link type it is
|
||||||
* @return the link type of url
|
* @return the link type of url
|
||||||
*/
|
*/
|
||||||
public final LinkType getLinkTypeByUrl(String url) throws ParsingException {
|
public final LinkType getLinkTypeByUrl(final String url) throws ParsingException {
|
||||||
url = Utils.followGoogleRedirectIfNeeded(url);
|
final String polishedUrl = Utils.followGoogleRedirectIfNeeded(url);
|
||||||
|
|
||||||
final LinkHandlerFactory sH = getStreamLHFactory();
|
final LinkHandlerFactory sH = getStreamLHFactory();
|
||||||
final LinkHandlerFactory cH = getChannelLHFactory();
|
final LinkHandlerFactory cH = getChannelLHFactory();
|
||||||
final LinkHandlerFactory pH = getPlaylistLHFactory();
|
final LinkHandlerFactory pH = getPlaylistLHFactory();
|
||||||
|
|
||||||
if (sH != null && sH.acceptUrl(url)) {
|
if (sH != null && sH.acceptUrl(polishedUrl)) {
|
||||||
return LinkType.STREAM;
|
return LinkType.STREAM;
|
||||||
} else if (cH != null && cH.acceptUrl(url)) {
|
} else if (cH != null && cH.acceptUrl(polishedUrl)) {
|
||||||
return LinkType.CHANNEL;
|
return LinkType.CHANNEL;
|
||||||
} else if (pH != null && pH.acceptUrl(url)) {
|
} else if (pH != null && pH.acceptUrl(polishedUrl)) {
|
||||||
return LinkType.PLAYLIST;
|
return LinkType.PLAYLIST;
|
||||||
} else {
|
} else {
|
||||||
return LinkType.NONE;
|
return LinkType.NONE;
|
||||||
|
@ -49,11 +49,10 @@ public abstract class LinkHandlerFactory {
|
|||||||
* @param url the url to extract path and id from
|
* @param url the url to extract path and id from
|
||||||
* @return a {@link LinkHandler} complete with information
|
* @return a {@link LinkHandler} complete with information
|
||||||
*/
|
*/
|
||||||
public LinkHandler fromUrl(String url) throws ParsingException {
|
public LinkHandler fromUrl(final String url) throws ParsingException {
|
||||||
if (url == null) throw new IllegalArgumentException("url can not be null");
|
final String polishedUrl = Utils.followGoogleRedirectIfNeeded(url);
|
||||||
url = Utils.followGoogleRedirectIfNeeded(url);
|
final String baseUrl = Utils.getBaseUrl(polishedUrl);
|
||||||
final String baseUrl = Utils.getBaseUrl(url);
|
return fromUrl(polishedUrl, baseUrl);
|
||||||
return fromUrl(url, baseUrl);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,10 +31,10 @@ public abstract class ListLinkHandlerFactory extends LinkHandlerFactory {
|
|||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ListLinkHandler fromUrl(String url) throws ParsingException {
|
public ListLinkHandler fromUrl(final String url) throws ParsingException {
|
||||||
url = Utils.followGoogleRedirectIfNeeded(url);
|
final String polishedUrl = Utils.followGoogleRedirectIfNeeded(url);
|
||||||
final String baseUrl = Utils.getBaseUrl(url);
|
final String baseUrl = Utils.getBaseUrl(polishedUrl);
|
||||||
return fromUrl(url, baseUrl);
|
return fromUrl(polishedUrl, baseUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -181,15 +181,15 @@ public class Utils {
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String getBaseUrl(String url) throws ParsingException {
|
public static String getBaseUrl(final String url) throws ParsingException {
|
||||||
try {
|
try {
|
||||||
final URL uri = stringToURL(url);
|
final URL uri = stringToURL(url);
|
||||||
return uri.getProtocol() + "://" + uri.getAuthority();
|
return uri.getProtocol() + "://" + uri.getAuthority();
|
||||||
} catch (MalformedURLException e) {
|
} catch (final MalformedURLException e) {
|
||||||
final String message = e.getMessage();
|
final String message = e.getMessage();
|
||||||
if (message.startsWith("unknown protocol: ")) {
|
if (message.startsWith("unknown protocol: ")) {
|
||||||
System.out.println(message.substring(18));
|
// return just the protocol (e.g. vnd.youtube)
|
||||||
return message.substring(18); // return just the protocol (e.g. vnd.youtube)
|
return message.substring("unknown protocol: ".length());
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new ParsingException("Malformed url: " + url, e);
|
throw new ParsingException("Malformed url: " + url, e);
|
||||||
|
Loading…
Reference in New Issue
Block a user