From 6e42cb87e8eae49de873f68b2acc7abff1a14c03 Mon Sep 17 00:00:00 2001 From: wb9688 Date: Wed, 8 Nov 2017 10:17:44 +0100 Subject: [PATCH 1/2] Add support for getting uploader URL --- .../soundcloud/SoundcloudStreamInfoItemExtractor.java | 5 +++++ .../youtube/YoutubeStreamInfoItemExtractor.java | 11 +++++++++++ .../extractor/stream/StreamInfoItemExtractor.java | 1 + 3 files changed, 17 insertions(+) diff --git a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamInfoItemExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamInfoItemExtractor.java index 6b436603..cfea37b9 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamInfoItemExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/soundcloud/SoundcloudStreamInfoItemExtractor.java @@ -33,6 +33,11 @@ public class SoundcloudStreamInfoItemExtractor implements StreamInfoItemExtracto return searchResult.getObject("user").getString("username"); } + @Override + public String getUploaderUrl() { + return searchResult.getObject("user").getString("permalink_url"); + } + @Override public String getUploadDate() throws ParsingException { return SoundcloudParsingHelper.toDateString(searchResult.getString("created_at")); diff --git a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamInfoItemExtractor.java b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamInfoItemExtractor.java index 8b48c1f2..2541e07d 100644 --- a/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamInfoItemExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamInfoItemExtractor.java @@ -94,6 +94,17 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor { } } + @Override + public String getUploaderUrl() throws ParsingException { + try { + return item.select("div[class=\"yt-lockup-byline\"]").first() + .select("a").first() + .attr("href"); + } catch (Exception e) { + throw new ParsingException("Could not get uploader", e); + } + } + @Override public String getUploadDate() throws ParsingException { try { diff --git a/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java b/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java index 17d3fd5b..5d52fef6 100644 --- a/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java +++ b/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemExtractor.java @@ -31,6 +31,7 @@ public interface StreamInfoItemExtractor extends InfoItemExtractor { long getViewCount() throws ParsingException; String getUploaderName() throws ParsingException; + String getUploaderUrl() throws ParsingException; String getUploadDate() throws ParsingException; } From acf05b748cc367eec9e58dd6918fa38795b60b18 Mon Sep 17 00:00:00 2001 From: Coffeemakr Date: Sat, 11 Nov 2017 12:46:14 +0100 Subject: [PATCH 2/2] Add uploaderUrl to StreamInfoItem --- .../newpipe/extractor/stream/StreamInfoItem.java | 10 ++++++++++ .../extractor/stream/StreamInfoItemCollector.java | 5 +++++ 2 files changed, 15 insertions(+) diff --git a/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItem.java b/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItem.java index 1894c808..08ac63d6 100644 --- a/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItem.java +++ b/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItem.java @@ -33,7 +33,17 @@ public class StreamInfoItem extends InfoItem { public long view_count = -1; public long duration = -1; + private String uploaderUrl = null; + public StreamInfoItem() { super(InfoType.STREAM); } + + public void setUploaderUrl(String uploaderUrl) { + this.uploaderUrl = uploaderUrl; + } + + public String getUploaderUrl() { + return uploaderUrl; + } } \ No newline at end of file diff --git a/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemCollector.java b/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemCollector.java index b0757b88..1a26df4d 100644 --- a/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemCollector.java +++ b/src/main/java/org/schabi/newpipe/extractor/stream/StreamInfoItemCollector.java @@ -72,6 +72,11 @@ public class StreamInfoItemCollector extends InfoItemCollector { } catch (Exception e) { addError(e); } + try { + resultItem.setUploaderUrl(extractor.getUploaderUrl()); + } catch (Exception e) { + addError(e); + } return resultItem; }