|
| 1 | +package org.schabi.newpipe.extractor.kiosk; |
| 2 | + |
| 3 | +/* |
| 4 | + * Created by Christian Schabesberger on 12.08.17. |
| 5 | + * |
| 6 | + * Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org> |
| 7 | + * KioskInfo.java is part of NewPipe. |
| 8 | + * |
| 9 | + * NewPipe is free software: you can redistribute it and/or modify |
| 10 | + * it under the terms of the GNU General Public License as published by |
| 11 | + * the Free Software Foundation, either version 3 of the License, or |
| 12 | + * (at your option) any later version. |
| 13 | + * |
| 14 | + * NewPipe is distributed in the hope that it will be useful, |
| 15 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | + * GNU General Public License for more details. |
| 18 | + * |
| 19 | + * You should have received a copy of the GNU General Public License |
| 20 | + * along with NewPipe. If not, see <http://www.gnu.org/licenses/>. |
| 21 | + */ |
| 22 | + |
| 23 | +import org.schabi.newpipe.extractor.ListInfo; |
| 24 | +import org.schabi.newpipe.extractor.NewPipe; |
| 25 | +import org.schabi.newpipe.extractor.ServiceList; |
| 26 | +import org.schabi.newpipe.extractor.StreamingService; |
| 27 | +import org.schabi.newpipe.extractor.exceptions.ExtractionException; |
| 28 | +import org.schabi.newpipe.extractor.exceptions.ParsingException; |
| 29 | +import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector; |
| 30 | + |
| 31 | +import java.io.IOException; |
| 32 | + |
| 33 | +public class KioskInfo extends ListInfo { |
| 34 | + public String type; |
| 35 | + |
| 36 | + public static KioskInfo getInfo(String url) throws IOException, ExtractionException { |
| 37 | + return getInfo(NewPipe.getServiceByUrl(url), url); |
| 38 | + } |
| 39 | + |
| 40 | + public static KioskInfo getInfo(ServiceList serviceItem, String url) throws IOException, ExtractionException { |
| 41 | + return getInfo(serviceItem.getService(), url); |
| 42 | + } |
| 43 | + |
| 44 | + public static KioskInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException { |
| 45 | + KioskList kl = service.getKioskList(); |
| 46 | + KioskExtractor extractor = kl.getExtryctorByUrl(url); |
| 47 | + return getInfo(extractor); |
| 48 | + } |
| 49 | + |
| 50 | + public static KioskInfo getInfo(KioskExtractor extractor) throws ParsingException { |
| 51 | + KioskInfo info = new KioskInfo(); |
| 52 | + info.type = extractor.getType(); |
| 53 | + |
| 54 | + try { |
| 55 | + StreamInfoItemCollector c = extractor.getStreams(); |
| 56 | + info.related_streams = c.getItemList(); |
| 57 | + info.errors.addAll(c.getErrors()); |
| 58 | + } catch (Exception e) { |
| 59 | + info.errors.add(e); |
| 60 | + } |
| 61 | + |
| 62 | + return info; |
| 63 | + } |
| 64 | +} |
0 commit comments