Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
20f280c
added peertube extractor
yausername Oct 11, 2018
9dee8d5
updated kiosk accept link
yausername Oct 11, 2018
26da308
fallback avatar and description
yausername Oct 11, 2018
c9fba9c
fallback avatar for channel
yausername Oct 11, 2018
706d427
empty suggestions for search
yausername Oct 12, 2018
4883b6f
return suggestion extractor
yausername Oct 12, 2018
df0db84
merged master
yausername Dec 25, 2018
8755c25
format date of comment published. changed default instance
yausername Dec 26, 2018
14cd1db
fixed kiosk by url
yausername Dec 26, 2018
203c884
strip base url
yausername Dec 26, 2018
bc82a53
replace base url
yausername Dec 26, 2018
b2c6928
added logic for fetching related streams
yausername Dec 26, 2018
a83342d
update peertube instance
yausername Dec 29, 2018
b1a77fa
update peertube instance
yausername Dec 29, 2018
ef0ffb2
added torrent url in streams
yausername Dec 30, 2018
fade7bd
getter for torrent url
yausername Dec 30, 2018
c4e502b
Merge branch 'master' into peertube
yausername Jan 19, 2019
22dac63
merged upstream/dev
yausername Mar 7, 2019
e66d188
throw content not available
yausername Mar 7, 2019
3613955
handle stream 404 error, fixed tests
yausername Mar 9, 2019
c220700
fixed tests
yausername Mar 9, 2019
2193119
youtube's comment censorship breaks test
yausername Mar 23, 2019
bd22b55
fixed youtube channel name test
yausername Mar 23, 2019
07a8129
fixed peertube search test
yausername Mar 23, 2019
aabc65b
added java doc for stream
yausername Mar 23, 2019
e4e6d44
reordered services
yausername Mar 23, 2019
f60c973
more javadoc
yausername Mar 23, 2019
d758273
merged upstream/dev
yausername Nov 15, 2019
193442d
add original url for share
yausername Nov 15, 2019
bb5ad49
fix html comments
yausername Nov 15, 2019
318f600
add subtitles support for peertube
yausername Nov 15, 2019
f3a59a6
merged upstream/dev
yausername Nov 19, 2019
8a7aa6b
added baseUrl param in linkhandlers. Required for multi instance serv…
yausername Nov 20, 2019
4e0adbe
[peertube] use baseUrl instead of global instance url
yausername Nov 21, 2019
279f175
validate peertube instance
yausername Nov 22, 2019
bc75c66
added getBaseUrl method to linkhandler
yausername Nov 22, 2019
281ccea
[peertube] constant name for service
yausername Nov 23, 2019
6a7680c
added instance getter
yausername Nov 23, 2019
5115541
fix peertube trending, added most-liked kiosk
yausername Dec 2, 2019
00c2368
Merge remote-tracking branch 'upstream/dev' into peertube
yausername Dec 2, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
package org.schabi.newpipe.extractor;

import java.io.IOException;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

import org.schabi.newpipe.extractor.downloader.Downloader;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
Expand All @@ -8,11 +13,6 @@
import org.schabi.newpipe.extractor.localization.Localization;
import org.schabi.newpipe.extractor.localization.TimeAgoParser;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.io.Serializable;

public abstract class Extractor{
/**
* {@link StreamingService} currently related to this extractor.<br>
Expand Down Expand Up @@ -93,6 +93,11 @@ public String getOriginalUrl() throws ParsingException {
public String getUrl() throws ParsingException {
return linkHandler.getUrl();
}

@Nonnull
public String getBaseUrl() throws ParsingException {
return linkHandler.getBaseUrl();
}

@Nonnull
public StreamingService getService() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,13 @@ public static MediaFormat getFormatById(int id) {
return null;
}

public static MediaFormat getFromSuffix(String suffix) {
for (MediaFormat vf: values()) {
if (vf.suffix.equals(suffix)) return vf;
}
return null;
}

/**
* Get the name of the format
* @return the name of the format
Expand All @@ -149,4 +156,5 @@ public String getSuffix() {
public String getMimeType() {
return mimeType;
}

}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.schabi.newpipe.extractor;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

import org.schabi.newpipe.extractor.services.media_ccc.MediaCCCService;
import org.schabi.newpipe.extractor.services.peertube.PeertubeService;
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudService;
import org.schabi.newpipe.extractor.services.youtube.YoutubeService;

import java.util.List;

import static java.util.Arrays.asList;
import static java.util.Collections.unmodifiableList;

/*
* Copyright (C) Christian Schabesberger 2018 <chris.schabesberger@mailbox.org>
* ServiceList.java is part of NewPipe.
Expand Down Expand Up @@ -38,16 +38,18 @@ private ServiceList() {
public static final YoutubeService YouTube;
public static final SoundcloudService SoundCloud;
public static final MediaCCCService MediaCCC;
public static final PeertubeService PeerTube;

/**
* When creating a new service, put this service in the end of this list,
* and give it the next free id.
*/
private static final List<StreamingService> SERVICES = unmodifiableList(
asList(
private static final List<StreamingService> SERVICES = Collections.unmodifiableList(
Arrays.asList(
YouTube = new YoutubeService(0),
SoundCloud = new SoundcloudService(1),
MediaCCC = new MediaCCCService(2)
MediaCCC = new MediaCCCService(2),
PeerTube = new PeertubeService(3)
));

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
package org.schabi.newpipe.extractor;

import java.util.Collections;
import java.util.List;

import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.comments.CommentsExtractor;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.kiosk.KioskList;
import org.schabi.newpipe.extractor.linkhandler.*;
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandlerFactory;
import org.schabi.newpipe.extractor.localization.ContentCountry;
import org.schabi.newpipe.extractor.localization.Localization;
import org.schabi.newpipe.extractor.localization.TimeAgoParser;
Expand All @@ -16,9 +24,6 @@
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;

import java.util.Collections;
import java.util.List;

/*
* Copyright (C) Christian Schabesberger 2018 <chris.schabesberger@mailbox.org>
* StreamingService.java is part of NewPipe.
Expand All @@ -44,6 +49,7 @@ public abstract class StreamingService {
*/
public static class ServiceInfo {
private final String name;

private final List<MediaCapability> mediaCapabilities;

/**
Expand All @@ -59,7 +65,7 @@ public ServiceInfo(String name, List<MediaCapability> mediaCapabilities) {
public String getName() {
return name;
}

public List<MediaCapability> getMediaCapabilities() {
return mediaCapabilities;
}
Expand Down Expand Up @@ -110,6 +116,8 @@ public ServiceInfo getServiceInfo() {
public String toString() {
return serviceId + ":" + serviceInfo.getName();
}

public abstract String getBaseUrl();

/*//////////////////////////////////////////////////////////////////////////
// Url Id handler
Expand Down Expand Up @@ -250,7 +258,7 @@ public CommentsExtractor getCommentsExtractor(String url) throws ExtractionExcep
}
return getCommentsExtractor(llhf.fromUrl(url));
}

/*//////////////////////////////////////////////////////////////////////////
// Utils
//////////////////////////////////////////////////////////////////////////*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public KioskExtractor getExtractorByUrl(String url, String nextPageUrl, Localiza
for(Map.Entry<String, KioskEntry> e : kioskList.entrySet()) {
KioskEntry ke = e.getValue();
if(ke.handlerFactory.acceptUrl(url)) {
return getExtractorById(e.getKey(), nextPageUrl, localization);
return getExtractorById(ke.handlerFactory.getId(url), nextPageUrl, localization);
}
}
throw new ExtractionException("Could not find a kiosk that fits to the url: " + url);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

import java.io.Serializable;

import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.utils.Utils;

public class LinkHandler implements Serializable {
protected final String originalUrl;
protected final String url;
Expand All @@ -28,4 +31,8 @@ public String getUrl() {
public String getId() {
return id;
}

public String getBaseUrl() throws ParsingException {
return Utils.getBaseUrl(url);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.schabi.newpipe.extractor.exceptions.FoundAdException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.utils.Utils;

/*
* Created by Christian Schabesberger on 26.07.16.
Expand Down Expand Up @@ -33,26 +34,41 @@ public abstract class LinkHandlerFactory {
public abstract String getUrl(String id) throws ParsingException;
public abstract boolean onAcceptUrl(final String url) throws ParsingException;

public String getUrl(String id, String baseUrl) throws ParsingException{
return getUrl(id);
}

///////////////////////////////////
// Logic
///////////////////////////////////

public LinkHandler fromUrl(String url) throws ParsingException {
final String baseUrl = Utils.getBaseUrl(url);
return fromUrl(url, baseUrl);
}

public LinkHandler fromUrl(String url, String baseUrl) throws ParsingException {
if(url == null) throw new IllegalArgumentException("url can not be null");
if(!acceptUrl(url)) {
throw new ParsingException("Malformed unacceptable url: " + url);
}

final String id = getId(url);
return new LinkHandler(url, getUrl(id), id);
return new LinkHandler(url, getUrl(id,baseUrl), id);
}

public LinkHandler fromId(String id) throws ParsingException {
if(id == null) throw new IllegalArgumentException("id can not be null");
final String url = getUrl(id);
return new LinkHandler(url, url, id);
}

public LinkHandler fromId(String id, String baseUrl) throws ParsingException {
if(id == null) throw new IllegalArgumentException("id can not be null");
final String url = getUrl(id, baseUrl);
return new LinkHandler(url, url, id);
}

/**
* When a VIEW_ACTION is caught this function will test if the url delivered within the calling
* Intent was meant to be watched with this Service.
Expand All @@ -65,4 +81,5 @@ public boolean acceptUrl(final String url) throws ParsingException {
throw fe;
}
}

}
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package org.schabi.newpipe.extractor.linkhandler;

import org.schabi.newpipe.extractor.exceptions.ParsingException;

import java.util.ArrayList;
import java.util.List;

import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.utils.Utils;

public abstract class ListLinkHandlerFactory extends LinkHandlerFactory {

///////////////////////////////////
Expand All @@ -14,32 +15,53 @@ public abstract class ListLinkHandlerFactory extends LinkHandlerFactory {
public List<String> getContentFilter(String url) throws ParsingException { return new ArrayList<>(0);}
public String getSortFilter(String url) throws ParsingException {return ""; }
public abstract String getUrl(String id, List<String> contentFilter, String sortFilter) throws ParsingException;

public String getUrl(String id, List<String> contentFilter, String sortFilter, String baseUrl) throws ParsingException {
return getUrl(id, contentFilter, sortFilter);
}

///////////////////////////////////
// Logic
///////////////////////////////////



@Override
public ListLinkHandler fromUrl(String url) throws ParsingException {
String baseUrl = Utils.getBaseUrl(url);
return fromUrl(url, baseUrl);
}

@Override
public ListLinkHandler fromUrl(String url, String baseUrl) throws ParsingException {
if(url == null) throw new IllegalArgumentException("url may not be null");

return new ListLinkHandler(super.fromUrl(url), getContentFilter(url), getSortFilter(url));
return new ListLinkHandler(super.fromUrl(url, baseUrl), getContentFilter(url), getSortFilter(url));
}

@Override
public ListLinkHandler fromId(String id) throws ParsingException {
return new ListLinkHandler(super.fromId(id), new ArrayList<String>(0), "");
}

@Override
public ListLinkHandler fromId(String id, String baseUrl) throws ParsingException {
return new ListLinkHandler(super.fromId(id, baseUrl), new ArrayList<String>(0), "");
}

public ListLinkHandler fromQuery(String id,
List<String> contentFilters,
String sortFilter) throws ParsingException {
final String url = getUrl(id, contentFilters, sortFilter);
return new ListLinkHandler(url, url, id, contentFilters, sortFilter);
}

public ListLinkHandler fromQuery(String id,
List<String> contentFilters,
String sortFilter, String baseUrl) throws ParsingException {
final String url = getUrl(id, contentFilters, sortFilter, baseUrl);
return new ListLinkHandler(url, url, id, contentFilters, sortFilter);
}


/**
* For makeing ListLinkHandlerFactory compatible with LinkHandlerFactory we need to override this,
* however it should not be overridden by the actual implementation.
Expand All @@ -50,6 +72,11 @@ public String getUrl(String id) throws ParsingException {
return getUrl(id, new ArrayList<String>(0), "");
}

@Override
public String getUrl(String id, String baseUrl) throws ParsingException {
return getUrl(id, new ArrayList<String>(0), "", baseUrl);
}

/**
* Will returns content filter the corresponding extractor can handle like "channels", "videos", "music", etc.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,9 @@ public CommentsExtractor getCommentsExtractor(ListLinkHandler linkHandler)
return null;
}

@Override
public String getBaseUrl() {
return "https://media.ccc.de";
}

}
Loading