Revert some changes

This commit is contained in:
Mauricio Colli 2017-04-21 18:31:40 -03:00
parent afef926844
commit 5907c35dfb
2 changed files with 20 additions and 15 deletions

View File

@ -18,6 +18,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.stream_info.StreamInfoItemCollector; import org.schabi.newpipe.extractor.stream_info.StreamInfoItemCollector;
import org.schabi.newpipe.extractor.stream_info.StreamInfoItemExtractor; import org.schabi.newpipe.extractor.stream_info.StreamInfoItemExtractor;
import java.io.IOException; import java.io.IOException;
/** /**
@ -45,20 +46,19 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
private static final String TAG = YoutubeChannelExtractor.class.toString(); private static final String TAG = YoutubeChannelExtractor.class.toString();
// private CSSOMParser cssParser = new CSSOMParser(new SACParserCSS3()); // private CSSOMParser cssParser = new CSSOMParser(new SACParserCSS3());
private static final String CHANNEL_FEED_BASE = "https://www.youtube.com/feeds/videos.xml?channel_id=";
private Document doc = null; private Document doc = null;
private boolean isAjaxPage = false; private boolean isAjaxPage = false;
private String userUrl = ""; private static String userUrl = "";
private String channelName = ""; private static String channelName = "";
private String avatarUrl = ""; private static String avatarUrl = "";
private String bannerUrl = ""; private static String bannerUrl = "";
private String feedUrl = ""; private static String feedUrl = "";
private long subscriberCount = -1; private static long subscriberCount = -1;
// the fist page is html all other pages are ajax. Every new page can be requested by sending // the fist page is html all other pages are ajax. Every new page can be requested by sending
// this request url. // this request url.
private String nextPageUrl = ""; private static String nextPageUrl = "";
public YoutubeChannelExtractor(UrlIdHandler urlIdHandler, String url, int page, int serviceId) public YoutubeChannelExtractor(UrlIdHandler urlIdHandler, String url, int page, int serviceId)
throws ExtractionException, IOException { throws ExtractionException, IOException {
@ -318,8 +318,13 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
@Override @Override
public String getFeedUrl() throws ParsingException { public String getFeedUrl() throws ParsingException {
try { try {
String channelId = doc.getElementsByClass("yt-uix-subscription-button").first().attr("data-channel-external-id"); if(userUrl.contains("channel")) {
feedUrl = CHANNEL_FEED_BASE + channelId; //channels don't have feeds in youtube, only user can provide such
return "";
}
if(!isAjaxPage) {
feedUrl = doc.select("link[title=\"RSS\"]").first().attr("abs:href");
}
return feedUrl; return feedUrl;
} catch(Exception e) { } catch(Exception e) {
throw new ParsingException("Could not get feed url", e); throw new ParsingException("Could not get feed url", e);

View File

@ -25,11 +25,11 @@ public class YoutubePlayListExtractor extends PlayListExtractor {
private Document doc = null; private Document doc = null;
private boolean isAjaxPage = false; private boolean isAjaxPage = false;
private String name = ""; private static String name = "";
private String feedUrl = ""; private static String feedUrl = "";
private String avatarUrl = ""; private static String avatarUrl = "";
private String bannerUrl = ""; private static String bannerUrl = "";
private String nextPageUrl = ""; private static String nextPageUrl = "";
public YoutubePlayListExtractor(UrlIdHandler urlIdHandler, public YoutubePlayListExtractor(UrlIdHandler urlIdHandler,
String url, int page, int serviceId) throws IOException, ExtractionException { String url, int page, int serviceId) throws IOException, ExtractionException {