From 045ca40a7790f45d8edc908d8e95a083fe7b10aa Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Sat, 27 Feb 2016 16:37:15 +0100 Subject: [PATCH] renamed video classes to stream classes --- .../youtube/YoutubeSearchEngineTest.java | 16 +- .../YoutubeStreamExtractorDefaultTest.java | 4 +- .../YoutubeStreamExtractorRestrictedTest.java | 4 +- .../org/schabi/newpipe/ActionBarHandler.java | 10 +- .../newpipe/VideoInfoItemViewCreator.java | 5 +- .../newpipe/VideoItemDetailFragment.java | 66 ++++---- .../schabi/newpipe/VideoItemListFragment.java | 6 +- .../org/schabi/newpipe/VideoListAdapter.java | 8 +- .../newpipe/extractor/AbstractVideoInfo.java | 2 +- .../newpipe/extractor/DashMpdParser.java | 6 +- .../newpipe/extractor/SearchEngine.java | 2 +- .../newpipe/extractor/StreamExtractor.java | 14 +- .../{VideoInfo.java => StreamInfo.java} | 160 +++++++++--------- ...reviewInfo.java => StreamPreviewInfo.java} | 6 +- ...IdHandler.java => StreamUrlIdHandler.java} | 4 +- .../newpipe/extractor/StreamingService.java | 4 +- .../services/youtube/YoutubeSearchEngine.java | 8 +- .../services/youtube/YoutubeService.java | 8 +- .../youtube/YoutubeStreamExtractor.java | 40 ++--- ...er.java => YoutubeStreamUrlIdHandler.java} | 6 +- 20 files changed, 190 insertions(+), 189 deletions(-) rename app/src/main/java/org/schabi/newpipe/extractor/{VideoInfo.java => StreamInfo.java} (61%) rename app/src/main/java/org/schabi/newpipe/extractor/{VideoPreviewInfo.java => StreamPreviewInfo.java} (85%) rename app/src/main/java/org/schabi/newpipe/extractor/{VideoUrlIdHandler.java => StreamUrlIdHandler.java} (93%) rename app/src/main/java/org/schabi/newpipe/extractor/services/youtube/{YoutubeVideoUrlIdHandler.java => YoutubeStreamUrlIdHandler.java} (93%) diff --git a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchEngineTest.java b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchEngineTest.java index ed6d17aae..6c3540754 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchEngineTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeSearchEngineTest.java @@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.youtube; import android.test.AndroidTestCase; -import org.schabi.newpipe.extractor.VideoPreviewInfo; +import org.schabi.newpipe.extractor.StreamPreviewInfo; import org.schabi.newpipe.extractor.SearchEngine; import org.schabi.newpipe.extractor.services.youtube.YoutubeSearchEngine; import org.schabi.newpipe.Downloader; @@ -52,44 +52,44 @@ public class YoutubeSearchEngineTest extends AndroidTestCase { } public void testItemsHaveTitle() { - for(VideoPreviewInfo i : result.resultList) { + for(StreamPreviewInfo i : result.resultList) { assertEquals(i.title.isEmpty(), false); } } public void testItemsHaveUploader() { - for(VideoPreviewInfo i : result.resultList) { + for(StreamPreviewInfo i : result.resultList) { assertEquals(i.uploader.isEmpty(), false); } } public void testItemsHaveRightDuration() { - for(VideoPreviewInfo i : result.resultList) { + for(StreamPreviewInfo i : result.resultList) { assertTrue(i.duration, i.duration.contains(":")); } } public void testItemsHaveRightThumbnail() { - for (VideoPreviewInfo i : result.resultList) { + for (StreamPreviewInfo i : result.resultList) { assertTrue(i.thumbnail_url, i.thumbnail_url.contains("https://")); } } public void testItemsHaveRightVideoUrl() { - for (VideoPreviewInfo i : result.resultList) { + for (StreamPreviewInfo i : result.resultList) { assertTrue(i.webpage_url, i.webpage_url.contains("https://")); } } public void testViewCount() { /* - for(VideoPreviewInfo i : result.resultList) { + for(StreamPreviewInfo i : result.resultList) { assertTrue(Long.toString(i.view_count), i.view_count != -1); } */ // that specific link used for this test, there are no videos with less // than 10.000 views, so we can test against that. - for(VideoPreviewInfo i : result.resultList) { + for(StreamPreviewInfo i : result.resultList) { assertTrue(Long.toString(i.view_count), i.view_count >= 10000); } } diff --git a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorDefaultTest.java b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorDefaultTest.java index 4f4c529e5..e35fd86d8 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorDefaultTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorDefaultTest.java @@ -6,7 +6,7 @@ import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.ExtractionException; import org.schabi.newpipe.extractor.ParsingException; import org.schabi.newpipe.extractor.services.youtube.YoutubeStreamExtractor; -import org.schabi.newpipe.extractor.VideoInfo; +import org.schabi.newpipe.extractor.StreamInfo; import java.io.IOException; @@ -94,7 +94,7 @@ public class YoutubeStreamExtractorDefaultTest extends AndroidTestCase { } public void testGetVideoStreams() throws ParsingException { - for(VideoInfo.VideoStream s : extractor.getVideoStreams()) { + for(StreamInfo.VideoStream s : extractor.getVideoStreams()) { assertTrue(s.url, s.url.contains("https://")); assertTrue(s.resolution.length() > 0); diff --git a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorRestrictedTest.java b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorRestrictedTest.java index c00a91ac8..12d8a65c7 100644 --- a/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorRestrictedTest.java +++ b/app/src/androidTest/java/org/schabi/newpipe/extractor/youtube/YoutubeStreamExtractorRestrictedTest.java @@ -5,7 +5,7 @@ import android.test.AndroidTestCase; import org.schabi.newpipe.Downloader; import org.schabi.newpipe.extractor.ExtractionException; import org.schabi.newpipe.extractor.ParsingException; -import org.schabi.newpipe.extractor.VideoInfo; +import org.schabi.newpipe.extractor.StreamInfo; import org.schabi.newpipe.extractor.services.youtube.YoutubeStreamExtractor; import java.io.IOException; @@ -73,7 +73,7 @@ public class YoutubeStreamExtractorRestrictedTest extends AndroidTestCase { } public void testGetVideoStreams() throws ParsingException { - for(VideoInfo.VideoStream s : extractor.getVideoStreams()) { + for(StreamInfo.VideoStream s : extractor.getVideoStreams()) { assertTrue(s.url, s.url.contains("https://")); assertTrue(s.resolution.length() > 0); diff --git a/app/src/main/java/org/schabi/newpipe/ActionBarHandler.java b/app/src/main/java/org/schabi/newpipe/ActionBarHandler.java index 5123f494b..6836f223e 100644 --- a/app/src/main/java/org/schabi/newpipe/ActionBarHandler.java +++ b/app/src/main/java/org/schabi/newpipe/ActionBarHandler.java @@ -12,7 +12,7 @@ import android.view.MenuItem; import android.widget.ArrayAdapter; import org.schabi.newpipe.extractor.MediaFormat; -import org.schabi.newpipe.extractor.VideoInfo; +import org.schabi.newpipe.extractor.StreamInfo; import java.util.List; @@ -75,7 +75,7 @@ class ActionBarHandler { } } - public void setupStreamList(final List videoStreams) { + public void setupStreamList(final List videoStreams) { if (activity != null) { selectedVideoStream = 0; @@ -83,7 +83,7 @@ class ActionBarHandler { // this array will be shown in the dropdown menu for selecting the stream/resolution. String[] itemArray = new String[videoStreams.size()]; for (int i = 0; i < videoStreams.size(); i++) { - VideoInfo.VideoStream item = videoStreams.get(i); + StreamInfo.VideoStream item = videoStreams.get(i); itemArray[i] = MediaFormat.getNameById(item.format) + " " + item.resolution; } int defaultResolution = getDefaultResolution(videoStreams); @@ -108,13 +108,13 @@ class ActionBarHandler { } - private int getDefaultResolution(final List videoStreams) { + private int getDefaultResolution(final List videoStreams) { String defaultResolution = defaultPreferences .getString(activity.getString(R.string.default_resolution_key), activity.getString(R.string.default_resolution_value)); for (int i = 0; i < videoStreams.size(); i++) { - VideoInfo.VideoStream item = videoStreams.get(i); + StreamInfo.VideoStream item = videoStreams.get(i); if (defaultResolution.equals(item.resolution)) { return i; } diff --git a/app/src/main/java/org/schabi/newpipe/VideoInfoItemViewCreator.java b/app/src/main/java/org/schabi/newpipe/VideoInfoItemViewCreator.java index 0cf8645d0..0c909e325 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoInfoItemViewCreator.java +++ b/app/src/main/java/org/schabi/newpipe/VideoInfoItemViewCreator.java @@ -7,7 +7,8 @@ import android.view.ViewGroup; import android.widget.ImageView; import android.widget.TextView; -import org.schabi.newpipe.extractor.VideoPreviewInfo; +import org.schabi.newpipe.extractor.StreamPreviewInfo; + import com.nostra13.universalimageloader.core.DisplayImageOptions; import com.nostra13.universalimageloader.core.ImageLoader; @@ -40,7 +41,7 @@ class VideoInfoItemViewCreator { this.inflater = inflater; } - public View getViewFromVideoInfoItem(View convertView, ViewGroup parent, VideoPreviewInfo info, Context context) { + public View getViewFromVideoInfoItem(View convertView, ViewGroup parent, StreamPreviewInfo info, Context context) { ViewHolder holder; if(convertView == null) { convertView = inflater.inflate(R.layout.video_item, parent, false); diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java b/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java index a023d36a7..50e0aeaba 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java @@ -50,9 +50,9 @@ import org.schabi.newpipe.extractor.MediaFormat; import org.schabi.newpipe.extractor.ParsingException; import org.schabi.newpipe.extractor.ServiceList; import org.schabi.newpipe.extractor.StreamExtractor; -import org.schabi.newpipe.extractor.VideoPreviewInfo; +import org.schabi.newpipe.extractor.StreamInfo; +import org.schabi.newpipe.extractor.StreamPreviewInfo; import org.schabi.newpipe.extractor.StreamingService; -import org.schabi.newpipe.extractor.VideoInfo; import org.schabi.newpipe.extractor.services.youtube.YoutubeStreamExtractor; @@ -127,12 +127,12 @@ public class VideoItemDetailFragment extends Fragment { @Override public void run() { - VideoInfo videoInfo = null; + StreamInfo streamInfo = null; try { streamExtractor = service.getExtractorInstance(videoUrl, new Downloader()); - videoInfo = VideoInfo.getVideoInfo(streamExtractor, new Downloader()); + streamInfo = StreamInfo.getVideoInfo(streamExtractor, new Downloader()); - h.post(new VideoResultReturnedRunnable(videoInfo)); + h.post(new VideoResultReturnedRunnable(streamInfo)); } catch (IOException e) { postNewErrorToast(h, R.string.network_error); e.printStackTrace(); @@ -165,14 +165,14 @@ public class VideoItemDetailFragment extends Fragment { } }); e.printStackTrace(); - } catch(VideoInfo.StreamExctractException e) { - if(!videoInfo.errors.isEmpty()) { + } catch(StreamInfo.StreamExctractException e) { + if(!streamInfo.errors.isEmpty()) { // !!! if this case ever kicks in someone gets kicked out !!! ErrorActivity.reportError(h, getActivity(), e, VideoItemListActivity.class, null, ErrorActivity.ErrorInfo.make(ErrorActivity.REQUESTED_STREAM, service.getServiceInfo().name, videoUrl, R.string.could_not_get_stream)); } else { - ErrorActivity.reportError(h, getActivity(), videoInfo.errors, VideoItemListActivity.class, null, + ErrorActivity.reportError(h, getActivity(), streamInfo.errors, VideoItemListActivity.class, null, ErrorActivity.ErrorInfo.make(ErrorActivity.REQUESTED_STREAM, service.getServiceInfo().name, videoUrl, R.string.could_not_get_stream)); } @@ -206,17 +206,17 @@ public class VideoItemDetailFragment extends Fragment { }); e.printStackTrace(); } finally { - if(videoInfo != null && - !videoInfo.errors.isEmpty()) { + if(streamInfo != null && + !streamInfo.errors.isEmpty()) { Log.e(TAG, "OCCURRED ERRORS DURING EXTRACTION:"); - for(Exception e : videoInfo.errors) { + for(Exception e : streamInfo.errors) { e.printStackTrace(); } Activity a = getActivity(); View rootView = a != null ? a.findViewById(R.id.videoitem_detail) : null; ErrorActivity.reportError(h, getActivity(), - videoInfo.errors, null, rootView, + streamInfo.errors, null, rootView, ErrorActivity.ErrorInfo.make(ErrorActivity.REQUESTED_STREAM, service.getServiceInfo().name, videoUrl, 0 /* no message for the user */)); } @@ -225,16 +225,16 @@ public class VideoItemDetailFragment extends Fragment { } private class VideoResultReturnedRunnable implements Runnable { - private final VideoInfo videoInfo; - public VideoResultReturnedRunnable(VideoInfo videoInfo) { - this.videoInfo = videoInfo; + private final StreamInfo streamInfo; + public VideoResultReturnedRunnable(StreamInfo streamInfo) { + this.streamInfo = streamInfo; } @Override public void run() { boolean show_age_restricted_content = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getBoolean(activity.getString(R.string.show_age_restricted_content), false); - if(videoInfo.age_limit == 0 || show_age_restricted_content) { - updateInfo(videoInfo); + if(streamInfo.age_limit == 0 || show_age_restricted_content) { + updateInfo(streamInfo); } else { onNotSpecifiedContentErrorWithMessage(R.string.video_is_age_restricted); } @@ -261,7 +261,7 @@ public class VideoItemDetailFragment extends Fragment { public void onLoadingCancelled(String imageUri, View view) {} } - private void updateInfo(final VideoInfo info) { + private void updateInfo(final StreamInfo info) { try { Context c = getContext(); VideoInfoItemViewCreator videoItemViewCreator = @@ -378,8 +378,8 @@ public class VideoItemDetailFragment extends Fragment { descriptionView.setMovementMethod(LinkMovementMethod.getInstance()); // parse streams - Vector streamsToUse = new Vector<>(); - for (VideoInfo.VideoStream i : info.video_streams) { + Vector streamsToUse = new Vector<>(); + for (StreamInfo.VideoStream i : info.video_streams) { if (useStream(i, streamsToUse)) { streamsToUse.add(i); } @@ -435,7 +435,7 @@ public class VideoItemDetailFragment extends Fragment { } } - private void initThumbnailViews(VideoInfo info, View nextVideoFrame) { + private void initThumbnailViews(StreamInfo info, View nextVideoFrame) { ImageView videoThumbnailView = (ImageView) activity.findViewById(R.id.detailThumbnailView); ImageView uploaderThumb = (ImageView) activity.findViewById(R.id.detailUploaderThumbnailView); @@ -478,7 +478,7 @@ public class VideoItemDetailFragment extends Fragment { } } - private void setupActionBarHandler(final VideoInfo info) { + private void setupActionBarHandler(final StreamInfo info) { actionBarHandler.setupStreamList(info.video_streams); actionBarHandler.setOnShareListener(new ActionBarHandler.OnActionListener() { @@ -545,7 +545,7 @@ public class VideoItemDetailFragment extends Fragment { // website which was crawled. Then the ui has to understand this and act right. if (info.audio_streams != null) { - VideoInfo.AudioStream audioStream = + StreamInfo.AudioStream audioStream = info.audio_streams.get(getPreferredAudioStreamId(info)); String audioSuffix = "." + MediaFormat.getSuffixById(audioStream.format); @@ -554,7 +554,7 @@ public class VideoItemDetailFragment extends Fragment { } if (info.video_streams != null) { - VideoInfo.VideoStream selectedStreamItem = info.video_streams.get(selectedStreamId); + StreamInfo.VideoStream selectedStreamItem = info.video_streams.get(selectedStreamId); String videoSuffix = "." + MediaFormat.getSuffixById(selectedStreamItem.format); args.putString(DownloadDialog.FILE_SUFFIX_VIDEO, videoSuffix); args.putString(DownloadDialog.VIDEO_URL, selectedStreamItem.url); @@ -581,7 +581,7 @@ public class VideoItemDetailFragment extends Fragment { boolean useExternalAudioPlayer = PreferenceManager.getDefaultSharedPreferences(activity) .getBoolean(activity.getString(R.string.use_external_audio_player_key), false); Intent intent; - VideoInfo.AudioStream audioStream = + StreamInfo.AudioStream audioStream = info.audio_streams.get(getPreferredAudioStreamId(info)); if (!useExternalAudioPlayer && android.os.Build.VERSION.SDK_INT >= 18) { //internal music player: explicit intent @@ -640,7 +640,7 @@ public class VideoItemDetailFragment extends Fragment { } } - private int getPreferredAudioStreamId(final VideoInfo info) { + private int getPreferredAudioStreamId(final StreamInfo info) { String preferredFormatString = PreferenceManager.getDefaultSharedPreferences(getActivity()) .getString(activity.getString(R.string.default_audio_format_key), "webm"); @@ -667,10 +667,10 @@ public class VideoItemDetailFragment extends Fragment { return 0; } - private void initSimilarVideos(final VideoInfo info, VideoInfoItemViewCreator videoItemViewCreator) { + private void initSimilarVideos(final StreamInfo info, VideoInfoItemViewCreator videoItemViewCreator) { LinearLayout similarLayout = (LinearLayout) activity.findViewById(R.id.similarVideosView); - ArrayList similar = new ArrayList<>(info.related_videos); - for (final VideoPreviewInfo item : similar) { + ArrayList similar = new ArrayList<>(info.related_videos); + for (final StreamPreviewInfo item : similar) { View similarView = videoItemViewCreator .getViewFromVideoInfoItem(null, similarLayout, item, getContext()); @@ -744,8 +744,8 @@ public class VideoItemDetailFragment extends Fragment { .show(); } - private boolean useStream(VideoInfo.VideoStream stream, Vector streams) { - for(VideoInfo.VideoStream i : streams) { + private boolean useStream(StreamInfo.VideoStream stream, Vector streams) { + for(StreamInfo.VideoStream i : streams) { if(i.resolution.equals(stream.resolution)) { return false; } @@ -835,9 +835,9 @@ public class VideoItemDetailFragment extends Fragment { } } - public void playVideo(final VideoInfo info) { + public void playVideo(final StreamInfo info) { // ----------- THE MAGIC MOMENT --------------- - VideoInfo.VideoStream selectedVideoStream = + StreamInfo.VideoStream selectedVideoStream = info.video_streams.get(actionBarHandler.getSelectedVideoStream()); if (PreferenceManager.getDefaultSharedPreferences(activity) diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java b/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java index 75f80f7ae..af659bfc4 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemListFragment.java @@ -17,7 +17,7 @@ import java.io.IOException; import java.util.List; import org.schabi.newpipe.extractor.ExtractionException; -import org.schabi.newpipe.extractor.VideoPreviewInfo; +import org.schabi.newpipe.extractor.StreamPreviewInfo; import org.schabi.newpipe.extractor.SearchEngine; import org.schabi.newpipe.extractor.StreamingService; @@ -125,7 +125,7 @@ public class VideoItemListFragment extends ListFragment { } } - public void present(List videoList) { + public void present(List videoList) { mode = PRESENT_VIDEOS_MODE; setListShown(true); getListView().smoothScrollToPosition(0); @@ -180,7 +180,7 @@ public class VideoItemListFragment extends ListFragment { } } - private void updateList(List list) { + private void updateList(List list) { try { videoListAdapter.addVideoList(list); terminateThreads(); diff --git a/app/src/main/java/org/schabi/newpipe/VideoListAdapter.java b/app/src/main/java/org/schabi/newpipe/VideoListAdapter.java index 702e2cfdd..06dab38b4 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoListAdapter.java +++ b/app/src/main/java/org/schabi/newpipe/VideoListAdapter.java @@ -8,7 +8,7 @@ import android.view.ViewGroup; import android.widget.BaseAdapter; import android.widget.ListView; -import org.schabi.newpipe.extractor.VideoPreviewInfo; +import org.schabi.newpipe.extractor.StreamPreviewInfo; import java.util.List; import java.util.Vector; @@ -36,7 +36,7 @@ import java.util.Vector; class VideoListAdapter extends BaseAdapter { private final Context context; private final VideoInfoItemViewCreator viewCreator; - private Vector videoList = new Vector<>(); + private Vector videoList = new Vector<>(); private final ListView listView; public VideoListAdapter(Context context, VideoItemListFragment videoListFragment) { @@ -47,7 +47,7 @@ class VideoListAdapter extends BaseAdapter { this.context = context; } - public void addVideoList(List videos) { + public void addVideoList(List videos) { videoList.addAll(videos); notifyDataSetChanged(); } @@ -57,7 +57,7 @@ class VideoListAdapter extends BaseAdapter { notifyDataSetChanged(); } - public Vector getVideoList() { + public Vector getVideoList() { return videoList; } diff --git a/app/src/main/java/org/schabi/newpipe/extractor/AbstractVideoInfo.java b/app/src/main/java/org/schabi/newpipe/extractor/AbstractVideoInfo.java index 1fe776e5e..79d43770b 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/AbstractVideoInfo.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/AbstractVideoInfo.java @@ -20,7 +20,7 @@ import android.graphics.Bitmap; * along with NewPipe. If not, see . */ -/**Common properties between VideoInfo and VideoPreviewInfo.*/ +/**Common properties between StreamInfo and StreamPreviewInfo.*/ public abstract class AbstractVideoInfo { public String id = ""; public String title = ""; diff --git a/app/src/main/java/org/schabi/newpipe/extractor/DashMpdParser.java b/app/src/main/java/org/schabi/newpipe/extractor/DashMpdParser.java index 9dfbe8d14..55cae46fa 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/DashMpdParser.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/DashMpdParser.java @@ -37,7 +37,7 @@ public class DashMpdParser { } } - public static List getAudioStreams(String dashManifestUrl, + public static List getAudioStreams(String dashManifestUrl, Downloader downloader) throws DashMpdParsingException { String dashDoc; @@ -46,7 +46,7 @@ public class DashMpdParser { } catch(IOException ioe) { throw new DashMpdParsingException("Could not get dash mpd: " + dashManifestUrl, ioe); } - Vector audioStreams = new Vector<>(); + Vector audioStreams = new Vector<>(); try { XmlPullParser parser = Xml.newPullParser(); parser.setInput(new StringReader(dashDoc)); @@ -83,7 +83,7 @@ public class DashMpdParser { } else if(currentMimeType.equals(MediaFormat.M4A.mimeType)) { format = MediaFormat.M4A.id; } - audioStreams.add(new VideoInfo.AudioStream(parser.getText(), + audioStreams.add(new StreamInfo.AudioStream(parser.getText(), format, currentBandwidth, currentSamplingRate)); } break; diff --git a/app/src/main/java/org/schabi/newpipe/extractor/SearchEngine.java b/app/src/main/java/org/schabi/newpipe/extractor/SearchEngine.java index 74f3f0f60..9b084b9d8 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/SearchEngine.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/SearchEngine.java @@ -30,7 +30,7 @@ public interface SearchEngine { class Result { public String errorMessage = ""; public String suggestion = ""; - public final List resultList = new Vector<>(); + public final List resultList = new Vector<>(); } ArrayList suggestionList(String query,String contentCountry, Downloader dl) diff --git a/app/src/main/java/org/schabi/newpipe/extractor/StreamExtractor.java b/app/src/main/java/org/schabi/newpipe/extractor/StreamExtractor.java index 53bbe317e..4fb396e1f 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/StreamExtractor.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/StreamExtractor.java @@ -3,7 +3,7 @@ package org.schabi.newpipe.extractor; /** * Created by Christian Schabesberger on 10.08.15. * - * Copyright (C) Christian Schabesberger 2015 + * Copyright (C) Christian Schabesberger 2016 * StreamExtractor.java is part of NewPipe. * * NewPipe is free software: you can redistribute it and/or modify @@ -61,16 +61,16 @@ public interface StreamExtractor { public abstract String getUploadDate() throws ParsingException; public abstract String getThumbnailUrl() throws ParsingException; public abstract String getUploaderThumbnailUrl() throws ParsingException; - public abstract List getAudioStreams() throws ParsingException; - public abstract List getVideoStreams() throws ParsingException; - public abstract List getVideoOnlyStreams() throws ParsingException; + public abstract List getAudioStreams() throws ParsingException; + public abstract List getVideoStreams() throws ParsingException; + public abstract List getVideoOnlyStreams() throws ParsingException; 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 VideoPreviewInfo getNextVideo() throws ParsingException; - public abstract List getRelatedVideos() throws ParsingException; - public abstract VideoUrlIdHandler getUrlIdConverter(); + public abstract StreamPreviewInfo getNextVideo() throws ParsingException; + public abstract List getRelatedVideos() throws ParsingException; + public abstract StreamUrlIdHandler getUrlIdConverter(); public abstract String getPageUrl(); } diff --git a/app/src/main/java/org/schabi/newpipe/extractor/VideoInfo.java b/app/src/main/java/org/schabi/newpipe/extractor/StreamInfo.java similarity index 61% rename from app/src/main/java/org/schabi/newpipe/extractor/VideoInfo.java rename to app/src/main/java/org/schabi/newpipe/extractor/StreamInfo.java index d023cf360..b6da26404 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/VideoInfo.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/StreamInfo.java @@ -7,8 +7,8 @@ import java.util.Vector; /** * Created by Christian Schabesberger on 26.08.15. * - * Copyright (C) Christian Schabesberger 2015 - * VideoInfo.java is part of NewPipe. + * Copyright (C) Christian Schabesberger 2016 + * StreamInfo.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 @@ -26,7 +26,7 @@ import java.util.Vector; /**Info object for opened videos, ie the video ready to play.*/ @SuppressWarnings("ALL") -public class VideoInfo extends AbstractVideoInfo { +public class StreamInfo extends AbstractVideoInfo { public static class StreamExctractException extends ExtractionException { StreamExctractException(String message) { @@ -36,178 +36,178 @@ public class VideoInfo extends AbstractVideoInfo { /**Fills out the video info fields which are common to all services. * Probably needs to be overridden by subclasses*/ - public static VideoInfo getVideoInfo(StreamExtractor extractor, Downloader downloader) + public static StreamInfo getVideoInfo(StreamExtractor extractor, Downloader downloader) throws ExtractionException, IOException { - VideoInfo videoInfo = new VideoInfo(); + StreamInfo streamInfo = new StreamInfo(); - videoInfo = extractImportantData(videoInfo, extractor, downloader); - videoInfo = extractStreams(videoInfo, extractor, downloader); - videoInfo = extractOptionalData(videoInfo, extractor, downloader); + streamInfo = extractImportantData(streamInfo, extractor, downloader); + streamInfo = extractStreams(streamInfo, extractor, downloader); + streamInfo = extractOptionalData(streamInfo, extractor, downloader); - return videoInfo; + return streamInfo; } - private static VideoInfo extractImportantData( - VideoInfo videoInfo, StreamExtractor extractor, Downloader downloader) + private static StreamInfo extractImportantData( + StreamInfo streamInfo, StreamExtractor extractor, Downloader downloader) throws ExtractionException, IOException { /* ---- importand data, withoug the video can't be displayed goes here: ---- */ // if one of these is not available an exception is ment to be thrown directly into the frontend. - VideoUrlIdHandler uiconv = extractor.getUrlIdConverter(); + StreamUrlIdHandler uiconv = extractor.getUrlIdConverter(); - videoInfo.webpage_url = extractor.getPageUrl(); - videoInfo.id = uiconv.getVideoId(extractor.getPageUrl()); - videoInfo.title = extractor.getTitle(); - videoInfo.age_limit = extractor.getAgeLimit(); + streamInfo.webpage_url = extractor.getPageUrl(); + streamInfo.id = uiconv.getVideoId(extractor.getPageUrl()); + streamInfo.title = extractor.getTitle(); + streamInfo.age_limit = extractor.getAgeLimit(); - if((videoInfo.webpage_url == null || videoInfo.webpage_url.isEmpty()) - || (videoInfo.id == null || videoInfo.id.isEmpty()) - || (videoInfo.title == null /* videoInfo.title can be empty of course */) - || (videoInfo.age_limit == -1)); + if((streamInfo.webpage_url == null || streamInfo.webpage_url.isEmpty()) + || (streamInfo.id == null || streamInfo.id.isEmpty()) + || (streamInfo.title == null /* streamInfo.title can be empty of course */) + || (streamInfo.age_limit == -1)); - return videoInfo; + return streamInfo; } - private static VideoInfo extractStreams( - VideoInfo videoInfo, StreamExtractor extractor, Downloader downloader) + private static StreamInfo extractStreams( + StreamInfo streamInfo, StreamExtractor extractor, Downloader downloader) throws ExtractionException, IOException { /* ---- stream extraction goes here ---- */ // At least one type of stream has to be available, // otherwise an exception will be thrown directly into the frontend. try { - videoInfo.dashMpdUrl = extractor.getDashMpdUrl(); + streamInfo.dashMpdUrl = extractor.getDashMpdUrl(); } catch(Exception e) { - videoInfo.addException(new ExtractionException("Couldn't get Dash manifest", e)); + streamInfo.addException(new ExtractionException("Couldn't get Dash manifest", e)); } /* Load and extract audio */ try { - videoInfo.audio_streams = extractor.getAudioStreams(); + streamInfo.audio_streams = extractor.getAudioStreams(); } catch(Exception e) { - videoInfo.addException(new ExtractionException("Couldn't get audio streams", e)); + streamInfo.addException(new ExtractionException("Couldn't get audio streams", e)); } // also try to get streams from the dashMpd - if(videoInfo.dashMpdUrl != null && !videoInfo.dashMpdUrl.isEmpty()) { - if(videoInfo.audio_streams == null) { - videoInfo.audio_streams = new Vector(); + if(streamInfo.dashMpdUrl != null && !streamInfo.dashMpdUrl.isEmpty()) { + if(streamInfo.audio_streams == null) { + streamInfo.audio_streams = new Vector(); } //todo: make this quick and dirty solution a real fallback // same as the quick and dirty aboth try { - videoInfo.audio_streams.addAll( - DashMpdParser.getAudioStreams(videoInfo.dashMpdUrl, downloader)); + streamInfo.audio_streams.addAll( + DashMpdParser.getAudioStreams(streamInfo.dashMpdUrl, downloader)); } catch(Exception e) { - videoInfo.addException( + streamInfo.addException( new ExtractionException("Couldn't get audio streams from dash mpd", e)); } } /* Extract video stream url*/ try { - videoInfo.video_streams = extractor.getVideoStreams(); + streamInfo.video_streams = extractor.getVideoStreams(); } catch (Exception e) { - videoInfo.addException( + streamInfo.addException( new ExtractionException("Couldn't get video streams", e)); } /* Extract video only stream url*/ try { - videoInfo.video_only_streams = extractor.getVideoOnlyStreams(); + streamInfo.video_only_streams = extractor.getVideoOnlyStreams(); } catch(Exception e) { - videoInfo.addException( + streamInfo.addException( new ExtractionException("Couldn't get video only streams", e)); } // either dash_mpd audio_only or video has to be available, otherwise we didn't get a stream, // and therefore failed. (Since video_only_streams are just optional they don't caunt). - if((videoInfo.video_streams == null || videoInfo.video_streams.isEmpty()) - && (videoInfo.audio_streams == null || videoInfo.audio_streams.isEmpty()) - && (videoInfo.dashMpdUrl == null || videoInfo.dashMpdUrl.isEmpty())) { + if((streamInfo.video_streams == null || streamInfo.video_streams.isEmpty()) + && (streamInfo.audio_streams == null || streamInfo.audio_streams.isEmpty()) + && (streamInfo.dashMpdUrl == null || streamInfo.dashMpdUrl.isEmpty())) { throw new StreamExctractException( "Could not get any stream. See error variable to get further details."); } - return videoInfo; + return streamInfo; } - private static VideoInfo extractOptionalData( - VideoInfo videoInfo, StreamExtractor extractor, Downloader downloader) { + private static StreamInfo extractOptionalData( + StreamInfo streamInfo, StreamExtractor extractor, Downloader downloader) { /* ---- optional data goes here: ---- */ // If one of these failes, the frontend neets to handle that they are not available. // Exceptions are therfore not thrown into the frontend, but stored into the error List, // so the frontend can afterwads check where errors happend. try { - videoInfo.thumbnail_url = extractor.getThumbnailUrl(); + streamInfo.thumbnail_url = extractor.getThumbnailUrl(); } catch(Exception e) { - videoInfo.addException(e); + streamInfo.addException(e); } try { - videoInfo.duration = extractor.getLength(); + streamInfo.duration = extractor.getLength(); } catch(Exception e) { - videoInfo.addException(e); + streamInfo.addException(e); } try { - videoInfo.uploader = extractor.getUploader(); + streamInfo.uploader = extractor.getUploader(); } catch(Exception e) { - videoInfo.addException(e); + streamInfo.addException(e); } try { - videoInfo.description = extractor.getDescription(); + streamInfo.description = extractor.getDescription(); } catch(Exception e) { - videoInfo.addException(e); + streamInfo.addException(e); } try { - videoInfo.view_count = extractor.getViewCount(); + streamInfo.view_count = extractor.getViewCount(); } catch(Exception e) { - videoInfo.addException(e); + streamInfo.addException(e); } try { - videoInfo.upload_date = extractor.getUploadDate(); + streamInfo.upload_date = extractor.getUploadDate(); } catch(Exception e) { - videoInfo.addException(e); + streamInfo.addException(e); } try { - videoInfo.uploader_thumbnail_url = extractor.getUploaderThumbnailUrl(); + streamInfo.uploader_thumbnail_url = extractor.getUploaderThumbnailUrl(); } catch(Exception e) { - videoInfo.addException(e); + streamInfo.addException(e); } try { - videoInfo.start_position = extractor.getTimeStamp(); + streamInfo.start_position = extractor.getTimeStamp(); } catch(Exception e) { - videoInfo.addException(e); + streamInfo.addException(e); } try { - videoInfo.average_rating = extractor.getAverageRating(); + streamInfo.average_rating = extractor.getAverageRating(); } catch(Exception e) { - videoInfo.addException(e); + streamInfo.addException(e); } try { - videoInfo.like_count = extractor.getLikeCount(); + streamInfo.like_count = extractor.getLikeCount(); } catch(Exception e) { - videoInfo.addException(e); + streamInfo.addException(e); } try { - videoInfo.dislike_count = extractor.getDislikeCount(); + streamInfo.dislike_count = extractor.getDislikeCount(); } catch(Exception e) { - videoInfo.addException(e); + streamInfo.addException(e); } try { - videoInfo.next_video = extractor.getNextVideo(); + streamInfo.next_video = extractor.getNextVideo(); } catch(Exception e) { - videoInfo.addException(e); + streamInfo.addException(e); } try { - videoInfo.related_videos = extractor.getRelatedVideos(); + streamInfo.related_videos = extractor.getRelatedVideos(); } catch(Exception e) { - videoInfo.addException(e); + streamInfo.addException(e); } try { } catch (Exception e) { - videoInfo.addException(e); + streamInfo.addException(e); } - return videoInfo; + return streamInfo; } public String uploader_thumbnail_url = ""; @@ -227,20 +227,20 @@ public class VideoInfo extends AbstractVideoInfo { public int like_count = -1; public int dislike_count = -1; public String average_rating = ""; - public VideoPreviewInfo next_video = null; - public List related_videos = null; - //in seconds. some metadata is not passed using a VideoInfo object! + public StreamPreviewInfo next_video = null; + public List related_videos = null; + //in seconds. some metadata is not passed using a StreamInfo object! public int start_position = 0; //todo: public int service_id = -1; public List errors = new Vector<>(); - public VideoInfo() {} + public StreamInfo() {} - /**Creates a new VideoInfo object from an existing AbstractVideoInfo. - * All the shared properties are copied to the new VideoInfo.*/ + /**Creates a new StreamInfo object from an existing AbstractVideoInfo. + * All the shared properties are copied to the new StreamInfo.*/ @SuppressWarnings("WeakerAccess") - public VideoInfo(AbstractVideoInfo avi) { + public StreamInfo(AbstractVideoInfo avi) { this.id = avi.id; this.title = avi.title; this.uploader = avi.uploader; @@ -252,9 +252,9 @@ public class VideoInfo extends AbstractVideoInfo { this.view_count = avi.view_count; //todo: better than this - if(avi instanceof VideoPreviewInfo) { + if(avi instanceof StreamPreviewInfo) { //shitty String to convert code - String dur = ((VideoPreviewInfo)avi).duration; + String dur = ((StreamPreviewInfo)avi).duration; int minutes = Integer.parseInt(dur.substring(0, dur.indexOf(":"))); int seconds = Integer.parseInt(dur.substring(dur.indexOf(":")+1, dur.length())); this.duration = (minutes*60)+seconds; diff --git a/app/src/main/java/org/schabi/newpipe/extractor/VideoPreviewInfo.java b/app/src/main/java/org/schabi/newpipe/extractor/StreamPreviewInfo.java similarity index 85% rename from app/src/main/java/org/schabi/newpipe/extractor/VideoPreviewInfo.java rename to app/src/main/java/org/schabi/newpipe/extractor/StreamPreviewInfo.java index 29bab20bd..05d87799c 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/VideoPreviewInfo.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/StreamPreviewInfo.java @@ -7,8 +7,8 @@ import android.os.Parcelable; /** * Created by Christian Schabesberger on 26.08.15. * - * Copyright (C) Christian Schabesberger 2015 - * VideoPreviewInfo.java is part of NewPipe. + * Copyright (C) Christian Schabesberger 2016 + * StreamPreviewInfo.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 @@ -25,6 +25,6 @@ import android.os.Parcelable; */ /**Info object for previews of unopened videos, eg search results, related videos*/ -public class VideoPreviewInfo extends AbstractVideoInfo { +public class StreamPreviewInfo extends AbstractVideoInfo { public String duration = ""; } \ No newline at end of file diff --git a/app/src/main/java/org/schabi/newpipe/extractor/VideoUrlIdHandler.java b/app/src/main/java/org/schabi/newpipe/extractor/StreamUrlIdHandler.java similarity index 93% rename from app/src/main/java/org/schabi/newpipe/extractor/VideoUrlIdHandler.java rename to app/src/main/java/org/schabi/newpipe/extractor/StreamUrlIdHandler.java index 88736896f..4f91ac80e 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/VideoUrlIdHandler.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/StreamUrlIdHandler.java @@ -4,7 +4,7 @@ package org.schabi.newpipe.extractor; * Created by Christian Schabesberger on 02.02.16. * * Copyright (C) Christian Schabesberger 2016 - * VideoUrlIdHandler.java is part of NewPipe. + * StreamUrlIdHandler.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 @@ -20,7 +20,7 @@ package org.schabi.newpipe.extractor; * along with NewPipe. If not, see . */ -public interface VideoUrlIdHandler { +public interface StreamUrlIdHandler { String getVideoUrl(String videoId); String getVideoId(String siteUrl) throws ParsingException; String cleanUrl(String siteUrl) throws ParsingException; diff --git a/app/src/main/java/org/schabi/newpipe/extractor/StreamingService.java b/app/src/main/java/org/schabi/newpipe/extractor/StreamingService.java index 88e2757e4..5e929e9d1 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/StreamingService.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/StreamingService.java @@ -5,7 +5,7 @@ import java.io.IOException; /** * Created by Christian Schabesberger on 23.08.15. * - * Copyright (C) Christian Schabesberger 2015 + * Copyright (C) Christian Schabesberger 2016 * StreamingService.java is part of NewPipe. * * NewPipe is free software: you can redistribute it and/or modify @@ -31,7 +31,7 @@ public interface StreamingService { throws IOException, ExtractionException; SearchEngine getSearchEngineInstance(); - VideoUrlIdHandler getUrlIdHandler(); + StreamUrlIdHandler getUrlIdHandler(); } 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 ed0b09036..cf2b4c235 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 @@ -10,7 +10,7 @@ import org.schabi.newpipe.extractor.Downloader; import org.schabi.newpipe.extractor.Parser; import org.schabi.newpipe.extractor.ParsingException; import org.schabi.newpipe.extractor.SearchEngine; -import org.schabi.newpipe.extractor.VideoPreviewInfo; +import org.schabi.newpipe.extractor.StreamPreviewInfo; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.InputSource; @@ -99,11 +99,11 @@ public class YoutubeSearchEngine implements SearchEngine { // video item type } else if (!((el = item.select("div[class*=\"yt-lockup-video\"").first()) == null)) { - VideoPreviewInfo resultItem = new VideoPreviewInfo(); + StreamPreviewInfo resultItem = new StreamPreviewInfo(); // importand information resultItem.webpage_url = getWebpageUrl(item); - resultItem.id = (new YoutubeVideoUrlIdHandler()).getVideoId(resultItem.webpage_url); + resultItem.id = (new YoutubeStreamUrlIdHandler()).getVideoId(resultItem.webpage_url); resultItem.title = getTitle(item); // optional iformation @@ -147,7 +147,7 @@ public class YoutubeSearchEngine implements SearchEngine { } @Override - public ArrayList suggestionList(String query,String contentCountry, Downloader dl) + public ArrayList suggestionList(String query, String contentCountry, Downloader dl) throws IOException, ParsingException { ArrayList suggestions = new ArrayList<>(); diff --git a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java index 768337043..f35ae4044 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeService.java @@ -4,7 +4,7 @@ import org.schabi.newpipe.extractor.ExtractionException; import org.schabi.newpipe.extractor.Downloader; import org.schabi.newpipe.extractor.StreamExtractor; import org.schabi.newpipe.extractor.StreamingService; -import org.schabi.newpipe.extractor.VideoUrlIdHandler; +import org.schabi.newpipe.extractor.StreamUrlIdHandler; import org.schabi.newpipe.extractor.SearchEngine; import java.io.IOException; @@ -40,7 +40,7 @@ public class YoutubeService implements StreamingService { @Override public StreamExtractor getExtractorInstance(String url, Downloader downloader) throws ExtractionException, IOException { - VideoUrlIdHandler urlIdHandler = new YoutubeVideoUrlIdHandler(); + StreamUrlIdHandler urlIdHandler = new YoutubeStreamUrlIdHandler(); if(urlIdHandler.acceptUrl(url)) { return new YoutubeStreamExtractor(url, downloader) ; } @@ -54,7 +54,7 @@ public class YoutubeService implements StreamingService { } @Override - public VideoUrlIdHandler getUrlIdHandler() { - return new YoutubeVideoUrlIdHandler(); + public StreamUrlIdHandler getUrlIdHandler() { + return new YoutubeStreamUrlIdHandler(); } } 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 758fb86f6..4c6bf424f 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 @@ -14,11 +14,11 @@ import org.schabi.newpipe.extractor.ExtractionException; import org.schabi.newpipe.extractor.Downloader; import org.schabi.newpipe.extractor.Parser; import org.schabi.newpipe.extractor.ParsingException; -import org.schabi.newpipe.extractor.VideoUrlIdHandler; +import org.schabi.newpipe.extractor.StreamInfo; +import org.schabi.newpipe.extractor.StreamPreviewInfo; +import org.schabi.newpipe.extractor.StreamUrlIdHandler; import org.schabi.newpipe.extractor.StreamExtractor; import org.schabi.newpipe.extractor.MediaFormat; -import org.schabi.newpipe.extractor.VideoInfo; -import org.schabi.newpipe.extractor.VideoPreviewInfo; import java.io.IOException; import java.util.List; @@ -179,7 +179,7 @@ public class YoutubeStreamExtractor implements StreamExtractor { // cached values private static volatile String decryptionCode = ""; - VideoUrlIdHandler urlidhandler = new YoutubeVideoUrlIdHandler(); + StreamUrlIdHandler urlidhandler = new YoutubeStreamUrlIdHandler(); String pageUrl = ""; private Downloader downloader; @@ -433,8 +433,8 @@ public class YoutubeStreamExtractor implements StreamExtractor { @Override - public List getAudioStreams() throws ParsingException { - Vector audioStreams = new Vector<>(); + public List getAudioStreams() throws ParsingException { + Vector audioStreams = new Vector<>(); try{ String encoded_url_map; // playerArgs could be null if the video is age restricted @@ -461,7 +461,7 @@ public class YoutubeStreamExtractor implements StreamExtractor { + decryptSignature(tags.get("s"), decryptionCode); } - audioStreams.add(new VideoInfo.AudioStream(streamUrl, + audioStreams.add(new StreamInfo.AudioStream(streamUrl, itagItem.mediaFormatId, itagItem.bandWidth, itagItem.samplingRate)); @@ -475,8 +475,8 @@ public class YoutubeStreamExtractor implements StreamExtractor { } @Override - public List getVideoStreams() throws ParsingException { - Vector videoStreams = new Vector<>(); + public List getVideoStreams() throws ParsingException { + Vector videoStreams = new Vector<>(); try{ String encoded_url_map; @@ -504,7 +504,7 @@ public class YoutubeStreamExtractor implements StreamExtractor { streamUrl = streamUrl + "&signature=" + decryptSignature(tags.get("s"), decryptionCode); } - videoStreams.add(new VideoInfo.VideoStream( + videoStreams.add(new StreamInfo.VideoStream( streamUrl, itagItem.mediaFormatId, itagItem.resolutionString)); @@ -527,7 +527,7 @@ public class YoutubeStreamExtractor implements StreamExtractor { } @Override - public List getVideoOnlyStreams() throws ParsingException { + public List getVideoOnlyStreams() throws ParsingException { return null; } @@ -638,7 +638,7 @@ public class YoutubeStreamExtractor implements StreamExtractor { } @Override - public VideoPreviewInfo getNextVideo() throws ParsingException { + public StreamPreviewInfo getNextVideo() throws ParsingException { try { return extractVideoPreviewInfo(doc.select("div[class=\"watch-sidebar-section\"]").first() .select("li").first()); @@ -648,9 +648,9 @@ public class YoutubeStreamExtractor implements StreamExtractor { } @Override - public Vector getRelatedVideos() throws ParsingException { + public Vector getRelatedVideos() throws ParsingException { try { - Vector relatedVideos = new Vector<>(); + Vector relatedVideos = new Vector<>(); for (Element li : doc.select("ul[id=\"watch-related\"]").first().children()) { // first check if we have a playlist. If so leave them out if (li.select("a[class*=\"content-link\"]").first() != null) { @@ -664,8 +664,8 @@ public class YoutubeStreamExtractor implements StreamExtractor { } @Override - public VideoUrlIdHandler getUrlIdConverter() { - return new YoutubeVideoUrlIdHandler(); + public StreamUrlIdHandler getUrlIdConverter() { + return new YoutubeStreamUrlIdHandler(); } @Override @@ -674,10 +674,10 @@ public class YoutubeStreamExtractor implements StreamExtractor { } /**Provides information about links to other videos on the video page, such as related videos. - * This is encapsulated in a VideoPreviewInfo object, - * which is a subset of the fields in a full VideoInfo.*/ - private VideoPreviewInfo extractVideoPreviewInfo(Element li) throws ParsingException { - VideoPreviewInfo info = new VideoPreviewInfo(); + * This is encapsulated in a StreamPreviewInfo object, + * which is a subset of the fields in a full StreamInfo.*/ + private StreamPreviewInfo extractVideoPreviewInfo(Element li) throws ParsingException { + StreamPreviewInfo info = new StreamPreviewInfo(); try { info.webpage_url = li.select("a.content-link").first() diff --git a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeVideoUrlIdHandler.java b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamUrlIdHandler.java similarity index 93% rename from app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeVideoUrlIdHandler.java rename to app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamUrlIdHandler.java index c74924cc1..4edc6cd91 100644 --- a/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeVideoUrlIdHandler.java +++ b/app/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeStreamUrlIdHandler.java @@ -2,7 +2,7 @@ package org.schabi.newpipe.extractor.services.youtube; import org.schabi.newpipe.extractor.Parser; import org.schabi.newpipe.extractor.ParsingException; -import org.schabi.newpipe.extractor.VideoUrlIdHandler; +import org.schabi.newpipe.extractor.StreamUrlIdHandler; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; @@ -11,7 +11,7 @@ import java.net.URLDecoder; * Created by Christian Schabesberger on 02.02.16. * * Copyright (C) Christian Schabesberger 2016 - * YoutubeVideoUrlIdHandler.java is part of NewPipe. + * YoutubeStreamUrlIdHandler.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 @@ -27,7 +27,7 @@ import java.net.URLDecoder; * along with NewPipe. If not, see . */ -public class YoutubeVideoUrlIdHandler implements VideoUrlIdHandler { +public class YoutubeStreamUrlIdHandler implements StreamUrlIdHandler { @SuppressWarnings("WeakerAccess") @Override public String getVideoUrl(String videoId) {