From ef15902ec4f5a1a7e1261990587772ba78776ab4 Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sat, 11 Feb 2017 21:33:01 +0100 Subject: [PATCH] add InfoItem --- .../detail/VideoItemDetailFragment.java | 4 +-- .../newpipe/extractor/AbstractStreamInfo.java | 4 +-- .../schabi/newpipe/extractor/InfoItem.java | 35 +++++++++++++++++++ .../extractor/channel/ChannelExtractor.java | 10 +++--- .../extractor/channel/ChannelInfo.java | 9 ++--- .../extractor/channel/ChannelInfoItem.java | 8 +++++ .../extractor/search/SearchEngine.java | 8 ++--- .../extractor/search/SearchResult.java | 4 +-- ...ava => StreamInfoSearchItemCollector.java} | 8 ++--- .../youtube/YoutubeChannelExtractor.java | 10 +++--- .../services/youtube/YoutubeSearchEngine.java | 12 +++---- .../youtube/YoutubeStreamExtractor.java | 16 ++++----- ...va => YoutubeStreamInfoItemExtractor.java} | 8 ++--- .../stream_info/StreamExtractor.java | 10 +++--- .../extractor/stream_info/StreamInfo.java | 16 ++++----- ...amPreviewInfo.java => StreamInfoItem.java} | 4 +-- ...ctor.java => StreamInfoItemCollector.java} | 15 ++++---- ...ctor.java => StreamInfoItemExtractor.java} | 4 +-- .../newpipe/info_list/InfoItemBuilder.java | 6 ++-- .../newpipe/info_list/InfoListAdapter.java | 6 ++-- 20 files changed, 120 insertions(+), 77 deletions(-) create mode 100644 app/src/main/java/org/schabi/newpipe/extractor/InfoItem.java create mode 100644 app/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItem.java rename app/src/main/java/org/schabi/newpipe/extractor/search/{StreamPreviewInfoSearchCollector.java => StreamInfoSearchItemCollector.java} (81%) rename app/src/main/java/org/schabi/newpipe/extractor/services/youtube/{YoutubeStreamPreviewInfoExtractor.java => YoutubeStreamInfoItemExtractor.java} (95%) rename app/src/main/java/org/schabi/newpipe/extractor/stream_info/{StreamPreviewInfo.java => StreamInfoItem.java} (90%) rename app/src/main/java/org/schabi/newpipe/extractor/stream_info/{StreamPreviewInfoCollector.java => StreamInfoItemCollector.java} (85%) rename app/src/main/java/org/schabi/newpipe/extractor/stream_info/{StreamPreviewInfoExtractor.java => StreamInfoItemExtractor.java} (93%) diff --git a/app/src/main/java/org/schabi/newpipe/detail/VideoItemDetailFragment.java b/app/src/main/java/org/schabi/newpipe/detail/VideoItemDetailFragment.java index eb75dfa6d..8f2496740 100644 --- a/app/src/main/java/org/schabi/newpipe/detail/VideoItemDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/detail/VideoItemDetailFragment.java @@ -50,7 +50,7 @@ import org.schabi.newpipe.extractor.MediaFormat; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.stream_info.AudioStream; import org.schabi.newpipe.extractor.stream_info.StreamInfo; -import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfo; +import org.schabi.newpipe.extractor.stream_info.StreamInfoItem; import org.schabi.newpipe.extractor.stream_info.VideoStream; import org.schabi.newpipe.info_list.InfoItemBuilder; import org.schabi.newpipe.player.BackgroundPlayer; @@ -536,7 +536,7 @@ public class VideoItemDetailFragment extends Fragment { private void initSimilarVideos(final StreamInfo info) { LinearLayout similarLayout = (LinearLayout) activity.findViewById(R.id.similar_streams_view); - for (final StreamPreviewInfo item : info.related_streams) { + for (final StreamInfoItem item : info.related_streams) { similarLayout.addView(infoItemBuilder.buildView(similarLayout, item)); } infoItemBuilder.setOnItemSelectedListener(new InfoItemBuilder.OnItemSelectedListener() { diff --git a/app/src/main/java/org/schabi/newpipe/extractor/AbstractStreamInfo.java b/app/src/main/java/org/schabi/newpipe/extractor/AbstractStreamInfo.java index 308f5127d..bfa86b3f7 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/AbstractStreamInfo.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/AbstractStreamInfo.java @@ -18,9 +18,9 @@ package org.schabi.newpipe.extractor; * along with NewPipe. If not, see . */ -/**Common properties between StreamInfo and StreamPreviewInfo.*/ +/**Common properties between StreamInfo and StreamInfoItem.*/ public abstract class AbstractStreamInfo { - public static enum StreamType { + public enum StreamType { NONE, // placeholder to check if stream type was checked or not VIDEO_STREAM, AUDIO_STREAM, diff --git a/app/src/main/java/org/schabi/newpipe/extractor/InfoItem.java b/app/src/main/java/org/schabi/newpipe/extractor/InfoItem.java new file mode 100644 index 000000000..1b95a3868 --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/extractor/InfoItem.java @@ -0,0 +1,35 @@ +package org.schabi.newpipe.extractor; + +import android.icu.text.IDNA; + +import static org.schabi.newpipe.extractor.InfoItem.InfoType.STREAM; + +/** + * Created by the-scrabi on 11.02.17. + * + * Copyright (C) Christian Schabesberger 2017 + * InfoItem.java is part of NewPipe. + * + * NewPipe is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * NewPipe is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with NewPipe. If not, see . + */ + +public interface InfoItem { + public enum InfoType { + STREAM, + PLAYLIST, + CHANNEL + } + void setInfoType(InfoType iT); + InfoType getInfoType(); +} diff --git a/app/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java b/app/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java index 35d3604d9..18bf67550 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java @@ -3,7 +3,7 @@ package org.schabi.newpipe.extractor.channel; import org.schabi.newpipe.extractor.UrlIdHandler; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ParsingException; -import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfoCollector; +import org.schabi.newpipe.extractor.stream_info.StreamInfoItemCollector; import java.io.IOException; @@ -31,7 +31,7 @@ public abstract class ChannelExtractor { private int serviceId; private String url; private UrlIdHandler urlIdHandler; - private StreamPreviewInfoCollector previewInfoCollector; + private StreamInfoItemCollector previewInfoCollector; private int page = -1; public ChannelExtractor(UrlIdHandler urlIdHandler, String url, int page, int serviceId) @@ -40,12 +40,12 @@ public abstract class ChannelExtractor { this.page = page; this.serviceId = serviceId; this.urlIdHandler = urlIdHandler; - previewInfoCollector = new StreamPreviewInfoCollector(urlIdHandler, serviceId); + previewInfoCollector = new StreamInfoItemCollector(urlIdHandler, serviceId); } public String getUrl() { return url; } public UrlIdHandler getUrlIdHandler() { return urlIdHandler; } - public StreamPreviewInfoCollector getStreamPreviewInfoCollector() { + public StreamInfoItemCollector getStreamPreviewInfoCollector() { return previewInfoCollector; } @@ -53,7 +53,7 @@ public abstract class ChannelExtractor { public abstract String getAvatarUrl() throws ParsingException; public abstract String getBannerUrl() throws ParsingException; public abstract String getFeedUrl() throws ParsingException; - public abstract StreamPreviewInfoCollector getStreams() throws ParsingException; + public abstract StreamInfoItemCollector getStreams() throws ParsingException; public abstract boolean hasNextPage() throws ParsingException; public int getServiceId() { return serviceId; diff --git a/app/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java b/app/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java index 7dc4b00e0..2cf0733d9 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java @@ -1,8 +1,9 @@ package org.schabi.newpipe.extractor.channel; +import org.schabi.newpipe.extractor.InfoItem; import org.schabi.newpipe.extractor.exceptions.ParsingException; -import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfo; -import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfoCollector; +import org.schabi.newpipe.extractor.stream_info.StreamInfoItem; +import org.schabi.newpipe.extractor.stream_info.StreamInfoItemCollector; import java.util.List; import java.util.Vector; @@ -59,7 +60,7 @@ public class ChannelInfo { info.errors.add(e); } try { - StreamPreviewInfoCollector c = extractor.getStreams(); + StreamInfoItemCollector c = extractor.getStreams(); info.related_streams = c.getItemList(); info.errors.addAll(c.getErrors()); } catch(Exception e) { @@ -74,7 +75,7 @@ public class ChannelInfo { public String avatar_url = ""; public String banner_url = ""; public String feed_url = ""; - public List related_streams = null; + public List related_streams = null; public boolean hasNextPage = false; public List errors = new Vector<>(); diff --git a/app/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItem.java b/app/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItem.java new file mode 100644 index 000000000..21f4b5eaa --- /dev/null +++ b/app/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItem.java @@ -0,0 +1,8 @@ +package org.schabi.newpipe.extractor.channel; + +/** + * Created by the-scrabi on 11.02.17. + */ + +public class ChannelInfoItem { +} diff --git a/app/src/main/java/org/schabi/newpipe/extractor/search/SearchEngine.java b/app/src/main/java/org/schabi/newpipe/extractor/search/SearchEngine.java index b0dfbfc8a..669ad266b 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/search/SearchEngine.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/search/SearchEngine.java @@ -32,18 +32,18 @@ public abstract class SearchEngine { } } - private StreamPreviewInfoSearchCollector collector; + private StreamInfoSearchItemCollector collector; public SearchEngine(UrlIdHandler urlIdHandler, int serviceId) { - collector = new StreamPreviewInfoSearchCollector(urlIdHandler, serviceId); + collector = new StreamInfoSearchItemCollector(urlIdHandler, serviceId); } - protected StreamPreviewInfoSearchCollector getStreamPreviewInfoSearchCollector() { + protected StreamInfoSearchItemCollector getStreamPreviewInfoSearchCollector() { return collector; } //Result search(String query, int page); - public abstract StreamPreviewInfoSearchCollector search( + public abstract StreamInfoSearchItemCollector search( String query, int page, String contentCountry) throws ExtractionException, IOException; } diff --git a/app/src/main/java/org/schabi/newpipe/extractor/search/SearchResult.java b/app/src/main/java/org/schabi/newpipe/extractor/search/SearchResult.java index 97ceb46fb..7fa56a3e9 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/search/SearchResult.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/search/SearchResult.java @@ -1,7 +1,7 @@ package org.schabi.newpipe.extractor.search; import org.schabi.newpipe.extractor.exceptions.ExtractionException; -import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfo; +import org.schabi.newpipe.extractor.stream_info.StreamInfoItem; import java.io.IOException; import java.util.List; @@ -45,6 +45,6 @@ public class SearchResult { } public String suggestion = ""; - public List resultList = new Vector<>(); + public List resultList = new Vector<>(); public List errors = new Vector<>(); } diff --git a/app/src/main/java/org/schabi/newpipe/extractor/search/StreamPreviewInfoSearchCollector.java b/app/src/main/java/org/schabi/newpipe/extractor/search/StreamInfoSearchItemCollector.java similarity index 81% rename from app/src/main/java/org/schabi/newpipe/extractor/search/StreamPreviewInfoSearchCollector.java rename to app/src/main/java/org/schabi/newpipe/extractor/search/StreamInfoSearchItemCollector.java index 40874f717..17be8e17e 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/search/StreamPreviewInfoSearchCollector.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/search/StreamInfoSearchItemCollector.java @@ -1,13 +1,13 @@ package org.schabi.newpipe.extractor.search; import org.schabi.newpipe.extractor.UrlIdHandler; -import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfoCollector; +import org.schabi.newpipe.extractor.stream_info.StreamInfoItemCollector; /** * Created by Christian Schabesberger on 11.05.16. * * Copyright (C) Christian Schabesberger 2016 - * StreamPreviewInfoSearchCollector.java is part of NewPipe. + * StreamInfoSearchItemCollector.java is part of NewPipe. * * NewPipe is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,11 +23,11 @@ import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfoCollector; * along with NewPipe. If not, see . */ -public class StreamPreviewInfoSearchCollector extends StreamPreviewInfoCollector { +public class StreamInfoSearchItemCollector extends StreamInfoItemCollector { private String suggestion = ""; - public StreamPreviewInfoSearchCollector(UrlIdHandler handler, int serviceId) { + public StreamInfoSearchItemCollector(UrlIdHandler handler, int serviceId) { super(handler, serviceId); } diff --git a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractor.java b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractor.java index 62e63ab1b..65803a6f7 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractor.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeChannelExtractor.java @@ -15,8 +15,8 @@ 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.ParsingException; -import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfoCollector; -import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfoExtractor; +import org.schabi.newpipe.extractor.stream_info.StreamInfoItemCollector; +import org.schabi.newpipe.extractor.stream_info.StreamInfoItemExtractor; import java.io.IOException; @@ -150,8 +150,8 @@ public class YoutubeChannelExtractor extends ChannelExtractor { } @Override - public StreamPreviewInfoCollector getStreams() throws ParsingException { - StreamPreviewInfoCollector collector = getStreamPreviewInfoCollector(); + public StreamInfoItemCollector getStreams() throws ParsingException { + StreamInfoItemCollector collector = getStreamPreviewInfoCollector(); Element ul = null; if(isAjaxPage) { ul = doc.select("body").first(); @@ -161,7 +161,7 @@ public class YoutubeChannelExtractor extends ChannelExtractor { for(final Element li : ul.children()) { if (li.select("div[class=\"feed-item-dismissable\"]").first() != null) { - collector.commit(new StreamPreviewInfoExtractor() { + collector.commit(new StreamInfoItemExtractor() { @Override public AbstractStreamInfo.StreamType getStreamType() throws ParsingException { return AbstractStreamInfo.StreamType.VIDEO_STREAM; diff --git a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngine.java b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngine.java index 55e05bb76..e4314f716 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngine.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeSearchEngine.java @@ -8,8 +8,8 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.UrlIdHandler; import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.search.SearchEngine; -import org.schabi.newpipe.extractor.search.StreamPreviewInfoSearchCollector; -import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfoExtractor; +import org.schabi.newpipe.extractor.search.StreamInfoSearchItemCollector; +import org.schabi.newpipe.extractor.stream_info.StreamInfoItemExtractor; import java.net.URLEncoder; import java.io.IOException; @@ -45,9 +45,9 @@ public class YoutubeSearchEngine extends SearchEngine { } @Override - public StreamPreviewInfoSearchCollector search(String query, int page, String languageCode) + public StreamInfoSearchItemCollector search(String query, int page, String languageCode) throws IOException, ExtractionException { - StreamPreviewInfoSearchCollector collector = getStreamPreviewInfoSearchCollector(); + StreamInfoSearchItemCollector collector = getStreamPreviewInfoSearchCollector(); Downloader downloader = NewPipe.getDownloader(); @@ -107,7 +107,7 @@ public class YoutubeSearchEngine extends SearchEngine { return collector; } - private StreamPreviewInfoExtractor extractPreviewInfo(final Element item) { - return new YoutubeStreamPreviewInfoExtractor(item); + private StreamInfoItemExtractor extractPreviewInfo(final Element item) { + return new YoutubeStreamInfoItemExtractor(item); } } diff --git a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java index 6dd0daa7c..30846fedc 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamExtractor.java @@ -20,8 +20,8 @@ import org.schabi.newpipe.extractor.UrlIdHandler; import org.schabi.newpipe.extractor.MediaFormat; import org.schabi.newpipe.extractor.stream_info.StreamExtractor; import org.schabi.newpipe.extractor.stream_info.StreamInfo; -import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfoCollector; -import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfoExtractor; +import org.schabi.newpipe.extractor.stream_info.StreamInfoItemCollector; +import org.schabi.newpipe.extractor.stream_info.StreamInfoItemExtractor; import org.schabi.newpipe.extractor.stream_info.VideoStream; import java.io.IOException; @@ -657,7 +657,7 @@ public class YoutubeStreamExtractor extends StreamExtractor { } @Override - public StreamPreviewInfoExtractor getNextVideo() throws ParsingException { + public StreamInfoItemExtractor getNextVideo() throws ParsingException { try { return extractVideoPreviewInfo(doc.select("div[class=\"watch-sidebar-section\"]").first() .select("li").first()); @@ -667,9 +667,9 @@ public class YoutubeStreamExtractor extends StreamExtractor { } @Override - public StreamPreviewInfoCollector getRelatedVideos() throws ParsingException { + public StreamInfoItemCollector getRelatedVideos() throws ParsingException { try { - StreamPreviewInfoCollector collector = getStreamPreviewInfoCollector(); + StreamInfoItemCollector collector = getStreamPreviewInfoCollector(); Element ul = doc.select("ul[id=\"watch-related\"]").first(); if(ul != null) { for (Element li : ul.children()) { @@ -707,10 +707,10 @@ public class YoutubeStreamExtractor extends StreamExtractor { } /**Provides information about links to other videos on the video page, such as related videos. - * This is encapsulated in a StreamPreviewInfo object, + * This is encapsulated in a StreamInfoItem object, * which is a subset of the fields in a full StreamInfo.*/ - private StreamPreviewInfoExtractor extractVideoPreviewInfo(final Element li) { - return new StreamPreviewInfoExtractor() { + private StreamInfoItemExtractor extractVideoPreviewInfo(final Element li) { + return new StreamInfoItemExtractor() { @Override public AbstractStreamInfo.StreamType getStreamType() throws ParsingException { return null; diff --git a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamPreviewInfoExtractor.java b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamInfoItemExtractor.java similarity index 95% rename from app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamPreviewInfoExtractor.java rename to app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamInfoItemExtractor.java index e7420deda..fbac1a6a0 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamPreviewInfoExtractor.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamInfoItemExtractor.java @@ -4,11 +4,11 @@ import org.jsoup.nodes.Element; import org.schabi.newpipe.extractor.AbstractStreamInfo; import org.schabi.newpipe.extractor.Parser; import org.schabi.newpipe.extractor.exceptions.ParsingException; -import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfoExtractor; +import org.schabi.newpipe.extractor.stream_info.StreamInfoItemExtractor; /** * Copyright (C) Christian Schabesberger 2016 - * YoutubeStreamPreviewInfoExtractor.java is part of NewPipe. + * YoutubeStreamInfoItemExtractor.java is part of NewPipe. * * NewPipe is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,11 +24,11 @@ import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfoExtractor; * along with NewPipe. If not, see . */ -public class YoutubeStreamPreviewInfoExtractor implements StreamPreviewInfoExtractor { +public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor { private final Element item; - public YoutubeStreamPreviewInfoExtractor(Element item) { + public YoutubeStreamInfoItemExtractor(Element item) { this.item = item; } diff --git a/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamExtractor.java b/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamExtractor.java index 0f4eb7502..1b7c1b5ab 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamExtractor.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamExtractor.java @@ -35,7 +35,7 @@ public abstract class StreamExtractor { private int serviceId; private String url; private UrlIdHandler urlIdHandler; - private StreamPreviewInfoCollector previewInfoCollector; + private StreamInfoItemCollector previewInfoCollector; public class ExtractorInitException extends ExtractionException { public ExtractorInitException(String message) { @@ -61,10 +61,10 @@ public abstract class StreamExtractor { public StreamExtractor(UrlIdHandler urlIdHandler, String url, int serviceId) { this.serviceId = serviceId; this.urlIdHandler = urlIdHandler; - previewInfoCollector = new StreamPreviewInfoCollector(urlIdHandler, serviceId); + previewInfoCollector = new StreamInfoItemCollector(urlIdHandler, serviceId); } - protected StreamPreviewInfoCollector getStreamPreviewInfoCollector() { + protected StreamInfoItemCollector getStreamPreviewInfoCollector() { return previewInfoCollector; } @@ -94,8 +94,8 @@ public abstract class StreamExtractor { public abstract String getAverageRating() throws ParsingException; public abstract int getLikeCount() throws ParsingException; public abstract int getDislikeCount() throws ParsingException; - public abstract StreamPreviewInfoExtractor getNextVideo() throws ParsingException; - public abstract StreamPreviewInfoCollector getRelatedVideos() throws ParsingException; + public abstract StreamInfoItemExtractor getNextVideo() throws ParsingException; + public abstract StreamInfoItemCollector getRelatedVideos() throws ParsingException; public abstract String getPageUrl(); public abstract StreamInfo.StreamType getStreamType() throws ParsingException; public int getServiceId() { diff --git a/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamInfo.java b/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamInfo.java index 5a1c0b740..2d1abc522 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamInfo.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamInfo.java @@ -55,14 +55,14 @@ public class StreamInfo extends AbstractStreamInfo { this.view_count = avi.view_count; //todo: better than this - if(avi instanceof StreamPreviewInfo) { + if(avi instanceof StreamInfoItem) { //shitty String to convert code /* - String dur = ((StreamPreviewInfo)avi).duration; + String dur = ((StreamInfoItem)avi).duration; int minutes = Integer.parseInt(dur.substring(0, dur.indexOf(":"))); int seconds = Integer.parseInt(dur.substring(dur.indexOf(":")+1, dur.length())); */ - this.duration = ((StreamPreviewInfo)avi).duration; + this.duration = ((StreamInfoItem)avi).duration; } } @@ -241,9 +241,9 @@ public class StreamInfo extends AbstractStreamInfo { // get next video if(streamInfo.next_video != null) { - StreamPreviewInfoCollector c = new StreamPreviewInfoCollector( + StreamInfoItemCollector c = new StreamInfoItemCollector( extractor.getUrlIdHandler(), extractor.getServiceId()); - StreamPreviewInfoExtractor nextVideo = extractor.getNextVideo(); + StreamInfoItemExtractor nextVideo = extractor.getNextVideo(); c.commit(nextVideo); if(c.getItemList().size() != 0) { streamInfo.next_video = c.getItemList().get(0); @@ -256,7 +256,7 @@ public class StreamInfo extends AbstractStreamInfo { } try { // get related videos - StreamPreviewInfoCollector c = extractor.getRelatedVideos(); + StreamInfoItemCollector c = extractor.getRelatedVideos(); streamInfo.related_streams = c.getItemList(); streamInfo.errors.addAll(c.getErrors()); } catch(Exception e) { @@ -284,8 +284,8 @@ public class StreamInfo extends AbstractStreamInfo { public int like_count = -1; public int dislike_count = -1; public String average_rating = ""; - public StreamPreviewInfo next_video = null; - public List related_streams = null; + public StreamInfoItem next_video = null; + public List related_streams = null; //in seconds. some metadata is not passed using a StreamInfo object! public int start_position = 0; diff --git a/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamPreviewInfo.java b/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamInfoItem.java similarity index 90% rename from app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamPreviewInfo.java rename to app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamInfoItem.java index 77de2db95..f9c4e2860 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamPreviewInfo.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamInfoItem.java @@ -4,7 +4,7 @@ package org.schabi.newpipe.extractor.stream_info; * Created by Christian Schabesberger on 26.08.15. * * Copyright (C) Christian Schabesberger 2016 - * StreamPreviewInfo.java is part of NewPipe. + * StreamInfoItem.java is part of NewPipe. * * NewPipe is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,6 +23,6 @@ package org.schabi.newpipe.extractor.stream_info; import org.schabi.newpipe.extractor.AbstractStreamInfo; /**Info object for previews of unopened videos, eg search results, related videos*/ -public class StreamPreviewInfo extends AbstractStreamInfo { +public class StreamInfoItem extends AbstractStreamInfo { public int duration; } \ No newline at end of file diff --git a/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamPreviewInfoCollector.java b/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamInfoItemCollector.java similarity index 85% rename from app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamPreviewInfoCollector.java rename to app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamInfoItemCollector.java index 20120fa2d..cefef9fa7 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamPreviewInfoCollector.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamInfoItemCollector.java @@ -4,7 +4,6 @@ import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.UrlIdHandler; import org.schabi.newpipe.extractor.exceptions.FoundAdException; import org.schabi.newpipe.extractor.exceptions.ParsingException; -import org.schabi.newpipe.extractor.services.youtube.YoutubeStreamUrlIdHandler; import java.util.List; import java.util.Vector; @@ -13,7 +12,7 @@ import java.util.Vector; * Created by Christian Schabesberger on 28.02.16. * * Copyright (C) Christian Schabesberger 2016 - * StreamPreviewInfoCollector.java is part of NewPipe. + * StreamInfoItemCollector.java is part of NewPipe. * * NewPipe is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -29,18 +28,18 @@ import java.util.Vector; * along with NewPipe. If not, see . */ -public class StreamPreviewInfoCollector { - private List itemList = new Vector<>(); +public class StreamInfoItemCollector { + private List itemList = new Vector<>(); private List errors = new Vector<>(); private UrlIdHandler urlIdHandler; private int serviceId = -1; - public StreamPreviewInfoCollector(UrlIdHandler handler, int serviceId) { + public StreamInfoItemCollector(UrlIdHandler handler, int serviceId) { urlIdHandler = handler; this.serviceId = serviceId; } - public List getItemList() { + public List getItemList() { return itemList; } @@ -52,9 +51,9 @@ public class StreamPreviewInfoCollector { errors.add(e); } - public void commit(StreamPreviewInfoExtractor extractor) throws ParsingException { + public void commit(StreamInfoItemExtractor extractor) throws ParsingException { try { - StreamPreviewInfo resultItem = new StreamPreviewInfo(); + StreamInfoItem resultItem = new StreamInfoItem(); // importand information resultItem.service_id = serviceId; resultItem.webpage_url = extractor.getWebPageUrl(); diff --git a/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamPreviewInfoExtractor.java b/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamInfoItemExtractor.java similarity index 93% rename from app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamPreviewInfoExtractor.java rename to app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamInfoItemExtractor.java index 3e35fc8da..4a4080a88 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamPreviewInfoExtractor.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/stream_info/StreamInfoItemExtractor.java @@ -7,7 +7,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; * Created by Christian Schabesberger on 28.02.16. * * Copyright (C) Christian Schabesberger 2016 - * StreamPreviewInfoExtractor.java is part of NewPipe. + * StreamInfoItemExtractor.java is part of NewPipe. * * NewPipe is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,7 +23,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException; * along with NewPipe. If not, see . */ -public interface StreamPreviewInfoExtractor { +public interface StreamInfoItemExtractor { AbstractStreamInfo.StreamType getStreamType() throws ParsingException; String getWebPageUrl() throws ParsingException; String getTitle() throws ParsingException; diff --git a/app/src/main/java/org/schabi/newpipe/info_list/InfoItemBuilder.java b/app/src/main/java/org/schabi/newpipe/info_list/InfoItemBuilder.java index 30836053e..a0a7e2c87 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/InfoItemBuilder.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/InfoItemBuilder.java @@ -11,7 +11,7 @@ import com.nostra13.universalimageloader.core.ImageLoader; import org.schabi.newpipe.ImageErrorLoadingListener; import org.schabi.newpipe.R; import org.schabi.newpipe.extractor.AbstractStreamInfo; -import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfo; +import org.schabi.newpipe.extractor.stream_info.StreamInfoItem; /** * Created by Christian Schabesberger on 26.09.16. @@ -55,7 +55,7 @@ public class InfoItemBuilder { this.onItemSelectedListener = onItemSelectedListener; } - public void buildByHolder(InfoItemHolder holder, final StreamPreviewInfo info) { + public void buildByHolder(InfoItemHolder holder, final StreamInfoItem info) { // fill holder with information holder.itemVideoTitleView.setText(info.title); if(info.uploader != null && !info.uploader.isEmpty()) { @@ -97,7 +97,7 @@ public class InfoItemBuilder { }); } - public View buildView(ViewGroup parent, final StreamPreviewInfo info) { + public View buildView(ViewGroup parent, final StreamInfoItem info) { View streamPreviewView = LayoutInflater.from(parent.getContext()) .inflate(R.layout.video_item, parent, false); InfoItemHolder holder = new InfoItemHolder(streamPreviewView); diff --git a/app/src/main/java/org/schabi/newpipe/info_list/InfoListAdapter.java b/app/src/main/java/org/schabi/newpipe/info_list/InfoListAdapter.java index cc5a0f4bb..843010865 100644 --- a/app/src/main/java/org/schabi/newpipe/info_list/InfoListAdapter.java +++ b/app/src/main/java/org/schabi/newpipe/info_list/InfoListAdapter.java @@ -7,7 +7,7 @@ import android.view.View; import android.view.ViewGroup; import org.schabi.newpipe.R; -import org.schabi.newpipe.extractor.stream_info.StreamPreviewInfo; +import org.schabi.newpipe.extractor.stream_info.StreamInfoItem; import java.util.List; import java.util.Vector; @@ -35,7 +35,7 @@ import java.util.Vector; public class InfoListAdapter extends RecyclerView.Adapter { private final InfoItemBuilder infoItemBuilder; - private final List streamList; + private final List streamList; public InfoListAdapter(Activity a, View rootView) { infoItemBuilder = new InfoItemBuilder(a, rootView); @@ -47,7 +47,7 @@ public class InfoListAdapter extends RecyclerView.Adapter { infoItemBuilder.setOnItemSelectedListener(onItemSelectedListener); } - public void addStreamItemList(List videos) { + public void addStreamItemList(List videos) { if(videos!= null) { streamList.addAll(videos); notifyDataSetChanged();