From 5ebb5301c9dba5ed7e6fad97548c01bd4837166c Mon Sep 17 00:00:00 2001 From: Mauricio Colli Date: Tue, 8 Aug 2017 18:36:11 -0300 Subject: [PATCH] Rename some variables and methods --- .../extractor/playlist/PlaylistExtractor.java | 2 +- .../extractor/playlist/PlaylistInfo.java | 4 +-- .../SoundcloudPlaylistExtractor.java | 2 +- .../soundcloud/SoundcloudStreamExtractor.java | 11 ++----- .../youtube/YoutubePlaylistExtractor.java | 4 +-- .../youtube/YoutubeStreamExtractor.java | 18 ++--------- .../youtube/YoutubeUserExtractor.java | 2 +- .../extractor/stream/StreamExtractor.java | 7 ++--- .../newpipe/extractor/stream/StreamInfo.java | 31 ++++++++----------- .../SoundcloudPlaylistExtractorTest.java | 4 +-- .../SoundcloudStreamExtractorDefaultTest.java | 12 +++---- .../youtube/YoutubePlaylistExtractorTest.java | 4 +-- .../YoutubeStreamExtractorDefaultTest.java | 14 ++++----- .../YoutubeStreamExtractorRestrictedTest.java | 10 +++--- 14 files changed, 51 insertions(+), 74 deletions(-) diff --git a/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java b/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java index f9f62e9cc..e6d0bc319 100644 --- a/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistExtractor.java @@ -21,7 +21,7 @@ public abstract class PlaylistExtractor extends ListExtractor { public abstract String getPlaylistId() throws ParsingException; public abstract String getPlaylistName() throws ParsingException; - public abstract String getAvatarUrl() throws ParsingException; + public abstract String getThumbnailUrl() throws ParsingException; public abstract String getBannerUrl() throws ParsingException; public abstract String getUploaderUrl() throws ParsingException; public abstract String getUploaderName() throws ParsingException; diff --git a/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java b/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java index 6e296dd76..f356c4566 100644 --- a/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java +++ b/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java @@ -48,7 +48,7 @@ public class PlaylistInfo extends ListInfo { info.errors.add(e); } try { - info.avatar_url = extractor.getAvatarUrl(); + info.thumbnail_url = extractor.getThumbnailUrl(); } catch (Exception e) { info.errors.add(e); } @@ -88,7 +88,7 @@ public class PlaylistInfo extends ListInfo { return info; } - public String avatar_url; + public String thumbnail_url; public String banner_url; public String uploader_url; public String uploader_name; diff --git a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java index ac8ea1a03..1395364bd 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractor.java @@ -52,7 +52,7 @@ public class SoundcloudPlaylistExtractor extends PlaylistExtractor { } @Override - public String getAvatarUrl() { + public String getThumbnailUrl() { return playlist.optString("artwork_url"); } diff --git a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java index ec61a94d3..51c4c25c0 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractor.java @@ -57,7 +57,7 @@ public class SoundcloudStreamExtractor extends StreamExtractor { } @Override - public String getUploader() { + public String getUploaderName() { return track.getJSONObject("user").getString("username"); } @@ -82,7 +82,7 @@ public class SoundcloudStreamExtractor extends StreamExtractor { } @Override - public String getUploaderThumbnailUrl() { + public String getUploaderAvatarUrl() { return track.getJSONObject("user").getString("avatar_url"); } @@ -170,11 +170,6 @@ public class SoundcloudStreamExtractor extends StreamExtractor { return 0; } - @Override - public String getAverageRating() { - return null; - } - @Override public int getLikeCount() { return track.getInt("likes_count"); @@ -210,7 +205,7 @@ public class SoundcloudStreamExtractor extends StreamExtractor { } @Override - public String getUserUrl() { + public String getUploaderUrl() { return track.getJSONObject("user").getString("permalink_url"); } diff --git a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractor.java index 36fe614c7..36750f1d2 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractor.java @@ -64,11 +64,11 @@ public class YoutubePlaylistExtractor extends PlaylistExtractor { } @Override - public String getAvatarUrl() throws ParsingException { + public String getThumbnailUrl() throws ParsingException { try { return doc.select("div[id=pl-header] div[class=pl-header-thumb] img").first().attr("abs:src"); } catch (Exception e) { - throw new ParsingException("Could not get playlist avatar"); + throw new ParsingException("Could not get playlist thumbnail"); } } diff --git a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java index 18ef2449c..8db32e2b3 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java @@ -127,7 +127,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { } @Override - public String getUploader() throws ParsingException { + public String getUploaderName() throws ParsingException { try { if (playerArgs == null) { return videoInfoPage.get("author"); @@ -199,7 +199,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { } @Override - public String getUploaderThumbnailUrl() throws ParsingException { + public String getUploaderAvatarUrl() throws ParsingException { try { return doc.select("a[class*=\"yt-user-photo\"]").first() .select("img").first() @@ -459,18 +459,6 @@ public class YoutubeStreamExtractor extends StreamExtractor { } } - @Override - public String getAverageRating() throws ParsingException { - try { - if (playerArgs == null) { - return videoInfoPage.get("avg_rating"); - } - return playerArgs.getString("avg_rating"); - } catch (JSONException e) { - throw new ParsingException("Could not get Average rating", e); - } - } - @Override public int getLikeCount() throws ParsingException { String likesString = ""; @@ -542,7 +530,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { } @Override - public String getUserUrl() throws ParsingException { + public String getUploaderUrl() throws ParsingException { try { return doc.select("div[class=\"yt-user-info\"]").first().children() .select("a").first().attr("abs:href"); diff --git a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeUserExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeUserExtractor.java index 28af77420..a22b75a73 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeUserExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeUserExtractor.java @@ -124,7 +124,7 @@ public class YoutubeUserExtractor extends UserExtractor { try { return doc.select("meta[name=\"description\"]").first().attr("content"); } catch(Exception e) { - throw new ParsingException("Could not get channel name", e); + throw new ParsingException("Could not get channel description", e); } } diff --git a/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java b/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java index 2a236c146..ad22c4c74 100644 --- a/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/stream/StreamExtractor.java @@ -48,19 +48,18 @@ public abstract class StreamExtractor extends Extractor { public abstract int getTimeStamp() throws ParsingException; public abstract String getTitle() throws ParsingException; public abstract String getDescription() throws ParsingException; - public abstract String getUploader() throws ParsingException; - public abstract String getUserUrl() throws ParsingException; + public abstract String getUploaderName() throws ParsingException; + public abstract String getUploaderUrl() throws ParsingException; public abstract int getLength() throws ParsingException; public abstract long getViewCount() throws ParsingException; public abstract String getUploadDate() throws ParsingException; public abstract String getThumbnailUrl() throws ParsingException; - public abstract String getUploaderThumbnailUrl() throws ParsingException; + public abstract String getUploaderAvatarUrl() throws ParsingException; public abstract List getAudioStreams() throws IOException, ExtractionException; public abstract List getVideoStreams() throws IOException, ExtractionException; public abstract List getVideoOnlyStreams() throws IOException, ExtractionException; public abstract String getDashMpdUrl() throws ParsingException; public abstract int getAgeLimit() throws ParsingException; - public abstract String getAverageRating() throws ParsingException; public abstract int getLikeCount() throws ParsingException; public abstract int getDislikeCount() throws ParsingException; public abstract StreamInfoItemExtractor getNextVideo() throws IOException, ExtractionException; diff --git a/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java b/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java index 70537e584..b2a2a48d4 100644 --- a/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java +++ b/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfo.java @@ -190,12 +190,12 @@ public class StreamInfo extends Info { streamInfo.addException(e); } try { - streamInfo.uploader = extractor.getUploader(); + streamInfo.uploader_name = extractor.getUploaderName(); } catch (Exception e) { streamInfo.addException(e); } try { - streamInfo.user_url = extractor.getUserUrl(); + streamInfo.uploader_url = extractor.getUploaderUrl(); } catch (Exception e) { streamInfo.addException(e); } @@ -215,7 +215,7 @@ public class StreamInfo extends Info { streamInfo.addException(e); } try { - streamInfo.uploader_thumbnail_url = extractor.getUploaderThumbnailUrl(); + streamInfo.uploader_avatar_url = extractor.getUploaderAvatarUrl(); } catch (Exception e) { streamInfo.addException(e); } @@ -224,11 +224,6 @@ public class StreamInfo extends Info { } catch (Exception e) { streamInfo.addException(e); } - try { - streamInfo.average_rating = extractor.getAverageRating(); - } catch (Exception e) { - streamInfo.addException(e); - } try { streamInfo.like_count = extractor.getLikeCount(); } catch (Exception e) { @@ -269,14 +264,18 @@ public class StreamInfo extends Info { } public StreamType stream_type; - public String uploader; public String thumbnail_url; public String upload_date; - public long view_count = -1; + public int duration = -1; + public int age_limit = -1; - public String uploader_thumbnail_url; - public String user_url; - public String description; + public long view_count = -1; + public int like_count = -1; + public int dislike_count = -1; + + public String uploader_name; + public String uploader_url; + public String uploader_avatar_url; public List video_streams; public List audio_streams; @@ -286,14 +285,10 @@ public class StreamInfo extends Info { // crawling such a file is not service dependent. Therefore getting audio only streams by yust // providing the dash mpd fille will be possible in the future. public String dashMpdUrl; - public int duration = -1; - public int age_limit = -1; - public int like_count = -1; - public int dislike_count = -1; - public String average_rating; public StreamInfoItem next_video; public List related_streams; //in seconds. some metadata is not passed using a StreamInfo object! public int start_position = 0; + public String description = ""; } diff --git a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractorTest.java b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractorTest.java index 3200bd505..860a3c2b0 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractorTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudPlaylistExtractorTest.java @@ -39,8 +39,8 @@ public class SoundcloudPlaylistExtractorTest { } @Test - public void testGetAvatarUrl() throws Exception { - assertEquals(extractor.getAvatarUrl(), "https://i1.sndcdn.com/artworks-000174203688-bweu12-large.jpg"); + public void testGetThumbnailUrl() throws Exception { + assertEquals(extractor.getThumbnailUrl(), "https://i1.sndcdn.com/artworks-000174203688-bweu12-large.jpg"); } @Test diff --git a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorDefaultTest.java b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorDefaultTest.java index 6bd53247d..440413ed0 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorDefaultTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamExtractorDefaultTest.java @@ -50,8 +50,8 @@ public class SoundcloudStreamExtractorDefaultTest { } @Test - public void testGetUploader() throws ParsingException { - assertEquals(extractor.getUploader(), "LIL UZI VERT"); + public void testGetUploaderName() throws ParsingException { + assertEquals(extractor.getUploaderName(), "LIL UZI VERT"); } @Test @@ -71,8 +71,8 @@ public class SoundcloudStreamExtractorDefaultTest { } @Test - public void testGetUserUrl() throws ParsingException { - assertEquals(extractor.getUserUrl(), "http://soundcloud.com/liluzivert"); + public void testGetUploaderUrl() throws ParsingException { + assertEquals(extractor.getUploaderUrl(), "http://soundcloud.com/liluzivert"); } @Test @@ -81,8 +81,8 @@ public class SoundcloudStreamExtractorDefaultTest { } @Test - public void testGetUploaderThumbnailUrl() throws ParsingException { - assertEquals(extractor.getUploaderThumbnailUrl(), "https://a1.sndcdn.com/images/default_avatar_large.png"); + public void testGetUploaderAvatarUrl() throws ParsingException { + assertEquals(extractor.getUploaderAvatarUrl(), "https://a1.sndcdn.com/images/default_avatar_large.png"); } @Test diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java index 37edb5d19..eebfc3710 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java @@ -39,8 +39,8 @@ public class YoutubePlaylistExtractorTest { } @Test - public void testGetAvatarUrl() throws Exception { - assertTrue(extractor.getAvatarUrl(), extractor.getAvatarUrl().contains("yt")); + public void testGetThumbnailUrl() throws Exception { + assertTrue(extractor.getThumbnailUrl(), extractor.getThumbnailUrl().contains("yt")); } @Test diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java index f6c1f9428..92a191142 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorDefaultTest.java @@ -74,8 +74,8 @@ public class YoutubeStreamExtractorDefaultTest { } @Test - public void testGetUploader() throws ParsingException { - assertTrue(!extractor.getUploader().isEmpty()); + public void testGetUploaderName() throws ParsingException { + assertTrue(!extractor.getUploaderName().isEmpty()); } @Test @@ -95,8 +95,8 @@ public class YoutubeStreamExtractorDefaultTest { } @Test - public void testGetUserlUrl() throws ParsingException { - assertTrue(extractor.getUserUrl().length() > 0); + public void testGetUploaderUrl() throws ParsingException { + assertTrue(extractor.getUploaderUrl().length() > 0); } @Test @@ -106,9 +106,9 @@ public class YoutubeStreamExtractorDefaultTest { } @Test - public void testGetUploaderThumbnailUrl() throws ParsingException { - assertTrue(extractor.getUploaderThumbnailUrl(), - extractor.getUploaderThumbnailUrl().contains(HTTPS)); + public void testGetUploaderAvatarUrl() throws ParsingException { + assertTrue(extractor.getUploaderAvatarUrl(), + extractor.getUploaderAvatarUrl().contains(HTTPS)); } @Test diff --git a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorRestrictedTest.java b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorRestrictedTest.java index faeba3b47..8d8633b93 100644 --- a/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorRestrictedTest.java +++ b/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractorRestrictedTest.java @@ -58,8 +58,8 @@ public class YoutubeStreamExtractorRestrictedTest { } @Test - public void testGetUploader() throws ParsingException { - assertTrue(!extractor.getUploader().isEmpty()); + public void testGetUploaderName() throws ParsingException { + assertTrue(!extractor.getUploaderName().isEmpty()); } @Test @@ -84,9 +84,9 @@ public class YoutubeStreamExtractorRestrictedTest { } @Test - public void testGetUploaderThumbnailUrl() throws ParsingException { - assertTrue(extractor.getUploaderThumbnailUrl(), - extractor.getUploaderThumbnailUrl().contains(HTTPS)); + public void testGetUploaderAvatarUrl() throws ParsingException { + assertTrue(extractor.getUploaderAvatarUrl(), + extractor.getUploaderAvatarUrl().contains(HTTPS)); } @Test