mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2025-04-29 08:20:34 +05:30
Merge pull request #1015 from AudricV/yt_fix-channel-id-rss-feeds
[YouTube] Fix channel ID extraction of YouTube channels RSS feeds
This commit is contained in:
commit
3519d4c367
@ -22,6 +22,8 @@ import java.io.IOException;
|
|||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class YoutubeFeedExtractor extends FeedExtractor {
|
public class YoutubeFeedExtractor extends FeedExtractor {
|
||||||
|
private static final String WEBSITE_CHANNEL_BASE_URL = "https://www.youtube.com/channel/";
|
||||||
|
|
||||||
public YoutubeFeedExtractor(final StreamingService service, final ListLinkHandler linkHandler) {
|
public YoutubeFeedExtractor(final StreamingService service, final ListLinkHandler linkHandler) {
|
||||||
super(service, linkHandler);
|
super(service, linkHandler);
|
||||||
}
|
}
|
||||||
@ -57,19 +59,40 @@ public class YoutubeFeedExtractor extends FeedExtractor {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getId() {
|
public String getId() {
|
||||||
return document.getElementsByTag("yt:channelId").first().text();
|
return getUrl().replace(WEBSITE_CHANNEL_BASE_URL, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return document.select("feed > author > uri").first().text();
|
final Element authorUriElement = document.select("feed > author > uri")
|
||||||
|
.first();
|
||||||
|
if (authorUriElement != null) {
|
||||||
|
final String authorUriElementText = authorUriElement.text();
|
||||||
|
if (!authorUriElementText.equals("")) {
|
||||||
|
return authorUriElementText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final Element linkElement = document.select("feed > link[rel*=alternate]")
|
||||||
|
.first();
|
||||||
|
if (linkElement != null) {
|
||||||
|
return linkElement.attr("href");
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
return document.select("feed > author > name").first().text();
|
final Element nameElement = document.select("feed > author > name")
|
||||||
|
.first();
|
||||||
|
if (nameElement == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
return nameElement.text();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
x
Reference in New Issue
Block a user