Skip to content
Closed
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions extractor/src/main/java/org/schabi/newpipe/extractor/Image.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package org.schabi.newpipe.extractor;

public class Image {
// Make it so that HIGH > LOW
public final static int LOW = -2;
public final static int HIGH = -1;

private final String url;
private final int width;
private final int height;

public Image(final String url, final int width, final int height) {
this.url = url;
this.width = width;
this.height = height;
}

public String getUrl() {
return url;
}

public int getWidth() {
return width;
}

public int getHeight() {
return height;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
*/

import java.io.Serializable;
import java.util.List;

public abstract class InfoItem implements Serializable {
private final InfoType infoType;
private final int serviceId;
private final String url;
private final String name;
private String thumbnailUrl;
private List<Image> thumbnails;

public InfoItem(InfoType infoType, int serviceId, String url, String name) {
this.infoType = infoType;
Expand All @@ -52,12 +53,12 @@ public String getName() {
return name;
}

public void setThumbnailUrl(String thumbnailUrl) {
this.thumbnailUrl = thumbnailUrl;
public void setThumbnails(List<Image> thumbnails) {
this.thumbnails = thumbnails;
}

public String getThumbnailUrl() {
return thumbnailUrl;
public List<Image> getThumbnails() {
return thumbnails;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.schabi.newpipe.extractor.exceptions.ParsingException;

import java.util.List;

public interface InfoItemExtractor {
String getName() throws ParsingException;
String getUrl() throws ParsingException;
String getThumbnailUrl() throws ParsingException;
List<Image> getThumbnails() throws ParsingException;
}
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package org.schabi.newpipe.extractor.channel;

import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;

import java.util.List;

/*
* Created by Christian Schabesberger on 25.07.16.
*
Expand All @@ -32,8 +35,8 @@ public ChannelExtractor(StreamingService service, ListLinkHandler linkHandler) {
super(service, linkHandler);
}

public abstract String getAvatarUrl() throws ParsingException;
public abstract String getBannerUrl() throws ParsingException;
public abstract List<Image> getAvatars() throws ParsingException;
public abstract List<Image> getBanners() throws ParsingException;
public abstract String getFeedUrl() throws ParsingException;
public abstract long getSubscriberCount() throws ParsingException;
public abstract String getDescription() throws ParsingException;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.schabi.newpipe.extractor.channel;

import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
import org.schabi.newpipe.extractor.ListInfo;
import org.schabi.newpipe.extractor.NewPipe;
Expand All @@ -10,6 +11,7 @@
import org.schabi.newpipe.extractor.utils.ExtractorHelper;

import java.io.IOException;
import java.util.List;

/*
* Created by Christian Schabesberger on 31.07.16.
Expand Down Expand Up @@ -64,12 +66,12 @@ public static ChannelInfo getInfo(ChannelExtractor extractor) throws IOException
final ChannelInfo info = new ChannelInfo(serviceId, id, url, originalUrl, name, extractor.getLinkHandler());

try {
info.setAvatarUrl(extractor.getAvatarUrl());
info.setAvatars(extractor.getAvatars());
} catch (Exception e) {
info.addError(e);
}
try {
info.setBannerUrl(extractor.getBannerUrl());
info.setBanners(extractor.getBanners());
} catch (Exception e) {
info.addError(e);
}
Expand Down Expand Up @@ -97,27 +99,27 @@ public static ChannelInfo getInfo(ChannelExtractor extractor) throws IOException
return info;
}

private String avatarUrl;
private String bannerUrl;
private List<Image> avatars;
private List<Image> banners;
private String feedUrl;
private long subscriberCount = -1;
private String description;
private String[] donationLinks;

public String getAvatarUrl() {
return avatarUrl;
public List<Image> getAvatars() {
return avatars;
}

public void setAvatarUrl(String avatarUrl) {
this.avatarUrl = avatarUrl;
public void setAvatars(List<Image> avatars) {
this.avatars = avatars;
}

public String getBannerUrl() {
return bannerUrl;
public List<Image> getBanners() {
return banners;
}

public void setBannerUrl(String bannerUrl) {
this.bannerUrl = bannerUrl;
public void setBanners(List<Image> banners) {
this.banners = banners;
}

public String getFeedUrl() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public ChannelInfoItem extract(ChannelInfoItemExtractor extractor) throws Parsin
addError(e);
}
try {
resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
resultItem.setThumbnails(extractor.getThumbnails());
} catch (Exception e) {
addError(e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package org.schabi.newpipe.extractor.comments;

import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.localization.DateWrapper;

import java.util.List;

import javax.annotation.Nullable;

public class CommentsInfoItem extends InfoItem {

private String commentId;
private String commentText;
private String authorName;
private String authorThumbnail;
private List<Image> authorThumbnails;
private String authorEndpoint;
private String textualPublishedTime;
@Nullable private DateWrapper publishedTime;
Expand Down Expand Up @@ -44,12 +47,12 @@ public void setAuthorName(String authorName) {
this.authorName = authorName;
}

public String getAuthorThumbnail() {
return authorThumbnail;
public List<Image> getAuthorThumbnails() {
return authorThumbnails;
}

public void setAuthorThumbnail(String authorThumbnail) {
this.authorThumbnail = authorThumbnail;
public void setAuthorThumbnails(List<Image> authorThumbnails) {
this.authorThumbnails = authorThumbnails;
}

public String getAuthorEndpoint() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
package org.schabi.newpipe.extractor.comments;

import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.InfoItemExtractor;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.localization.DateWrapper;

import java.util.List;

import javax.annotation.Nullable;

public interface CommentsInfoItemExtractor extends InfoItemExtractor {
String getCommentId() throws ParsingException;
String getCommentText() throws ParsingException;
String getAuthorName() throws ParsingException;
String getAuthorThumbnail() throws ParsingException;
List<Image> getAuthorThumbnails() throws ParsingException;
String getAuthorEndpoint() throws ParsingException;
String getTextualPublishedTime() throws ParsingException;
@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public CommentsInfoItem extract(CommentsInfoItemExtractor extractor) throws Pars
addError(e);
}
try {
resultItem.setAuthorThumbnail(extractor.getAuthorThumbnail());
resultItem.setAuthorThumbnails(extractor.getAuthorThumbnails());
} catch (Exception e) {
addError(e);
}
Expand All @@ -65,7 +65,7 @@ public CommentsInfoItem extract(CommentsInfoItemExtractor extractor) throws Pars
addError(e);
}
try {
resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
resultItem.setThumbnails(extractor.getThumbnails());
} catch (Exception e) {
addError(e);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,26 @@
package org.schabi.newpipe.extractor.playlist;

import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import org.schabi.newpipe.extractor.stream.StreamInfoItem;

import java.util.List;

public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> {

public PlaylistExtractor(StreamingService service, ListLinkHandler linkHandler) {
super(service, linkHandler);
}

public abstract String getThumbnailUrl() throws ParsingException;
public abstract String getBannerUrl() throws ParsingException;
public abstract List<Image> getThumbnails() throws ParsingException;
public abstract List<Image> getBanners() throws ParsingException;

public abstract String getUploaderUrl() throws ParsingException;
public abstract String getUploaderName() throws ParsingException;
public abstract String getUploaderAvatarUrl() throws ParsingException;
public abstract List<Image> getUploaderAvatars() throws ParsingException;

public abstract long getStreamCount() throws ParsingException;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.schabi.newpipe.extractor.playlist;

import org.schabi.newpipe.extractor.Image;
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
import org.schabi.newpipe.extractor.ListInfo;
import org.schabi.newpipe.extractor.NewPipe;
Expand Down Expand Up @@ -62,7 +63,7 @@ public static PlaylistInfo getInfo(PlaylistExtractor extractor) throws Extractio
info.addError(e);
}
try {
info.setThumbnailUrl(extractor.getThumbnailUrl());
info.setThumbnails(extractor.getThumbnails());
} catch (Exception e) {
info.addError(e);
}
Expand All @@ -79,13 +80,13 @@ public static PlaylistInfo getInfo(PlaylistExtractor extractor) throws Extractio
uploaderParsingErrors.add(e);
}
try {
info.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
info.setUploaderAvatars(extractor.getUploaderAvatars());
} catch (Exception e) {
info.setUploaderAvatarUrl("");
info.setUploaderAvatars(null);
uploaderParsingErrors.add(e);
}
try {
info.setBannerUrl(extractor.getBannerUrl());
info.setBanners(extractor.getBanners());
} catch (Exception e) {
info.addError(e);
}
Expand All @@ -102,27 +103,27 @@ public static PlaylistInfo getInfo(PlaylistExtractor extractor) throws Extractio
return info;
}

private String thumbnailUrl;
private String bannerUrl;
private List<Image> thumbnails;
private List<Image> banners;
private String uploaderUrl;
private String uploaderName;
private String uploaderAvatarUrl;
private List<Image> uploaderAvatars;
private long streamCount = 0;

public String getThumbnailUrl() {
return thumbnailUrl;
public List<Image> getThumbnails() {
return thumbnails;
}

public void setThumbnailUrl(String thumbnailUrl) {
this.thumbnailUrl = thumbnailUrl;
public void setThumbnails(List<Image> thumbnails) {
this.thumbnails = thumbnails;
}

public String getBannerUrl() {
return bannerUrl;
public List<Image> getBanners() {
return banners;
}

public void setBannerUrl(String bannerUrl) {
this.bannerUrl = bannerUrl;
public void setBanners(List<Image> banners) {
this.banners = banners;
}

public String getUploaderUrl() {
Expand All @@ -141,12 +142,12 @@ public void setUploaderName(String uploaderName) {
this.uploaderName = uploaderName;
}

public String getUploaderAvatarUrl() {
return uploaderAvatarUrl;
public List<Image> getUploaderAvatars() {
return uploaderAvatars;
}

public void setUploaderAvatarUrl(String uploaderAvatarUrl) {
this.uploaderAvatarUrl = uploaderAvatarUrl;
public void setUploaderAvatars(List<Image> uploaderAvatars) {
this.uploaderAvatars = uploaderAvatars;
}

public long getStreamCount() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public PlaylistInfoItem extract(PlaylistInfoItemExtractor extractor) throws Pars
addError(e);
}
try {
resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
resultItem.setThumbnails(extractor.getThumbnails());
} catch (Exception e) {
addError(e);
}
Expand Down
Loading