2017-08-11 03:23:09 +02:00
|
|
|
package org.schabi.newpipe.extractor.channel;
|
2017-03-01 18:47:52 +01:00
|
|
|
|
|
|
|
import org.schabi.newpipe.extractor.InfoItemCollector;
|
|
|
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|
|
|
|
2017-06-29 20:12:55 +02:00
|
|
|
/*
|
2017-03-01 18:47:52 +01:00
|
|
|
* Created by Christian Schabesberger on 12.02.17.
|
|
|
|
*
|
|
|
|
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
|
2017-08-11 03:23:09 +02:00
|
|
|
* ChannelInfoItemCollector.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/>.
|
|
|
|
*/
|
|
|
|
|
2017-11-11 12:17:14 +01:00
|
|
|
public class ChannelInfoItemCollector extends InfoItemCollector<ChannelInfoItem, ChannelInfoItemExtractor> {
|
2017-08-11 03:23:09 +02:00
|
|
|
public ChannelInfoItemCollector(int serviceId) {
|
2017-03-01 18:47:52 +01:00
|
|
|
super(serviceId);
|
|
|
|
}
|
|
|
|
|
2017-11-11 12:17:14 +01:00
|
|
|
@Override
|
2017-08-11 03:23:09 +02:00
|
|
|
public ChannelInfoItem extract(ChannelInfoItemExtractor extractor) throws ParsingException {
|
2017-06-29 19:34:21 +02:00
|
|
|
// important information
|
2017-11-11 02:55:56 +01:00
|
|
|
int serviceId = getServiceId();
|
|
|
|
String name = extractor.getName();
|
|
|
|
String url = extractor.getUrl();
|
|
|
|
|
2017-12-07 09:46:59 +01:00
|
|
|
ChannelInfoItem resultItem = new ChannelInfoItem(serviceId, url, name);
|
2017-11-11 02:55:56 +01:00
|
|
|
|
2017-03-01 18:47:52 +01:00
|
|
|
|
|
|
|
// optional information
|
|
|
|
try {
|
2017-11-11 02:55:56 +01:00
|
|
|
resultItem.setSubscriberCount(extractor.getSubscriberCount());
|
2017-03-01 18:47:52 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
addError(e);
|
|
|
|
}
|
|
|
|
try {
|
2017-11-11 02:55:56 +01:00
|
|
|
resultItem.setStreamCount(extractor.getStreamCount());
|
2017-03-01 18:47:52 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
addError(e);
|
|
|
|
}
|
|
|
|
try {
|
2017-11-11 02:55:56 +01:00
|
|
|
resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
|
2017-03-01 18:47:52 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
addError(e);
|
|
|
|
}
|
|
|
|
try {
|
2017-11-11 02:55:56 +01:00
|
|
|
resultItem.setDescription(extractor.getDescription());
|
2017-03-01 18:47:52 +01:00
|
|
|
} catch (Exception e) {
|
|
|
|
addError(e);
|
|
|
|
}
|
|
|
|
return resultItem;
|
|
|
|
}
|
|
|
|
}
|