mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-13 05:40:34 +05:30
Rollback classes naming
This commit is contained in:
parent
8d88093eb7
commit
03634a2b6a
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,7 +1,8 @@
|
|||||||
.gradle
|
.gradle
|
||||||
/build/
|
build/
|
||||||
.idea
|
.idea
|
||||||
local.properties
|
local.properties
|
||||||
|
out/
|
||||||
|
|
||||||
# Ignore Gradle GUI config
|
# Ignore Gradle GUI config
|
||||||
gradle-app.setting
|
gradle-app.setting
|
||||||
|
@ -20,7 +20,7 @@ public abstract class Extractor {
|
|||||||
* <pre>
|
* <pre>
|
||||||
* https://www.youtube.com/watch?v=a9Zf_258aTI<i>&t=4s</i> → <i><b>&t=4s</b></i>
|
* https://www.youtube.com/watch?v=a9Zf_258aTI<i>&t=4s</i> → <i><b>&t=4s</b></i>
|
||||||
* </pre>
|
* </pre>
|
||||||
* But as you can imagine, the time parameter is very important when calling, for example, {@link org.schabi.newpipe.extractor.stream.StreamExtractor#getTimeStamp()}.
|
* But as you can imagine, the time parameter is very important when calling {@link org.schabi.newpipe.extractor.stream.StreamExtractor#getTimeStamp()}.
|
||||||
*/
|
*/
|
||||||
private final String originalUrl;
|
private final String originalUrl;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public abstract class Extractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return a {@link UrlIdHandler} of the current extractor type (e.g. a UserExtractor should return a user url handler).
|
* @return a {@link UrlIdHandler} of the current extractor type (e.g. a ChannelExtractor should return a channel url handler).
|
||||||
*/
|
*/
|
||||||
protected abstract UrlIdHandler getUrlIdHandler() throws ParsingException;
|
protected abstract UrlIdHandler getUrlIdHandler() throws ParsingException;
|
||||||
|
|
||||||
@ -46,6 +46,9 @@ public abstract class Extractor {
|
|||||||
*/
|
*/
|
||||||
public abstract void fetchPage() throws IOException, ExtractionException;
|
public abstract void fetchPage() throws IOException, ExtractionException;
|
||||||
|
|
||||||
|
public abstract String getId() throws ParsingException;
|
||||||
|
public abstract String getName() throws ParsingException;
|
||||||
|
|
||||||
public String getOriginalUrl() {
|
public String getOriginalUrl() {
|
||||||
return originalUrl;
|
return originalUrl;
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public abstract class InfoItem implements Serializable {
|
|||||||
public enum InfoType {
|
public enum InfoType {
|
||||||
STREAM,
|
STREAM,
|
||||||
PLAYLIST,
|
PLAYLIST,
|
||||||
USER
|
CHANNEL
|
||||||
}
|
}
|
||||||
|
|
||||||
public final InfoType info_type;
|
public final InfoType info_type;
|
||||||
|
@ -4,7 +4,7 @@ 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 org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||||
|
|
||||||
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,
|
||||||
USER,
|
CHANNEL,
|
||||||
PLAYLIST
|
PLAYLIST
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,16 +41,16 @@ public abstract class StreamingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract UrlIdHandler getStreamUrlIdHandler();
|
public abstract UrlIdHandler getStreamUrlIdHandler();
|
||||||
public abstract UrlIdHandler getUserUrlIdHandler();
|
public abstract UrlIdHandler getChannelUrlIdHandler();
|
||||||
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 UserExtractor getUserExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException;
|
public abstract ChannelExtractor getChannelExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException;
|
||||||
public abstract PlaylistExtractor getPlaylistExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException;
|
public abstract PlaylistExtractor getPlaylistExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException;
|
||||||
|
|
||||||
public UserExtractor getUserExtractor(String url) throws IOException, ExtractionException {
|
public ChannelExtractor getChannelExtractor(String url) throws IOException, ExtractionException {
|
||||||
return getUserExtractor(url, null);
|
return getChannelExtractor(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 user, video, playlist, etc.)
|
* figure out where the link is pointing to (a channel, video, playlist, etc.)
|
||||||
*/
|
*/
|
||||||
public final LinkType getLinkTypeByUrl(String url) {
|
public final LinkType getLinkTypeByUrl(String url) {
|
||||||
UrlIdHandler sH = getStreamUrlIdHandler();
|
UrlIdHandler sH = getStreamUrlIdHandler();
|
||||||
UrlIdHandler cH = getUserUrlIdHandler();
|
UrlIdHandler cH = getChannelUrlIdHandler();
|
||||||
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.USER;
|
return LinkType.CHANNEL;
|
||||||
} else if (pH.acceptUrl(url)) {
|
} else if (pH.acceptUrl(url)) {
|
||||||
return LinkType.PLAYLIST;
|
return LinkType.PLAYLIST;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package org.schabi.newpipe.extractor.user;
|
package org.schabi.newpipe.extractor.channel;
|
||||||
|
|
||||||
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>
|
||||||
* UserExtractor.java is part of NewPipe.
|
* ChannelExtractor.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,17 @@ 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 UserExtractor extends ListExtractor {
|
public abstract class ChannelExtractor extends ListExtractor {
|
||||||
|
|
||||||
public UserExtractor(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
public ChannelExtractor(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().getUserUrlIdHandler();
|
return getService().getChannelUrlIdHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getUserId() 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.user;
|
package org.schabi.newpipe.extractor.channel;
|
||||||
|
|
||||||
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>
|
||||||
* UserInfo.java is part of NewPipe.
|
* ChannelInfo.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 UserInfo extends ListInfo {
|
public class ChannelInfo 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.getUserExtractor(null, nextStreamsUrl).getNextStreams();
|
return service.getChannelExtractor(null, nextStreamsUrl).getNextStreams();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UserInfo getInfo(String url) throws IOException, ExtractionException {
|
public static ChannelInfo getInfo(String url) throws IOException, ExtractionException {
|
||||||
return getInfo(NewPipe.getServiceByUrl(url), url);
|
return getInfo(NewPipe.getServiceByUrl(url), url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UserInfo getInfo(ServiceList serviceItem, String url) throws IOException, ExtractionException {
|
public static ChannelInfo getInfo(ServiceList serviceItem, String url) throws IOException, ExtractionException {
|
||||||
return getInfo(serviceItem.getService(), url);
|
return getInfo(serviceItem.getService(), url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UserInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
|
public static ChannelInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
|
||||||
return getInfo(service.getUserExtractor(url));
|
return getInfo(service.getChannelExtractor(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static UserInfo getInfo(UserExtractor extractor) throws ParsingException {
|
public static ChannelInfo getInfo(ChannelExtractor extractor) throws ParsingException {
|
||||||
UserInfo info = new UserInfo();
|
ChannelInfo info = new ChannelInfo();
|
||||||
|
|
||||||
// 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.getUserId();
|
info.id = extractor.getId();
|
||||||
info.name = extractor.getUserName();
|
info.name = extractor.getName();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
info.avatar_url = extractor.getAvatarUrl();
|
info.avatar_url = extractor.getAvatarUrl();
|
@ -1,4 +1,4 @@
|
|||||||
package org.schabi.newpipe.extractor.user;
|
package org.schabi.newpipe.extractor.channel;
|
||||||
|
|
||||||
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>
|
||||||
* UserInfoItem.java is part of NewPipe.
|
* ChannelInfoItem.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 UserInfoItem extends InfoItem {
|
public class ChannelInfoItem 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 UserInfoItem() {
|
public ChannelInfoItem() {
|
||||||
super(InfoType.USER);
|
super(InfoType.CHANNEL);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package org.schabi.newpipe.extractor.user;
|
package org.schabi.newpipe.extractor.channel;
|
||||||
|
|
||||||
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>
|
||||||
* UserInfoItemCollector.java is part of NewPipe.
|
* ChannelInfoItemCollector.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,16 +23,16 @@ 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 UserInfoItemCollector extends InfoItemCollector {
|
public class ChannelInfoItemCollector extends InfoItemCollector {
|
||||||
public UserInfoItemCollector(int serviceId) {
|
public ChannelInfoItemCollector(int serviceId) {
|
||||||
super(serviceId);
|
super(serviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserInfoItem extract(UserInfoItemExtractor extractor) throws ParsingException {
|
public ChannelInfoItem extract(ChannelInfoItemExtractor extractor) throws ParsingException {
|
||||||
UserInfoItem resultItem = new UserInfoItem();
|
ChannelInfoItem resultItem = new ChannelInfoItem();
|
||||||
// important information
|
// important information
|
||||||
resultItem.service_id = getServiceId();
|
resultItem.service_id = getServiceId();
|
||||||
resultItem.name = extractor.getUserName();
|
resultItem.name = extractor.getChannelName();
|
||||||
resultItem.url = extractor.getWebPageUrl();
|
resultItem.url = extractor.getWebPageUrl();
|
||||||
|
|
||||||
// optional information
|
// optional information
|
||||||
@ -59,7 +59,7 @@ public class UserInfoItemCollector extends InfoItemCollector {
|
|||||||
return resultItem;
|
return resultItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void commit(UserInfoItemExtractor extractor) throws ParsingException {
|
public void commit(ChannelInfoItemExtractor 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.user;
|
package org.schabi.newpipe.extractor.channel;
|
||||||
|
|
||||||
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>
|
||||||
* UserInfoItemExtractor.java is part of NewPipe.
|
* ChannelInfoItemExtractor.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 UserInfoItemExtractor {
|
public interface ChannelInfoItemExtractor {
|
||||||
String getThumbnailUrl() throws ParsingException;
|
String getThumbnailUrl() throws ParsingException;
|
||||||
String getUserName() throws ParsingException;
|
String getChannelName() 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;
|
@ -19,12 +19,12 @@ public abstract class PlaylistExtractor extends ListExtractor {
|
|||||||
return getService().getPlaylistUrlIdHandler();
|
return getService().getPlaylistUrlIdHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getPlaylistId() throws ParsingException;
|
|
||||||
public abstract String getPlaylistName() throws ParsingException;
|
|
||||||
public abstract String getThumbnailUrl() throws ParsingException;
|
public abstract String getThumbnailUrl() throws ParsingException;
|
||||||
public abstract String getBannerUrl() throws ParsingException;
|
public abstract String getBannerUrl() throws ParsingException;
|
||||||
|
|
||||||
public abstract String getUploaderUrl() throws ParsingException;
|
public abstract String getUploaderUrl() throws ParsingException;
|
||||||
public abstract String getUploaderName() throws ParsingException;
|
public abstract String getUploaderName() throws ParsingException;
|
||||||
public abstract String getUploaderAvatarUrl() throws ParsingException;
|
public abstract String getUploaderAvatarUrl() throws ParsingException;
|
||||||
|
|
||||||
public abstract long getStreamCount() throws ParsingException;
|
public abstract long getStreamCount() throws ParsingException;
|
||||||
}
|
}
|
||||||
|
@ -39,8 +39,8 @@ public class PlaylistInfo extends ListInfo {
|
|||||||
|
|
||||||
info.service_id = extractor.getServiceId();
|
info.service_id = extractor.getServiceId();
|
||||||
info.url = extractor.getCleanUrl();
|
info.url = extractor.getCleanUrl();
|
||||||
info.id = extractor.getPlaylistId();
|
info.id = extractor.getId();
|
||||||
info.name = extractor.getPlaylistName();
|
info.name = extractor.getName();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
info.stream_count = extractor.getStreamCount();
|
info.stream_count = extractor.getStreamCount();
|
||||||
|
@ -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.user.UserInfoItemExtractor;
|
|||||||
public class InfoItemSearchCollector extends InfoItemCollector {
|
public class InfoItemSearchCollector extends InfoItemCollector {
|
||||||
private String suggestion = "";
|
private String suggestion = "";
|
||||||
private StreamInfoItemCollector streamCollector;
|
private StreamInfoItemCollector streamCollector;
|
||||||
private UserInfoItemCollector userCollector;
|
private ChannelInfoItemCollector 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);
|
||||||
userCollector = new UserInfoItemCollector(serviceId);
|
userCollector = new ChannelInfoItemCollector(serviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSuggestion(String suggestion) {
|
public void setSuggestion(String suggestion) {
|
||||||
@ -65,7 +65,7 @@ public class InfoItemSearchCollector extends InfoItemCollector {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void commit(UserInfoItemExtractor extractor) {
|
public void commit(ChannelInfoItemExtractor extractor) {
|
||||||
try {
|
try {
|
||||||
result.resultList.add(userCollector.extract(extractor));
|
result.resultList.add(userCollector.extract(extractor));
|
||||||
} catch (FoundAdException ae) {
|
} catch (FoundAdException ae) {
|
||||||
|
@ -27,7 +27,7 @@ import java.util.EnumSet;
|
|||||||
|
|
||||||
public abstract class SearchEngine {
|
public abstract class SearchEngine {
|
||||||
public enum Filter {
|
public enum Filter {
|
||||||
STREAM, USER, PLAYLIST
|
STREAM, CHANNEL, PLAYLIST
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class NothingFoundException extends ExtractionException {
|
public static class NothingFoundException extends ExtractionException {
|
||||||
|
@ -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 SoundcloudUserExtractor extends UserExtractor {
|
public class SoundcloudChannelExtractor extends ChannelExtractor {
|
||||||
private String userId;
|
private String userId;
|
||||||
private JSONObject user;
|
private JSONObject user;
|
||||||
|
|
||||||
public SoundcloudUserExtractor(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
public SoundcloudChannelExtractor(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||||
super(service, url, nextStreamsUrl);
|
super(service, url, nextStreamsUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,12 +42,12 @@ public class SoundcloudUserExtractor extends UserExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUserId() {
|
public String getId() {
|
||||||
return userId;
|
return userId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUserName() {
|
public String getName() {
|
||||||
return user.getString("username");
|
return user.getString("username");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -65,21 +65,26 @@ public class SoundcloudUserExtractor extends UserExtractor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFeedUrl() throws ParsingException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSubscriberCount() {
|
public long getSubscriberCount() {
|
||||||
return user.optLong("followers_count", 0L);
|
return user.optLong("followers_count", 0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getFeedUrl() throws ParsingException {
|
public String getDescription() throws ParsingException {
|
||||||
return null;
|
return user.optString("description");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
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/" + getUserId() + "/tracks"
|
String apiUrl = "https://api-v2.soundcloud.com/users/" + getId() + "/tracks"
|
||||||
+ "?client_id=" + SoundcloudParsingHelper.clientId()
|
+ "?client_id=" + SoundcloudParsingHelper.clientId()
|
||||||
+ "&limit=20"
|
+ "&limit=20"
|
||||||
+ "&linked_partitioning=1";
|
+ "&linked_partitioning=1";
|
||||||
@ -91,7 +96,7 @@ public class SoundcloudUserExtractor extends UserExtractor {
|
|||||||
@Override
|
@Override
|
||||||
public NextItemsResult getNextStreams() throws IOException, ExtractionException {
|
public NextItemsResult getNextStreams() throws IOException, ExtractionException {
|
||||||
if (!hasMoreStreams()) {
|
if (!hasMoreStreams()) {
|
||||||
throw new ExtractionException("User doesn't have more streams");
|
throw new ExtractionException("Channel doesn't have more streams");
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId());
|
StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId());
|
||||||
@ -99,9 +104,4 @@ public class SoundcloudUserExtractor extends UserExtractor {
|
|||||||
|
|
||||||
return new NextItemsResult(collector.getItemList(), nextStreamsUrl);
|
return new NextItemsResult(collector.getItemList(), nextStreamsUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() throws ParsingException {
|
|
||||||
return user.optString("description");
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -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.user.UserInfoItemExtractor;
|
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;
|
||||||
|
|
||||||
public class SoundcloudUserInfoItemExtractor implements UserInfoItemExtractor {
|
public class SoundcloudChannelInfoItemExtractor implements ChannelInfoItemExtractor {
|
||||||
private JSONObject searchResult;
|
private JSONObject searchResult;
|
||||||
|
|
||||||
public SoundcloudUserInfoItemExtractor(JSONObject searchResult) {
|
public SoundcloudChannelInfoItemExtractor(JSONObject searchResult) {
|
||||||
this.searchResult = searchResult;
|
this.searchResult = searchResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ public class SoundcloudUserInfoItemExtractor implements UserInfoItemExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUserName() {
|
public String getChannelName() {
|
||||||
return searchResult.getString("username");
|
return searchResult.getString("username");
|
||||||
}
|
}
|
||||||
|
|
@ -8,13 +8,13 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|||||||
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;
|
||||||
|
|
||||||
public class SoundcloudUserUrlIdHandler implements UrlIdHandler {
|
public class SoundcloudChannelUrlIdHandler implements UrlIdHandler {
|
||||||
|
|
||||||
private static final SoundcloudUserUrlIdHandler instance = new SoundcloudUserUrlIdHandler();
|
private static final SoundcloudChannelUrlIdHandler instance = new SoundcloudChannelUrlIdHandler();
|
||||||
private final String URL_PATTERN = "^https?://(www\\.)?soundcloud.com/[0-9a-z_-]+" +
|
private final String URL_PATTERN = "^https?://(www\\.)?soundcloud.com/[0-9a-z_-]+" +
|
||||||
"(/((tracks|albums|sets|reposts|followers|following)/?)?)?([#?].*)?$";
|
"(/((tracks|albums|sets|reposts|followers|following)/?)?)?([#?].*)?$";
|
||||||
|
|
||||||
public static SoundcloudUserUrlIdHandler getInstance() {
|
public static SoundcloudChannelUrlIdHandler getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
@ -42,12 +42,12 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlaylistId() {
|
public String getId() {
|
||||||
return playlistId;
|
return playlistId;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlaylistName() {
|
public String getName() {
|
||||||
return playlist.optString("title");
|
return playlist.optString("title");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor {
|
|||||||
StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId());
|
StreamInfoItemCollector collector = new StreamInfoItemCollector(getServiceId());
|
||||||
|
|
||||||
// Note the "api", NOT "api-v2"
|
// Note the "api", NOT "api-v2"
|
||||||
String apiUrl = "https://api.soundcloud.com/playlists/" + getPlaylistId() + "/tracks"
|
String apiUrl = "https://api.soundcloud.com/playlists/" + getId() + "/tracks"
|
||||||
+ "?client_id=" + SoundcloudParsingHelper.clientId()
|
+ "?client_id=" + SoundcloudParsingHelper.clientId()
|
||||||
+ "&limit=20"
|
+ "&limit=20"
|
||||||
+ "&linked_partitioning=1";
|
+ "&linked_partitioning=1";
|
||||||
|
@ -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.USER)) {
|
if (filter.contains(Filter.STREAM) && !filter.contains(Filter.CHANNEL)) {
|
||||||
url += "/tracks";
|
url += "/tracks";
|
||||||
} else if (!filter.contains(Filter.STREAM) && filter.contains(Filter.USER)) {
|
} else if (!filter.contains(Filter.STREAM) && filter.contains(Filter.CHANNEL)) {
|
||||||
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 SoundcloudUserInfoItemExtractor(searchResult));
|
collector.commit(new SoundcloudChannelInfoItemExtractor(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 getUserUrlIdHandler() {
|
public UrlIdHandler getChannelUrlIdHandler() {
|
||||||
return SoundcloudUserUrlIdHandler.getInstance();
|
return SoundcloudChannelUrlIdHandler.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -44,8 +44,8 @@ public class SoundcloudService extends StreamingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserExtractor getUserExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
public ChannelExtractor getChannelExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||||
return new SoundcloudUserExtractor(this, url, nextStreamsUrl);
|
return new SoundcloudChannelExtractor(this, url, nextStreamsUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -47,84 +47,37 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTitle() {
|
public String getName() {
|
||||||
return track.optString("title");
|
return track.optString("title");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() {
|
|
||||||
return track.optString("description");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUploaderName() {
|
|
||||||
return track.getJSONObject("user").getString("username");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUploaderUrl() {
|
|
||||||
return track.getJSONObject("user").getString("permalink_url");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUploaderAvatarUrl() {
|
|
||||||
return track.getJSONObject("user").optString("avatar_url");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getThumbnailUrl() {
|
|
||||||
return track.optString("artwork_url");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getLength() {
|
|
||||||
return track.getLong("duration") / 1000L;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getViewCount() {
|
|
||||||
return track.getLong("playback_count");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUploadDate() throws ParsingException {
|
public String getUploadDate() throws ParsingException {
|
||||||
return SoundcloudParsingHelper.toDateString(track.getString("created_at"));
|
return SoundcloudParsingHelper.toDateString(track.getString("created_at"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getDashMpdUrl() {
|
public String getThumbnailUrl() {
|
||||||
return null;
|
return track.optString("artwork_url");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<AudioStream> getAudioStreams() throws IOException, ExtractionException {
|
public String getDescription() {
|
||||||
List<AudioStream> audioStreams = new ArrayList<>();
|
return track.optString("description");
|
||||||
Downloader dl = NewPipe.getDownloader();
|
|
||||||
|
|
||||||
String apiUrl = "https://api.soundcloud.com/i1/tracks/" + getId() + "/streams"
|
|
||||||
+ "?client_id=" + SoundcloudParsingHelper.clientId();
|
|
||||||
|
|
||||||
String response = dl.download(apiUrl);
|
|
||||||
JSONObject responseObject = new JSONObject(response);
|
|
||||||
|
|
||||||
AudioStream audioStream = new AudioStream(responseObject.getString("http_mp3_128_url"), MediaFormat.MP3.id, 128);
|
|
||||||
audioStreams.add(audioStream);
|
|
||||||
|
|
||||||
return audioStreams;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<VideoStream> getVideoStreams() throws IOException, ExtractionException {
|
public int getAgeLimit() {
|
||||||
return null;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<VideoStream> getVideoOnlyStreams() throws IOException, ExtractionException {
|
public long getLength() {
|
||||||
return null;
|
return track.getLong("duration") / 1000L;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeStamp() throws ParsingException {
|
public long getTimeStamp() throws ParsingException {
|
||||||
String timeStamp;
|
String timeStamp;
|
||||||
try {
|
try {
|
||||||
timeStamp = Parser.matchGroup1("(#t=\\d{0,3}h?\\d{0,3}m?\\d{1,3}s?)", getOriginalUrl());
|
timeStamp = Parser.matchGroup1("(#t=\\d{0,3}h?\\d{0,3}m?\\d{1,3}s?)", getOriginalUrl());
|
||||||
@ -171,8 +124,8 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getAgeLimit() {
|
public long getViewCount() {
|
||||||
return 0;
|
return track.getLong("playback_count");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -185,6 +138,58 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUploaderUrl() {
|
||||||
|
return track.getJSONObject("user").getString("permalink_url");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUploaderName() {
|
||||||
|
return track.getJSONObject("user").getString("username");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUploaderAvatarUrl() {
|
||||||
|
return track.getJSONObject("user").optString("avatar_url");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDashMpdUrl() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<AudioStream> getAudioStreams() throws IOException, ExtractionException {
|
||||||
|
List<AudioStream> audioStreams = new ArrayList<>();
|
||||||
|
Downloader dl = NewPipe.getDownloader();
|
||||||
|
|
||||||
|
String apiUrl = "https://api.soundcloud.com/i1/tracks/" + getId() + "/streams"
|
||||||
|
+ "?client_id=" + SoundcloudParsingHelper.clientId();
|
||||||
|
|
||||||
|
String response = dl.download(apiUrl);
|
||||||
|
JSONObject responseObject = new JSONObject(response);
|
||||||
|
|
||||||
|
AudioStream audioStream = new AudioStream(responseObject.getString("http_mp3_128_url"), MediaFormat.MP3.id, 128);
|
||||||
|
audioStreams.add(audioStream);
|
||||||
|
|
||||||
|
return audioStreams;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<VideoStream> getVideoStreams() throws IOException, ExtractionException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<VideoStream> getVideoOnlyStreams() throws IOException, ExtractionException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public StreamType getStreamType() {
|
||||||
|
return StreamType.AUDIO_STREAM;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StreamInfoItem getNextVideo() throws IOException, ExtractionException {
|
public StreamInfoItem getNextVideo() throws IOException, ExtractionException {
|
||||||
return null;
|
return null;
|
||||||
@ -201,10 +206,6 @@ public class SoundcloudStreamExtractor extends StreamExtractor {
|
|||||||
return collector;
|
return collector;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public StreamType getStreamType() {
|
|
||||||
return StreamType.AUDIO_STREAM;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getErrorMessage() {
|
public String getErrorMessage() {
|
||||||
|
@ -9,11 +9,11 @@ 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.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;
|
||||||
|
|
||||||
@ -23,7 +23,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>
|
||||||
* YoutubeUserExtractor.java is part of NewPipe.
|
* YoutubeChannelExtractor.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
|
||||||
@ -40,7 +40,7 @@ import java.io.IOException;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
public class YoutubeUserExtractor extends UserExtractor {
|
public class YoutubeChannelExtractor extends ChannelExtractor {
|
||||||
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";
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ public class YoutubeUserExtractor extends UserExtractor {
|
|||||||
*/
|
*/
|
||||||
private Document nextStreamsAjax;
|
private Document nextStreamsAjax;
|
||||||
|
|
||||||
public YoutubeUserExtractor(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
public YoutubeChannelExtractor(StreamingService service, String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||||
super(service, url, nextStreamsUrl);
|
super(service, url, nextStreamsUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,16 +58,16 @@ public class YoutubeUserExtractor extends UserExtractor {
|
|||||||
public void fetchPage() throws IOException, ExtractionException {
|
public void fetchPage() throws IOException, ExtractionException {
|
||||||
Downloader downloader = NewPipe.getDownloader();
|
Downloader downloader = NewPipe.getDownloader();
|
||||||
|
|
||||||
String userUrl = getCleanUrl() + CHANNEL_URL_PARAMETERS;
|
String channelUrl = getCleanUrl() + CHANNEL_URL_PARAMETERS;
|
||||||
String pageContent = downloader.download(userUrl);
|
String pageContent = downloader.download(channelUrl);
|
||||||
doc = Jsoup.parse(pageContent, userUrl);
|
doc = Jsoup.parse(pageContent, channelUrl);
|
||||||
|
|
||||||
nextStreamsUrl = getNextStreamsUrlFrom(doc);
|
nextStreamsUrl = getNextStreamsUrlFrom(doc);
|
||||||
nextStreamsAjax = null;
|
nextStreamsAjax = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUserId() throws ParsingException {
|
public String getId() throws ParsingException {
|
||||||
try {
|
try {
|
||||||
return getUrlIdHandler().getId(getCleanUrl());
|
return getUrlIdHandler().getId(getCleanUrl());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -76,7 +76,7 @@ public class YoutubeUserExtractor extends UserExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUserName() throws ParsingException {
|
public String getName() 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) {
|
||||||
@ -106,6 +106,15 @@ public class YoutubeUserExtractor extends UserExtractor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getFeedUrl() throws ParsingException {
|
||||||
|
try {
|
||||||
|
String channelId = doc.getElementsByClass("yt-uix-subscription-button").first().attr("data-channel-external-id");
|
||||||
|
return channelId == null ? "" : CHANNEL_FEED_BASE + channelId;
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ParsingException("Could not get feed url", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long getSubscriberCount() throws ParsingException {
|
public long getSubscriberCount() throws ParsingException {
|
||||||
@ -121,18 +130,8 @@ public class YoutubeUserExtractor extends UserExtractor {
|
|||||||
public String getDescription() throws ParsingException {
|
public String getDescription() throws ParsingException {
|
||||||
try {
|
try {
|
||||||
return doc.select("meta[name=\"description\"]").first().attr("content");
|
return doc.select("meta[name=\"description\"]").first().attr("content");
|
||||||
} catch(Exception e) {
|
|
||||||
throw new ParsingException("Could not get channel description", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getFeedUrl() throws ParsingException {
|
|
||||||
try {
|
|
||||||
String channelId = doc.getElementsByClass("yt-uix-subscription-button").first().attr("data-channel-external-id");
|
|
||||||
return channelId == null ? "" : CHANNEL_FEED_BASE + channelId;
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ParsingException("Could not get feed url", e);
|
throw new ParsingException("Could not get channel description", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -220,7 +219,7 @@ public class YoutubeUserExtractor extends UserExtractor {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUploaderName() throws ParsingException {
|
public String getUploaderName() throws ParsingException {
|
||||||
return getUserName();
|
return getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@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>
|
||||||
* YoutubeUserInfoItemExtractor.java is part of NewPipe.
|
* YoutubeChannelInfoItemExtractor.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 YoutubeUserInfoItemExtractor implements UserInfoItemExtractor {
|
public class YoutubeChannelInfoItemExtractor implements ChannelInfoItemExtractor {
|
||||||
private Element el;
|
private Element el;
|
||||||
|
|
||||||
public YoutubeUserInfoItemExtractor(Element el) {
|
public YoutubeChannelInfoItemExtractor(Element el) {
|
||||||
this.el = el;
|
this.el = el;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ public class YoutubeUserInfoItemExtractor implements UserInfoItemExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUserName() throws ParsingException {
|
public String getChannelName() 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>
|
||||||
* YoutubeUserUrlIdHandler.java is part of NewPipe.
|
* YoutubeChannelUrlIdHandler.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,12 +24,12 @@ 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 YoutubeUserUrlIdHandler implements UrlIdHandler {
|
public class YoutubeChannelUrlIdHandler implements UrlIdHandler {
|
||||||
|
|
||||||
private static final YoutubeUserUrlIdHandler instance = new YoutubeUserUrlIdHandler();
|
private static final YoutubeChannelUrlIdHandler instance = new YoutubeChannelUrlIdHandler();
|
||||||
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 YoutubeUserUrlIdHandler getInstance() {
|
public static YoutubeChannelUrlIdHandler getInstance() {
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
@ -45,7 +45,7 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlaylistId() throws ParsingException {
|
public String getId() throws ParsingException {
|
||||||
try {
|
try {
|
||||||
return getUrlIdHandler().getId(getCleanUrl());
|
return getUrlIdHandler().getId(getCleanUrl());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@ -54,7 +54,7 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlaylistName() throws ParsingException {
|
public String getName() throws ParsingException {
|
||||||
try {
|
try {
|
||||||
return doc.select("div[id=pl-header] h1[class=pl-header-title]").first().text();
|
return doc.select("div[id=pl-header] h1[class=pl-header-title]").first().text();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -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.USER)) {
|
if (filter.contains(Filter.STREAM) && !filter.contains(Filter.CHANNEL)) {
|
||||||
url += "&sp=EgIQAQ%253D%253D";
|
url += "&sp=EgIQAQ%253D%253D";
|
||||||
} else if (!filter.contains(Filter.STREAM) && filter.contains(Filter.USER)) {
|
} else if (!filter.contains(Filter.STREAM) && filter.contains(Filter.CHANNEL)) {
|
||||||
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 YoutubeUserInfoItemExtractor(el));
|
collector.commit(new YoutubeChannelInfoItemExtractor(el));
|
||||||
} else {
|
} else {
|
||||||
// noinspection ConstantConditions
|
// noinspection ConstantConditions
|
||||||
// simply ignore not known items
|
// simply ignore not known items
|
||||||
|
@ -7,7 +7,7 @@ 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 org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -49,8 +49,8 @@ public class YoutubeService extends StreamingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UrlIdHandler getUserUrlIdHandler() {
|
public UrlIdHandler getChannelUrlIdHandler() {
|
||||||
return YoutubeUserUrlIdHandler.getInstance();
|
return YoutubeChannelUrlIdHandler.getInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -65,8 +65,8 @@ public class YoutubeService extends StreamingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public UserExtractor getUserExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
public ChannelExtractor getChannelExtractor(String url, String nextStreamsUrl) throws IOException, ExtractionException {
|
||||||
return new YoutubeUserExtractor(this, url, nextStreamsUrl);
|
return new YoutubeChannelExtractor(this, url, nextStreamsUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -97,85 +97,26 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTitle() throws ParsingException {
|
public String getName() throws ParsingException {
|
||||||
try {
|
try {
|
||||||
if (playerArgs == null) {
|
|
||||||
return videoInfoPage.get("title");
|
|
||||||
}
|
|
||||||
//json player args method
|
|
||||||
return playerArgs.getString("title");
|
return playerArgs.getString("title");
|
||||||
} catch (Exception je) {
|
} catch (Exception ignored) {
|
||||||
System.err.println("failed to load title from JSON args; trying to extract it from HTML");
|
// Try other method...
|
||||||
try { // fall-back to html
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return videoInfoPage.get("title");
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// Try other method...
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Fallback to HTML method
|
||||||
return doc.select("meta[name=title]").attr(CONTENT);
|
return doc.select("meta[name=title]").attr(CONTENT);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ParsingException("Could not get the title", e);
|
throw new ParsingException("Could not get the title", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getDescription() throws ParsingException {
|
|
||||||
try {
|
|
||||||
return doc.select("p[id=\"eow-description\"]").first().html();
|
|
||||||
} catch (Exception e) {//todo: add fallback method <-- there is no ... as long as i know
|
|
||||||
throw new ParsingException("Could not get the description", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUploaderName() throws ParsingException {
|
|
||||||
try {
|
|
||||||
return playerArgs.getString("author");
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
// Try other method...
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return videoInfoPage.get("author");
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
// Try other method...
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Fallback to HTML method
|
|
||||||
return doc.select("div.yt-user-info").first().text();
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new ParsingException("Could not get uploader name", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getLength() throws ParsingException {
|
|
||||||
try {
|
|
||||||
return playerArgs.getLong("length_seconds");
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
// Try other method...
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return Long.parseLong(videoInfoPage.get("length_seconds"));
|
|
||||||
} catch (Exception ignored) {
|
|
||||||
// Try other method...
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
// Fallback to HTML method
|
|
||||||
return Long.parseLong(doc.select("div[class~=\"ytp-progress-bar\"][role=\"slider\"]")
|
|
||||||
.first().attr("aria-valuemax"));
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new ParsingException("Could not get video length", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getViewCount() throws ParsingException {
|
|
||||||
try {
|
|
||||||
return Long.parseLong(doc.select("meta[itemprop=interactionCount]").attr(CONTENT));
|
|
||||||
} catch (Exception e) {//todo: find fallback method
|
|
||||||
throw new ParsingException("Could not get number of views", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUploadDate() throws ParsingException {
|
public String getUploadDate() throws ParsingException {
|
||||||
@ -208,6 +149,182 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getDescription() throws ParsingException {
|
||||||
|
try {
|
||||||
|
return doc.select("p[id=\"eow-description\"]").first().html();
|
||||||
|
} catch (Exception e) {//todo: add fallback method <-- there is no ... as long as i know
|
||||||
|
throw new ParsingException("Could not get the description", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getAgeLimit() throws ParsingException {
|
||||||
|
if (!isAgeRestricted) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return Integer.valueOf(doc.select("meta[property=\"og:restrictions:age\"]")
|
||||||
|
.attr(CONTENT).replace("+", ""));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ParsingException("Could not get age restriction");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getLength() throws ParsingException {
|
||||||
|
try {
|
||||||
|
return playerArgs.getLong("length_seconds");
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// Try other method...
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return Long.parseLong(videoInfoPage.get("length_seconds"));
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// Try other method...
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Fallback to HTML method
|
||||||
|
return Long.parseLong(doc.select("div[class~=\"ytp-progress-bar\"][role=\"slider\"]")
|
||||||
|
.first().attr("aria-valuemax"));
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ParsingException("Could not get video length", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Attempts to parse (and return) the offset to start playing the video from.
|
||||||
|
*
|
||||||
|
* @return the offset (in seconds), or 0 if no timestamp is found.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public long getTimeStamp() throws ParsingException {
|
||||||
|
String timeStamp;
|
||||||
|
try {
|
||||||
|
timeStamp = Parser.matchGroup1("((#|&|\\?)t=\\d{0,3}h?\\d{0,3}m?\\d{1,3}s?)", getOriginalUrl());
|
||||||
|
} catch (Parser.RegexException e) {
|
||||||
|
// catch this instantly since an url does not necessarily have to have a time stamp
|
||||||
|
|
||||||
|
// -2 because well the testing system will then know its the regex that failed :/
|
||||||
|
// not good i know
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!timeStamp.isEmpty()) {
|
||||||
|
try {
|
||||||
|
String secondsString = "";
|
||||||
|
String minutesString = "";
|
||||||
|
String hoursString = "";
|
||||||
|
try {
|
||||||
|
secondsString = Parser.matchGroup1("(\\d{1,3})s", timeStamp);
|
||||||
|
minutesString = Parser.matchGroup1("(\\d{1,3})m", timeStamp);
|
||||||
|
hoursString = Parser.matchGroup1("(\\d{1,3})h", timeStamp);
|
||||||
|
} catch (Exception e) {
|
||||||
|
//it could be that time is given in another method
|
||||||
|
if (secondsString.isEmpty() //if nothing was got,
|
||||||
|
&& minutesString.isEmpty()//treat as unlabelled seconds
|
||||||
|
&& hoursString.isEmpty()) {
|
||||||
|
secondsString = Parser.matchGroup1("t=(\\d+)", timeStamp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int seconds = secondsString.isEmpty() ? 0 : Integer.parseInt(secondsString);
|
||||||
|
int minutes = minutesString.isEmpty() ? 0 : Integer.parseInt(minutesString);
|
||||||
|
int hours = hoursString.isEmpty() ? 0 : Integer.parseInt(hoursString);
|
||||||
|
|
||||||
|
//don't trust BODMAS!
|
||||||
|
return seconds + (60 * minutes) + (3600 * hours);
|
||||||
|
//Log.d(TAG, "derived timestamp value:"+ret);
|
||||||
|
//the ordering varies internationally
|
||||||
|
} catch (ParsingException e) {
|
||||||
|
throw new ParsingException("Could not get timestamp.", e);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getViewCount() throws ParsingException {
|
||||||
|
try {
|
||||||
|
return Long.parseLong(doc.select("meta[itemprop=interactionCount]").attr(CONTENT));
|
||||||
|
} catch (Exception e) {//todo: find fallback method
|
||||||
|
throw new ParsingException("Could not get number of views", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getLikeCount() throws ParsingException {
|
||||||
|
String likesString = "";
|
||||||
|
try {
|
||||||
|
Element button = doc.select("button.like-button-renderer-like-button").first();
|
||||||
|
try {
|
||||||
|
likesString = button.select("span.yt-uix-button-content").first().text();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
//if this ckicks in our button has no content and thefore likes/dislikes are disabled
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return Integer.parseInt(Utils.removeNonDigitCharacters(likesString));
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
throw new ParsingException("Could not parse \"" + likesString + "\" as an Integer", nfe);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ParsingException("Could not get like count", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public long getDislikeCount() throws ParsingException {
|
||||||
|
String dislikesString = "";
|
||||||
|
try {
|
||||||
|
Element button = doc.select("button.like-button-renderer-dislike-button").first();
|
||||||
|
try {
|
||||||
|
dislikesString = button.select("span.yt-uix-button-content").first().text();
|
||||||
|
} catch (NullPointerException e) {
|
||||||
|
//if this kicks in our button has no content and therefore likes/dislikes are disabled
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
return Integer.parseInt(Utils.removeNonDigitCharacters(dislikesString));
|
||||||
|
} catch (NumberFormatException nfe) {
|
||||||
|
throw new ParsingException("Could not parse \"" + dislikesString + "\" as an Integer", nfe);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ParsingException("Could not get dislike count", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUploaderUrl() throws ParsingException {
|
||||||
|
try {
|
||||||
|
return doc.select("div[class=\"yt-user-info\"]").first().children()
|
||||||
|
.select("a").first().attr("abs:href");
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ParsingException("Could not get channel link", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUploaderName() throws ParsingException {
|
||||||
|
try {
|
||||||
|
return playerArgs.getString("author");
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// Try other method...
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return videoInfoPage.get("author");
|
||||||
|
} catch (Exception ignored) {
|
||||||
|
// Try other method...
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Fallback to HTML method
|
||||||
|
return doc.select("div.yt-user-info").first().text();
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ParsingException("Could not get uploader name", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUploaderAvatarUrl() throws ParsingException {
|
public String getUploaderAvatarUrl() throws ParsingException {
|
||||||
try {
|
try {
|
||||||
@ -302,108 +419,10 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||||||
return videoOnlyStreams;
|
return videoOnlyStreams;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Attempts to parse (and return) the offset to start playing the video from.
|
|
||||||
*
|
|
||||||
* @return the offset (in seconds), or 0 if no timestamp is found.
|
|
||||||
*/
|
|
||||||
@Override
|
@Override
|
||||||
public int getTimeStamp() throws ParsingException {
|
public StreamType getStreamType() throws ParsingException {
|
||||||
String timeStamp;
|
//todo: if implementing livestream support this value should be generated dynamically
|
||||||
try {
|
return StreamType.VIDEO_STREAM;
|
||||||
timeStamp = Parser.matchGroup1("((#|&|\\?)t=\\d{0,3}h?\\d{0,3}m?\\d{1,3}s?)", getOriginalUrl());
|
|
||||||
} catch (Parser.RegexException e) {
|
|
||||||
// catch this instantly since an url does not necessarily have to have a time stamp
|
|
||||||
|
|
||||||
// -2 because well the testing system will then know its the regex that failed :/
|
|
||||||
// not good i know
|
|
||||||
return -2;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!timeStamp.isEmpty()) {
|
|
||||||
try {
|
|
||||||
String secondsString = "";
|
|
||||||
String minutesString = "";
|
|
||||||
String hoursString = "";
|
|
||||||
try {
|
|
||||||
secondsString = Parser.matchGroup1("(\\d{1,3})s", timeStamp);
|
|
||||||
minutesString = Parser.matchGroup1("(\\d{1,3})m", timeStamp);
|
|
||||||
hoursString = Parser.matchGroup1("(\\d{1,3})h", timeStamp);
|
|
||||||
} catch (Exception e) {
|
|
||||||
//it could be that time is given in another method
|
|
||||||
if (secondsString.isEmpty() //if nothing was got,
|
|
||||||
&& minutesString.isEmpty()//treat as unlabelled seconds
|
|
||||||
&& hoursString.isEmpty()) {
|
|
||||||
secondsString = Parser.matchGroup1("t=(\\d+)", timeStamp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int seconds = secondsString.isEmpty() ? 0 : Integer.parseInt(secondsString);
|
|
||||||
int minutes = minutesString.isEmpty() ? 0 : Integer.parseInt(minutesString);
|
|
||||||
int hours = hoursString.isEmpty() ? 0 : Integer.parseInt(hoursString);
|
|
||||||
|
|
||||||
//don't trust BODMAS!
|
|
||||||
return seconds + (60 * minutes) + (3600 * hours);
|
|
||||||
//Log.d(TAG, "derived timestamp value:"+ret);
|
|
||||||
//the ordering varies internationally
|
|
||||||
} catch (ParsingException e) {
|
|
||||||
throw new ParsingException("Could not get timestamp.", e);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAgeLimit() throws ParsingException {
|
|
||||||
if (!isAgeRestricted) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
return Integer.valueOf(doc.head()
|
|
||||||
.getElementsByAttributeValue("property", "og:restrictions:age")
|
|
||||||
.attr(CONTENT).replace("+", ""));
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new ParsingException("Could not get age restriction");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getLikeCount() throws ParsingException {
|
|
||||||
String likesString = "";
|
|
||||||
try {
|
|
||||||
Element button = doc.select("button.like-button-renderer-like-button").first();
|
|
||||||
try {
|
|
||||||
likesString = button.select("span.yt-uix-button-content").first().text();
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
//if this ckicks in our button has no content and thefore likes/dislikes are disabled
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return Integer.parseInt(Utils.removeNonDigitCharacters(likesString));
|
|
||||||
} catch (NumberFormatException nfe) {
|
|
||||||
throw new ParsingException("Could not parse \"" + likesString + "\" as an Integer", nfe);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new ParsingException("Could not get like count", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public long getDislikeCount() throws ParsingException {
|
|
||||||
String dislikesString = "";
|
|
||||||
try {
|
|
||||||
Element button = doc.select("button.like-button-renderer-dislike-button").first();
|
|
||||||
try {
|
|
||||||
dislikesString = button.select("span.yt-uix-button-content").first().text();
|
|
||||||
} catch (NullPointerException e) {
|
|
||||||
//if this kicks in our button has no content and therefore likes/dislikes are disabled
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return Integer.parseInt(Utils.removeNonDigitCharacters(dislikesString));
|
|
||||||
} catch (NumberFormatException nfe) {
|
|
||||||
throw new ParsingException("Could not parse \"" + dislikesString + "\" as an Integer", nfe);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new ParsingException("Could not get dislike count", e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -438,22 +457,6 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUploaderUrl() throws ParsingException {
|
|
||||||
try {
|
|
||||||
return doc.select("div[class=\"yt-user-info\"]").first().children()
|
|
||||||
.select("a").first().attr("abs:href");
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new ParsingException("Could not get channel link", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public StreamType getStreamType() throws ParsingException {
|
|
||||||
//todo: if implementing livestream support this value should be generated dynamically
|
|
||||||
return StreamType.VIDEO_STREAM;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
|
@ -44,27 +44,30 @@ public abstract class StreamExtractor extends Extractor {
|
|||||||
return getService().getStreamUrlIdHandler();
|
return getService().getStreamUrlIdHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getId() throws ParsingException;
|
|
||||||
public abstract int getTimeStamp() throws ParsingException;
|
|
||||||
public abstract String getTitle() throws ParsingException;
|
|
||||||
public abstract String getDescription() throws ParsingException;
|
|
||||||
public abstract String getUploaderName() throws ParsingException;
|
|
||||||
public abstract String getUploaderUrl() throws ParsingException;
|
|
||||||
public abstract long getLength() throws ParsingException;
|
|
||||||
public abstract long getViewCount() throws ParsingException;
|
|
||||||
public abstract String getUploadDate() throws ParsingException;
|
public abstract String getUploadDate() throws ParsingException;
|
||||||
public abstract String getThumbnailUrl() throws ParsingException;
|
public abstract String getThumbnailUrl() throws ParsingException;
|
||||||
|
public abstract String getDescription() throws ParsingException;
|
||||||
|
public abstract int getAgeLimit() throws ParsingException;
|
||||||
|
|
||||||
|
public abstract long getLength() throws ParsingException;
|
||||||
|
public abstract long getTimeStamp() throws ParsingException;
|
||||||
|
|
||||||
|
public abstract long getViewCount() throws ParsingException;
|
||||||
|
public abstract long getLikeCount() throws ParsingException;
|
||||||
|
public abstract long getDislikeCount() throws ParsingException;
|
||||||
|
|
||||||
|
public abstract String getUploaderUrl() throws ParsingException;
|
||||||
|
public abstract String getUploaderName() throws ParsingException;
|
||||||
public abstract String getUploaderAvatarUrl() throws ParsingException;
|
public abstract String getUploaderAvatarUrl() throws ParsingException;
|
||||||
|
|
||||||
|
public abstract String getDashMpdUrl() throws ParsingException;
|
||||||
public abstract List<AudioStream> getAudioStreams() throws IOException, ExtractionException;
|
public abstract List<AudioStream> getAudioStreams() throws IOException, ExtractionException;
|
||||||
public abstract List<VideoStream> getVideoStreams() throws IOException, ExtractionException;
|
public abstract List<VideoStream> getVideoStreams() throws IOException, ExtractionException;
|
||||||
public abstract List<VideoStream> getVideoOnlyStreams() throws IOException, ExtractionException;
|
public abstract List<VideoStream> getVideoOnlyStreams() throws IOException, ExtractionException;
|
||||||
public abstract String getDashMpdUrl() throws ParsingException;
|
|
||||||
public abstract int getAgeLimit() throws ParsingException;
|
public abstract StreamType getStreamType() throws ParsingException;
|
||||||
public abstract long getLikeCount() throws ParsingException;
|
|
||||||
public abstract long getDislikeCount() throws ParsingException;
|
|
||||||
public abstract StreamInfoItem getNextVideo() throws IOException, ExtractionException;
|
public abstract StreamInfoItem getNextVideo() throws IOException, ExtractionException;
|
||||||
public abstract StreamInfoItemCollector getRelatedVideos() throws IOException, ExtractionException;
|
public abstract StreamInfoItemCollector getRelatedVideos() throws IOException, ExtractionException;
|
||||||
public abstract StreamType getStreamType() throws ParsingException;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Analyses the webpage's document and extracts any error message there might be.
|
* Analyses the webpage's document and extracts any error message there might be.
|
||||||
|
@ -99,7 +99,7 @@ public class StreamInfo extends Info {
|
|||||||
streamInfo.url = extractor.getCleanUrl();
|
streamInfo.url = extractor.getCleanUrl();
|
||||||
streamInfo.stream_type = extractor.getStreamType();
|
streamInfo.stream_type = extractor.getStreamType();
|
||||||
streamInfo.id = extractor.getId();
|
streamInfo.id = extractor.getId();
|
||||||
streamInfo.name = extractor.getTitle();
|
streamInfo.name = extractor.getName();
|
||||||
streamInfo.age_limit = extractor.getAgeLimit();
|
streamInfo.age_limit = extractor.getAgeLimit();
|
||||||
|
|
||||||
if ((streamInfo.stream_type == StreamType.NONE)
|
if ((streamInfo.stream_type == StreamType.NONE)
|
||||||
@ -282,6 +282,6 @@ public class StreamInfo extends Info {
|
|||||||
public StreamInfoItem next_video;
|
public StreamInfoItem next_video;
|
||||||
public List<InfoItem> related_streams;
|
public List<InfoItem> related_streams;
|
||||||
//in seconds. some metadata is not passed using a StreamInfo object!
|
//in seconds. some metadata is not passed using a StreamInfo object!
|
||||||
public int start_position = 0;
|
public long start_position = 0;
|
||||||
public String description = "";
|
public String description = "";
|
||||||
}
|
}
|
||||||
|
@ -4,24 +4,24 @@ 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.user.UserExtractor;
|
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link UserExtractor}
|
* Test for {@link ChannelExtractor}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class SoundcloudUserExtractorTest {
|
public class SoundcloudChannelExtractorTest {
|
||||||
|
|
||||||
UserExtractor extractor;
|
ChannelExtractor extractor;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
NewPipe.init(Downloader.getInstance());
|
NewPipe.init(Downloader.getInstance());
|
||||||
extractor = SoundCloud.getService()
|
extractor = SoundCloud.getService()
|
||||||
.getUserExtractor("https://soundcloud.com/liluzivert");
|
.getChannelExtractor("https://soundcloud.com/liluzivert");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -30,8 +30,8 @@ public class SoundcloudUserExtractorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetUserName() throws Exception {
|
public void testGetName() throws Exception {
|
||||||
assertEquals(extractor.getUserName(), "LIL UZI VERT");
|
assertEquals(extractor.getName(), "LIL UZI VERT");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
@ -30,12 +30,12 @@ public class SoundcloudPlaylistExtractorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetId() throws Exception {
|
public void testGetId() throws Exception {
|
||||||
assertEquals(extractor.getPlaylistId(), "246349810");
|
assertEquals(extractor.getId(), "246349810");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetName() throws Exception {
|
public void testGetName() throws Exception {
|
||||||
assertEquals(extractor.getPlaylistName(), "THE PERFECT LUV TAPE®️");
|
assertEquals(extractor.getName(), "THE PERFECT LUV TAPE®️");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -28,7 +28,7 @@ public class SoundcloudSearchEngineAllTest {
|
|||||||
// SoundCloud will suggest "lil uzi vert" instead of "lill uzi vert"
|
// SoundCloud will suggest "lil uzi vert" instead of "lill uzi vert"
|
||||||
// keep in mind that the suggestions can NOT change by country (the parameter "de")
|
// keep in mind that the suggestions can NOT change by country (the parameter "de")
|
||||||
result = engine.search("lill uzi vert", 0, "de",
|
result = engine.search("lill uzi vert", 0, "de",
|
||||||
EnumSet.of(SearchEngine.Filter.USER,
|
EnumSet.of(SearchEngine.Filter.CHANNEL,
|
||||||
SearchEngine.Filter.STREAM)).getSearchResult();
|
SearchEngine.Filter.STREAM)).getSearchResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ import static org.schabi.newpipe.extractor.ServiceList.SoundCloud;
|
|||||||
/**
|
/**
|
||||||
* Test for {@link SearchEngine}
|
* Test for {@link SearchEngine}
|
||||||
*/
|
*/
|
||||||
public class SoundcloudSearchEngineUserTest {
|
public class SoundcloudSearchEngineChannelTest {
|
||||||
private SearchResult result;
|
private SearchResult result;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@ -28,7 +28,7 @@ public class SoundcloudSearchEngineUserTest {
|
|||||||
// SoundCloud will suggest "lil uzi vert" instead of "lill uzi vert"
|
// SoundCloud will suggest "lil uzi vert" instead of "lill uzi vert"
|
||||||
// keep in mind that the suggestions can NOT change by country (the parameter "de")
|
// keep in mind that the suggestions can NOT change by country (the parameter "de")
|
||||||
result = engine.search("lill uzi vert", 0, "de",
|
result = engine.search("lill uzi vert", 0, "de",
|
||||||
EnumSet.of(SearchEngine.Filter.USER)).getSearchResult();
|
EnumSet.of(SearchEngine.Filter.CHANNEL)).getSearchResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -39,7 +39,7 @@ public class SoundcloudSearchEngineUserTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testResultsItemType() {
|
public void testResultsItemType() {
|
||||||
for (InfoItem infoItem : result.resultList) {
|
for (InfoItem infoItem : result.resultList) {
|
||||||
assertEquals(InfoItem.InfoType.USER, infoItem.info_type);
|
assertEquals(InfoItem.InfoType.CHANNEL, infoItem.info_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -29,19 +29,19 @@ public class SoundcloudStreamExtractorDefaultTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetInvalidTimeStamp() throws ParsingException {
|
public void testGetInvalidTimeStamp() throws ParsingException {
|
||||||
assertTrue(Integer.toString(extractor.getTimeStamp()),
|
assertTrue(extractor.getTimeStamp() + "",
|
||||||
extractor.getTimeStamp() <= 0);
|
extractor.getTimeStamp() <= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetValidTimeStamp() throws IOException, ExtractionException {
|
public void testGetValidTimeStamp() throws IOException, ExtractionException {
|
||||||
StreamExtractor extractor = SoundCloud.getService().getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon#t=69");
|
StreamExtractor extractor = SoundCloud.getService().getStreamExtractor("https://soundcloud.com/liluzivert/do-what-i-want-produced-by-maaly-raw-don-cannon#t=69");
|
||||||
assertEquals(Integer.toString(extractor.getTimeStamp()), "69");
|
assertEquals(extractor.getTimeStamp() + "", "69");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetTitle() throws ParsingException {
|
public void testGetTitle() throws ParsingException {
|
||||||
assertEquals(extractor.getTitle(), "Do What I Want [Produced By Maaly Raw + Don Cannon]");
|
assertEquals(extractor.getName(), "Do What I Want [Produced By Maaly Raw + Don Cannon]");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -4,7 +4,7 @@ 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.user.UserExtractor;
|
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
import static org.junit.Assert.*;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
@ -30,17 +30,17 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Test for {@link UserExtractor}
|
* Test for {@link ChannelExtractor}
|
||||||
*/
|
*/
|
||||||
public class YoutubeUserExtractorTest {
|
public class YoutubeChannelExtractorTest {
|
||||||
|
|
||||||
UserExtractor extractor;
|
ChannelExtractor 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()
|
||||||
.getUserExtractor("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw");
|
.getChannelExtractor("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -49,8 +49,8 @@ public class YoutubeUserExtractorTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetUserName() throws Exception {
|
public void testGetName() throws Exception {
|
||||||
assertEquals(extractor.getUserName(), "Gronkh");
|
assertEquals(extractor.getName(), "Gronkh");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
@ -30,12 +30,12 @@ public class YoutubePlaylistExtractorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetId() throws Exception {
|
public void testGetId() throws Exception {
|
||||||
assertEquals(extractor.getPlaylistId(), "PL7XlqX4npddfrdpMCxBnNZXg2GFll7t5y");
|
assertEquals(extractor.getId(), "PL7XlqX4npddfrdpMCxBnNZXg2GFll7t5y");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetName() throws Exception {
|
public void testGetName() throws Exception {
|
||||||
assertEquals(extractor.getPlaylistName(), "important videos");
|
assertEquals(extractor.getName(), "important videos");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -49,7 +49,7 @@ public class YoutubeSearchEngineAllTest {
|
|||||||
// 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.USER,
|
EnumSet.of(SearchEngine.Filter.CHANNEL,
|
||||||
SearchEngine.Filter.STREAM)).getSearchResult();
|
SearchEngine.Filter.STREAM)).getSearchResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
|||||||
/**
|
/**
|
||||||
* Test for {@link SearchEngine}
|
* Test for {@link SearchEngine}
|
||||||
*/
|
*/
|
||||||
public class YoutubeSearchEngineUserTest {
|
public class YoutubeSearchEngineChannelTest {
|
||||||
private SearchResult result;
|
private SearchResult result;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
@ -49,7 +49,7 @@ public class YoutubeSearchEngineUserTest {
|
|||||||
// 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.USER)).getSearchResult();
|
EnumSet.of(SearchEngine.Filter.CHANNEL)).getSearchResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -60,7 +60,7 @@ public class YoutubeSearchEngineUserTest {
|
|||||||
@Test
|
@Test
|
||||||
public void testResultsItemType() {
|
public void testResultsItemType() {
|
||||||
for (InfoItem infoItem : result.resultList) {
|
for (InfoItem infoItem : result.resultList) {
|
||||||
assertEquals(InfoItem.InfoType.USER, infoItem.info_type);
|
assertEquals(InfoItem.InfoType.CHANNEL, infoItem.info_type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -13,6 +13,7 @@ import org.schabi.newpipe.extractor.stream.VideoStream;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
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;
|
||||||
@ -52,20 +53,19 @@ public class YoutubeStreamExtractorDefaultTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetInvalidTimeStamp() throws ParsingException {
|
public void testGetInvalidTimeStamp() throws ParsingException {
|
||||||
assertTrue(Integer.toString(extractor.getTimeStamp()),
|
assertTrue(extractor.getTimeStamp() + "",
|
||||||
extractor.getTimeStamp() <= 0);
|
extractor.getTimeStamp() <= 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@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()),
|
assertEquals(extractor.getTimeStamp() + "", "174");
|
||||||
extractor.getTimeStamp() == 174);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetTitle() throws ParsingException {
|
public void testGetTitle() throws ParsingException {
|
||||||
assertTrue(!extractor.getTitle().isEmpty());
|
assertTrue(!extractor.getName().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@ -11,6 +11,7 @@ import org.schabi.newpipe.extractor.stream.VideoStream;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
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;
|
||||||
|
|
||||||
@ -30,16 +31,13 @@ public class YoutubeStreamExtractorRestrictedTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetInvalidTimeStamp() throws ParsingException {
|
public void testGetInvalidTimeStamp() throws ParsingException {
|
||||||
assertTrue(Integer.toString(extractor.getTimeStamp()),
|
assertTrue(extractor.getTimeStamp() + "", extractor.getTimeStamp() <= 0);
|
||||||
extractor.getTimeStamp() <= 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@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");
|
assertEquals(extractor.getTimeStamp() + "", "174");
|
||||||
assertTrue(Integer.toString(extractor.getTimeStamp()),
|
|
||||||
extractor.getTimeStamp() == 174);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -49,7 +47,7 @@ public class YoutubeStreamExtractorRestrictedTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetTitle() throws ParsingException {
|
public void testGetTitle() throws ParsingException {
|
||||||
assertTrue(!extractor.getTitle().isEmpty());
|
assertTrue(!extractor.getName().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
Reference in New Issue
Block a user