|
| 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, |
| 37 | + String contentCountry) throws IOException, ExtractionException { |
| 38 | + return getInfo(NewPipe.getServiceByUrl(url), url, contentCountry); |
| 39 | + } |
| 40 | + |
| 41 | + public static KioskInfo getInfo(ServiceList serviceItem, |
| 42 | + String url, |
| 43 | + String contentContry) throws IOException, ExtractionException { |
| 44 | + return getInfo(serviceItem.getService(), url, contentContry); |
| 45 | + } |
| 46 | + |
| 47 | + public static KioskInfo getInfo(StreamingService service, |
| 48 | + String url, |
| 49 | + String contentCountry) throws IOException, ExtractionException { |
| 50 | + KioskList kl = service.getKioskList(); |
| 51 | + KioskExtractor extractor = kl.getExtryctorByUrl(url); |
| 52 | + return getInfo(extractor, contentCountry); |
| 53 | + } |
| 54 | + |
| 55 | + public static KioskInfo getInfo(KioskExtractor extractor, |
| 56 | + String contentCountry) throws IOException, ExtractionException { |
| 57 | + KioskInfo info = new KioskInfo(); |
| 58 | + extractor.setContentCountry(contentCountry); |
| 59 | + extractor.fetchPage(); |
| 60 | + info.type = extractor.getType(); |
| 61 | + info.name = extractor.getName(); |
| 62 | + info.id = extractor.getId(); |
| 63 | + |
| 64 | + try { |
| 65 | + StreamInfoItemCollector c = extractor.getStreams(); |
| 66 | + info.related_streams = c.getItemList(); |
| 67 | + info.errors.addAll(c.getErrors()); |
| 68 | + } catch (Exception e) { |
| 69 | + info.errors.add(e); |
| 70 | + } |
| 71 | + |
| 72 | + return info; |
| 73 | + } |
| 74 | +} |
0 commit comments