made the ui react on missing information
This commit is contained in:
parent
77850464d4
commit
a94f9fd3e5
|
@ -3,7 +3,7 @@ package org.schabi.newpipe.services.youtube;
|
|||
import android.test.AndroidTestCase;
|
||||
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.CrawlingException;
|
||||
import org.schabi.newpipe.extractor.ExctractionException;
|
||||
import org.schabi.newpipe.extractor.ParsingException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.YoutubeStreamExtractor;
|
||||
import org.schabi.newpipe.extractor.VideoInfo;
|
||||
|
@ -33,7 +33,7 @@ import java.io.IOException;
|
|||
public class YoutubeStreamExtractorDefaultTest extends AndroidTestCase {
|
||||
private YoutubeStreamExtractor extractor;
|
||||
|
||||
public void setUp() throws IOException, CrawlingException {
|
||||
public void setUp() throws IOException, ExctractionException {
|
||||
/* some anonymus video test
|
||||
extractor = new YoutubeStreamExtractor("https://www.youtube.com/watch?v=FmG385_uUys",
|
||||
new Downloader()); */
|
||||
|
@ -47,7 +47,7 @@ public class YoutubeStreamExtractorDefaultTest extends AndroidTestCase {
|
|||
extractor.getTimeStamp() <= 0);
|
||||
}
|
||||
|
||||
public void testGetValidTimeStamp() throws CrawlingException, IOException {
|
||||
public void testGetValidTimeStamp() throws ExctractionException, IOException {
|
||||
YoutubeStreamExtractor extractor =
|
||||
new YoutubeStreamExtractor("https://youtu.be/FmG385_uUys?t=174", new Downloader());
|
||||
assertTrue(Integer.toString(extractor.getTimeStamp()),
|
||||
|
|
|
@ -3,7 +3,7 @@ package org.schabi.newpipe.services.youtube;
|
|||
import android.test.AndroidTestCase;
|
||||
|
||||
import org.schabi.newpipe.Downloader;
|
||||
import org.schabi.newpipe.extractor.CrawlingException;
|
||||
import org.schabi.newpipe.extractor.ExctractionException;
|
||||
import org.schabi.newpipe.extractor.services.youtube.YoutubeStreamExtractor;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -35,7 +35,7 @@ public class YoutubeStreamExtractorGemaTest extends AndroidTestCase {
|
|||
// Deaktivate this Test Case bevore uploading it githup, otherwise CI will fail.
|
||||
private static final boolean testActive = false;
|
||||
|
||||
public void testGemaError() throws IOException, CrawlingException {
|
||||
public void testGemaError() throws IOException, ExctractionException {
|
||||
if(testActive) {
|
||||
try {
|
||||
new YoutubeStreamExtractor("https://www.youtube.com/watch?v=3O1_3zBUKM8",
|
||||
|
|
|
@ -98,7 +98,7 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
private Bitmap videoThumbnail;
|
||||
|
||||
private View thumbnailWindowLayout;
|
||||
//this only remains dueto downwards compartiblity
|
||||
//this only remains due to downwards compatibility
|
||||
private FloatingActionButton playVideoButton;
|
||||
private final Point initialThumbnailPos = new Point(0, 0);
|
||||
|
||||
|
@ -224,11 +224,20 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
Button backgroundButton = (Button)
|
||||
activity.findViewById(R.id.detailVideoThumbnailWindowBackgroundButton);
|
||||
View topView = activity.findViewById(R.id.detailTopView);
|
||||
View nextVideoView = videoItemViewCreator
|
||||
.getViewFromVideoInfoItem(null, nextVideoFrame, info.next_video, getContext());
|
||||
View nextVideoView = null;
|
||||
if(info.next_video != null) {
|
||||
nextVideoView = videoItemViewCreator
|
||||
.getViewFromVideoInfoItem(null, nextVideoFrame, info.next_video, getContext());
|
||||
} else {
|
||||
activity.findViewById(R.id.detailNextVidButtonAndContentLayout).setVisibility(View.GONE);
|
||||
activity.findViewById(R.id.detailNextVideoTitle).setVisibility(View.GONE);
|
||||
activity.findViewById(R.id.detailNextVideoButton).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
progressBar.setVisibility(View.GONE);
|
||||
nextVideoFrame.addView(nextVideoView);
|
||||
if(nextVideoView != null) {
|
||||
nextVideoFrame.addView(nextVideoView);
|
||||
}
|
||||
|
||||
initThumbnailViews(info, nextVideoFrame);
|
||||
|
||||
|
@ -265,14 +274,43 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
}
|
||||
});
|
||||
|
||||
uploaderView.setText(info.uploader);
|
||||
// Since newpipe is designed to work even if certain information is not available,
|
||||
// the UI has to react on missing information.
|
||||
videoTitleView.setText(info.title);
|
||||
uploaderView.setText(info.uploader);
|
||||
viewCountView.setText(Localization.localizeViewCount(info.view_count, c));
|
||||
thumbsUpView.setText(Localization.localizeNumber(info.like_count, c));
|
||||
thumbsDownView.setText(Localization.localizeNumber(info.dislike_count, c));
|
||||
uploadDateView.setText(Localization.localizeDate(info.upload_date, c));
|
||||
descriptionView.setText(Html.fromHtml(info.description));
|
||||
if(!info.uploader.isEmpty()) {
|
||||
uploaderView.setText(info.uploader);
|
||||
} else {
|
||||
activity.findViewById(R.id.detailUploaderWrapView).setVisibility(View.GONE);
|
||||
}
|
||||
if(info.view_count >= 0) {
|
||||
viewCountView.setText(Localization.localizeViewCount(info.view_count, c));
|
||||
} else {
|
||||
viewCountView.setVisibility(View.GONE);
|
||||
}
|
||||
if(info.dislike_count >= 0) {
|
||||
thumbsDownView.setText(Localization.localizeNumber(info.dislike_count, c));
|
||||
} else {
|
||||
thumbsDownView.setVisibility(View.INVISIBLE);
|
||||
activity.findViewById(R.id.detailThumbsDownImgView).setVisibility(View.GONE);
|
||||
}
|
||||
if(info.like_count >= 0) {
|
||||
thumbsUpView.setText(Localization.localizeNumber(info.like_count, c));
|
||||
} else {
|
||||
thumbsUpView.setVisibility(View.GONE);
|
||||
activity.findViewById(R.id.detailThumbsUpImgView).setVisibility(View.GONE);
|
||||
thumbsDownView.setVisibility(View.GONE);
|
||||
activity.findViewById(R.id.detailThumbsDownImgView).setVisibility(View.GONE);
|
||||
}
|
||||
if(!info.upload_date.isEmpty()) {
|
||||
uploadDateView.setText(Localization.localizeDate(info.upload_date, c));
|
||||
} else {
|
||||
uploadDateView.setVisibility(View.GONE);
|
||||
}
|
||||
if(!info.description.isEmpty()) {
|
||||
descriptionView.setText(Html.fromHtml(info.description));
|
||||
} else {
|
||||
descriptionView.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
descriptionView.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
|
||||
|
@ -299,7 +337,12 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
});
|
||||
textContentLayout.setVisibility(View.VISIBLE);
|
||||
|
||||
initSimilarVideos(info, videoItemViewCreator);
|
||||
if(info.related_videos != null && !info.related_videos.isEmpty()) {
|
||||
initSimilarVideos(info, videoItemViewCreator);
|
||||
} else {
|
||||
activity.findViewById(R.id.detailSimilarTitle).setVisibility(View.GONE);
|
||||
activity.findViewById(R.id.similarVideosView).setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
if(autoPlayEnabled) {
|
||||
playVideo(info);
|
||||
|
@ -335,32 +378,40 @@ public class VideoItemDetailFragment extends Fragment {
|
|||
ImageView nextVideoThumb =
|
||||
(ImageView) nextVideoFrame.findViewById(R.id.itemThumbnailView);
|
||||
|
||||
imageLoader.displayImage(info.thumbnail_url, videoThumbnailView,
|
||||
displayImageOptions, new ImageLoadingListener() {
|
||||
@Override
|
||||
public void onLoadingStarted(String imageUri, View view) {
|
||||
}
|
||||
if(info.thumbnail_url != null && !info.thumbnail_url.isEmpty()) {
|
||||
imageLoader.displayImage(info.thumbnail_url, videoThumbnailView,
|
||||
displayImageOptions, new ImageLoadingListener() {
|
||||
@Override
|
||||
public void onLoadingStarted(String imageUri, View view) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
|
||||
Toast.makeText(VideoItemDetailFragment.this.getActivity(),
|
||||
R.string.could_not_load_thumbnails, Toast.LENGTH_LONG).show();
|
||||
failReason.getCause().printStackTrace();
|
||||
}
|
||||
@Override
|
||||
public void onLoadingFailed(String imageUri, View view, FailReason failReason) {
|
||||
Toast.makeText(VideoItemDetailFragment.this.getActivity(),
|
||||
R.string.could_not_load_thumbnails, Toast.LENGTH_LONG).show();
|
||||
failReason.getCause().printStackTrace();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
videoThumbnail = loadedImage;
|
||||
}
|
||||
@Override
|
||||
public void onLoadingComplete(String imageUri, View view, Bitmap loadedImage) {
|
||||
videoThumbnail = loadedImage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadingCancelled(String imageUri, View view) {
|
||||
}
|
||||
});
|
||||
imageLoader.displayImage(info.uploader_thumbnail_url,
|
||||
uploaderThumb, displayImageOptions, new ThumbnailLoadingListener());
|
||||
imageLoader.displayImage(info.next_video.thumbnail_url,
|
||||
nextVideoThumb, displayImageOptions, new ThumbnailLoadingListener());
|
||||
@Override
|
||||
public void onLoadingCancelled(String imageUri, View view) {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
videoThumbnailView.setImageResource(R.drawable.dummy_thumbnail_dark);
|
||||
}
|
||||
if(info.uploader_thumbnail_url != null && !info.uploader_thumbnail_url.isEmpty()) {
|
||||
imageLoader.displayImage(info.uploader_thumbnail_url,
|
||||
uploaderThumb, displayImageOptions, new ThumbnailLoadingListener());
|
||||
}
|
||||
if(info.thumbnail_url != null && !info.thumbnail_url.isEmpty()) {
|
||||
imageLoader.displayImage(info.next_video.thumbnail_url,
|
||||
nextVideoThumb, displayImageOptions, new ThumbnailLoadingListener());
|
||||
}
|
||||
}
|
||||
|
||||
private void setupActionBarHandler(final VideoInfo info) {
|
||||
|
|
|
@ -16,7 +16,7 @@ import android.widget.Toast;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import org.schabi.newpipe.extractor.CrawlingException;
|
||||
import org.schabi.newpipe.extractor.ExctractionException;
|
||||
import org.schabi.newpipe.extractor.VideoPreviewInfo;
|
||||
import org.schabi.newpipe.extractor.SearchEngine;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
|
@ -115,7 +115,7 @@ public class VideoItemListFragment extends ListFragment {
|
|||
} catch(IOException e) {
|
||||
postNewErrorToast(h, R.string.network_error);
|
||||
e.printStackTrace();
|
||||
} catch(CrawlingException ce) {
|
||||
} catch(ExctractionException ce) {
|
||||
postNewErrorToast(h, R.string.parsing_error);
|
||||
ce.printStackTrace();
|
||||
} catch(Exception e) {
|
||||
|
|
|
@ -4,7 +4,7 @@ package org.schabi.newpipe.extractor;
|
|||
* Created by Christian Schabesberger on 30.01.16.
|
||||
*
|
||||
* Copyright (C) Christian Schabesberger 2016 <chris.schabesberger@mailbox.org>
|
||||
* CrawlingException.java is part of NewPipe.
|
||||
* ExctractionException.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,18 +20,18 @@ package org.schabi.newpipe.extractor;
|
|||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
public class CrawlingException extends Exception {
|
||||
public CrawlingException() {}
|
||||
public class ExctractionException extends Exception {
|
||||
public ExctractionException() {}
|
||||
|
||||
public CrawlingException(String message) {
|
||||
public ExctractionException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public CrawlingException(Throwable cause) {
|
||||
public ExctractionException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
public CrawlingException(String message, Throwable cause) {
|
||||
public ExctractionException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@ package org.schabi.newpipe.extractor;
|
|||
*/
|
||||
|
||||
|
||||
public class ParsingException extends CrawlingException {
|
||||
public class ParsingException extends ExctractionException {
|
||||
public ParsingException() {}
|
||||
public ParsingException(String message) {
|
||||
super(message);
|
||||
|
|
|
@ -34,9 +34,9 @@ public interface SearchEngine {
|
|||
}
|
||||
|
||||
ArrayList<String> suggestionList(String query, Downloader dl)
|
||||
throws CrawlingException, IOException;
|
||||
throws ExctractionException, IOException;
|
||||
|
||||
//Result search(String query, int page);
|
||||
Result search(String query, int page, String contentCountry, Downloader dl)
|
||||
throws CrawlingException, IOException;
|
||||
throws ExctractionException, IOException;
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.util.List;
|
|||
@SuppressWarnings("ALL")
|
||||
public interface StreamExtractor {
|
||||
|
||||
public class ExctractorInitException extends CrawlingException {
|
||||
public class ExctractorInitException extends ExctractionException {
|
||||
public ExctractorInitException() {}
|
||||
public ExctractorInitException(String message) {
|
||||
super(message);
|
||||
|
|
|
@ -28,7 +28,7 @@ public interface StreamingService {
|
|||
}
|
||||
ServiceInfo getServiceInfo();
|
||||
StreamExtractor getExtractorInstance(String url, Downloader downloader)
|
||||
throws IOException, CrawlingException;
|
||||
throws IOException, ExctractionException;
|
||||
SearchEngine getSearchEngineInstance();
|
||||
|
||||
VideoUrlIdHandler getUrlIdHandler();
|
||||
|
|
|
@ -31,33 +31,54 @@ 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)
|
||||
throws CrawlingException, IOException {
|
||||
throws ExctractionException, IOException {
|
||||
VideoInfo videoInfo = new VideoInfo();
|
||||
|
||||
videoInfo = extractImportantData(videoInfo, extractor, downloader);
|
||||
videoInfo = extractStreams(videoInfo, extractor, downloader);
|
||||
videoInfo = extractOptionalData(videoInfo, extractor, downloader);
|
||||
|
||||
return videoInfo;
|
||||
}
|
||||
|
||||
private static VideoInfo extractImportantData(
|
||||
VideoInfo videoInfo, StreamExtractor extractor, Downloader downloader)
|
||||
throws ExctractionException, 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();
|
||||
|
||||
|
||||
videoInfo.webpage_url = extractor.getPageUrl();
|
||||
videoInfo.title = extractor.getTitle();
|
||||
videoInfo.duration = extractor.getLength();
|
||||
videoInfo.uploader = extractor.getUploader();
|
||||
videoInfo.description = extractor.getDescription();
|
||||
videoInfo.view_count = extractor.getViews();
|
||||
videoInfo.upload_date = extractor.getUploadDate();
|
||||
videoInfo.thumbnail_url = extractor.getThumbnailUrl();
|
||||
videoInfo.id = uiconv.getVideoId(extractor.getPageUrl());
|
||||
//todo: make this quick and dirty solution a real fallback
|
||||
// The front end should be notified that the dash mpd could not be downloaded
|
||||
// although not getting the dash mpd is not the end of the world, therfore
|
||||
// we continue.
|
||||
videoInfo.title = extractor.getTitle();
|
||||
|
||||
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 */));
|
||||
|
||||
return videoInfo;
|
||||
}
|
||||
|
||||
private static VideoInfo extractStreams(
|
||||
VideoInfo videoInfo, StreamExtractor extractor, Downloader downloader)
|
||||
throws ExctractionException, 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();
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
videoInfo.addException(new ExctractionException("Couldn't get Dash manifest", e));
|
||||
}
|
||||
|
||||
/** Load and extract audio*/
|
||||
videoInfo.audio_streams = extractor.getAudioStreams();
|
||||
/* Load and extract audio */
|
||||
try {
|
||||
videoInfo.audio_streams = extractor.getAudioStreams();
|
||||
} catch(Exception e) {
|
||||
videoInfo.addException(new ExctractionException("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) {
|
||||
|
@ -69,28 +90,115 @@ public class VideoInfo extends AbstractVideoInfo {
|
|||
videoInfo.audio_streams.addAll(
|
||||
DashMpdParser.getAudioStreams(videoInfo.dashMpdUrl, downloader));
|
||||
} catch(Exception e) {
|
||||
e.printStackTrace();
|
||||
videoInfo.addException(
|
||||
new ExctractionException("Couldn't get audio streams from dash mpd", e));
|
||||
}
|
||||
}
|
||||
/** Extract video stream url*/
|
||||
videoInfo.video_streams = extractor.getVideoStreams();
|
||||
/** Extract video only stream url*/
|
||||
videoInfo.video_only_streams = extractor.getVideoOnlyStreams();
|
||||
videoInfo.uploader_thumbnail_url = extractor.getUploaderThumbnailUrl();
|
||||
videoInfo.start_position = extractor.getTimeStamp();
|
||||
videoInfo.average_rating = extractor.getAverageRating();
|
||||
videoInfo.like_count = extractor.getLikeCount();
|
||||
videoInfo.dislike_count = extractor.getDislikeCount();
|
||||
videoInfo.next_video = extractor.getNextVideo();
|
||||
videoInfo.related_videos = extractor.getRelatedVideos();
|
||||
/* Extract video stream url*/
|
||||
try {
|
||||
videoInfo.video_streams = extractor.getVideoStreams();
|
||||
} catch (Exception e) {
|
||||
videoInfo.addException(
|
||||
new ExctractionException("Couldn't get video streams", e));
|
||||
}
|
||||
/* Extract video only stream url*/
|
||||
try {
|
||||
videoInfo.video_only_streams = extractor.getVideoOnlyStreams();
|
||||
} catch(Exception e) {
|
||||
videoInfo.addException(
|
||||
new ExctractionException("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())) {
|
||||
throw new ExctractionException("Could not get any stream. See error variable to get further details.");
|
||||
}
|
||||
|
||||
return videoInfo;
|
||||
}
|
||||
|
||||
private static VideoInfo extractOptionalData(
|
||||
VideoInfo videoInfo, 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();
|
||||
} catch(Exception e) {
|
||||
videoInfo.addException(e);
|
||||
}
|
||||
try {
|
||||
videoInfo.duration = extractor.getLength();
|
||||
} catch(Exception e) {
|
||||
videoInfo.addException(e);
|
||||
}
|
||||
try {
|
||||
videoInfo.uploader = extractor.getUploader();
|
||||
} catch(Exception e) {
|
||||
videoInfo.addException(e);
|
||||
}
|
||||
try {
|
||||
videoInfo.description = extractor.getDescription();
|
||||
} catch(Exception e) {
|
||||
videoInfo.addException(e);
|
||||
}
|
||||
try {
|
||||
videoInfo.view_count = extractor.getViews();
|
||||
} catch(Exception e) {
|
||||
videoInfo.addException(e);
|
||||
}
|
||||
try {
|
||||
videoInfo.upload_date = extractor.getUploadDate();
|
||||
} catch(Exception e) {
|
||||
videoInfo.addException(e);
|
||||
}
|
||||
try {
|
||||
videoInfo.uploader_thumbnail_url = extractor.getUploaderThumbnailUrl();
|
||||
} catch(Exception e) {
|
||||
videoInfo.addException(e);
|
||||
}
|
||||
try {
|
||||
videoInfo.start_position = extractor.getTimeStamp();
|
||||
} catch(Exception e) {
|
||||
videoInfo.addException(e);
|
||||
}
|
||||
try {
|
||||
videoInfo.average_rating = extractor.getAverageRating();
|
||||
} catch(Exception e) {
|
||||
videoInfo.addException(e);
|
||||
}
|
||||
try {
|
||||
videoInfo.like_count = extractor.getLikeCount();
|
||||
} catch(Exception e) {
|
||||
videoInfo.addException(e);
|
||||
}
|
||||
try {
|
||||
videoInfo.dislike_count = extractor.getDislikeCount();
|
||||
} catch(Exception e) {
|
||||
videoInfo.addException(e);
|
||||
}
|
||||
try {
|
||||
videoInfo.next_video = extractor.getNextVideo();
|
||||
} catch(Exception e) {
|
||||
videoInfo.addException(e);
|
||||
}
|
||||
try {
|
||||
videoInfo.related_videos = extractor.getRelatedVideos();
|
||||
} catch(Exception e) {
|
||||
videoInfo.addException(e);
|
||||
}
|
||||
|
||||
return videoInfo;
|
||||
}
|
||||
|
||||
public String uploader_thumbnail_url = "";
|
||||
public String description = "";
|
||||
/*todo: make this lists over vectors*/
|
||||
|
||||
public List<VideoStream> video_streams = null;
|
||||
public List<AudioStream> audio_streams = null;
|
||||
public List<VideoStream> video_only_streams = null;
|
||||
|
@ -101,8 +209,6 @@ public class VideoInfo extends AbstractVideoInfo {
|
|||
public String dashMpdUrl = "";
|
||||
public int duration = -1;
|
||||
|
||||
/*YouTube-specific fields
|
||||
todo: move these to a subclass*/
|
||||
public int age_limit = 0;
|
||||
public int like_count = -1;
|
||||
public int dislike_count = -1;
|
||||
|
@ -113,6 +219,8 @@ public class VideoInfo extends AbstractVideoInfo {
|
|||
public int start_position = 0;
|
||||
//todo: public int service_id = -1;
|
||||
|
||||
public List<Exception> errors = new Vector<>();
|
||||
|
||||
public VideoInfo() {}
|
||||
|
||||
/**Creates a new VideoInfo object from an existing AbstractVideoInfo.
|
||||
|
@ -187,4 +295,8 @@ public class VideoInfo extends AbstractVideoInfo {
|
|||
&& url == cmp.url;
|
||||
}
|
||||
}
|
||||
|
||||
public void addException(Exception e) {
|
||||
errors.add(e);
|
||||
}
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
package org.schabi.newpipe.extractor.services.youtube;
|
||||
|
||||
import org.schabi.newpipe.extractor.CrawlingException;
|
||||
import org.schabi.newpipe.extractor.ExctractionException;
|
||||
import org.schabi.newpipe.extractor.Downloader;
|
||||
import org.schabi.newpipe.extractor.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.StreamingService;
|
||||
|
@ -39,7 +39,7 @@ public class YoutubeService implements StreamingService {
|
|||
}
|
||||
@Override
|
||||
public StreamExtractor getExtractorInstance(String url, Downloader downloader)
|
||||
throws CrawlingException, IOException {
|
||||
throws ExctractionException, IOException {
|
||||
VideoUrlIdHandler urlIdHandler = new YoutubeVideoUrlIdHandler();
|
||||
if(urlIdHandler.acceptUrl(url)) {
|
||||
return new YoutubeStreamExtractor(url, downloader) ;
|
||||
|
|
|
@ -10,7 +10,7 @@ import org.jsoup.nodes.Element;
|
|||
import org.mozilla.javascript.Context;
|
||||
import org.mozilla.javascript.Function;
|
||||
import org.mozilla.javascript.ScriptableObject;
|
||||
import org.schabi.newpipe.extractor.CrawlingException;
|
||||
import org.schabi.newpipe.extractor.ExctractionException;
|
||||
import org.schabi.newpipe.extractor.Downloader;
|
||||
import org.schabi.newpipe.extractor.Parser;
|
||||
import org.schabi.newpipe.extractor.ParsingException;
|
||||
|
@ -173,7 +173,7 @@ public class YoutubeStreamExtractor implements StreamExtractor {
|
|||
|
||||
private Downloader downloader;
|
||||
|
||||
public YoutubeStreamExtractor(String pageUrl, Downloader dl) throws CrawlingException, IOException {
|
||||
public YoutubeStreamExtractor(String pageUrl, Downloader dl) throws ExctractionException, IOException {
|
||||
//most common videoInfo fields are now set in our superclass, for all services
|
||||
downloader = dl;
|
||||
this.pageUrl = pageUrl;
|
||||
|
|
|
@ -266,10 +266,10 @@
|
|||
android:layout_below="@id/detailNextVidButtonAndContentLayout"
|
||||
android:textAllCaps="true" />
|
||||
<LinearLayout
|
||||
android:id="@+id/similarVideosView"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:id="@+id/similarVideosView"
|
||||
android:layout_below="@id/detailSimilarTitle">
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
|
|
Loading…
Reference in New Issue