mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-13 05:40:34 +05:30
add youtube trending extractor
This commit is contained in:
parent
a6c1728dac
commit
b89f5a9b42
@ -49,7 +49,7 @@ public abstract class StreamingService {
|
|||||||
public abstract StreamExtractor getStreamExtractor(String url) throws IOException, ExtractionException;
|
public abstract StreamExtractor getStreamExtractor(String url) throws IOException, ExtractionException;
|
||||||
public abstract ChannelExtractor getChannelExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException;
|
public abstract ChannelExtractor getChannelExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException;
|
||||||
public abstract PlaylistExtractor getPlaylistExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException;
|
public abstract PlaylistExtractor getPlaylistExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException;
|
||||||
public abstract KioskList getKioskList();
|
public abstract KioskList getKioskList() throws ExtractionException;
|
||||||
|
|
||||||
public ChannelExtractor getChannelExtractor(String url) throws IOException, ExtractionException {
|
public ChannelExtractor getChannelExtractor(String url) throws IOException, ExtractionException {
|
||||||
return getChannelExtractor(url, null);
|
return getChannelExtractor(url, null);
|
||||||
|
@ -1,25 +1,5 @@
|
|||||||
package org.schabi.newpipe.extractor.kiosk;
|
package org.schabi.newpipe.extractor.kiosk;
|
||||||
|
|
||||||
/*
|
|
||||||
* Created by Christian Schabesberger on 12.08.17.
|
|
||||||
*
|
|
||||||
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
|
|
||||||
* KioskList.java is part of NewPipe.
|
|
||||||
*
|
|
||||||
* 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/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.UrlIdHandler;
|
import org.schabi.newpipe.extractor.UrlIdHandler;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
|
|
||||||
@ -27,7 +7,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
public class KioskList {
|
public class KioskList {
|
||||||
private int service_id;
|
private int service_id;
|
||||||
private HashMap<String, KioskEntry> kioskList = new HashMap<>();
|
private HashMap<String, KioskEntry> kioskList = new HashMap<>();
|
||||||
|
|
||||||
@ -44,12 +24,12 @@ public class KioskList {
|
|||||||
this.service_id = service_id;
|
this.service_id = service_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addKioskEntry(String kioskType, KioskExtractor extractor, UrlIdHandler handler)
|
public void addKioskEntry(KioskExtractor extractor, UrlIdHandler handler)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
if(kioskList.get(kioskType) != null) {
|
if(kioskList.get(extractor.getType()) != null) {
|
||||||
throw new Exception("Kiosk with type " + kioskType + " already exists.");
|
throw new Exception("Kiosk with type " + extractor.getType() + " already exists.");
|
||||||
}
|
}
|
||||||
kioskList.put(kioskType, new KioskEntry(extractor, handler));
|
kioskList.put(extractor.getType(), new KioskEntry(extractor, handler));
|
||||||
}
|
}
|
||||||
|
|
||||||
public KioskExtractor getExtractorByType(String kioskType) throws ExtractionException {
|
public KioskExtractor getExtractorByType(String kioskType) throws ExtractionException {
|
||||||
|
@ -81,11 +81,16 @@ public class YoutubeService extends StreamingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public KioskList getKioskList() {
|
public KioskList getKioskList() throws ExtractionException {
|
||||||
KioskList list = new KioskList(getServiceId());
|
KioskList list = new KioskList(getServiceId());
|
||||||
|
|
||||||
// add kiosks here e.g.:
|
// add kiosks here e.g.:
|
||||||
//list.addKioskEntry("trinding", new TrendingKiosk(), new TrendingUrlIdHandler());
|
YoutubeTrendingUrlIdHandler h = new YoutubeTrendingUrlIdHandler();
|
||||||
|
try {
|
||||||
|
list.addKioskEntry(new YoutubeTrendingExtractor(this, h.getUrl(""), h.getUrl("")), h);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ExtractionException(e);
|
||||||
|
}
|
||||||
|
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
package org.schabi.newpipe.extractor.services.youtube;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Created by Christian Schabesberger on 12.08.17.
|
||||||
|
*
|
||||||
|
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
|
||||||
|
* YoutubeTrendingExtractor.java is part of NewPipe.
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import org.schabi.newpipe.extractor.ListExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
|
import org.schabi.newpipe.extractor.UrlIdHandler;
|
||||||
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
|
import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public class YoutubeTrendingExtractor extends KioskExtractor {
|
||||||
|
|
||||||
|
public YoutubeTrendingExtractor(StreamingService service, String url, String nextStreamsUrl)
|
||||||
|
throws IOException, ExtractionException {
|
||||||
|
super(service, url, nextStreamsUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fetchPage()
|
||||||
|
throws IOException, ExtractionException {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "Treinding";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UrlIdHandler getUrlIdHandler() {
|
||||||
|
return new YoutubeTrendingUrlIdHandler();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ListExtractor.NextItemsResult getNextStreams() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StreamInfoItemCollector getStreams() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package org.schabi.newpipe.extractor.services.youtube;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Created by Christian Schabesberger on 12.08.17.
|
||||||
|
*
|
||||||
|
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
|
||||||
|
* YoutubeTrendingUrlIdHandler.java is part of NewPipe.
|
||||||
|
*
|
||||||
|
* 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/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import org.schabi.newpipe.extractor.UrlIdHandler;
|
||||||
|
|
||||||
|
public class YoutubeTrendingUrlIdHandler implements UrlIdHandler {
|
||||||
|
|
||||||
|
public String getUrl(String id) {
|
||||||
|
return "https://www.youtube.com/feed/trending";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getId(String url) {
|
||||||
|
return "Trending";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String cleanUrl(String url) {
|
||||||
|
return getUrl("");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean acceptUrl(String url) {
|
||||||
|
return url.contains("feed/treinding");
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user