2017-06-29 20:12:55 +02:00
|
|
|
package org.schabi.newpipe.extractor.playlist;
|
|
|
|
|
2018-03-11 21:54:41 +01:00
|
|
|
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
|
2018-02-10 03:46:05 +01:00
|
|
|
import org.schabi.newpipe.extractor.ListInfo;
|
|
|
|
import org.schabi.newpipe.extractor.NewPipe;
|
|
|
|
import org.schabi.newpipe.extractor.StreamingService;
|
2017-08-06 22:20:15 +02:00
|
|
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
2018-03-01 01:02:43 +01:00
|
|
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
2018-03-11 21:54:41 +01:00
|
|
|
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
|
2017-06-29 20:12:55 +02:00
|
|
|
|
2017-08-06 22:20:15 +02:00
|
|
|
import java.io.IOException;
|
2017-11-11 02:55:56 +01:00
|
|
|
|
2018-03-11 21:54:41 +01:00
|
|
|
public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
2017-08-06 22:20:15 +02:00
|
|
|
|
2017-11-11 02:55:56 +01:00
|
|
|
public PlaylistInfo(int serviceId, String id, String url, String name) {
|
|
|
|
super(serviceId, id, url, name);
|
|
|
|
}
|
|
|
|
|
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(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-06-29 20:12:55 +02:00
|
|
|
|
2018-03-11 21:54:41 +01:00
|
|
|
public static InfoItemsPage<StreamInfoItem> getMoreItems(StreamingService service, String url, String pageUrl) throws IOException, ExtractionException {
|
|
|
|
return service.getPlaylistExtractor(url).getPage(pageUrl);
|
|
|
|
}
|
|
|
|
|
2017-12-29 14:40:42 +01:00
|
|
|
/**
|
|
|
|
* Get PlaylistInfo from PlaylistExtractor
|
|
|
|
*
|
|
|
|
* @param extractor an extractor where fetchPage() was already got called on.
|
|
|
|
*/
|
2018-02-26 15:55:27 +01:00
|
|
|
public static PlaylistInfo getInfo(PlaylistExtractor extractor) throws IOException, ExtractionException {
|
2017-06-29 20:12:55 +02:00
|
|
|
|
2017-11-11 02:55:56 +01:00
|
|
|
int serviceId = extractor.getServiceId();
|
|
|
|
String url = extractor.getCleanUrl();
|
|
|
|
String id = extractor.getId();
|
|
|
|
String name = extractor.getName();
|
2018-01-04 01:42:55 +01:00
|
|
|
PlaylistInfo info = new PlaylistInfo(serviceId, id, url, name);
|
2017-06-29 20:12:55 +02:00
|
|
|
|
|
|
|
try {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.setStreamCount(extractor.getStreamCount());
|
2017-06-29 20:12:55 +02:00
|
|
|
} catch (Exception e) {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.addError(e);
|
2017-06-29 20:12:55 +02:00
|
|
|
}
|
|
|
|
try {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.setThumbnailUrl(extractor.getThumbnailUrl());
|
2017-06-29 20:12:55 +02:00
|
|
|
} catch (Exception e) {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.addError(e);
|
2017-06-29 20:12:55 +02:00
|
|
|
}
|
|
|
|
try {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.setUploaderUrl(extractor.getUploaderUrl());
|
2017-06-29 20:12:55 +02:00
|
|
|
} catch (Exception e) {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.addError(e);
|
2017-06-29 20:12:55 +02:00
|
|
|
}
|
|
|
|
try {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.setUploaderName(extractor.getUploaderName());
|
2017-06-29 20:12:55 +02:00
|
|
|
} catch (Exception e) {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.addError(e);
|
2017-06-29 20:12:55 +02:00
|
|
|
}
|
|
|
|
try {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
|
2017-06-29 20:12:55 +02:00
|
|
|
} catch (Exception e) {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.addError(e);
|
2017-06-29 20:12:55 +02:00
|
|
|
}
|
|
|
|
try {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.setBannerUrl(extractor.getBannerUrl());
|
2017-06-29 20:12:55 +02:00
|
|
|
} catch (Exception e) {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.addError(e);
|
2017-06-29 20:12:55 +02:00
|
|
|
}
|
|
|
|
|
2018-03-11 21:54:41 +01:00
|
|
|
final InfoItemsPage<StreamInfoItem> itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor);
|
|
|
|
info.setRelatedItems(itemsPage.getItems());
|
|
|
|
info.setNextPageUrl(itemsPage.getNextPageUrl());
|
|
|
|
|
2017-06-29 20:12:55 +02:00
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
2018-03-11 21:50:40 +01:00
|
|
|
private String thumbnailUrl;
|
|
|
|
private String bannerUrl;
|
|
|
|
private String uploaderUrl;
|
|
|
|
private String uploaderName;
|
|
|
|
private String uploaderAvatarUrl;
|
|
|
|
private long streamCount = 0;
|
2017-11-11 02:55:56 +01:00
|
|
|
|
|
|
|
public String getThumbnailUrl() {
|
2018-03-11 21:50:40 +01:00
|
|
|
return thumbnailUrl;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
2018-03-11 21:50:40 +01:00
|
|
|
public void setThumbnailUrl(String thumbnailUrl) {
|
|
|
|
this.thumbnailUrl = thumbnailUrl;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
2018-03-11 21:50:40 +01:00
|
|
|
public String getBannerUrl() {
|
|
|
|
return bannerUrl;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
2018-03-11 21:50:40 +01:00
|
|
|
public void setBannerUrl(String bannerUrl) {
|
|
|
|
this.bannerUrl = bannerUrl;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
2018-03-11 21:50:40 +01:00
|
|
|
public String getUploaderUrl() {
|
|
|
|
return uploaderUrl;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
2018-03-11 21:50:40 +01:00
|
|
|
public void setUploaderUrl(String uploaderUrl) {
|
|
|
|
this.uploaderUrl = uploaderUrl;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
2018-03-11 21:50:40 +01:00
|
|
|
public String getUploaderName() {
|
|
|
|
return uploaderName;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
2018-03-11 21:50:40 +01:00
|
|
|
public void setUploaderName(String uploaderName) {
|
|
|
|
this.uploaderName = uploaderName;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
2018-03-11 21:50:40 +01:00
|
|
|
public String getUploaderAvatarUrl() {
|
|
|
|
return uploaderAvatarUrl;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
2018-03-11 21:50:40 +01:00
|
|
|
public void setUploaderAvatarUrl(String uploaderAvatarUrl) {
|
|
|
|
this.uploaderAvatarUrl = uploaderAvatarUrl;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
2018-03-11 21:50:40 +01:00
|
|
|
public long getStreamCount() {
|
|
|
|
return streamCount;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setStreamCount(long streamCount) {
|
2018-03-11 21:50:40 +01:00
|
|
|
this.streamCount = streamCount;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
2017-06-29 20:12:55 +02:00
|
|
|
}
|