NewPipeExtractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java

145 lines
4.4 KiB
Java
Raw Normal View History

package org.schabi.newpipe.extractor.playlist;
2017-11-11 02:55:56 +01:00
import org.schabi.newpipe.extractor.*;
2017-08-06 22:20:15 +02:00
import org.schabi.newpipe.extractor.ListExtractor.NextItemsResult;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
2017-08-06 22:20:15 +02:00
import java.io.IOException;
2017-11-11 02:55:56 +01:00
import static org.schabi.newpipe.extractor.utils.ExtractorHelper.getStreamsOrLogError;
2017-08-06 22:20:15 +02:00
public class PlaylistInfo extends ListInfo {
2017-11-11 02:55:56 +01:00
public PlaylistInfo(int serviceId, String id, String url, String name) {
super(serviceId, id, url, name);
}
public static NextItemsResult getMoreItems(ServiceList serviceItem, String url, String nextStreamsUrl) throws IOException, ExtractionException {
return getMoreItems(serviceItem.getService(), url, nextStreamsUrl);
2017-08-06 22:20:15 +02:00
}
public static NextItemsResult getMoreItems(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
return service.getPlaylistExtractor(url, nextStreamsUrl).getNextStreams();
2017-08-06 22:20:15 +02:00
}
public static PlaylistInfo getInfo(String url) throws IOException, ExtractionException {
return getInfo(NewPipe.getServiceByUrl(url), url);
}
public static PlaylistInfo getInfo(ServiceList serviceItem, String url) throws IOException, ExtractionException {
return getInfo(serviceItem.getService(), url);
}
public static PlaylistInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
2017-12-29 14:40:42 +01:00
PlaylistExtractor extractor = service.getPlaylistExtractor(url);
extractor.fetchPage();
return getInfo(extractor);
2017-08-06 22:20:15 +02:00
}
2017-12-29 14:40:42 +01:00
/**
* Get PlaylistInfo from PlaylistExtractor
*
* @param extractor an extractor where fetchPage() was already got called on.
*/
public static PlaylistInfo getInfo(PlaylistExtractor extractor) throws ParsingException {
2017-11-11 02:55:56 +01:00
int serviceId = extractor.getServiceId();
String url = extractor.getCleanUrl();
String id = extractor.getId();
String name = extractor.getName();
PlaylistInfo info = new PlaylistInfo(serviceId, url, id, name);
try {
2017-11-11 02:55:56 +01:00
info.setStreamCount(extractor.getStreamCount());
} catch (Exception e) {
2017-11-11 02:55:56 +01:00
info.addError(e);
}
try {
2017-11-11 02:55:56 +01:00
info.setThumbnailUrl(extractor.getThumbnailUrl());
} catch (Exception e) {
2017-11-11 02:55:56 +01:00
info.addError(e);
}
try {
2017-11-11 02:55:56 +01:00
info.setUploaderUrl(extractor.getUploaderUrl());
} catch (Exception e) {
2017-11-11 02:55:56 +01:00
info.addError(e);
}
try {
2017-11-11 02:55:56 +01:00
info.setUploaderName(extractor.getUploaderName());
} catch (Exception e) {
2017-11-11 02:55:56 +01:00
info.addError(e);
}
try {
2017-11-11 02:55:56 +01:00
info.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
} catch (Exception e) {
2017-11-11 02:55:56 +01:00
info.addError(e);
}
try {
2017-11-11 02:55:56 +01:00
info.setBannerUrl(extractor.getBannerUrl());
} catch (Exception e) {
2017-11-11 02:55:56 +01:00
info.addError(e);
}
2017-11-11 02:55:56 +01:00
info.setRelatedStreams(getStreamsOrLogError(info, extractor));
info.setHasMoreStreams(extractor.hasMoreStreams());
info.setNextStreamsUrl(extractor.getNextStreamsUrl());
return info;
}
2017-08-08 23:36:11 +02:00
public String thumbnail_url;
public String banner_url;
public String uploader_url;
public String uploader_name;
public String uploader_avatar_url;
2017-08-06 22:20:15 +02:00
public long stream_count = 0;
2017-11-11 02:55:56 +01:00
public String getThumbnailUrl() {
return thumbnail_url;
}
public String getBannerUrl() {
return banner_url;
}
public String getUploaderUrl() {
return uploader_url;
}
public String getUploaderName() {
return uploader_name;
}
public String getUploaderAvatarUrl() {
return uploader_avatar_url;
}
public long getStreamCount() {
return stream_count;
}
public void setThumbnailUrl(String thumbnailUrl) {
this.thumbnail_url = thumbnailUrl;
}
public void setBannerUrl(String bannerUrl) {
this.banner_url = bannerUrl;
}
public void setUploaderUrl(String uploaderUrl) {
this.uploader_url = uploaderUrl;
}
public void setUploaderName(String uploaderName) {
this.uploader_name = uploaderName;
}
public void setUploaderAvatarUrl(String uploaderAvatarUrl) {
this.uploader_avatar_url = uploaderAvatarUrl;
}
public void setStreamCount(long streamCount) {
this.stream_count = streamCount;
}
}