2017-08-11 03:23:09 +02:00
|
|
|
package org.schabi.newpipe.extractor.channel;
|
2017-03-01 18:47:52 +01:00
|
|
|
|
2018-03-11 21:54:41 +01:00
|
|
|
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
|
2017-08-06 22:20:15 +02:00
|
|
|
import org.schabi.newpipe.extractor.ListInfo;
|
|
|
|
import org.schabi.newpipe.extractor.NewPipe;
|
|
|
|
import org.schabi.newpipe.extractor.StreamingService;
|
|
|
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
2018-05-13 21:28:51 +02:00
|
|
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
2018-07-13 18:02:40 +02:00
|
|
|
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
2018-09-02 08:51:15 +02:00
|
|
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
2017-11-11 02:55:56 +01:00
|
|
|
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
|
2017-03-01 18:47:52 +01:00
|
|
|
|
2017-08-06 22:20:15 +02:00
|
|
|
import java.io.IOException;
|
2017-03-01 18:47:52 +01:00
|
|
|
|
2017-06-29 20:12:55 +02:00
|
|
|
/*
|
2017-03-01 18:47:52 +01:00
|
|
|
* Created by Christian Schabesberger on 31.07.16.
|
|
|
|
*
|
|
|
|
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
|
2017-08-11 03:23:09 +02:00
|
|
|
* ChannelInfo.java is part of NewPipe.
|
2017-03-01 18:47:52 +01:00
|
|
|
*
|
|
|
|
* NewPipe is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* NewPipe is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2018-03-11 21:54:41 +01:00
|
|
|
public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
2017-08-06 22:20:15 +02:00
|
|
|
|
2018-07-13 18:02:40 +02:00
|
|
|
public ChannelInfo(int serviceId, ListLinkHandler urlIdHandler, String name) throws ParsingException {
|
2018-05-13 21:28:51 +02:00
|
|
|
super(serviceId, urlIdHandler, name);
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
2018-09-02 08:51:15 +02:00
|
|
|
@Deprecated
|
2017-08-11 03:23:09 +02:00
|
|
|
public static ChannelInfo getInfo(String url) throws IOException, ExtractionException {
|
2018-09-02 08:51:15 +02:00
|
|
|
return getInfo(NewPipe.getServiceByUrl(url), url, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ChannelInfo getInfo(String url, String language) throws IOException, ExtractionException {
|
|
|
|
return getInfo(NewPipe.getServiceByUrl(url), url, language);
|
2017-08-06 22:20:15 +02:00
|
|
|
}
|
|
|
|
|
2018-09-02 08:51:15 +02:00
|
|
|
@Deprecated
|
2017-08-11 03:23:09 +02:00
|
|
|
public static ChannelInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
|
2018-09-02 08:51:15 +02:00
|
|
|
return getInfo(service, url, null);
|
|
|
|
}
|
|
|
|
|
|
|
|
public static ChannelInfo getInfo(StreamingService service, String url, String language) throws IOException, ExtractionException {
|
2017-12-29 14:40:42 +01:00
|
|
|
ChannelExtractor extractor = service.getChannelExtractor(url);
|
2018-09-02 08:51:15 +02:00
|
|
|
extractor.setLanguage(language);
|
2017-12-29 14:40:42 +01:00
|
|
|
extractor.fetchPage();
|
2017-12-30 01:13:24 +01:00
|
|
|
return getInfo(extractor);
|
2017-08-06 22:20:15 +02:00
|
|
|
}
|
2017-03-01 18:47:52 +01: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.getChannelExtractor(url).getPage(pageUrl);
|
|
|
|
}
|
|
|
|
|
2018-02-26 15:55:27 +01:00
|
|
|
public static ChannelInfo getInfo(ChannelExtractor extractor) throws IOException, ExtractionException {
|
2017-03-01 18:47:52 +01:00
|
|
|
|
2018-05-13 21:28:51 +02:00
|
|
|
ChannelInfo info = new ChannelInfo(extractor.getServiceId(),
|
2018-07-01 16:21:40 +02:00
|
|
|
extractor.getUIHandler(),
|
2018-05-13 21:28:51 +02:00
|
|
|
extractor.getName());
|
2017-11-11 02:55:56 +01:00
|
|
|
|
2017-03-01 18:47:52 +01:00
|
|
|
|
|
|
|
try {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.setAvatarUrl(extractor.getAvatarUrl());
|
2017-03-01 18:47:52 +01:00
|
|
|
} catch (Exception e) {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.addError(e);
|
2017-03-01 18:47:52 +01: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-03-01 18:47:52 +01:00
|
|
|
}
|
|
|
|
try {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.setFeedUrl(extractor.getFeedUrl());
|
2017-06-29 20:12:55 +02:00
|
|
|
} catch (Exception e) {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.addError(e);
|
2017-03-01 18:47:52 +01:00
|
|
|
}
|
2017-11-11 02:55:56 +01: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-11-11 02:55:56 +01:00
|
|
|
|
2017-03-01 18:47:52 +01:00
|
|
|
try {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.setSubscriberCount(extractor.getSubscriberCount());
|
2017-03-01 18:47:52 +01:00
|
|
|
} catch (Exception e) {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.addError(e);
|
2017-03-01 18:47:52 +01:00
|
|
|
}
|
2017-08-07 19:00:36 +02:00
|
|
|
try {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.setDescription(extractor.getDescription());
|
2017-08-07 19:00:36 +02:00
|
|
|
} catch (Exception e) {
|
2017-11-11 02:55:56 +01:00
|
|
|
info.addError(e);
|
2017-08-07 19:00:36 +02:00
|
|
|
}
|
2018-04-07 16:45:07 +02:00
|
|
|
try {
|
|
|
|
info.setDonationLinks(extractor.getDonationLinks());
|
|
|
|
} catch (Exception e) {
|
|
|
|
info.addError(e);
|
|
|
|
}
|
2017-03-01 18:47:52 +01:00
|
|
|
|
|
|
|
return info;
|
|
|
|
}
|
|
|
|
|
2018-03-11 21:50:40 +01:00
|
|
|
private String avatarUrl;
|
|
|
|
private String bannerUrl;
|
|
|
|
private String feedUrl;
|
|
|
|
private long subscriberCount = -1;
|
|
|
|
private String description;
|
2018-04-07 16:45:07 +02:00
|
|
|
private String[] donationLinks;
|
2017-11-11 02:55:56 +01:00
|
|
|
|
|
|
|
public String getAvatarUrl() {
|
2018-03-11 21:50:40 +01:00
|
|
|
return avatarUrl;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setAvatarUrl(String avatarUrl) {
|
2018-03-11 21:50:40 +01:00
|
|
|
this.avatarUrl = avatarUrl;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getBannerUrl() {
|
2018-03-11 21:50:40 +01:00
|
|
|
return bannerUrl;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setBannerUrl(String bannerUrl) {
|
2018-03-11 21:50:40 +01:00
|
|
|
this.bannerUrl = bannerUrl;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getFeedUrl() {
|
2018-03-11 21:50:40 +01:00
|
|
|
return feedUrl;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setFeedUrl(String feedUrl) {
|
2018-03-11 21:50:40 +01:00
|
|
|
this.feedUrl = feedUrl;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public long getSubscriberCount() {
|
2018-03-11 21:50:40 +01:00
|
|
|
return subscriberCount;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public void setSubscriberCount(long subscriberCount) {
|
2018-03-11 21:50:40 +01:00
|
|
|
this.subscriberCount = subscriberCount;
|
2017-11-11 02:55:56 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public String getDescription() {
|
|
|
|
return description;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDescription(String description) {
|
|
|
|
this.description = description;
|
|
|
|
}
|
2018-04-07 16:45:07 +02:00
|
|
|
|
|
|
|
public String[] getDonationLinks() {
|
|
|
|
return donationLinks;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setDonationLinks(String[] donationLinks) {
|
|
|
|
this.donationLinks = donationLinks;
|
|
|
|
}
|
2017-03-01 18:47:52 +01:00
|
|
|
}
|