Skip to content

Commit afef926

Browse files
committed
Make some items serializable and fix channel feed url
1 parent 08457de commit afef926

5 files changed

Lines changed: 23 additions & 24 deletions

File tree

AbstractStreamInfo.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@
1818
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
1919
*/
2020

21+
import java.io.Serializable;
22+
2123
/**Common properties between StreamInfo and StreamInfoItem.*/
22-
public abstract class AbstractStreamInfo {
24+
public abstract class AbstractStreamInfo implements Serializable{
2325
public enum StreamType {
2426
NONE, // placeholder to check if stream type was checked or not
2527
VIDEO_STREAM,

InfoItem.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.schabi.newpipe.extractor;
22

3+
import java.io.Serializable;
4+
35
/**
46
* Created by the-scrabi on 11.02.17.
57
*
@@ -20,7 +22,7 @@
2022
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
2123
*/
2224

23-
public interface InfoItem {
25+
public interface InfoItem extends Serializable{
2426
public enum InfoType {
2527
STREAM,
2628
PLAYLIST,

channel/ChannelInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
import org.schabi.newpipe.extractor.InfoItem;
44
import org.schabi.newpipe.extractor.exceptions.ParsingException;
5-
import org.schabi.newpipe.extractor.stream_info.StreamInfoItem;
65
import org.schabi.newpipe.extractor.stream_info.StreamInfoItemCollector;
76

7+
import java.io.Serializable;
88
import java.util.List;
99
import java.util.Vector;
1010

@@ -28,7 +28,7 @@
2828
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
2929
*/
3030

31-
public class ChannelInfo {
31+
public class ChannelInfo implements Serializable{
3232
public void addException(Exception e) {
3333
errors.add(e);
3434
}

services/youtube/YoutubeChannelExtractor.java

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
import org.schabi.newpipe.extractor.stream_info.StreamInfoItemCollector;
1919
import org.schabi.newpipe.extractor.stream_info.StreamInfoItemExtractor;
2020

21-
2221
import java.io.IOException;
2322

2423
/**
@@ -46,19 +45,20 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
4645
private static final String TAG = YoutubeChannelExtractor.class.toString();
4746

4847
// private CSSOMParser cssParser = new CSSOMParser(new SACParserCSS3());
48+
private static final String CHANNEL_FEED_BASE = "https://www.youtube.com/feeds/videos.xml?channel_id=";
4949

5050
private Document doc = null;
5151

5252
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;
5959
// the fist page is html all other pages are ajax. Every new page can be requested by sending
6060
// this request url.
61-
private static String nextPageUrl = "";
61+
private String nextPageUrl = "";
6262

6363
public YoutubeChannelExtractor(UrlIdHandler urlIdHandler, String url, int page, int serviceId)
6464
throws ExtractionException, IOException {
@@ -318,13 +318,8 @@ public long getSubscriberCount() throws ParsingException {
318318
@Override
319319
public String getFeedUrl() throws ParsingException {
320320
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;
328323
return feedUrl;
329324
} catch(Exception e) {
330325
throw new ParsingException("Could not get feed url", e);

services/youtube/YoutubePlayListExtractor.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ public class YoutubePlayListExtractor extends PlayListExtractor {
2525
private Document doc = null;
2626

2727
private boolean isAjaxPage = false;
28-
private static String name = "";
29-
private static String feedUrl = "";
30-
private static String avatarUrl = "";
31-
private static String bannerUrl = "";
32-
private static String nextPageUrl = "";
28+
private String name = "";
29+
private String feedUrl = "";
30+
private String avatarUrl = "";
31+
private String bannerUrl = "";
32+
private String nextPageUrl = "";
3333

3434
public YoutubePlayListExtractor(UrlIdHandler urlIdHandler,
3535
String url, int page, int serviceId) throws IOException, ExtractionException {

0 commit comments

Comments
 (0)