Renaming and new fields/methods

- Mainly in PlaylistInfoItem and the collector
This commit is contained in:
Mauricio Colli 2017-08-09 23:50:29 -03:00
parent b1eefa040e
commit 5bf2e95d7b
16 changed files with 19 additions and 15 deletions

View File

@ -29,11 +29,12 @@ public abstract class InfoItem implements Serializable {
USER USER
} }
public final InfoType info_type;
public InfoItem(InfoType infoType) { public InfoItem(InfoType infoType) {
this.info_type = infoType; this.info_type = infoType;
} }
public final InfoType info_type;
public int service_id = -1; public int service_id = -1;
public String url; public String url;
public String name; public String name;

View File

@ -38,9 +38,7 @@ public enum MediaFormat {
MP3 (0x5, "MP3", "mp3", "audio/mpeg"); MP3 (0x5, "MP3", "mp3", "audio/mpeg");
public final int id; public final int id;
@SuppressWarnings("WeakerAccess")
public final String name; public final String name;
@SuppressWarnings("WeakerAccess")
public final String suffix; public final String suffix;
public final String mimeType; public final String mimeType;

View File

@ -4,6 +4,7 @@ import org.schabi.newpipe.extractor.InfoItem;
public class PlaylistInfoItem extends InfoItem { public class PlaylistInfoItem extends InfoItem {
public String uploader_name;
public String thumbnail_url; public String thumbnail_url;
/** /**
* How many streams this playlist have * How many streams this playlist have

View File

@ -15,6 +15,11 @@ public class PlaylistInfoItemCollector extends InfoItemCollector {
resultItem.service_id = getServiceId(); resultItem.service_id = getServiceId();
resultItem.url = extractor.getWebPageUrl(); resultItem.url = extractor.getWebPageUrl();
try {
resultItem.uploader_name = extractor.getUploaderName();
} catch (Exception e) {
addError(e);
}
try { try {
resultItem.thumbnail_url = extractor.getThumbnailUrl(); resultItem.thumbnail_url = extractor.getThumbnailUrl();
} catch (Exception e) { } catch (Exception e) {

View File

@ -4,6 +4,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
public interface PlaylistInfoItemExtractor { public interface PlaylistInfoItemExtractor {
String getThumbnailUrl() throws ParsingException; String getThumbnailUrl() throws ParsingException;
String getUploaderName() throws ParsingException;
String getPlaylistName() throws ParsingException; String getPlaylistName() throws ParsingException;
String getWebPageUrl() throws ParsingException; String getWebPageUrl() throws ParsingException;
long getStreamCount() throws ParsingException; long getStreamCount() throws ParsingException;

View File

@ -29,7 +29,7 @@ public class SoundcloudStreamInfoItemExtractor implements StreamInfoItemExtracto
} }
@Override @Override
public String getUploader() { public String getUploaderName() {
return searchResult.getJSONObject("user").getString("username"); return searchResult.getJSONObject("user").getString("username");
} }

View File

@ -239,7 +239,7 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor {
} }
@Override @Override
public String getUploader() throws ParsingException { public String getUploaderName() throws ParsingException {
return li.select("div[class=pl-video-owner] a").text(); return li.select("div[class=pl-video-owner] a").text();
} }

View File

@ -829,7 +829,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
} }
@Override @Override
public String getUploader() throws ParsingException { public String getUploaderName() throws ParsingException {
return li.select("span.g-hovercard").first().text(); return li.select("span.g-hovercard").first().text();
} }

View File

@ -71,7 +71,7 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor {
} }
@Override @Override
public String getUploader() throws ParsingException { public String getUploaderName() throws ParsingException {
try { try {
return item.select("div[class=\"yt-lockup-byline\"]").first() return item.select("div[class=\"yt-lockup-byline\"]").first()
.select("a").first() .select("a").first()

View File

@ -247,7 +247,7 @@ public class YoutubeUserExtractor extends UserExtractor {
} }
@Override @Override
public String getUploader() throws ParsingException { public String getUploaderName() throws ParsingException {
return getUserName(); return getUserName();
} }

View File

@ -28,7 +28,7 @@ import org.schabi.newpipe.extractor.InfoItem;
public class StreamInfoItem extends InfoItem { public class StreamInfoItem extends InfoItem {
public StreamType stream_type; public StreamType stream_type;
public String uploader; public String uploader_name;
public String thumbnail_url; public String thumbnail_url;
public String upload_date; public String upload_date;
public long view_count = -1; public long view_count = -1;

View File

@ -50,7 +50,7 @@ public class StreamInfoItemCollector extends InfoItemCollector {
addError(e); addError(e);
} }
try { try {
resultItem.uploader = extractor.getUploader(); resultItem.uploader_name = extractor.getUploaderName();
} catch (Exception e) { } catch (Exception e) {
addError(e); addError(e);
} }

View File

@ -27,7 +27,7 @@ public interface StreamInfoItemExtractor {
String getWebPageUrl() throws ParsingException; String getWebPageUrl() throws ParsingException;
String getTitle() throws ParsingException; String getTitle() throws ParsingException;
int getDuration() throws ParsingException; int getDuration() throws ParsingException;
String getUploader() throws ParsingException; String getUploaderName() throws ParsingException;
String getUploadDate() throws ParsingException; String getUploadDate() throws ParsingException;
long getViewCount() throws ParsingException; long getViewCount() throws ParsingException;
String getThumbnailUrl() throws ParsingException; String getThumbnailUrl() throws ParsingException;

View File

@ -31,9 +31,8 @@ public class UserInfoItemCollector extends InfoItemCollector {
public UserInfoItem extract(UserInfoItemExtractor extractor) throws ParsingException { public UserInfoItem extract(UserInfoItemExtractor extractor) throws ParsingException {
UserInfoItem resultItem = new UserInfoItem(); UserInfoItem resultItem = new UserInfoItem();
// important information // important information
resultItem.name = extractor.getUserName();
resultItem.service_id = getServiceId(); resultItem.service_id = getServiceId();
resultItem.name = extractor.getUserName();
resultItem.url = extractor.getWebPageUrl(); resultItem.url = extractor.getWebPageUrl();
// optional information // optional information

View File

@ -57,7 +57,7 @@ public class Utils {
} }
if (!Parser.isMatch(pattern, url.toLowerCase())) { if (!Parser.isMatch(pattern, url.toLowerCase())) {
throw new ParsingException("Url not suitable for this url handler"); throw new ParsingException("Url don't match the pattern");
} }
} }
} }

View File

@ -32,7 +32,6 @@ import static org.schabi.newpipe.extractor.ServiceList.YouTube;
/** /**
* Test for {@link UserExtractor} * Test for {@link UserExtractor}
*/ */
public class YoutubeUserExtractorTest { public class YoutubeUserExtractorTest {
UserExtractor extractor; UserExtractor extractor;