commit
28d12cd90c
41 changed files with 204 additions and 204 deletions
|
@ -37,7 +37,7 @@ public abstract class Extractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a {@link UrlIdHandler} of the current extractor type (e.g. a ChannelExtractor should return a channel url handler).
|
* @return a {@link UrlIdHandler} of the current extractor type (e.g. a UserExtractor should return a user url handler).
|
||||||
*/
|
*/
|
||||||
protected abstract UrlIdHandler getUrlIdHandler() throws ParsingException;
|
protected abstract UrlIdHandler getUrlIdHandler() throws ParsingException;
|
||||||
|
|
||||||
|
|
|
@ -26,7 +26,7 @@ public abstract class InfoItem implements Serializable {
|
||||||
public enum InfoType {
|
public enum InfoType {
|
||||||
STREAM,
|
STREAM,
|
||||||
PLAYLIST,
|
PLAYLIST,
|
||||||
CHANNEL
|
USER
|
||||||
}
|
}
|
||||||
|
|
||||||
public InfoItem(InfoType infoType) {
|
public InfoItem(InfoType infoType) {
|
||||||
|
|
|
@ -7,7 +7,7 @@ import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class to extractors that have a list (e.g. playlists, channels).
|
* Base class to extractors that have a list (e.g. playlists, users).
|
||||||
*/
|
*/
|
||||||
public abstract class ListExtractor extends Extractor {
|
public abstract class ListExtractor extends Extractor {
|
||||||
protected String nextStreamsUrl;
|
protected String nextStreamsUrl;
|
||||||
|
|
|
@ -7,7 +7,7 @@ import org.schabi.newpipe.extractor.services.youtube.YoutubeService;
|
||||||
* A list of supported services.
|
* A list of supported services.
|
||||||
*/
|
*/
|
||||||
public enum ServiceList {
|
public enum ServiceList {
|
||||||
Youtube(new YoutubeService(0, "Youtube")),
|
YouTube(new YoutubeService(0, "YouTube")),
|
||||||
SoundCloud(new SoundcloudService(1, "SoundCloud"));
|
SoundCloud(new SoundcloudService(1, "SoundCloud"));
|
||||||
// DailyMotion(new DailyMotionService(2, "DailyMotion"));
|
// DailyMotion(new DailyMotionService(2, "DailyMotion"));
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
package org.schabi.newpipe.extractor;
|
package org.schabi.newpipe.extractor;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
||||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.user.UserExtractor;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ public abstract class StreamingService {
|
||||||
public enum LinkType {
|
public enum LinkType {
|
||||||
NONE,
|
NONE,
|
||||||
STREAM,
|
STREAM,
|
||||||
CHANNEL,
|
USER,
|
||||||
PLAYLIST
|
PLAYLIST
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -41,16 +41,16 @@ public abstract class StreamingService {
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract UrlIdHandler getStreamUrlIdHandler();
|
public abstract UrlIdHandler getStreamUrlIdHandler();
|
||||||
public abstract UrlIdHandler getChannelUrlIdHandler();
|
public abstract UrlIdHandler getUserUrlIdHandler();
|
||||||
public abstract UrlIdHandler getPlaylistUrlIdHandler();
|
public abstract UrlIdHandler getPlaylistUrlIdHandler();
|
||||||
public abstract SearchEngine getSearchEngine();
|
public abstract SearchEngine getSearchEngine();
|
||||||
public abstract SuggestionExtractor getSuggestionExtractor();
|
public abstract SuggestionExtractor getSuggestionExtractor();
|
||||||
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 UserExtractor getUserExtractor(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 ChannelExtractor getChannelExtractor(String url) throws IOException, ExtractionException {
|
public UserExtractor getUserExtractor(String url) throws IOException, ExtractionException {
|
||||||
return getChannelExtractor(url, null);
|
return getUserExtractor(url, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlaylistExtractor getPlaylistExtractor(String url) throws IOException, ExtractionException {
|
public PlaylistExtractor getPlaylistExtractor(String url) throws IOException, ExtractionException {
|
||||||
|
@ -58,17 +58,17 @@ public abstract class StreamingService {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* figure out where the link is pointing to (a channel, video, playlist, etc.)
|
* figure out where the link is pointing to (a user, video, playlist, etc.)
|
||||||
*/
|
*/
|
||||||
public final LinkType getLinkTypeByUrl(String url) {
|
public final LinkType getLinkTypeByUrl(String url) {
|
||||||
UrlIdHandler sH = getStreamUrlIdHandler();
|
UrlIdHandler sH = getStreamUrlIdHandler();
|
||||||
UrlIdHandler cH = getChannelUrlIdHandler();
|
UrlIdHandler cH = getUserUrlIdHandler();
|
||||||
UrlIdHandler pH = getPlaylistUrlIdHandler();
|
UrlIdHandler pH = getPlaylistUrlIdHandler();
|
||||||
|
|
||||||
if (sH.acceptUrl(url)) {
|
if (sH.acceptUrl(url)) {
|
||||||
return LinkType.STREAM;
|
return LinkType.STREAM;
|
||||||
} else if (cH.acceptUrl(url)) {
|
} else if (cH.acceptUrl(url)) {
|
||||||
return LinkType.CHANNEL;
|
return LinkType.USER;
|
||||||
} else if (pH.acceptUrl(url)) {
|
} else if (pH.acceptUrl(url)) {
|
||||||
return LinkType.PLAYLIST;
|
return LinkType.PLAYLIST;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -24,14 +24,14 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
|
||||||
public interface UrlIdHandler {
|
public interface UrlIdHandler {
|
||||||
|
|
||||||
String getUrl(String videoId) throws ParsingException;
|
String getUrl(String id) throws ParsingException;
|
||||||
String getId(String siteUrl) throws ParsingException;
|
String getId(String url) throws ParsingException;
|
||||||
String cleanUrl(String siteUrl) throws ParsingException;
|
String cleanUrl(String complexUrl) throws ParsingException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* When a VIEW_ACTION is caught this function will test if the url delivered within the calling
|
* 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.
|
* Intent was meant to be watched with this Service.
|
||||||
* Return false if this service shall not allow to be called through ACTIONs.
|
* Return false if this service shall not allow to be called through ACTIONs.
|
||||||
*/
|
*/
|
||||||
boolean acceptUrl(String videoUrl);
|
boolean acceptUrl(String url);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
package org.schabi.newpipe.extractor.search;
|
package org.schabi.newpipe.extractor.search;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.InfoItemCollector;
|
import org.schabi.newpipe.extractor.InfoItemCollector;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItemCollector;
|
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;
|
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
|
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.user.UserInfoItemCollector;
|
||||||
|
import org.schabi.newpipe.extractor.user.UserInfoItemExtractor;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Created by Christian Schabesberger on 12.02.17.
|
* Created by Christian Schabesberger on 12.02.17.
|
||||||
|
@ -31,14 +31,14 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor;
|
||||||
public class InfoItemSearchCollector extends InfoItemCollector {
|
public class InfoItemSearchCollector extends InfoItemCollector {
|
||||||
private String suggestion;
|
private String suggestion;
|
||||||
private StreamInfoItemCollector streamCollector;
|
private StreamInfoItemCollector streamCollector;
|
||||||
private ChannelInfoItemCollector channelCollector;
|
private UserInfoItemCollector userCollector;
|
||||||
|
|
||||||
private SearchResult result = new SearchResult();
|
private SearchResult result = new SearchResult();
|
||||||
|
|
||||||
InfoItemSearchCollector(int serviceId) {
|
InfoItemSearchCollector(int serviceId) {
|
||||||
super(serviceId);
|
super(serviceId);
|
||||||
streamCollector = new StreamInfoItemCollector(serviceId);
|
streamCollector = new StreamInfoItemCollector(serviceId);
|
||||||
channelCollector = new ChannelInfoItemCollector(serviceId);
|
userCollector = new UserInfoItemCollector(serviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSuggestion(String suggestion) {
|
public void setSuggestion(String suggestion) {
|
||||||
|
@ -47,7 +47,7 @@ public class InfoItemSearchCollector extends InfoItemCollector {
|
||||||
|
|
||||||
public SearchResult getSearchResult() throws ExtractionException {
|
public SearchResult getSearchResult() throws ExtractionException {
|
||||||
|
|
||||||
addFromCollector(channelCollector);
|
addFromCollector(userCollector);
|
||||||
addFromCollector(streamCollector);
|
addFromCollector(streamCollector);
|
||||||
|
|
||||||
result.suggestion = suggestion;
|
result.suggestion = suggestion;
|
||||||
|
@ -65,9 +65,9 @@ public class InfoItemSearchCollector extends InfoItemCollector {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void commit(ChannelInfoItemExtractor extractor) {
|
public void commit(UserInfoItemExtractor extractor) {
|
||||||
try {
|
try {
|
||||||
result.resultList.add(channelCollector.extract(extractor));
|
result.resultList.add(userCollector.extract(extractor));
|
||||||
} catch (FoundAdException ae) {
|
} catch (FoundAdException ae) {
|
||||||
System.err.println("Found ad");
|
System.err.println("Found ad");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.EnumSet;
|
||||||
|
|
||||||
public abstract class SearchEngine {
|
public abstract class SearchEngine {
|
||||||
public enum Filter {
|
public enum Filter {
|
||||||
STREAM, CHANNEL, PLAYLIST
|
STREAM, USER, PLAYLIST
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class NothingFoundException extends ExtractionException {
|
public static class NothingFoundException extends ExtractionException {
|
||||||
|
|
|
@ -16,9 +16,9 @@ public class SoundcloudPlaylistUrlIdHandler implements UrlIdHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUrl(String listId) throws ParsingException {
|
public String getUrl(String id) throws ParsingException {
|
||||||
try {
|
try {
|
||||||
return SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/playlists/" + listId);
|
return SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/playlists/" + id);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ParsingException(e.getMessage(), e);
|
throw new ParsingException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,8 @@ public class SoundcloudPlaylistUrlIdHandler implements UrlIdHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptUrl(String videoUrl) {
|
public boolean acceptUrl(String url) {
|
||||||
String regex = "^https?://(www\\.)?soundcloud.com/[0-9a-z_-]+/sets/[0-9a-z_-]+/?([#?].*)?$";
|
String regex = "^https?://(www\\.)?soundcloud.com/[0-9a-z_-]+/sets/[0-9a-z_-]+/?([#?].*)?$";
|
||||||
return Parser.isMatch(regex, videoUrl.toLowerCase());
|
return Parser.isMatch(regex, url.toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,9 +27,9 @@ public class SoundcloudSearchEngine extends SearchEngine {
|
||||||
|
|
||||||
String url = "https://api-v2.soundcloud.com/search";
|
String url = "https://api-v2.soundcloud.com/search";
|
||||||
|
|
||||||
if (filter.contains(Filter.STREAM) && !filter.contains(Filter.CHANNEL)) {
|
if (filter.contains(Filter.STREAM) && !filter.contains(Filter.USER)) {
|
||||||
url += "/tracks";
|
url += "/tracks";
|
||||||
} else if (!filter.contains(Filter.STREAM) && filter.contains(Filter.CHANNEL)) {
|
} else if (!filter.contains(Filter.STREAM) && filter.contains(Filter.USER)) {
|
||||||
url += "/users";
|
url += "/users";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class SoundcloudSearchEngine extends SearchEngine {
|
||||||
JSONObject searchResult = searchCollection.getJSONObject(i);
|
JSONObject searchResult = searchCollection.getJSONObject(i);
|
||||||
String kind = searchResult.getString("kind");
|
String kind = searchResult.getString("kind");
|
||||||
if (kind.equals("user")) {
|
if (kind.equals("user")) {
|
||||||
collector.commit(new SoundcloudChannelInfoItemExtractor(searchResult));
|
collector.commit(new SoundcloudUserInfoItemExtractor(searchResult));
|
||||||
} else if (kind.equals("track")) {
|
} else if (kind.equals("track")) {
|
||||||
collector.commit(new SoundcloudStreamInfoItemExtractor(searchResult));
|
collector.commit(new SoundcloudStreamInfoItemExtractor(searchResult));
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,11 @@ package org.schabi.newpipe.extractor.services.soundcloud;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.SuggestionExtractor;
|
import org.schabi.newpipe.extractor.SuggestionExtractor;
|
||||||
import org.schabi.newpipe.extractor.UrlIdHandler;
|
import org.schabi.newpipe.extractor.UrlIdHandler;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
||||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.user.UserExtractor;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ public class SoundcloudService extends StreamingService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UrlIdHandler getChannelUrlIdHandler() {
|
public UrlIdHandler getUserUrlIdHandler() {
|
||||||
return SoundcloudChannelUrlIdHandler.getInstance();
|
return SoundcloudUserUrlIdHandler.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -44,8 +44,8 @@ public class SoundcloudService extends StreamingService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChannelExtractor getChannelExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
public UserExtractor getUserExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||||
return new SoundcloudChannelExtractor(this, url, nextStreamsUrl);
|
return new SoundcloudUserExtractor(this, url, nextStreamsUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -215,7 +215,7 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChannelUrl() {
|
public String getUserUrl() {
|
||||||
return track.getJSONObject("user").getString("permalink_url");
|
return track.getJSONObject("user").getString("permalink_url");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,9 @@ public class SoundcloudStreamUrlIdHandler implements UrlIdHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUrl(String videoId) throws ParsingException {
|
public String getUrl(String id) throws ParsingException {
|
||||||
try {
|
try {
|
||||||
return SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/tracks/" + videoId);
|
return SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/tracks/" + id);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ParsingException(e.getMessage(), e);
|
throw new ParsingException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
@ -49,8 +49,8 @@ public class SoundcloudStreamUrlIdHandler implements UrlIdHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptUrl(String videoUrl) {
|
public boolean acceptUrl(String url) {
|
||||||
String regex = "^https?://(www\\.)?soundcloud.com/[0-9a-z_-]+/(?!(tracks|albums|sets|reposts|followers|following)/?$)[0-9a-z_-]+/?([#?].*)?$";
|
String regex = "^https?://(www\\.)?soundcloud.com/[0-9a-z_-]+/(?!(tracks|albums|sets|reposts|followers|following)/?$)[0-9a-z_-]+/?([#?].*)?$";
|
||||||
return Parser.isMatch(regex, videoUrl.toLowerCase());
|
return Parser.isMatch(regex, url.toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,19 +4,19 @@ import org.json.JSONObject;
|
||||||
import org.schabi.newpipe.extractor.Downloader;
|
import org.schabi.newpipe.extractor.Downloader;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
||||||
|
import org.schabi.newpipe.extractor.user.UserExtractor;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
public class SoundcloudChannelExtractor extends ChannelExtractor {
|
public class SoundcloudUserExtractor extends UserExtractor {
|
||||||
private String channelId;
|
private String userId;
|
||||||
private JSONObject channel;
|
private JSONObject user;
|
||||||
|
|
||||||
public SoundcloudChannelExtractor(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
public SoundcloudUserExtractor(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||||
super(service, url, nextStreamsUrl);
|
super(service, url, nextStreamsUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,42 +24,42 @@ public class SoundcloudChannelExtractor extends ChannelExtractor {
|
||||||
public void fetchPage() throws IOException, ExtractionException {
|
public void fetchPage() throws IOException, ExtractionException {
|
||||||
Downloader dl = NewPipe.getDownloader();
|
Downloader dl = NewPipe.getDownloader();
|
||||||
|
|
||||||
channelId = getUrlIdHandler().getId(getOriginalUrl());
|
userId = getUrlIdHandler().getId(getOriginalUrl());
|
||||||
String apiUrl = "https://api.soundcloud.com/users/" + channelId +
|
String apiUrl = "https://api.soundcloud.com/users/" + userId +
|
||||||
"?client_id=" + SoundcloudParsingHelper.clientId();
|
"?client_id=" + SoundcloudParsingHelper.clientId();
|
||||||
|
|
||||||
String response = dl.download(apiUrl);
|
String response = dl.download(apiUrl);
|
||||||
channel = new JSONObject(response);
|
user = new JSONObject(response);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getCleanUrl() {
|
public String getCleanUrl() {
|
||||||
try {
|
try {
|
||||||
return channel.getString("permalink_url");
|
return user.getString("permalink_url");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return getOriginalUrl();
|
return getOriginalUrl();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChannelId() {
|
public String getUserId() {
|
||||||
return channelId;
|
return userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChannelName() {
|
public String getUserName() {
|
||||||
return channel.getString("username");
|
return user.getString("username");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getAvatarUrl() {
|
public String getAvatarUrl() {
|
||||||
return channel.getString("avatar_url");
|
return user.getString("avatar_url");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getBannerUrl() throws ParsingException {
|
public String getBannerUrl() throws ParsingException {
|
||||||
try {
|
try {
|
||||||
return channel.getJSONObject("visuals").getJSONArray("visuals").getJSONObject(0).getString("visual_url");
|
return user.getJSONObject("visuals").getJSONArray("visuals").getJSONObject(0).getString("visual_url");
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ParsingException("Could not get Banner", e);
|
throw new ParsingException("Could not get Banner", e);
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ public class SoundcloudChannelExtractor extends ChannelExtractor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSubscriberCount() {
|
public long getSubscriberCount() {
|
||||||
return channel.getLong("followers_count");
|
return user.getLong("followers_count");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -79,7 +79,7 @@ public class SoundcloudChannelExtractor extends ChannelExtractor {
|
||||||
public StreamInfoItemCollector getStreams() throws IOException, ExtractionException {
|
public StreamInfoItemCollector getStreams() throws IOException, ExtractionException {
|
||||||
StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId());
|
StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId());
|
||||||
|
|
||||||
String apiUrl = "https://api-v2.soundcloud.com/users/" + getChannelId() + "/tracks"
|
String apiUrl = "https://api-v2.soundcloud.com/users/" + getUserId() + "/tracks"
|
||||||
+ "?client_id=" + SoundcloudParsingHelper.clientId()
|
+ "?client_id=" + SoundcloudParsingHelper.clientId()
|
||||||
+ "&limit=20"
|
+ "&limit=20"
|
||||||
+ "&linked_partitioning=1";
|
+ "&linked_partitioning=1";
|
||||||
|
@ -91,7 +91,7 @@ public class SoundcloudChannelExtractor extends ChannelExtractor {
|
||||||
@Override
|
@Override
|
||||||
public NextItemsResult getNextStreams() throws IOException, ExtractionException {
|
public NextItemsResult getNextStreams() throws IOException, ExtractionException {
|
||||||
if (!hasMoreStreams()) {
|
if (!hasMoreStreams()) {
|
||||||
throw new ExtractionException("Channel doesn't have more streams");
|
throw new ExtractionException("User doesn't have more streams");
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId());
|
StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId());
|
|
@ -1,12 +1,12 @@
|
||||||
package org.schabi.newpipe.extractor.services.soundcloud;
|
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;
|
import org.schabi.newpipe.extractor.user.UserInfoItemExtractor;
|
||||||
|
|
||||||
public class SoundcloudChannelInfoItemExtractor implements ChannelInfoItemExtractor {
|
public class SoundcloudUserInfoItemExtractor implements UserInfoItemExtractor {
|
||||||
private JSONObject searchResult;
|
private JSONObject searchResult;
|
||||||
|
|
||||||
public SoundcloudChannelInfoItemExtractor(JSONObject searchResult) {
|
public SoundcloudUserInfoItemExtractor(JSONObject searchResult) {
|
||||||
this.searchResult = searchResult;
|
this.searchResult = searchResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@ public class SoundcloudChannelInfoItemExtractor implements ChannelInfoItemExtrac
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChannelName() {
|
public String getUserName() {
|
||||||
return searchResult.getString("username");
|
return searchResult.getString("username");
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,18 +7,18 @@ import org.schabi.newpipe.extractor.UrlIdHandler;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.utils.Parser;
|
import org.schabi.newpipe.extractor.utils.Parser;
|
||||||
|
|
||||||
public class SoundcloudChannelUrlIdHandler implements UrlIdHandler {
|
public class SoundcloudUserUrlIdHandler implements UrlIdHandler {
|
||||||
|
|
||||||
private static final SoundcloudChannelUrlIdHandler instance = new SoundcloudChannelUrlIdHandler();
|
private static final SoundcloudUserUrlIdHandler instance = new SoundcloudUserUrlIdHandler();
|
||||||
|
|
||||||
public static SoundcloudChannelUrlIdHandler getInstance() {
|
public static SoundcloudUserUrlIdHandler getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUrl(String channelId) throws ParsingException {
|
public String getUrl(String id) throws ParsingException {
|
||||||
try {
|
try {
|
||||||
return SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/users/" + channelId);
|
return SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/users/" + id);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ParsingException(e.getMessage(), e);
|
throw new ParsingException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
@ -46,8 +46,8 @@ public class SoundcloudChannelUrlIdHandler implements UrlIdHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptUrl(String channelUrl) {
|
public boolean acceptUrl(String url) {
|
||||||
String regex = "^https?://(www\\.)?soundcloud.com/[0-9a-z_-]+(/((tracks|albums|sets|reposts|followers|following)/?)?)?([#?].*)?$";
|
String regex = "^https?://(www\\.)?soundcloud.com/[0-9a-z_-]+(/((tracks|albums|sets|reposts|followers|following)/?)?)?([#?].*)?$";
|
||||||
return Parser.isMatch(regex, channelUrl.toLowerCase());
|
return Parser.isMatch(regex, url.toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -15,8 +15,8 @@ public class YoutubePlaylistUrlIdHandler implements UrlIdHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUrl(String listId) {
|
public String getUrl(String id) {
|
||||||
return "https://www.youtube.com/playlist?list=" + listId;
|
return "https://www.youtube.com/playlist?list=" + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -34,9 +34,9 @@ public class YoutubePlaylistUrlIdHandler implements UrlIdHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptUrl(String videoUrl) {
|
public boolean acceptUrl(String url) {
|
||||||
final boolean hasNotEmptyUrl = videoUrl != null && !videoUrl.isEmpty();
|
final boolean hasNotEmptyUrl = url != null && !url.isEmpty();
|
||||||
final boolean isYoutubeDomain = hasNotEmptyUrl && (videoUrl.contains("youtube") || videoUrl.contains("youtu.be"));
|
final boolean isYoutubeDomain = hasNotEmptyUrl && (url.contains("youtube") || url.contains("youtu.be"));
|
||||||
return isYoutubeDomain && videoUrl.contains("list=");
|
return isYoutubeDomain && url.contains("list=");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,9 +57,9 @@ public class YoutubeSearchEngine extends SearchEngine {
|
||||||
String url = "https://www.youtube.com/results"
|
String url = "https://www.youtube.com/results"
|
||||||
+ "?q=" + URLEncoder.encode(query, CHARSET_UTF_8)
|
+ "?q=" + URLEncoder.encode(query, CHARSET_UTF_8)
|
||||||
+ "&page=" + Integer.toString(page + 1);
|
+ "&page=" + Integer.toString(page + 1);
|
||||||
if (filter.contains(Filter.STREAM) && !filter.contains(Filter.CHANNEL)) {
|
if (filter.contains(Filter.STREAM) && !filter.contains(Filter.USER)) {
|
||||||
url += "&sp=EgIQAQ%253D%253D";
|
url += "&sp=EgIQAQ%253D%253D";
|
||||||
} else if (!filter.contains(Filter.STREAM) && filter.contains(Filter.CHANNEL)) {
|
} else if (!filter.contains(Filter.STREAM) && filter.contains(Filter.USER)) {
|
||||||
url += "&sp=EgIQAg%253D%253D";
|
url += "&sp=EgIQAg%253D%253D";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ public class YoutubeSearchEngine extends SearchEngine {
|
||||||
} else if ((el = item.select("div[class*=\"yt-lockup-video\"]").first()) != null) {
|
} else if ((el = item.select("div[class*=\"yt-lockup-video\"]").first()) != null) {
|
||||||
collector.commit(new YoutubeStreamInfoItemExtractor(el));
|
collector.commit(new YoutubeStreamInfoItemExtractor(el));
|
||||||
} else if ((el = item.select("div[class*=\"yt-lockup-channel\"]").first()) != null) {
|
} else if ((el = item.select("div[class*=\"yt-lockup-channel\"]").first()) != null) {
|
||||||
collector.commit(new YoutubeChannelInfoItemExtractor(el));
|
collector.commit(new YoutubeUserInfoItemExtractor(el));
|
||||||
} else {
|
} else {
|
||||||
// noinspection ConstantConditions
|
// noinspection ConstantConditions
|
||||||
// simply ignore not known items
|
// simply ignore not known items
|
||||||
|
|
|
@ -3,11 +3,11 @@ package org.schabi.newpipe.extractor.services.youtube;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.SuggestionExtractor;
|
import org.schabi.newpipe.extractor.SuggestionExtractor;
|
||||||
import org.schabi.newpipe.extractor.UrlIdHandler;
|
import org.schabi.newpipe.extractor.UrlIdHandler;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
||||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.user.UserExtractor;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@ -49,8 +49,8 @@ public class YoutubeService extends StreamingService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UrlIdHandler getChannelUrlIdHandler() {
|
public UrlIdHandler getUserUrlIdHandler() {
|
||||||
return YoutubeChannelUrlIdHandler.getInstance();
|
return YoutubeUserUrlIdHandler.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -65,8 +65,8 @@ public class YoutubeService extends StreamingService {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChannelExtractor getChannelExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
public UserExtractor getUserExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||||
return new YoutubeChannelExtractor(this, url, nextStreamsUrl);
|
return new YoutubeUserExtractor(this, url, nextStreamsUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -542,7 +542,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChannelUrl() throws ParsingException {
|
public String getUserUrl() throws ParsingException {
|
||||||
try {
|
try {
|
||||||
return doc.select("div[class=\"yt-user-info\"]").first().children()
|
return doc.select("div[class=\"yt-user-info\"]").first().children()
|
||||||
.select("a").first().attr("abs:href");
|
.select("a").first().attr("abs:href");
|
||||||
|
|
|
@ -47,8 +47,8 @@ public class YoutubeStreamUrlIdHandler implements UrlIdHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUrl(String videoId) {
|
public String getUrl(String id) {
|
||||||
return "https://www.youtube.com/watch?v=" + videoId;
|
return "https://www.youtube.com/watch?v=" + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -146,13 +146,13 @@ public class YoutubeStreamUrlIdHandler implements UrlIdHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptUrl(String videoUrl) {
|
public boolean acceptUrl(String url) {
|
||||||
String lowercaseUrl = videoUrl.toLowerCase();
|
String lowercaseUrl = url.toLowerCase();
|
||||||
if (lowercaseUrl.contains("youtube") ||
|
if (lowercaseUrl.contains("youtube") ||
|
||||||
lowercaseUrl.contains("youtu.be")) {
|
lowercaseUrl.contains("youtu.be")) {
|
||||||
// bad programming I know
|
// bad programming I know
|
||||||
try {
|
try {
|
||||||
getId(videoUrl);
|
getId(url);
|
||||||
return true;
|
return true;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -9,13 +9,13 @@ import org.jsoup.nodes.Element;
|
||||||
import org.schabi.newpipe.extractor.Downloader;
|
import org.schabi.newpipe.extractor.Downloader;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
|
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamType;
|
import org.schabi.newpipe.extractor.stream.StreamType;
|
||||||
|
import org.schabi.newpipe.extractor.user.UserExtractor;
|
||||||
import org.schabi.newpipe.extractor.utils.Parser;
|
import org.schabi.newpipe.extractor.utils.Parser;
|
||||||
import org.schabi.newpipe.extractor.utils.Utils;
|
import org.schabi.newpipe.extractor.utils.Utils;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ import java.io.IOException;
|
||||||
* Created by Christian Schabesberger on 25.07.16.
|
* Created by Christian Schabesberger on 25.07.16.
|
||||||
*
|
*
|
||||||
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
|
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
|
||||||
* YoutubeChannelExtractor.java is part of NewPipe.
|
* YoutubeUserExtractor.java is part of NewPipe.
|
||||||
*
|
*
|
||||||
* NewPipe is free software: you can redistribute it and/or modify
|
* NewPipe is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -42,7 +42,7 @@ import java.io.IOException;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
public class YoutubeChannelExtractor extends ChannelExtractor {
|
public class YoutubeUserExtractor extends UserExtractor {
|
||||||
private static final String CHANNEL_FEED_BASE = "https://www.youtube.com/feeds/videos.xml?channel_id=";
|
private static final String CHANNEL_FEED_BASE = "https://www.youtube.com/feeds/videos.xml?channel_id=";
|
||||||
private static final String CHANNEL_URL_PARAMETERS = "/videos?view=0&flow=list&sort=dd&live_view=10000";
|
private static final String CHANNEL_URL_PARAMETERS = "/videos?view=0&flow=list&sort=dd&live_view=10000";
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
||||||
*/
|
*/
|
||||||
private Document nextStreamsAjax;
|
private Document nextStreamsAjax;
|
||||||
|
|
||||||
public YoutubeChannelExtractor(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
public YoutubeUserExtractor(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||||
super(service, url, nextStreamsUrl);
|
super(service, url, nextStreamsUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChannelId() throws ParsingException {
|
public String getUserId() throws ParsingException {
|
||||||
try {
|
try {
|
||||||
return getUrlIdHandler().getId(getCleanUrl());
|
return getUrlIdHandler().getId(getCleanUrl());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -78,7 +78,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChannelName() throws ParsingException {
|
public String getUserName() throws ParsingException {
|
||||||
try {
|
try {
|
||||||
return doc.select("span[class=\"qualified-channel-title-text\"]").first().select("a").first().text();
|
return doc.select("span[class=\"qualified-channel-title-text\"]").first().select("a").first().text();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -239,7 +239,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUploader() throws ParsingException {
|
public String getUploader() throws ParsingException {
|
||||||
return getChannelName();
|
return getUserName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
|
@ -1,15 +1,15 @@
|
||||||
package org.schabi.newpipe.extractor.services.youtube;
|
package org.schabi.newpipe.extractor.services.youtube;
|
||||||
|
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;
|
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
import org.schabi.newpipe.extractor.user.UserInfoItemExtractor;
|
||||||
import org.schabi.newpipe.extractor.utils.Utils;
|
import org.schabi.newpipe.extractor.utils.Utils;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Created by Christian Schabesberger on 12.02.17.
|
* Created by Christian Schabesberger on 12.02.17.
|
||||||
*
|
*
|
||||||
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
|
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
|
||||||
* YoutubeChannelInfoItemExtractor.java is part of NewPipe.
|
* YoutubeUserInfoItemExtractor.java is part of NewPipe.
|
||||||
*
|
*
|
||||||
* NewPipe is free software: you can redistribute it and/or modify
|
* NewPipe is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -25,10 +25,10 @@ import org.schabi.newpipe.extractor.utils.Utils;
|
||||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class YoutubeChannelInfoItemExtractor implements ChannelInfoItemExtractor {
|
public class YoutubeUserInfoItemExtractor implements UserInfoItemExtractor {
|
||||||
private Element el;
|
private Element el;
|
||||||
|
|
||||||
public YoutubeChannelInfoItemExtractor(Element el) {
|
public YoutubeUserInfoItemExtractor(Element el) {
|
||||||
this.el = el;
|
this.el = el;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ public class YoutubeChannelInfoItemExtractor implements ChannelInfoItemExtractor
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getChannelName() throws ParsingException {
|
public String getUserName() throws ParsingException {
|
||||||
return el.select("a[class*=\"yt-uix-tile-link\"]").first()
|
return el.select("a[class*=\"yt-uix-tile-link\"]").first()
|
||||||
.text();
|
.text();
|
||||||
}
|
}
|
|
@ -8,7 +8,7 @@ import org.schabi.newpipe.extractor.utils.Parser;
|
||||||
* Created by Christian Schabesberger on 25.07.16.
|
* Created by Christian Schabesberger on 25.07.16.
|
||||||
*
|
*
|
||||||
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
|
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
|
||||||
* YoutubeChannelUrlIdHandler.java is part of NewPipe.
|
* YoutubeUserUrlIdHandler.java is part of NewPipe.
|
||||||
*
|
*
|
||||||
* NewPipe is free software: you can redistribute it and/or modify
|
* NewPipe is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -24,35 +24,35 @@ import org.schabi.newpipe.extractor.utils.Parser;
|
||||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class YoutubeChannelUrlIdHandler implements UrlIdHandler {
|
public class YoutubeUserUrlIdHandler implements UrlIdHandler {
|
||||||
|
|
||||||
private static final YoutubeChannelUrlIdHandler instance = new YoutubeChannelUrlIdHandler();
|
private static final YoutubeUserUrlIdHandler instance = new YoutubeUserUrlIdHandler();
|
||||||
private static final String ID_PATTERN = "/(user/[A-Za-z0-9_-]*|channel/[A-Za-z0-9_-]*)";
|
private static final String ID_PATTERN = "/(user/[A-Za-z0-9_-]*|channel/[A-Za-z0-9_-]*)";
|
||||||
|
|
||||||
public static YoutubeChannelUrlIdHandler getInstance() {
|
public static YoutubeUserUrlIdHandler getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUrl(String channelId) {
|
public String getUrl(String id) {
|
||||||
return "https://www.youtube.com/" + channelId;
|
return "https://www.youtube.com/" + id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId(String siteUrl) throws ParsingException {
|
public String getId(String url) throws ParsingException {
|
||||||
return Parser.matchGroup1(ID_PATTERN, siteUrl);
|
return Parser.matchGroup1(ID_PATTERN, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String cleanUrl(String siteUrl) throws ParsingException {
|
public String cleanUrl(String complexUrl) throws ParsingException {
|
||||||
return getUrl(getId(siteUrl));
|
return getUrl(getId(complexUrl));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean acceptUrl(String videoUrl) {
|
public boolean acceptUrl(String url) {
|
||||||
return (videoUrl.contains("youtube") ||
|
return (url.contains("youtube") ||
|
||||||
videoUrl.contains("youtu.be")) &&
|
url.contains("youtu.be")) &&
|
||||||
(videoUrl.contains("/user/") ||
|
(url.contains("/user/") ||
|
||||||
videoUrl.contains("/channel/"));
|
url.contains("/channel/"));
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -49,7 +49,7 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
public abstract String getTitle() throws ParsingException;
|
public abstract String getTitle() throws ParsingException;
|
||||||
public abstract String getDescription() throws ParsingException;
|
public abstract String getDescription() throws ParsingException;
|
||||||
public abstract String getUploader() throws ParsingException;
|
public abstract String getUploader() throws ParsingException;
|
||||||
public abstract String getChannelUrl() throws ParsingException;
|
public abstract String getUserUrl() throws ParsingException;
|
||||||
public abstract int getLength() throws ParsingException;
|
public abstract int getLength() throws ParsingException;
|
||||||
public abstract long getViewCount() throws ParsingException;
|
public abstract long getViewCount() throws ParsingException;
|
||||||
public abstract String getUploadDate() throws ParsingException;
|
public abstract String getUploadDate() throws ParsingException;
|
||||||
|
|
|
@ -195,7 +195,7 @@ public class StreamInfo extends Info {
|
||||||
streamInfo.addException(e);
|
streamInfo.addException(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.channel_url = extractor.getChannelUrl();
|
streamInfo.user_url = extractor.getUserUrl();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
streamInfo.addException(e);
|
streamInfo.addException(e);
|
||||||
}
|
}
|
||||||
|
@ -275,7 +275,7 @@ public class StreamInfo extends Info {
|
||||||
public long view_count = -1;
|
public long view_count = -1;
|
||||||
|
|
||||||
public String uploader_thumbnail_url;
|
public String uploader_thumbnail_url;
|
||||||
public String channel_url;
|
public String user_url;
|
||||||
public String description;
|
public String description;
|
||||||
|
|
||||||
public List<VideoStream> video_streams;
|
public List<VideoStream> video_streams;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
package org.schabi.newpipe.extractor.channel;
|
package org.schabi.newpipe.extractor.user;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.ListExtractor;
|
import org.schabi.newpipe.extractor.ListExtractor;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
|
@ -12,7 +12,7 @@ import java.io.IOException;
|
||||||
* Created by Christian Schabesberger on 25.07.16.
|
* Created by Christian Schabesberger on 25.07.16.
|
||||||
*
|
*
|
||||||
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
|
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
|
||||||
* ChannelExtractor.java is part of NewPipe.
|
* UserExtractor.java is part of NewPipe.
|
||||||
*
|
*
|
||||||
* NewPipe is free software: you can redistribute it and/or modify
|
* NewPipe is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -28,19 +28,19 @@ import java.io.IOException;
|
||||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public abstract class ChannelExtractor extends ListExtractor {
|
public abstract class UserExtractor extends ListExtractor {
|
||||||
|
|
||||||
public ChannelExtractor(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
public UserExtractor(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||||
super(service, url, nextStreamsUrl);
|
super(service, url, nextStreamsUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected UrlIdHandler getUrlIdHandler() throws ParsingException {
|
protected UrlIdHandler getUrlIdHandler() throws ParsingException {
|
||||||
return getService().getChannelUrlIdHandler();
|
return getService().getUserUrlIdHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getChannelId() throws ParsingException;
|
public abstract String getUserId() throws ParsingException;
|
||||||
public abstract String getChannelName() throws ParsingException;
|
public abstract String getUserName() throws ParsingException;
|
||||||
public abstract String getAvatarUrl() throws ParsingException;
|
public abstract String getAvatarUrl() throws ParsingException;
|
||||||
public abstract String getBannerUrl() throws ParsingException;
|
public abstract String getBannerUrl() throws ParsingException;
|
||||||
public abstract String getFeedUrl() throws ParsingException;
|
public abstract String getFeedUrl() throws ParsingException;
|
|
@ -1,4 +1,4 @@
|
||||||
package org.schabi.newpipe.extractor.channel;
|
package org.schabi.newpipe.extractor.user;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.ListExtractor.NextItemsResult;
|
import org.schabi.newpipe.extractor.ListExtractor.NextItemsResult;
|
||||||
import org.schabi.newpipe.extractor.ListInfo;
|
import org.schabi.newpipe.extractor.ListInfo;
|
||||||
|
@ -16,7 +16,7 @@ import java.util.ArrayList;
|
||||||
* Created by Christian Schabesberger on 31.07.16.
|
* Created by Christian Schabesberger on 31.07.16.
|
||||||
*
|
*
|
||||||
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
|
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
|
||||||
* ChannelInfo.java is part of NewPipe.
|
* UserInfo.java is part of NewPipe.
|
||||||
*
|
*
|
||||||
* NewPipe is free software: you can redistribute it and/or modify
|
* NewPipe is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -32,36 +32,36 @@ import java.util.ArrayList;
|
||||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ChannelInfo extends ListInfo {
|
public class UserInfo extends ListInfo {
|
||||||
|
|
||||||
public static NextItemsResult getMoreItems(ServiceList serviceItem, String nextStreamsUrl) throws IOException, ExtractionException {
|
public static NextItemsResult getMoreItems(ServiceList serviceItem, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||||
return getMoreItems(serviceItem.getService(), nextStreamsUrl);
|
return getMoreItems(serviceItem.getService(), nextStreamsUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static NextItemsResult getMoreItems(StreamingService service, String nextStreamsUrl) throws IOException, ExtractionException {
|
public static NextItemsResult getMoreItems(StreamingService service, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||||
return service.getChannelExtractor(null, nextStreamsUrl).getNextStreams();
|
return service.getUserExtractor(null, nextStreamsUrl).getNextStreams();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ChannelInfo getInfo(String url) throws IOException, ExtractionException {
|
public static UserInfo getInfo(String url) throws IOException, ExtractionException {
|
||||||
return getInfo(NewPipe.getServiceByUrl(url), url);
|
return getInfo(NewPipe.getServiceByUrl(url), url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ChannelInfo getInfo(ServiceList serviceItem, String url) throws IOException, ExtractionException {
|
public static UserInfo getInfo(ServiceList serviceItem, String url) throws IOException, ExtractionException {
|
||||||
return getInfo(serviceItem.getService(), url);
|
return getInfo(serviceItem.getService(), url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ChannelInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
|
public static UserInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
|
||||||
return getInfo(service.getChannelExtractor(url));
|
return getInfo(service.getUserExtractor(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ChannelInfo getInfo(ChannelExtractor extractor) throws ParsingException {
|
public static UserInfo getInfo(UserExtractor extractor) throws ParsingException {
|
||||||
ChannelInfo info = new ChannelInfo();
|
UserInfo info = new UserInfo();
|
||||||
|
|
||||||
// important data
|
// important data
|
||||||
info.service_id = extractor.getServiceId();
|
info.service_id = extractor.getServiceId();
|
||||||
info.url = extractor.getCleanUrl();
|
info.url = extractor.getCleanUrl();
|
||||||
info.id = extractor.getChannelId();
|
info.id = extractor.getUserId();
|
||||||
info.name = extractor.getChannelName();
|
info.name = extractor.getUserName();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
info.avatar_url = extractor.getAvatarUrl();
|
info.avatar_url = extractor.getAvatarUrl();
|
|
@ -1,4 +1,4 @@
|
||||||
package org.schabi.newpipe.extractor.channel;
|
package org.schabi.newpipe.extractor.user;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.InfoItem;
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import org.schabi.newpipe.extractor.InfoItem;
|
||||||
* Created by Christian Schabesberger on 11.02.17.
|
* Created by Christian Schabesberger on 11.02.17.
|
||||||
*
|
*
|
||||||
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
|
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
|
||||||
* ChannelInfoItem.java is part of NewPipe.
|
* UserInfoItem.java is part of NewPipe.
|
||||||
*
|
*
|
||||||
* NewPipe is free software: you can redistribute it and/or modify
|
* NewPipe is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -22,14 +22,14 @@ import org.schabi.newpipe.extractor.InfoItem;
|
||||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ChannelInfoItem extends InfoItem {
|
public class UserInfoItem extends InfoItem {
|
||||||
|
|
||||||
public String thumbnail_url;
|
public String thumbnail_url;
|
||||||
public String description;
|
public String description;
|
||||||
public long subscriber_count = -1;
|
public long subscriber_count = -1;
|
||||||
public long stream_count = -1;
|
public long stream_count = -1;
|
||||||
|
|
||||||
public ChannelInfoItem() {
|
public UserInfoItem() {
|
||||||
super(InfoType.CHANNEL);
|
super(InfoType.USER);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,4 +1,4 @@
|
||||||
package org.schabi.newpipe.extractor.channel;
|
package org.schabi.newpipe.extractor.user;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.InfoItemCollector;
|
import org.schabi.newpipe.extractor.InfoItemCollector;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
@ -7,7 +7,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
* Created by Christian Schabesberger on 12.02.17.
|
* Created by Christian Schabesberger on 12.02.17.
|
||||||
*
|
*
|
||||||
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
|
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
|
||||||
* ChannelInfoItemCollector.java is part of NewPipe.
|
* UserInfoItemCollector.java is part of NewPipe.
|
||||||
*
|
*
|
||||||
* NewPipe is free software: you can redistribute it and/or modify
|
* NewPipe is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -23,15 +23,15 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ChannelInfoItemCollector extends InfoItemCollector {
|
public class UserInfoItemCollector extends InfoItemCollector {
|
||||||
public ChannelInfoItemCollector(int serviceId) {
|
public UserInfoItemCollector(int serviceId) {
|
||||||
super(serviceId);
|
super(serviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChannelInfoItem extract(ChannelInfoItemExtractor extractor) throws ParsingException {
|
public UserInfoItem extract(UserInfoItemExtractor extractor) throws ParsingException {
|
||||||
ChannelInfoItem resultItem = new ChannelInfoItem();
|
UserInfoItem resultItem = new UserInfoItem();
|
||||||
// important information
|
// important information
|
||||||
resultItem.name = extractor.getChannelName();
|
resultItem.name = extractor.getUserName();
|
||||||
|
|
||||||
resultItem.service_id = getServiceId();
|
resultItem.service_id = getServiceId();
|
||||||
resultItem.url = extractor.getWebPageUrl();
|
resultItem.url = extractor.getWebPageUrl();
|
||||||
|
@ -60,7 +60,7 @@ public class ChannelInfoItemCollector extends InfoItemCollector {
|
||||||
return resultItem;
|
return resultItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void commit(ChannelInfoItemExtractor extractor) throws ParsingException {
|
public void commit(UserInfoItemExtractor extractor) throws ParsingException {
|
||||||
try {
|
try {
|
||||||
addItem(extract(extractor));
|
addItem(extract(extractor));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
|
@ -1,4 +1,4 @@
|
||||||
package org.schabi.newpipe.extractor.channel;
|
package org.schabi.newpipe.extractor.user;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
* Created by Christian Schabesberger on 12.02.17.
|
* Created by Christian Schabesberger on 12.02.17.
|
||||||
*
|
*
|
||||||
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
|
* Copyright (C) Christian Schabesberger 2017 <chris.schabesberger@mailbox.org>
|
||||||
* ChannelInfoItemExtractor.java is part of NewPipe.
|
* UserInfoItemExtractor.java is part of NewPipe.
|
||||||
*
|
*
|
||||||
* NewPipe is free software: you can redistribute it and/or modify
|
* NewPipe is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
@ -22,9 +22,9 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public interface ChannelInfoItemExtractor {
|
public interface UserInfoItemExtractor {
|
||||||
String getThumbnailUrl() throws ParsingException;
|
String getThumbnailUrl() throws ParsingException;
|
||||||
String getChannelName() throws ParsingException;
|
String getUserName() throws ParsingException;
|
||||||
String getWebPageUrl() throws ParsingException;
|
String getWebPageUrl() throws ParsingException;
|
||||||
String getDescription() throws ParsingException;
|
String getDescription() throws ParsingException;
|
||||||
long getSubscriberCount() throws ParsingException;
|
long getSubscriberCount() throws ParsingException;
|
|
@ -8,7 +8,7 @@ import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotEquals;
|
import static org.junit.Assert.assertNotEquals;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.Youtube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
import static org.schabi.newpipe.extractor.NewPipe.getServiceByUrl;
|
import static org.schabi.newpipe.extractor.NewPipe.getServiceByUrl;
|
||||||
|
|
||||||
public class NewPipeTest {
|
public class NewPipeTest {
|
||||||
|
@ -29,46 +29,46 @@ public class NewPipeTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getServiceWithId() throws Exception {
|
public void getServiceWithId() throws Exception {
|
||||||
assertEquals(NewPipe.getService(Youtube.getId()), Youtube.getService());
|
assertEquals(NewPipe.getService(YouTube.getId()), YouTube.getService());
|
||||||
assertEquals(NewPipe.getService(SoundCloud.getId()), SoundCloud.getService());
|
assertEquals(NewPipe.getService(SoundCloud.getId()), SoundCloud.getService());
|
||||||
|
|
||||||
assertNotEquals(NewPipe.getService(SoundCloud.getId()), Youtube.getService());
|
assertNotEquals(NewPipe.getService(SoundCloud.getId()), YouTube.getService());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getServiceWithName() throws Exception {
|
public void getServiceWithName() throws Exception {
|
||||||
assertEquals(NewPipe.getService(Youtube.getServiceInfo().name), Youtube.getService());
|
assertEquals(NewPipe.getService(YouTube.getServiceInfo().name), YouTube.getService());
|
||||||
assertEquals(NewPipe.getService(SoundCloud.getServiceInfo().name), SoundCloud.getService());
|
assertEquals(NewPipe.getService(SoundCloud.getServiceInfo().name), SoundCloud.getService());
|
||||||
|
|
||||||
assertNotEquals(NewPipe.getService(Youtube.getServiceInfo().name), SoundCloud.getService());
|
assertNotEquals(NewPipe.getService(YouTube.getServiceInfo().name), SoundCloud.getService());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getServiceWithUrl() throws Exception {
|
public void getServiceWithUrl() throws Exception {
|
||||||
assertEquals(getServiceByUrl("https://www.youtube.com/watch?v=_r6CgaFNAGg"), Youtube.getService());
|
assertEquals(getServiceByUrl("https://www.youtube.com/watch?v=_r6CgaFNAGg"), YouTube.getService());
|
||||||
assertEquals(getServiceByUrl("https://www.youtube.com/channel/UCi2bIyFtz-JdI-ou8kaqsqg"), Youtube.getService());
|
assertEquals(getServiceByUrl("https://www.youtube.com/channel/UCi2bIyFtz-JdI-ou8kaqsqg"), YouTube.getService());
|
||||||
assertEquals(getServiceByUrl("https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH"), Youtube.getService());
|
assertEquals(getServiceByUrl("https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH"), YouTube.getService());
|
||||||
assertEquals(getServiceByUrl("https://soundcloud.com/shupemoosic/pegboard-nerds-try-this"), SoundCloud.getService());
|
assertEquals(getServiceByUrl("https://soundcloud.com/shupemoosic/pegboard-nerds-try-this"), SoundCloud.getService());
|
||||||
assertEquals(getServiceByUrl("https://soundcloud.com/deluxe314/sets/pegboard-nerds"), SoundCloud.getService());
|
assertEquals(getServiceByUrl("https://soundcloud.com/deluxe314/sets/pegboard-nerds"), SoundCloud.getService());
|
||||||
assertEquals(getServiceByUrl("https://soundcloud.com/pegboardnerds"), SoundCloud.getService());
|
assertEquals(getServiceByUrl("https://soundcloud.com/pegboardnerds"), SoundCloud.getService());
|
||||||
|
|
||||||
assertNotEquals(getServiceByUrl("https://soundcloud.com/pegboardnerds"), Youtube.getService());
|
assertNotEquals(getServiceByUrl("https://soundcloud.com/pegboardnerds"), YouTube.getService());
|
||||||
assertNotEquals(getServiceByUrl("https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH"), SoundCloud.getService());
|
assertNotEquals(getServiceByUrl("https://www.youtube.com/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH"), SoundCloud.getService());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getIdWithServiceName() throws Exception {
|
public void getIdWithServiceName() throws Exception {
|
||||||
assertEquals(NewPipe.getIdOfService(Youtube.getServiceInfo().name), Youtube.getId());
|
assertEquals(NewPipe.getIdOfService(YouTube.getServiceInfo().name), YouTube.getId());
|
||||||
assertEquals(NewPipe.getIdOfService(SoundCloud.getServiceInfo().name), SoundCloud.getId());
|
assertEquals(NewPipe.getIdOfService(SoundCloud.getServiceInfo().name), SoundCloud.getId());
|
||||||
|
|
||||||
assertNotEquals(NewPipe.getIdOfService(SoundCloud.getServiceInfo().name), Youtube.getId());
|
assertNotEquals(NewPipe.getIdOfService(SoundCloud.getServiceInfo().name), YouTube.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getServiceNameWithId() throws Exception {
|
public void getServiceNameWithId() throws Exception {
|
||||||
assertEquals(NewPipe.getNameOfService(Youtube.getId()), Youtube.getServiceInfo().name);
|
assertEquals(NewPipe.getNameOfService(YouTube.getId()), YouTube.getServiceInfo().name);
|
||||||
assertEquals(NewPipe.getNameOfService(SoundCloud.getId()), SoundCloud.getServiceInfo().name);
|
assertEquals(NewPipe.getNameOfService(SoundCloud.getId()), SoundCloud.getServiceInfo().name);
|
||||||
|
|
||||||
assertNotEquals(NewPipe.getNameOfService(Youtube.getId()), SoundCloud.getServiceInfo().name);
|
assertNotEquals(NewPipe.getNameOfService(YouTube.getId()), SoundCloud.getServiceInfo().name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.Youtube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link PlaylistExtractor}
|
* Test for {@link PlaylistExtractor}
|
||||||
|
@ -21,7 +21,7 @@ public class YoutubePlaylistExtractorTest {
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
extractor = Youtube.getService()
|
extractor = YouTube.getService()
|
||||||
.getPlaylistExtractor("https://www.youtube.com/playlist?list=PL7XlqX4npddfrdpMCxBnNZXg2GFll7t5y");
|
.getPlaylistExtractor("https://www.youtube.com/playlist?list=PL7XlqX4npddfrdpMCxBnNZXg2GFll7t5y");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import java.util.EnumSet;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.Youtube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -43,12 +43,12 @@ public class YoutubeSearchEngineAllTest {
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
SearchEngine engine = Youtube.getService().getSearchEngine();
|
SearchEngine engine = YouTube.getService().getSearchEngine();
|
||||||
|
|
||||||
// Youtube will suggest "asdf" instead of "asdgff"
|
// Youtube will suggest "asdf" instead of "asdgff"
|
||||||
// keep in mind that the suggestions can change by country (the parameter "de")
|
// keep in mind that the suggestions can change by country (the parameter "de")
|
||||||
result = engine.search("asdgff", 0, "de",
|
result = engine.search("asdgff", 0, "de",
|
||||||
EnumSet.of(SearchEngine.Filter.CHANNEL,
|
EnumSet.of(SearchEngine.Filter.USER,
|
||||||
SearchEngine.Filter.STREAM)).getSearchResult();
|
SearchEngine.Filter.STREAM)).getSearchResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ import java.util.EnumSet;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.Youtube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -46,7 +46,7 @@ public class YoutubeSearchEngineStreamTest {
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
SearchEngine engine = Youtube.getService().getSearchEngine();
|
SearchEngine engine = YouTube.getService().getSearchEngine();
|
||||||
|
|
||||||
// Youtube will suggest "results" instead of "rsults",
|
// Youtube will suggest "results" instead of "rsults",
|
||||||
// keep in mind that the suggestions can change by country (the parameter "de")
|
// keep in mind that the suggestions can change by country (the parameter "de")
|
||||||
|
|
|
@ -13,7 +13,7 @@ import java.util.EnumSet;
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.Youtube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -39,18 +39,18 @@ import static org.schabi.newpipe.extractor.ServiceList.Youtube;
|
||||||
/**
|
/**
|
||||||
* Test for {@link SearchEngine}
|
* Test for {@link SearchEngine}
|
||||||
*/
|
*/
|
||||||
public class YoutubeSearchEngineChannelTest {
|
public class YoutubeSearchEngineUserTest {
|
||||||
private SearchResult result;
|
private SearchResult result;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
SearchEngine engine = Youtube.getService().getSearchEngine();
|
SearchEngine engine = YouTube.getService().getSearchEngine();
|
||||||
|
|
||||||
// Youtube will suggest "gronkh" instead of "grrunkh"
|
// Youtube will suggest "gronkh" instead of "grrunkh"
|
||||||
// keep in mind that the suggestions can change by country (the parameter "de")
|
// keep in mind that the suggestions can change by country (the parameter "de")
|
||||||
result = engine.search("grrunkh", 0, "de",
|
result = engine.search("grrunkh", 0, "de",
|
||||||
EnumSet.of(SearchEngine.Filter.CHANNEL)).getSearchResult();
|
EnumSet.of(SearchEngine.Filter.USER)).getSearchResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -59,9 +59,9 @@ public class YoutubeSearchEngineChannelTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testChannelItemType() {
|
public void testUserItemType() {
|
||||||
for (InfoItem infoItem : result.resultList) {
|
for (InfoItem infoItem : result.resultList) {
|
||||||
assertEquals(InfoItem.InfoType.CHANNEL, infoItem.info_type);
|
assertEquals(InfoItem.InfoType.USER, infoItem.info_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.io.IOException;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.Youtube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Created by Christian Schabesberger on 30.12.15.
|
* Created by Christian Schabesberger on 30.12.15.
|
||||||
|
@ -47,7 +47,7 @@ public class YoutubeStreamExtractorDefaultTest {
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
extractor = Youtube.getService().getStreamExtractor("https://www.youtube.com/watch?v=YQHsXMglC9A");
|
extractor = YouTube.getService().getStreamExtractor("https://www.youtube.com/watch?v=YQHsXMglC9A");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -58,7 +58,7 @@ public class YoutubeStreamExtractorDefaultTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetValidTimeStamp() throws IOException, ExtractionException {
|
public void testGetValidTimeStamp() throws IOException, ExtractionException {
|
||||||
StreamExtractor extractor = Youtube.getService().getStreamExtractor("https://youtu.be/FmG385_uUys?t=174");
|
StreamExtractor extractor = YouTube.getService().getStreamExtractor("https://youtu.be/FmG385_uUys?t=174");
|
||||||
assertTrue(Integer.toString(extractor.getTimeStamp()),
|
assertTrue(Integer.toString(extractor.getTimeStamp()),
|
||||||
extractor.getTimeStamp() == 174);
|
extractor.getTimeStamp() == 174);
|
||||||
}
|
}
|
||||||
|
@ -95,8 +95,8 @@ public class YoutubeStreamExtractorDefaultTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetChannelUrl() throws ParsingException {
|
public void testGetUserlUrl() throws ParsingException {
|
||||||
assertTrue(extractor.getChannelUrl().length() > 0);
|
assertTrue(extractor.getUserUrl().length() > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -9,7 +9,7 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static org.junit.Assert.fail;
|
import static org.junit.Assert.fail;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.Youtube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Created by Christian Schabesberger on 30.12.15.
|
* Created by Christian Schabesberger on 30.12.15.
|
||||||
|
@ -43,7 +43,7 @@ public class YoutubeStreamExtractorGemaTest {
|
||||||
public void testGemaError() throws IOException, ExtractionException {
|
public void testGemaError() throws IOException, ExtractionException {
|
||||||
try {
|
try {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
Youtube.getService().getStreamExtractor("https://www.youtube.com/watch?v=3O1_3zBUKM8");
|
YouTube.getService().getStreamExtractor("https://www.youtube.com/watch?v=3O1_3zBUKM8");
|
||||||
|
|
||||||
fail("GemaException should be thrown");
|
fail("GemaException should be thrown");
|
||||||
} catch (YoutubeStreamExtractor.GemaException ignored) {
|
} catch (YoutubeStreamExtractor.GemaException ignored) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.Youtube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link YoutubeStreamUrlIdHandler}
|
* Test for {@link YoutubeStreamUrlIdHandler}
|
||||||
|
@ -24,7 +24,7 @@ public class YoutubeStreamExtractorRestrictedTest {
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
extractor = Youtube.getService()
|
extractor = YouTube.getService()
|
||||||
.getStreamExtractor("https://www.youtube.com/watch?v=i6JTvzrpBy0");
|
.getStreamExtractor("https://www.youtube.com/watch?v=i6JTvzrpBy0");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class YoutubeStreamExtractorRestrictedTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetValidTimeStamp() throws IOException, ExtractionException {
|
public void testGetValidTimeStamp() throws IOException, ExtractionException {
|
||||||
StreamExtractor extractor= Youtube.getService()
|
StreamExtractor extractor= YouTube.getService()
|
||||||
.getStreamExtractor("https://youtu.be/FmG385_uUys?t=174");
|
.getStreamExtractor("https://youtu.be/FmG385_uUys?t=174");
|
||||||
assertTrue(Integer.toString(extractor.getTimeStamp()),
|
assertTrue(Integer.toString(extractor.getTimeStamp()),
|
||||||
extractor.getTimeStamp() == 174);
|
extractor.getTimeStamp() == 174);
|
||||||
|
|
|
@ -10,7 +10,7 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.Youtube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Created by Christian Schabesberger on 18.11.16.
|
* Created by Christian Schabesberger on 18.11.16.
|
||||||
|
@ -41,7 +41,7 @@ public class YoutubeSuggestionExtractorTest {
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
suggestionExtractor = Youtube.getService().getSuggestionExtractor();
|
suggestionExtractor = YouTube.getService().getSuggestionExtractor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|
|
@ -4,12 +4,12 @@ import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.schabi.newpipe.Downloader;
|
import org.schabi.newpipe.Downloader;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
import org.schabi.newpipe.extractor.user.UserExtractor;
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertNotNull;
|
import static org.junit.Assert.assertNotNull;
|
||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.Youtube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Created by Christian Schabesberger on 12.09.16.
|
* Created by Christian Schabesberger on 12.09.16.
|
||||||
|
@ -32,18 +32,18 @@ import static org.schabi.newpipe.extractor.ServiceList.Youtube;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link ChannelExtractor}
|
* Test for {@link UserExtractor}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class YoutubeChannelExtractorTest {
|
public class YoutubeUserExtractorTest {
|
||||||
|
|
||||||
ChannelExtractor extractor;
|
UserExtractor extractor;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
extractor = Youtube.getService()
|
extractor = YouTube.getService()
|
||||||
.getChannelExtractor("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw");
|
.getUserExtractor("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -52,8 +52,8 @@ public class YoutubeChannelExtractorTest {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetChannelName() throws Exception {
|
public void testGetUserName() throws Exception {
|
||||||
assertEquals(extractor.getChannelName(), "Gronkh");
|
assertEquals(extractor.getUserName(), "Gronkh");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
Loading…
Reference in a new issue