Make some items serializable and fix channel feed url

This commit is contained in:
Mauricio Colli 2017-04-21 09:11:14 -03:00
parent 08457de763
commit afef926844
5 changed files with 23 additions and 24 deletions

View File

@ -18,8 +18,10 @@ package org.schabi.newpipe.extractor;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>. * along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/ */
import java.io.Serializable;
/**Common properties between StreamInfo and StreamInfoItem.*/ /**Common properties between StreamInfo and StreamInfoItem.*/
public abstract class AbstractStreamInfo { public abstract class AbstractStreamInfo implements Serializable{
public enum StreamType { public enum StreamType {
NONE, // placeholder to check if stream type was checked or not NONE, // placeholder to check if stream type was checked or not
VIDEO_STREAM, VIDEO_STREAM,

View File

@ -1,5 +1,7 @@
package org.schabi.newpipe.extractor; package org.schabi.newpipe.extractor;
import java.io.Serializable;
/** /**
* Created by the-scrabi on 11.02.17. * Created by the-scrabi on 11.02.17.
* *
@ -20,7 +22,7 @@ package org.schabi.newpipe.extractor;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>. * along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/ */
public interface InfoItem { public interface InfoItem extends Serializable{
public enum InfoType { public enum InfoType {
STREAM, STREAM,
PLAYLIST, PLAYLIST,

View File

@ -2,9 +2,9 @@ package org.schabi.newpipe.extractor.channel;
import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.stream_info.StreamInfoItem;
import org.schabi.newpipe.extractor.stream_info.StreamInfoItemCollector; import org.schabi.newpipe.extractor.stream_info.StreamInfoItemCollector;
import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Vector; import java.util.Vector;
@ -28,7 +28,7 @@ import java.util.Vector;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>. * along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/ */
public class ChannelInfo { public class ChannelInfo implements Serializable{
public void addException(Exception e) { public void addException(Exception e) {
errors.add(e); errors.add(e);
} }

View File

@ -18,7 +18,6 @@ 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;
/** /**
@ -46,19 +45,20 @@ 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 static String userUrl = ""; private String userUrl = "";
private static String channelName = ""; private String channelName = "";
private static String avatarUrl = ""; private String avatarUrl = "";
private static String bannerUrl = ""; private String bannerUrl = "";
private static String feedUrl = ""; private String feedUrl = "";
private static long subscriberCount = -1; private 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 static String nextPageUrl = ""; private 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,13 +318,8 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
@Override @Override
public String getFeedUrl() throws ParsingException { public String getFeedUrl() throws ParsingException {
try { try {
if(userUrl.contains("channel")) { String channelId = doc.getElementsByClass("yt-uix-subscription-button").first().attr("data-channel-external-id");
//channels don't have feeds in youtube, only user can provide such feedUrl = CHANNEL_FEED_BASE + channelId;
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 static String name = ""; private String name = "";
private static String feedUrl = ""; private String feedUrl = "";
private static String avatarUrl = ""; private String avatarUrl = "";
private static String bannerUrl = ""; private String bannerUrl = "";
private static String nextPageUrl = ""; private 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 {