Skip to content

Commit 4f40651

Browse files
committed
Use YoutubeChannelLinkHandlerFactory
1 parent 4ff6553 commit 4f40651

3 files changed

Lines changed: 13 additions & 4 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.schabi.newpipe.extractor.exceptions.ParsingException;
1313
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
1414
import org.schabi.newpipe.extractor.localization.TimeAgoParser;
15+
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory;
1516
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingHelper;
1617
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
1718
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
@@ -50,8 +51,6 @@
5051

5152
@SuppressWarnings("WeakerAccess")
5253
public class YoutubeChannelExtractor extends ChannelExtractor {
53-
/*package-private*/ static final String CHANNEL_URL_BASE = "https://www.youtube.com/channel/";
54-
5554
private JsonObject initialData;
5655
private JsonObject videoTab;
5756

@@ -96,7 +95,7 @@ public String getNextPageUrl() throws ExtractionException {
9695
@Override
9796
public String getUrl() throws ParsingException {
9897
try {
99-
return CHANNEL_URL_BASE + getId();
98+
return YoutubeChannelLinkHandlerFactory.getInstance().getUrl("channel/" + getId());
10099
} catch (ParsingException e) {
101100
return super.getUrl();
102101
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.schabi.newpipe.extractor.localization.TimeAgoParser;
2222
import org.schabi.newpipe.extractor.localization.TimeAgoPatternsManager;
2323
import org.schabi.newpipe.extractor.services.youtube.ItagItem;
24+
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeChannelLinkHandlerFactory;
2425
import org.schabi.newpipe.extractor.services.youtube.linkHandler.YoutubeParsingHelper;
2526
import org.schabi.newpipe.extractor.stream.AudioStream;
2627
import org.schabi.newpipe.extractor.stream.Description;
@@ -328,7 +329,8 @@ public String getUploaderUrl() throws ParsingException {
328329
} catch (Exception ignored) {}
329330
try {
330331
String uploaderId = playerResponse.getObject("videoDetails").getString("channelId");
331-
if (uploaderId != null) return "https://www.youtube.com/channel/" + uploaderId;
332+
if (uploaderId != null)
333+
return YoutubeChannelLinkHandlerFactory.getInstance().getUrl("channel/" + uploaderId);
332334
} catch (Exception ignored) {}
333335
throw new ParsingException("Could not get uploader url");
334336
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/linkHandler/YoutubeChannelLinkHandlerFactory.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ public static YoutubeChannelLinkHandlerFactory getInstance() {
3535
return instance;
3636
}
3737

38+
/**
39+
* Returns URL to channel from an ID
40+
*
41+
* @param id Channel ID including e.g. 'channel/'
42+
* @param contentFilters
43+
* @param searchFilter
44+
* @return URL to channel
45+
*/
3846
@Override
3947
public String getUrl(String id, List<String> contentFilters, String searchFilter) {
4048
return "https://www.youtube.com/" + id;

0 commit comments

Comments
 (0)