|
18 | 18 | import org.schabi.newpipe.extractor.stream_info.StreamInfoItemCollector; |
19 | 19 | import org.schabi.newpipe.extractor.stream_info.StreamInfoItemExtractor; |
20 | 20 |
|
21 | | - |
22 | 21 | import java.io.IOException; |
23 | 22 |
|
24 | 23 | /** |
@@ -46,19 +45,20 @@ public class YoutubeChannelExtractor extends ChannelExtractor { |
46 | 45 | private static final String TAG = YoutubeChannelExtractor.class.toString(); |
47 | 46 |
|
48 | 47 | // 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 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; |
| 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; |
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 static String nextPageUrl = ""; |
| 61 | + private String nextPageUrl = ""; |
62 | 62 |
|
63 | 63 | public YoutubeChannelExtractor(UrlIdHandler urlIdHandler, String url, int page, int serviceId) |
64 | 64 | throws ExtractionException, IOException { |
@@ -318,13 +318,8 @@ public long getSubscriberCount() throws ParsingException { |
318 | 318 | @Override |
319 | 319 | public String getFeedUrl() throws ParsingException { |
320 | 320 | try { |
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 | | - } |
| 321 | + String channelId = doc.getElementsByClass("yt-uix-subscription-button").first().attr("data-channel-external-id"); |
| 322 | + feedUrl = CHANNEL_FEED_BASE + channelId; |
328 | 323 | return feedUrl; |
329 | 324 | } catch(Exception e) { |
330 | 325 | throw new ParsingException("Could not get feed url", e); |
|
0 commit comments