|
18 | 18 | import org.schabi.newpipe.extractor.stream_info.StreamInfoItemCollector; |
19 | 19 | import org.schabi.newpipe.extractor.stream_info.StreamInfoItemExtractor; |
20 | 20 |
|
| 21 | + |
21 | 22 | import java.io.IOException; |
22 | 23 |
|
23 | 24 | /** |
@@ -45,20 +46,19 @@ public class YoutubeChannelExtractor extends ChannelExtractor { |
45 | 46 | private static final String TAG = YoutubeChannelExtractor.class.toString(); |
46 | 47 |
|
47 | 48 | // private CSSOMParser cssParser = new CSSOMParser(new SACParserCSS3()); |
48 | | - private static final String CHANNEL_FEED_BASE = "https://www.youtube.com/feeds/videos.xml?channel_id="; |
49 | 49 |
|
50 | 50 | private Document doc = null; |
51 | 51 |
|
52 | 52 | private boolean isAjaxPage = false; |
53 | | - private String userUrl = ""; |
54 | | - private String channelName = ""; |
55 | | - private String avatarUrl = ""; |
56 | | - private String bannerUrl = ""; |
57 | | - private String feedUrl = ""; |
58 | | - private long subscriberCount = -1; |
| 53 | + private static String userUrl = ""; |
| 54 | + private static String channelName = ""; |
| 55 | + private static String avatarUrl = ""; |
| 56 | + private static String bannerUrl = ""; |
| 57 | + private static String feedUrl = ""; |
| 58 | + private static long subscriberCount = -1; |
59 | 59 | // the fist page is html all other pages are ajax. Every new page can be requested by sending |
60 | 60 | // this request url. |
61 | | - private String nextPageUrl = ""; |
| 61 | + private static String nextPageUrl = ""; |
62 | 62 |
|
63 | 63 | public YoutubeChannelExtractor(UrlIdHandler urlIdHandler, String url, int page, int serviceId) |
64 | 64 | throws ExtractionException, IOException { |
@@ -318,8 +318,13 @@ public long getSubscriberCount() throws ParsingException { |
318 | 318 | @Override |
319 | 319 | public String getFeedUrl() throws ParsingException { |
320 | 320 | try { |
321 | | - String channelId = doc.getElementsByClass("yt-uix-subscription-button").first().attr("data-channel-external-id"); |
322 | | - feedUrl = CHANNEL_FEED_BASE + channelId; |
| 321 | + if(userUrl.contains("channel")) { |
| 322 | + //channels don't have feeds in youtube, only user can provide such |
| 323 | + return ""; |
| 324 | + } |
| 325 | + if(!isAjaxPage) { |
| 326 | + feedUrl = doc.select("link[title=\"RSS\"]").first().attr("abs:href"); |
| 327 | + } |
323 | 328 | return feedUrl; |
324 | 329 | } catch(Exception e) { |
325 | 330 | throw new ParsingException("Could not get feed url", e); |
|
0 commit comments