Use YoutubeChannelLinkHandlerFactory
This commit is contained in:
parent
4ff655352d
commit
4f406512c2
|
@ -12,6 +12,7 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
|||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
||||
import org.schabi.newpipe.extractor.localization.TimeAgoParser;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingHelper;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
||||
|
@ -50,8 +51,6 @@ import static org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeP
|
|||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class YoutubeChannelExtractor extends ChannelExtractor {
|
||||
/*package-private*/ static final String CHANNEL_URL_BASE = "https://www.youtube.com/channel/";
|
||||
|
||||
private JsonObject initialData;
|
||||
private JsonObject videoTab;
|
||||
|
||||
|
@ -96,7 +95,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
@Override
|
||||
public String getUrl() throws ParsingException {
|
||||
try {
|
||||
return CHANNEL_URL_BASE + getId();
|
||||
return YoutubeChannelLinkHandlerFactory.getInstance().getUrl("channel/" + getId());
|
||||
} catch (ParsingException e) {
|
||||
return super.getUrl();
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ import org.schabi.newpipe.extractor.localization.Localization;
|
|||
import org.schabi.newpipe.extractor.localization.TimeAgoParser;
|
||||
import org.schabi.newpipe.extractor.localization.TimeAgoPatternsManager;
|
||||
import org.schabi.newpipe.extractor.services.youtube.ItagItem;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory;
|
||||
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingHelper;
|
||||
import org.schabi.newpipe.extractor.stream.AudioStream;
|
||||
import org.schabi.newpipe.extractor.stream.Description;
|
||||
|
@ -328,7 +329,8 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
} catch (Exception ignored) {}
|
||||
try {
|
||||
String uploaderId = playerResponse.getObject("videoDetails").getString("channelId");
|
||||
if (uploaderId != null) return "https://www.youtube.com/channel/" + uploaderId;
|
||||
if (uploaderId != null)
|
||||
return YoutubeChannelLinkHandlerFactory.getInstance().getUrl("channel/" + uploaderId);
|
||||
} catch (Exception ignored) {}
|
||||
throw new ParsingException("Could not get uploader url");
|
||||
}
|
||||
|
|
|
@ -35,6 +35,14 @@ public class YoutubeChannelLinkHandlerFactory extends ListLinkHandlerFactory {
|
|||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns URL to channel from an ID
|
||||
*
|
||||
* @param id Channel ID including e.g. 'channel/'
|
||||
* @param contentFilters
|
||||
* @param searchFilter
|
||||
* @return URL to channel
|
||||
*/
|
||||
@Override
|
||||
public String getUrl(String id, List<String> contentFilters, String searchFilter) {
|
||||
return "https://www.youtube.com/" + id;
|
||||
|
|
Loading…
Reference in New Issue