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;
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ public abstract class InfoItem implements Serializable {
|
|||
public enum InfoType {
|
||||
STREAM,
|
||||
PLAYLIST,
|
||||
CHANNEL
|
||||
USER
|
||||
}
|
||||
|
||||
public InfoItem(InfoType infoType) {
|
||||
|
|
|
@ -7,7 +7,7 @@ import java.io.IOException;
|
|||
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 {
|
||||
protected String nextStreamsUrl;
|
||||
|
|
|
@ -7,7 +7,7 @@ import org.schabi.newpipe.extractor.services.youtube.YoutubeService;
|
|||
* A list of supported services.
|
||||
*/
|
||||
public enum ServiceList {
|
||||
Youtube(new YoutubeService(0, "Youtube")),
|
||||
YouTube(new YoutubeService(0, "YouTube")),
|
||||
SoundCloud(new SoundcloudService(1, "SoundCloud"));
|
||||
// DailyMotion(new DailyMotionService(2, "DailyMotion"));
|
||||
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
package org.schabi.newpipe.extractor;
|
||||
|
||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
|
||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.user.UserExtractor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -20,7 +20,7 @@ public abstract class StreamingService {
|
|||
public enum LinkType {
|
||||
NONE,
|
||||
STREAM,
|
||||
CHANNEL,
|
||||
USER,
|
||||
PLAYLIST
|
||||
}
|
||||
|
||||
|
@ -41,16 +41,16 @@ public abstract class StreamingService {
|
|||
}
|
||||
|
||||
public abstract UrlIdHandler getStreamUrlIdHandler();
|
||||
public abstract UrlIdHandler getChannelUrlIdHandler();
|
||||
public abstract UrlIdHandler getUserUrlIdHandler();
|
||||
public abstract UrlIdHandler getPlaylistUrlIdHandler();
|
||||
public abstract SearchEngine getSearchEngine();
|
||||
public abstract SuggestionExtractor getSuggestionExtractor();
|
||||
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 ChannelExtractor getChannelExtractor(String url) throws IOException, ExtractionException {
|
||||
return getChannelExtractor(url, null);
|
||||
public UserExtractor getUserExtractor(String url) throws IOException, ExtractionException {
|
||||
return getUserExtractor(url, null);
|
||||
}
|
||||
|
||||
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) {
|
||||
UrlIdHandler sH = getStreamUrlIdHandler();
|
||||
UrlIdHandler cH = getChannelUrlIdHandler();
|
||||
UrlIdHandler cH = getUserUrlIdHandler();
|
||||
UrlIdHandler pH = getPlaylistUrlIdHandler();
|
||||
|
||||
if (sH.acceptUrl(url)) {
|
||||
return LinkType.STREAM;
|
||||
} else if (cH.acceptUrl(url)) {
|
||||
return LinkType.CHANNEL;
|
||||
return LinkType.USER;
|
||||
} else if (pH.acceptUrl(url)) {
|
||||
return LinkType.PLAYLIST;
|
||||
} else {
|
||||
|
|
|
@ -24,14 +24,14 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|||
|
||||
public interface UrlIdHandler {
|
||||
|
||||
String getUrl(String videoId) throws ParsingException;
|
||||
String getId(String siteUrl) throws ParsingException;
|
||||
String cleanUrl(String siteUrl) throws ParsingException;
|
||||
String getUrl(String id) throws ParsingException;
|
||||
String getId(String url) 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
|
||||
* Intent was meant to be watched with this Service.
|
||||
* 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;
|
||||
|
||||
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.FoundAdException;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
||||
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.
|
||||
|
@ -31,14 +31,14 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor;
|
|||
public class InfoItemSearchCollector extends InfoItemCollector {
|
||||
private String suggestion;
|
||||
private StreamInfoItemCollector streamCollector;
|
||||
private ChannelInfoItemCollector channelCollector;
|
||||
private UserInfoItemCollector userCollector;
|
||||
|
||||
private SearchResult result = new SearchResult();
|
||||
|
||||
InfoItemSearchCollector(int serviceId) {
|
||||
super(serviceId);
|
||||
streamCollector = new StreamInfoItemCollector(serviceId);
|
||||
channelCollector = new ChannelInfoItemCollector(serviceId);
|
||||
userCollector = new UserInfoItemCollector(serviceId);
|
||||
}
|
||||
|
||||
public void setSuggestion(String suggestion) {
|
||||
|
@ -47,7 +47,7 @@ public class InfoItemSearchCollector extends InfoItemCollector {
|
|||
|
||||
public SearchResult getSearchResult() throws ExtractionException {
|
||||
|
||||
addFromCollector(channelCollector);
|
||||
addFromCollector(userCollector);
|
||||
addFromCollector(streamCollector);
|
||||
|
||||
result.suggestion = suggestion;
|
||||
|
@ -65,9 +65,9 @@ public class InfoItemSearchCollector extends InfoItemCollector {
|
|||
}
|
||||
}
|
||||
|
||||
public void commit(ChannelInfoItemExtractor extractor) {
|
||||
public void commit(UserInfoItemExtractor extractor) {
|
||||
try {
|
||||
result.resultList.add(channelCollector.extract(extractor));
|
||||
result.resultList.add(userCollector.extract(extractor));
|
||||
} catch (FoundAdException ae) {
|
||||
System.err.println("Found ad");
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -27,7 +27,7 @@ import java.util.EnumSet;
|
|||
|
||||
public abstract class SearchEngine {
|
||||
public enum Filter {
|
||||
STREAM, CHANNEL, PLAYLIST
|
||||
STREAM, USER, PLAYLIST
|
||||
}
|
||||
|
||||
public static class NothingFoundException extends ExtractionException {
|
||||
|
|
|
@ -16,9 +16,9 @@ public class SoundcloudPlaylistUrlIdHandler implements UrlIdHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUrl(String listId) throws ParsingException {
|
||||
public String getUrl(String id) throws ParsingException {
|
||||
try {
|
||||
return SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/playlists/" + listId);
|
||||
return SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/playlists/" + id);
|
||||
} catch (Exception e) {
|
||||
throw new ParsingException(e.getMessage(), e);
|
||||
}
|
||||
|
@ -46,8 +46,8 @@ public class SoundcloudPlaylistUrlIdHandler implements UrlIdHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptUrl(String videoUrl) {
|
||||
public boolean acceptUrl(String url) {
|
||||
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";
|
||||
|
||||
if (filter.contains(Filter.STREAM) && !filter.contains(Filter.CHANNEL)) {
|
||||
if (filter.contains(Filter.STREAM) && !filter.contains(Filter.USER)) {
|
||||
url += "/tracks";
|
||||
} else if (!filter.contains(Filter.STREAM) && filter.contains(Filter.CHANNEL)) {
|
||||
} else if (!filter.contains(Filter.STREAM) && filter.contains(Filter.USER)) {
|
||||
url += "/users";
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class SoundcloudSearchEngine extends SearchEngine {
|
|||
JSONObject searchResult = searchCollection.getJSONObject(i);
|
||||
String kind = searchResult.getString("kind");
|
||||
if (kind.equals("user")) {
|
||||
collector.commit(new SoundcloudChannelInfoItemExtractor(searchResult));
|
||||
collector.commit(new SoundcloudUserInfoItemExtractor(searchResult));
|
||||
} else if (kind.equals("track")) {
|
||||
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.SuggestionExtractor;
|
||||
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.playlist.PlaylistExtractor;
|
||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.user.UserExtractor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -28,8 +28,8 @@ public class SoundcloudService extends StreamingService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public UrlIdHandler getChannelUrlIdHandler() {
|
||||
return SoundcloudChannelUrlIdHandler.getInstance();
|
||||
public UrlIdHandler getUserUrlIdHandler() {
|
||||
return SoundcloudUserUrlIdHandler.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -44,8 +44,8 @@ public class SoundcloudService extends StreamingService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ChannelExtractor getChannelExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||
return new SoundcloudChannelExtractor(this, url, nextStreamsUrl);
|
||||
public UserExtractor getUserExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||
return new SoundcloudUserExtractor(this, url, nextStreamsUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -215,7 +215,7 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getChannelUrl() {
|
||||
public String getUserUrl() {
|
||||
return track.getJSONObject("user").getString("permalink_url");
|
||||
}
|
||||
|
||||
|
|
|
@ -19,9 +19,9 @@ public class SoundcloudStreamUrlIdHandler implements UrlIdHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUrl(String videoId) throws ParsingException {
|
||||
public String getUrl(String id) throws ParsingException {
|
||||
try {
|
||||
return SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/tracks/" + videoId);
|
||||
return SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/tracks/" + id);
|
||||
} catch (Exception e) {
|
||||
throw new ParsingException(e.getMessage(), e);
|
||||
}
|
||||
|
@ -49,8 +49,8 @@ public class SoundcloudStreamUrlIdHandler implements UrlIdHandler {
|
|||
}
|
||||
|
||||
@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_-]+/?([#?].*)?$";
|
||||
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.NewPipe;
|
||||
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.ParsingException;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
||||
import org.schabi.newpipe.extractor.user.UserExtractor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
@SuppressWarnings("WeakerAccess")
|
||||
public class SoundcloudChannelExtractor extends ChannelExtractor {
|
||||
private String channelId;
|
||||
private JSONObject channel;
|
||||
public class SoundcloudUserExtractor extends UserExtractor {
|
||||
private String userId;
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -24,42 +24,42 @@ public class SoundcloudChannelExtractor extends ChannelExtractor {
|
|||
public void fetchPage() throws IOException, ExtractionException {
|
||||
Downloader dl = NewPipe.getDownloader();
|
||||
|
||||
channelId = getUrlIdHandler().getId(getOriginalUrl());
|
||||
String apiUrl = "https://api.soundcloud.com/users/" + channelId +
|
||||
userId = getUrlIdHandler().getId(getOriginalUrl());
|
||||
String apiUrl = "https://api.soundcloud.com/users/" + userId +
|
||||
"?client_id=" + SoundcloudParsingHelper.clientId();
|
||||
|
||||
String response = dl.download(apiUrl);
|
||||
channel = new JSONObject(response);
|
||||
user = new JSONObject(response);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCleanUrl() {
|
||||
try {
|
||||
return channel.getString("permalink_url");
|
||||
return user.getString("permalink_url");
|
||||
} catch (Exception e) {
|
||||
return getOriginalUrl();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChannelId() {
|
||||
return channelId;
|
||||
public String getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChannelName() {
|
||||
return channel.getString("username");
|
||||
public String getUserName() {
|
||||
return user.getString("username");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAvatarUrl() {
|
||||
return channel.getString("avatar_url");
|
||||
return user.getString("avatar_url");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBannerUrl() throws ParsingException {
|
||||
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) {
|
||||
throw new ParsingException("Could not get Banner", e);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ public class SoundcloudChannelExtractor extends ChannelExtractor {
|
|||
|
||||
@Override
|
||||
public long getSubscriberCount() {
|
||||
return channel.getLong("followers_count");
|
||||
return user.getLong("followers_count");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -79,7 +79,7 @@ public class SoundcloudChannelExtractor extends ChannelExtractor {
|
|||
public StreamInfoItemCollector getStreams() throws IOException, ExtractionException {
|
||||
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()
|
||||
+ "&limit=20"
|
||||
+ "&linked_partitioning=1";
|
||||
|
@ -91,7 +91,7 @@ public class SoundcloudChannelExtractor extends ChannelExtractor {
|
|||
@Override
|
||||
public NextItemsResult getNextStreams() throws IOException, ExtractionException {
|
||||
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());
|
|
@ -1,12 +1,12 @@
|
|||
package org.schabi.newpipe.extractor.services.soundcloud;
|
||||
|
||||
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;
|
||||
|
||||
public SoundcloudChannelInfoItemExtractor(JSONObject searchResult) {
|
||||
public SoundcloudUserInfoItemExtractor(JSONObject searchResult) {
|
||||
this.searchResult = searchResult;
|
||||
}
|
||||
|
||||
|
@ -16,7 +16,7 @@ public class SoundcloudChannelInfoItemExtractor implements ChannelInfoItemExtrac
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getChannelName() {
|
||||
public String getUserName() {
|
||||
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.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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl(String channelId) throws ParsingException {
|
||||
public String getUrl(String id) throws ParsingException {
|
||||
try {
|
||||
return SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/users/" + channelId);
|
||||
return SoundcloudParsingHelper.resolveUrlWithEmbedPlayer("https://api.soundcloud.com/users/" + id);
|
||||
} catch (Exception e) {
|
||||
throw new ParsingException(e.getMessage(), e);
|
||||
}
|
||||
|
@ -46,8 +46,8 @@ public class SoundcloudChannelUrlIdHandler implements UrlIdHandler {
|
|||
}
|
||||
|
||||
@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)/?)?)?([#?].*)?$";
|
||||
return Parser.isMatch(regex, channelUrl.toLowerCase());
|
||||
return Parser.isMatch(regex, url.toLowerCase());
|
||||
}
|
||||
}
|
|
@ -15,8 +15,8 @@ public class YoutubePlaylistUrlIdHandler implements UrlIdHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUrl(String listId) {
|
||||
return "https://www.youtube.com/playlist?list=" + listId;
|
||||
public String getUrl(String id) {
|
||||
return "https://www.youtube.com/playlist?list=" + id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,9 +34,9 @@ public class YoutubePlaylistUrlIdHandler implements UrlIdHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptUrl(String videoUrl) {
|
||||
final boolean hasNotEmptyUrl = videoUrl != null && !videoUrl.isEmpty();
|
||||
final boolean isYoutubeDomain = hasNotEmptyUrl && (videoUrl.contains("youtube") || videoUrl.contains("youtu.be"));
|
||||
return isYoutubeDomain && videoUrl.contains("list=");
|
||||
public boolean acceptUrl(String url) {
|
||||
final boolean hasNotEmptyUrl = url != null && !url.isEmpty();
|
||||
final boolean isYoutubeDomain = hasNotEmptyUrl && (url.contains("youtube") || url.contains("youtu.be"));
|
||||
return isYoutubeDomain && url.contains("list=");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,9 +57,9 @@ public class YoutubeSearchEngine extends SearchEngine {
|
|||
String url = "https://www.youtube.com/results"
|
||||
+ "?q=" + URLEncoder.encode(query, CHARSET_UTF_8)
|
||||
+ "&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";
|
||||
} 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";
|
||||
}
|
||||
|
||||
|
@ -104,7 +104,7 @@ public class YoutubeSearchEngine extends SearchEngine {
|
|||
} else if ((el = item.select("div[class*=\"yt-lockup-video\"]").first()) != null) {
|
||||
collector.commit(new YoutubeStreamInfoItemExtractor(el));
|
||||
} else if ((el = item.select("div[class*=\"yt-lockup-channel\"]").first()) != null) {
|
||||
collector.commit(new YoutubeChannelInfoItemExtractor(el));
|
||||
collector.commit(new YoutubeUserInfoItemExtractor(el));
|
||||
} else {
|
||||
// noinspection ConstantConditions
|
||||
// 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.SuggestionExtractor;
|
||||
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.playlist.PlaylistExtractor;
|
||||
import org.schabi.newpipe.extractor.search.SearchEngine;
|
||||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.user.UserExtractor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
@ -49,8 +49,8 @@ public class YoutubeService extends StreamingService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public UrlIdHandler getChannelUrlIdHandler() {
|
||||
return YoutubeChannelUrlIdHandler.getInstance();
|
||||
public UrlIdHandler getUserUrlIdHandler() {
|
||||
return YoutubeUserUrlIdHandler.getInstance();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -65,8 +65,8 @@ public class YoutubeService extends StreamingService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public ChannelExtractor getChannelExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||
return new YoutubeChannelExtractor(this, url, nextStreamsUrl);
|
||||
public UserExtractor getUserExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||
return new YoutubeUserExtractor(this, url, nextStreamsUrl);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -542,7 +542,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getChannelUrl() throws ParsingException {
|
||||
public String getUserUrl() throws ParsingException {
|
||||
try {
|
||||
return doc.select("div[class=\"yt-user-info\"]").first().children()
|
||||
.select("a").first().attr("abs:href");
|
||||
|
|
|
@ -47,8 +47,8 @@ public class YoutubeStreamUrlIdHandler implements UrlIdHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getUrl(String videoId) {
|
||||
return "https://www.youtube.com/watch?v=" + videoId;
|
||||
public String getUrl(String id) {
|
||||
return "https://www.youtube.com/watch?v=" + id;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -146,13 +146,13 @@ public class YoutubeStreamUrlIdHandler implements UrlIdHandler {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptUrl(String videoUrl) {
|
||||
String lowercaseUrl = videoUrl.toLowerCase();
|
||||
public boolean acceptUrl(String url) {
|
||||
String lowercaseUrl = url.toLowerCase();
|
||||
if (lowercaseUrl.contains("youtube") ||
|
||||
lowercaseUrl.contains("youtu.be")) {
|
||||
// bad programming I know
|
||||
try {
|
||||
getId(videoUrl);
|
||||
getId(url);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
|
|
|
@ -9,13 +9,13 @@ import org.jsoup.nodes.Element;
|
|||
import org.schabi.newpipe.extractor.Downloader;
|
||||
import org.schabi.newpipe.extractor.NewPipe;
|
||||
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.ParsingException;
|
||||
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemCollector;
|
||||
import org.schabi.newpipe.extractor.stream.StreamInfoItemExtractor;
|
||||
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.Utils;
|
||||
|
||||
|
@ -25,7 +25,7 @@ import java.io.IOException;
|
|||
* Created by Christian Schabesberger on 25.07.16.
|
||||
*
|
||||
* 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -42,7 +42,7 @@ import java.io.IOException;
|
|||
*/
|
||||
|
||||
@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_URL_PARAMETERS = "/videos?view=0&flow=list&sort=dd&live_view=10000";
|
||||
|
||||
|
@ -52,7 +52,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getChannelId() throws ParsingException {
|
||||
public String getUserId() throws ParsingException {
|
||||
try {
|
||||
return getUrlIdHandler().getId(getCleanUrl());
|
||||
} catch (Exception e) {
|
||||
|
@ -78,7 +78,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getChannelName() throws ParsingException {
|
||||
public String getUserName() throws ParsingException {
|
||||
try {
|
||||
return doc.select("span[class=\"qualified-channel-title-text\"]").first().select("a").first().text();
|
||||
} catch (Exception e) {
|
||||
|
@ -239,7 +239,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
|
||||
@Override
|
||||
public String getUploader() throws ParsingException {
|
||||
return getChannelName();
|
||||
return getUserName();
|
||||
}
|
||||
|
||||
@Override
|
|
@ -1,15 +1,15 @@
|
|||
package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;
|
||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
import org.schabi.newpipe.extractor.user.UserInfoItemExtractor;
|
||||
import org.schabi.newpipe.extractor.utils.Utils;
|
||||
|
||||
/*
|
||||
* Created by Christian Schabesberger on 12.02.17.
|
||||
*
|
||||
* 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
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
public class YoutubeChannelInfoItemExtractor implements ChannelInfoItemExtractor {
|
||||
public class YoutubeUserInfoItemExtractor implements UserInfoItemExtractor {
|
||||
private Element el;
|
||||
|
||||
public YoutubeChannelInfoItemExtractor(Element el) {
|
||||
public YoutubeUserInfoItemExtractor(Element el) {
|
||||
this.el = el;
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class YoutubeChannelInfoItemExtractor implements ChannelInfoItemExtractor
|
|||
}
|
||||
|
||||
@Override
|
||||
public String getChannelName() throws ParsingException {
|
||||
public String getUserName() throws ParsingException {
|
||||
return el.select("a[class*=\"yt-uix-tile-link\"]").first()
|
||||
.text();
|
||||
}
|
|
@ -8,7 +8,7 @@ import org.schabi.newpipe.extractor.utils.Parser;
|
|||
* Created by Christian Schabesberger on 25.07.16.
|
||||
*
|
||||
* 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
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
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_-]*)";
|
||||
|
||||
public static YoutubeChannelUrlIdHandler getInstance() {
|
||||
public static YoutubeUserUrlIdHandler getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUrl(String channelId) {
|
||||
return "https://www.youtube.com/" + channelId;
|
||||
public String getUrl(String id) {
|
||||
return "https://www.youtube.com/" + id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getId(String siteUrl) throws ParsingException {
|
||||
return Parser.matchGroup1(ID_PATTERN, siteUrl);
|
||||
public String getId(String url) throws ParsingException {
|
||||
return Parser.matchGroup1(ID_PATTERN, url);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String cleanUrl(String siteUrl) throws ParsingException {
|
||||
return getUrl(getId(siteUrl));
|
||||
public String cleanUrl(String complexUrl) throws ParsingException {
|
||||
return getUrl(getId(complexUrl));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptUrl(String videoUrl) {
|
||||
return (videoUrl.contains("youtube") ||
|
||||
videoUrl.contains("youtu.be")) &&
|
||||
(videoUrl.contains("/user/") ||
|
||||
videoUrl.contains("/channel/"));
|
||||
public boolean acceptUrl(String url) {
|
||||
return (url.contains("youtube") ||
|
||||
url.contains("youtu.be")) &&
|
||||
(url.contains("/user/") ||
|
||||
url.contains("/channel/"));
|
||||
}
|
||||
}
|
|
@ -49,7 +49,7 @@ public abstract class StreamExtractor extends Extractor {
|
|||
public abstract String getTitle() throws ParsingException;
|
||||
public abstract String getDescription() 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 long getViewCount() throws ParsingException;
|
||||
public abstract String getUploadDate() throws ParsingException;
|
||||
|
|
|
@ -195,7 +195,7 @@ public class StreamInfo extends Info {
|
|||
streamInfo.addException(e);
|
||||
}
|
||||
try {
|
||||
streamInfo.channel_url = extractor.getChannelUrl();
|
||||
streamInfo.user_url = extractor.getUserUrl();
|
||||
} catch (Exception e) {
|
||||
streamInfo.addException(e);
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ public class StreamInfo extends Info {
|
|||
public long view_count = -1;
|
||||
|
||||
public String uploader_thumbnail_url;
|
||||
public String channel_url;
|
||||
public String user_url;
|
||||
public String description;
|
||||
|
||||
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.StreamingService;
|
||||
|
@ -12,7 +12,7 @@ import java.io.IOException;
|
|||
* Created by Christian Schabesberger on 25.07.16.
|
||||
*
|
||||
* 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
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected UrlIdHandler getUrlIdHandler() throws ParsingException {
|
||||
return getService().getChannelUrlIdHandler();
|
||||
return getService().getUserUrlIdHandler();
|
||||
}
|
||||
|
||||
public abstract String getChannelId() throws ParsingException;
|
||||
public abstract String getChannelName() throws ParsingException;
|
||||
public abstract String getUserId() throws ParsingException;
|
||||
public abstract String getUserName() throws ParsingException;
|
||||
public abstract String getAvatarUrl() throws ParsingException;
|
||||
public abstract String getBannerUrl() 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.ListInfo;
|
||||
|
@ -16,7 +16,7 @@ import java.util.ArrayList;
|
|||
* Created by Christian Schabesberger on 31.07.16.
|
||||
*
|
||||
* 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
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
public class ChannelInfo extends ListInfo {
|
||||
public class UserInfo extends ListInfo {
|
||||
|
||||
public static NextItemsResult getMoreItems(ServiceList serviceItem, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||
return getMoreItems(serviceItem.getService(), nextStreamsUrl);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public static ChannelInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
|
||||
return getInfo(service.getChannelExtractor(url));
|
||||
public static UserInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
|
||||
return getInfo(service.getUserExtractor(url));
|
||||
}
|
||||
|
||||
public static ChannelInfo getInfo(ChannelExtractor extractor) throws ParsingException {
|
||||
ChannelInfo info = new ChannelInfo();
|
||||
public static UserInfo getInfo(UserExtractor extractor) throws ParsingException {
|
||||
UserInfo info = new UserInfo();
|
||||
|
||||
// important data
|
||||
info.service_id = extractor.getServiceId();
|
||||
info.url = extractor.getCleanUrl();
|
||||
info.id = extractor.getChannelId();
|
||||
info.name = extractor.getChannelName();
|
||||
info.id = extractor.getUserId();
|
||||
info.name = extractor.getUserName();
|
||||
|
||||
try {
|
||||
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;
|
||||
|
||||
|
@ -6,7 +6,7 @@ import org.schabi.newpipe.extractor.InfoItem;
|
|||
* Created by Christian Schabesberger on 11.02.17.
|
||||
*
|
||||
* 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
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
public class ChannelInfoItem extends InfoItem {
|
||||
public class UserInfoItem extends InfoItem {
|
||||
|
||||
public String thumbnail_url;
|
||||
public String description;
|
||||
public long subscriber_count = -1;
|
||||
public long stream_count = -1;
|
||||
|
||||
public ChannelInfoItem() {
|
||||
super(InfoType.CHANNEL);
|
||||
public UserInfoItem() {
|
||||
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.exceptions.ParsingException;
|
||||
|
@ -7,7 +7,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|||
* Created by Christian Schabesberger on 12.02.17.
|
||||
*
|
||||
* 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
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
public class ChannelInfoItemCollector extends InfoItemCollector {
|
||||
public ChannelInfoItemCollector(int serviceId) {
|
||||
public class UserInfoItemCollector extends InfoItemCollector {
|
||||
public UserInfoItemCollector(int serviceId) {
|
||||
super(serviceId);
|
||||
}
|
||||
|
||||
public ChannelInfoItem extract(ChannelInfoItemExtractor extractor) throws ParsingException {
|
||||
ChannelInfoItem resultItem = new ChannelInfoItem();
|
||||
public UserInfoItem extract(UserInfoItemExtractor extractor) throws ParsingException {
|
||||
UserInfoItem resultItem = new UserInfoItem();
|
||||
// important information
|
||||
resultItem.name = extractor.getChannelName();
|
||||
resultItem.name = extractor.getUserName();
|
||||
|
||||
resultItem.service_id = getServiceId();
|
||||
resultItem.url = extractor.getWebPageUrl();
|
||||
|
@ -60,7 +60,7 @@ public class ChannelInfoItemCollector extends InfoItemCollector {
|
|||
return resultItem;
|
||||
}
|
||||
|
||||
public void commit(ChannelInfoItemExtractor extractor) throws ParsingException {
|
||||
public void commit(UserInfoItemExtractor extractor) throws ParsingException {
|
||||
try {
|
||||
addItem(extract(extractor));
|
||||
} 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;
|
||||
|
||||
|
@ -6,7 +6,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|||
* Created by Christian Schabesberger on 12.02.17.
|
||||
*
|
||||
* 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
|
||||
* 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/>.
|
||||
*/
|
||||
|
||||
public interface ChannelInfoItemExtractor {
|
||||
public interface UserInfoItemExtractor {
|
||||
String getThumbnailUrl() throws ParsingException;
|
||||
String getChannelName() throws ParsingException;
|
||||
String getUserName() throws ParsingException;
|
||||
String getWebPageUrl() throws ParsingException;
|
||||
String getDescription() 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.assertTrue;
|
||||
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;
|
||||
|
||||
public class NewPipeTest {
|
||||
|
@ -29,46 +29,46 @@ public class NewPipeTest {
|
|||
|
||||
@Test
|
||||
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());
|
||||
|
||||
assertNotEquals(NewPipe.getService(SoundCloud.getId()), Youtube.getService());
|
||||
assertNotEquals(NewPipe.getService(SoundCloud.getId()), YouTube.getService());
|
||||
}
|
||||
|
||||
@Test
|
||||
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());
|
||||
|
||||
assertNotEquals(NewPipe.getService(Youtube.getServiceInfo().name), SoundCloud.getService());
|
||||
assertNotEquals(NewPipe.getService(YouTube.getServiceInfo().name), SoundCloud.getService());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getServiceWithUrl() throws Exception {
|
||||
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/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH"), 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/playlist?list=PLRqwX-V7Uu6ZiZxtDDRCi6uhfTH4FilpH"), YouTube.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/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());
|
||||
}
|
||||
|
||||
@Test
|
||||
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());
|
||||
|
||||
assertNotEquals(NewPipe.getIdOfService(SoundCloud.getServiceInfo().name), Youtube.getId());
|
||||
assertNotEquals(NewPipe.getIdOfService(SoundCloud.getServiceInfo().name), YouTube.getId());
|
||||
}
|
||||
|
||||
@Test
|
||||
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);
|
||||
|
||||
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.assertNotNull;
|
||||
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}
|
||||
|
@ -21,7 +21,7 @@ public class YoutubePlaylistExtractorTest {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
extractor = Youtube.getService()
|
||||
extractor = YouTube.getService()
|
||||
.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.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
|
||||
public void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
SearchEngine engine = Youtube.getService().getSearchEngine();
|
||||
SearchEngine engine = YouTube.getService().getSearchEngine();
|
||||
|
||||
// Youtube will suggest "asdf" instead of "asdgff"
|
||||
// keep in mind that the suggestions can change by country (the parameter "de")
|
||||
result = engine.search("asdgff", 0, "de",
|
||||
EnumSet.of(SearchEngine.Filter.CHANNEL,
|
||||
EnumSet.of(SearchEngine.Filter.USER,
|
||||
SearchEngine.Filter.STREAM)).getSearchResult();
|
||||
}
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ import java.util.EnumSet;
|
|||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
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
|
||||
public void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
SearchEngine engine = Youtube.getService().getSearchEngine();
|
||||
SearchEngine engine = YouTube.getService().getSearchEngine();
|
||||
|
||||
// Youtube will suggest "results" instead of "rsults",
|
||||
// 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.assertFalse;
|
||||
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}
|
||||
*/
|
||||
public class YoutubeSearchEngineChannelTest {
|
||||
public class YoutubeSearchEngineUserTest {
|
||||
private SearchResult result;
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
SearchEngine engine = Youtube.getService().getSearchEngine();
|
||||
SearchEngine engine = YouTube.getService().getSearchEngine();
|
||||
|
||||
// Youtube will suggest "gronkh" instead of "grrunkh"
|
||||
// keep in mind that the suggestions can change by country (the parameter "de")
|
||||
result = engine.search("grrunkh", 0, "de",
|
||||
EnumSet.of(SearchEngine.Filter.CHANNEL)).getSearchResult();
|
||||
EnumSet.of(SearchEngine.Filter.USER)).getSearchResult();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -59,9 +59,9 @@ public class YoutubeSearchEngineChannelTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testChannelItemType() {
|
||||
public void testUserItemType() {
|
||||
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.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.
|
||||
|
@ -47,7 +47,7 @@ public class YoutubeStreamExtractorDefaultTest {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
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
|
||||
|
@ -58,7 +58,7 @@ public class YoutubeStreamExtractorDefaultTest {
|
|||
|
||||
@Test
|
||||
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()),
|
||||
extractor.getTimeStamp() == 174);
|
||||
}
|
||||
|
@ -95,8 +95,8 @@ public class YoutubeStreamExtractorDefaultTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGetChannelUrl() throws ParsingException {
|
||||
assertTrue(extractor.getChannelUrl().length() > 0);
|
||||
public void testGetUserlUrl() throws ParsingException {
|
||||
assertTrue(extractor.getUserUrl().length() > 0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -9,7 +9,7 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
|||
import java.io.IOException;
|
||||
|
||||
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.
|
||||
|
@ -43,7 +43,7 @@ public class YoutubeStreamExtractorGemaTest {
|
|||
public void testGemaError() throws IOException, ExtractionException {
|
||||
try {
|
||||
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");
|
||||
} catch (YoutubeStreamExtractor.GemaException ignored) {
|
||||
|
|
|
@ -12,7 +12,7 @@ import org.schabi.newpipe.extractor.stream.VideoStream;
|
|||
import java.io.IOException;
|
||||
|
||||
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}
|
||||
|
@ -24,7 +24,7 @@ public class YoutubeStreamExtractorRestrictedTest {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
extractor = Youtube.getService()
|
||||
extractor = YouTube.getService()
|
||||
.getStreamExtractor("https://www.youtube.com/watch?v=i6JTvzrpBy0");
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,7 @@ public class YoutubeStreamExtractorRestrictedTest {
|
|||
|
||||
@Test
|
||||
public void testGetValidTimeStamp() throws IOException, ExtractionException {
|
||||
StreamExtractor extractor= Youtube.getService()
|
||||
StreamExtractor extractor= YouTube.getService()
|
||||
.getStreamExtractor("https://youtu.be/FmG385_uUys?t=174");
|
||||
assertTrue(Integer.toString(extractor.getTimeStamp()),
|
||||
extractor.getTimeStamp() == 174);
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
|||
import java.io.IOException;
|
||||
|
||||
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.
|
||||
|
@ -41,7 +41,7 @@ public class YoutubeSuggestionExtractorTest {
|
|||
@Before
|
||||
public void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
suggestionExtractor = Youtube.getService().getSuggestionExtractor();
|
||||
suggestionExtractor = YouTube.getService().getSuggestionExtractor();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -4,12 +4,12 @@ import org.junit.Before;
|
|||
import org.junit.Test;
|
||||
import org.schabi.newpipe.Downloader;
|
||||
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.assertNotNull;
|
||||
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.
|
||||
|
@ -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
|
||||
public void setUp() throws Exception {
|
||||
NewPipe.init(Downloader.getInstance());
|
||||
extractor = Youtube.getService()
|
||||
.getChannelExtractor("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw");
|
||||
extractor = YouTube.getService()
|
||||
.getUserExtractor("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -52,8 +52,8 @@ public class YoutubeChannelExtractorTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
public void testGetChannelName() throws Exception {
|
||||
assertEquals(extractor.getChannelName(), "Gronkh");
|
||||
public void testGetUserName() throws Exception {
|
||||
assertEquals(extractor.getUserName(), "Gronkh");
|
||||
}
|
||||
|
||||
@Test
|
Loading…
Reference in a new issue