mirror of
https://github.com/TeamNewPipe/NewPipe
synced 2024-12-23 16:40:32 +00:00
clean up downloader thing
This commit is contained in:
parent
f9ac199c1f
commit
43afd5a2b8
@ -4,8 +4,7 @@ import android.test.AndroidTestCase;
|
|||||||
|
|
||||||
import org.schabi.newpipe.Downloader;
|
import org.schabi.newpipe.Downloader;
|
||||||
import org.schabi.newpipe.extractor.ChannelExtractor;
|
import org.schabi.newpipe.extractor.ChannelExtractor;
|
||||||
import org.schabi.newpipe.extractor.SearchEngine;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Christian Schabesberger on 12.09.16.
|
* Created by Christian Schabesberger on 12.09.16.
|
||||||
@ -33,7 +32,7 @@ public class YoutubeChannelExtractorTest extends AndroidTestCase {
|
|||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
extractor = ServiceList.getService("Youtube")
|
extractor = NewPipe.getService("Youtube")
|
||||||
.getChannelExtractorInstance("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw", 0, new Downloader());
|
.getChannelExtractorInstance("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw", 0, new Downloader());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,13 +66,13 @@ public class YoutubeChannelExtractorTest extends AndroidTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testGetNextPage() throws Exception {
|
public void testGetNextPage() throws Exception {
|
||||||
extractor = ServiceList.getService("Youtube")
|
extractor = NewPipe.getService("Youtube")
|
||||||
.getChannelExtractorInstance("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw", 1, new Downloader());
|
.getChannelExtractorInstance("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw", 1, new Downloader());
|
||||||
assertTrue("next page didn't have content", !extractor.getStreams().getItemList().isEmpty());
|
assertTrue("next page didn't have content", !extractor.getStreams().getItemList().isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void testGetNextNextPageUrl() throws Exception {
|
public void testGetNextNextPageUrl() throws Exception {
|
||||||
extractor = ServiceList.getService("Youtube")
|
extractor = NewPipe.getService("Youtube")
|
||||||
.getChannelExtractorInstance("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw", 2, new Downloader());
|
.getChannelExtractorInstance("https://www.youtube.com/channel/UCYJ61XIK64sp6ZFFS8sctxw", 2, new Downloader());
|
||||||
assertTrue("next page didn't have content", extractor.hasNextPage());
|
assertTrue("next page didn't have content", extractor.hasNextPage());
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,11 @@ package org.schabi.newpipe.extractor.youtube;
|
|||||||
|
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.AbstractVideoInfo;
|
|
||||||
import org.schabi.newpipe.extractor.SearchResult;
|
import org.schabi.newpipe.extractor.SearchResult;
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.StreamPreviewInfo;
|
|
||||||
import org.schabi.newpipe.extractor.SearchEngine;
|
import org.schabi.newpipe.extractor.SearchEngine;
|
||||||
import org.schabi.newpipe.Downloader;
|
import org.schabi.newpipe.Downloader;
|
||||||
|
|
||||||
import java.io.PrintWriter;
|
|
||||||
import java.io.StringWriter;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -40,7 +36,7 @@ public class YoutubeSearchEngineTest extends AndroidTestCase {
|
|||||||
@Override
|
@Override
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
super.setUp();
|
super.setUp();
|
||||||
SearchEngine engine = ServiceList.getService("Youtube")
|
SearchEngine engine = NewPipe.getService("Youtube")
|
||||||
.getSearchEngineInstance(new Downloader());
|
.getSearchEngineInstance(new Downloader());
|
||||||
|
|
||||||
result = engine.search("this is something boring",
|
result = engine.search("this is something boring",
|
||||||
|
@ -6,7 +6,7 @@ import org.schabi.newpipe.Downloader;
|
|||||||
import org.schabi.newpipe.extractor.AbstractVideoInfo;
|
import org.schabi.newpipe.extractor.AbstractVideoInfo;
|
||||||
import org.schabi.newpipe.extractor.ExtractionException;
|
import org.schabi.newpipe.extractor.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.ParsingException;
|
import org.schabi.newpipe.extractor.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.StreamExtractor;
|
import org.schabi.newpipe.extractor.StreamExtractor;
|
||||||
import org.schabi.newpipe.extractor.VideoStream;
|
import org.schabi.newpipe.extractor.VideoStream;
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ public class YoutubeStreamExtractorDefaultTest extends AndroidTestCase {
|
|||||||
private StreamExtractor extractor;
|
private StreamExtractor extractor;
|
||||||
|
|
||||||
public void setUp() throws IOException, ExtractionException {
|
public void setUp() throws IOException, ExtractionException {
|
||||||
extractor = ServiceList.getService("Youtube")
|
extractor = NewPipe.getService("Youtube")
|
||||||
.getExtractorInstance("https://www.youtube.com/watch?v=YQHsXMglC9A", new Downloader());
|
.getExtractorInstance("https://www.youtube.com/watch?v=YQHsXMglC9A", new Downloader());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ public class YoutubeStreamExtractorDefaultTest extends AndroidTestCase {
|
|||||||
|
|
||||||
public void testGetValidTimeStamp() throws ExtractionException, IOException {
|
public void testGetValidTimeStamp() throws ExtractionException, IOException {
|
||||||
StreamExtractor extractor =
|
StreamExtractor extractor =
|
||||||
ServiceList.getService("Youtube")
|
NewPipe.getService("Youtube")
|
||||||
.getExtractorInstance("https://youtu.be/FmG385_uUys?t=174", new Downloader());
|
.getExtractorInstance("https://youtu.be/FmG385_uUys?t=174", new Downloader());
|
||||||
assertTrue(Integer.toString(extractor.getTimeStamp()),
|
assertTrue(Integer.toString(extractor.getTimeStamp()),
|
||||||
extractor.getTimeStamp() == 174);
|
extractor.getTimeStamp() == 174);
|
||||||
|
@ -4,7 +4,7 @@ import android.test.AndroidTestCase;
|
|||||||
|
|
||||||
import org.schabi.newpipe.Downloader;
|
import org.schabi.newpipe.Downloader;
|
||||||
import org.schabi.newpipe.extractor.ExtractionException;
|
import org.schabi.newpipe.extractor.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.YoutubeStreamExtractor;
|
import org.schabi.newpipe.extractor.services.youtube.YoutubeStreamExtractor;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -39,7 +39,7 @@ public class YoutubeStreamExtractorGemaTest extends AndroidTestCase {
|
|||||||
public void testGemaError() throws IOException, ExtractionException {
|
public void testGemaError() throws IOException, ExtractionException {
|
||||||
if(testActive) {
|
if(testActive) {
|
||||||
try {
|
try {
|
||||||
ServiceList.getService("Youtube")
|
NewPipe.getService("Youtube")
|
||||||
.getExtractorInstance("https://www.youtube.com/watch?v=3O1_3zBUKM8",
|
.getExtractorInstance("https://www.youtube.com/watch?v=3O1_3zBUKM8",
|
||||||
new Downloader());
|
new Downloader());
|
||||||
} catch(YoutubeStreamExtractor.GemaException ge) {
|
} catch(YoutubeStreamExtractor.GemaException ge) {
|
||||||
|
@ -2,11 +2,8 @@ package org.schabi.newpipe.extractor.youtube;
|
|||||||
|
|
||||||
import android.test.AndroidTestCase;
|
import android.test.AndroidTestCase;
|
||||||
|
|
||||||
import org.schabi.newpipe.Downloader;
|
|
||||||
import org.schabi.newpipe.extractor.AbstractVideoInfo;
|
|
||||||
import org.schabi.newpipe.extractor.ExtractionException;
|
import org.schabi.newpipe.extractor.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.ParsingException;
|
import org.schabi.newpipe.extractor.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
|
||||||
import org.schabi.newpipe.extractor.StreamExtractor;
|
import org.schabi.newpipe.extractor.StreamExtractor;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -39,7 +36,7 @@ public class YoutubeStreamExtractorLiveStreamTest extends AndroidTestCase {
|
|||||||
public void setUp() throws IOException, ExtractionException {
|
public void setUp() throws IOException, ExtractionException {
|
||||||
//todo: make the extractor not throw over a livestream
|
//todo: make the extractor not throw over a livestream
|
||||||
/*
|
/*
|
||||||
extractor = ServiceList.getService("Youtube")
|
extractor = NewPipe.getService("Youtube")
|
||||||
.getExtractorInstance("https://www.youtube.com/watch?v=J0s6NjqdjLE", new Downloader());
|
.getExtractorInstance("https://www.youtube.com/watch?v=J0s6NjqdjLE", new Downloader());
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
@ -4,8 +4,8 @@ import android.test.AndroidTestCase;
|
|||||||
|
|
||||||
import org.schabi.newpipe.Downloader;
|
import org.schabi.newpipe.Downloader;
|
||||||
import org.schabi.newpipe.extractor.ExtractionException;
|
import org.schabi.newpipe.extractor.ExtractionException;
|
||||||
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.ParsingException;
|
import org.schabi.newpipe.extractor.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
|
||||||
import org.schabi.newpipe.extractor.StreamExtractor;
|
import org.schabi.newpipe.extractor.StreamExtractor;
|
||||||
import org.schabi.newpipe.extractor.VideoStream;
|
import org.schabi.newpipe.extractor.VideoStream;
|
||||||
|
|
||||||
@ -16,7 +16,7 @@ public class YoutubeStreamExtractorRestrictedTest extends AndroidTestCase {
|
|||||||
private StreamExtractor extractor;
|
private StreamExtractor extractor;
|
||||||
|
|
||||||
public void setUp() throws IOException, ExtractionException {
|
public void setUp() throws IOException, ExtractionException {
|
||||||
extractor = ServiceList.getService("Youtube")
|
extractor = NewPipe.getService("Youtube")
|
||||||
.getExtractorInstance("https://www.youtube.com/watch?v=i6JTvzrpBy0",
|
.getExtractorInstance("https://www.youtube.com/watch?v=i6JTvzrpBy0",
|
||||||
new Downloader());
|
new Downloader());
|
||||||
}
|
}
|
||||||
@ -27,7 +27,7 @@ public class YoutubeStreamExtractorRestrictedTest extends AndroidTestCase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testGetValidTimeStamp() throws ExtractionException, IOException {
|
public void testGetValidTimeStamp() throws ExtractionException, IOException {
|
||||||
StreamExtractor extractor=ServiceList.getService("Youtube")
|
StreamExtractor extractor= NewPipe.getService("Youtube")
|
||||||
.getExtractorInstance("https://youtu.be/FmG385_uUys?t=174",
|
.getExtractorInstance("https://youtu.be/FmG385_uUys?t=174",
|
||||||
new Downloader());
|
new Downloader());
|
||||||
assertTrue(Integer.toString(extractor.getTimeStamp()),
|
assertTrue(Integer.toString(extractor.getTimeStamp()),
|
||||||
|
@ -11,6 +11,7 @@ import org.acra.config.ACRAConfiguration;
|
|||||||
import org.acra.config.ACRAConfigurationException;
|
import org.acra.config.ACRAConfigurationException;
|
||||||
import org.acra.config.ConfigurationBuilder;
|
import org.acra.config.ConfigurationBuilder;
|
||||||
import org.acra.sender.ReportSenderFactory;
|
import org.acra.sender.ReportSenderFactory;
|
||||||
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.report.AcraReportSenderFactory;
|
import org.schabi.newpipe.report.AcraReportSenderFactory;
|
||||||
import org.schabi.newpipe.report.ErrorActivity;
|
import org.schabi.newpipe.report.ErrorActivity;
|
||||||
import org.schabi.newpipe.settings.SettingsActivity;
|
import org.schabi.newpipe.settings.SettingsActivity;
|
||||||
@ -60,6 +61,9 @@ public class App extends Application {
|
|||||||
"Could not initialize ACRA crash report", R.string.app_ui_crash));
|
"Could not initialize ACRA crash report", R.string.app_ui_crash));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//init NewPipe
|
||||||
|
NewPipe.init(new Downloader());
|
||||||
|
|
||||||
// Initialize image loader
|
// Initialize image loader
|
||||||
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).build();
|
ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(this).build();
|
||||||
ImageLoader.getInstance().init(config);
|
ImageLoader.getInstance().init(config);
|
||||||
|
@ -23,8 +23,8 @@ import org.schabi.newpipe.detail.VideoItemDetailFragment;
|
|||||||
import org.schabi.newpipe.extractor.ChannelExtractor;
|
import org.schabi.newpipe.extractor.ChannelExtractor;
|
||||||
import org.schabi.newpipe.extractor.ChannelInfo;
|
import org.schabi.newpipe.extractor.ChannelInfo;
|
||||||
import org.schabi.newpipe.extractor.ExtractionException;
|
import org.schabi.newpipe.extractor.ExtractionException;
|
||||||
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.ParsingException;
|
import org.schabi.newpipe.extractor.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.info_list.InfoItemBuilder;
|
import org.schabi.newpipe.info_list.InfoItemBuilder;
|
||||||
import org.schabi.newpipe.info_list.InfoListAdapter;
|
import org.schabi.newpipe.info_list.InfoListAdapter;
|
||||||
@ -188,9 +188,9 @@ public class ChannelActivity extends AppCompatActivity {
|
|||||||
public void run() {
|
public void run() {
|
||||||
StreamingService service = null;
|
StreamingService service = null;
|
||||||
try {
|
try {
|
||||||
service = ServiceList.getService(serviceId);
|
service = NewPipe.getService(serviceId);
|
||||||
ChannelExtractor extractor = service.getChannelExtractorInstance(
|
ChannelExtractor extractor = service.getChannelExtractorInstance(
|
||||||
channelUrl, pageNumber, new Downloader());
|
channelUrl, pageNumber);
|
||||||
|
|
||||||
final ChannelInfo info = ChannelInfo.getInfo(extractor, new Downloader());
|
final ChannelInfo info = ChannelInfo.getInfo(extractor, new Downloader());
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import com.nostra13.universalimageloader.core.assist.FailReason;
|
|||||||
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
|
import com.nostra13.universalimageloader.core.listener.ImageLoadingListener;
|
||||||
|
|
||||||
import org.schabi.newpipe.report.ErrorActivity;
|
import org.schabi.newpipe.report.ErrorActivity;
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Christian Schabesberger on 01.08.16.
|
* Created by Christian Schabesberger on 01.08.16.
|
||||||
@ -50,7 +50,7 @@ public class ImageErrorLoadingListener implements ImageLoadingListener {
|
|||||||
ErrorActivity.reportError(activity,
|
ErrorActivity.reportError(activity,
|
||||||
failReason.getCause(), null, rootView,
|
failReason.getCause(), null, rootView,
|
||||||
ErrorActivity.ErrorInfo.make(ErrorActivity.LOAD_IMAGE,
|
ErrorActivity.ErrorInfo.make(ErrorActivity.LOAD_IMAGE,
|
||||||
ServiceList.getNameOfService(serviceId), imageUri,
|
NewPipe.getNameOfService(serviceId), imageUri,
|
||||||
R.string.could_not_load_image));
|
R.string.could_not_load_image));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@ import org.schabi.newpipe.Downloader;
|
|||||||
import org.schabi.newpipe.report.ErrorActivity;
|
import org.schabi.newpipe.report.ErrorActivity;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.extractor.ParsingException;
|
import org.schabi.newpipe.extractor.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.StreamExtractor;
|
import org.schabi.newpipe.extractor.StreamExtractor;
|
||||||
import org.schabi.newpipe.extractor.StreamInfo;
|
import org.schabi.newpipe.extractor.StreamInfo;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
@ -51,7 +51,7 @@ public class StreamInfoWorker {
|
|||||||
StreamInfo streamInfo = null;
|
StreamInfo streamInfo = null;
|
||||||
StreamingService service = null;
|
StreamingService service = null;
|
||||||
try {
|
try {
|
||||||
service = ServiceList.getService(serviceId);
|
service = NewPipe.getService(serviceId);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
ErrorActivity.reportError(h, a, e, VideoItemDetailFragment.class, null,
|
ErrorActivity.reportError(h, a, e, VideoItemDetailFragment.class, null,
|
||||||
@ -60,7 +60,7 @@ public class StreamInfoWorker {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamExtractor = service.getExtractorInstance(videoUrl, new Downloader());
|
streamExtractor = service.getExtractorInstance(videoUrl);
|
||||||
streamInfo = StreamInfo.getVideoInfo(streamExtractor, new Downloader());
|
streamInfo = StreamInfo.getVideoInfo(streamExtractor, new Downloader());
|
||||||
|
|
||||||
final StreamInfo info = streamInfo;
|
final StreamInfo info = streamInfo;
|
||||||
|
@ -14,7 +14,7 @@ import android.widget.Toast;
|
|||||||
import org.schabi.newpipe.App;
|
import org.schabi.newpipe.App;
|
||||||
import org.schabi.newpipe.MainActivity;
|
import org.schabi.newpipe.MainActivity;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
|
|
||||||
|
|
||||||
@ -73,13 +73,13 @@ public class VideoItemDetailActivity extends AppCompatActivity {
|
|||||||
// this means the video was called though another app
|
// this means the video was called though another app
|
||||||
if (getIntent().getData() != null) {
|
if (getIntent().getData() != null) {
|
||||||
videoUrl = getIntent().getData().toString();
|
videoUrl = getIntent().getData().toString();
|
||||||
StreamingService[] serviceList = ServiceList.getServices();
|
StreamingService[] serviceList = NewPipe.getServices();
|
||||||
//StreamExtractor videoExtractor = null;
|
//StreamExtractor videoExtractor = null;
|
||||||
for (int i = 0; i < serviceList.length; i++) {
|
for (int i = 0; i < serviceList.length; i++) {
|
||||||
if (serviceList[i].getUrlIdHandlerInstance().acceptUrl(videoUrl)) {
|
if (serviceList[i].getUrlIdHandlerInstance().acceptUrl(videoUrl)) {
|
||||||
arguments.putInt(VideoItemDetailFragment.STREAMING_SERVICE, i);
|
arguments.putInt(VideoItemDetailFragment.STREAMING_SERVICE, i);
|
||||||
currentStreamingService = i;
|
currentStreamingService = i;
|
||||||
//videoExtractor = ServiceList.getService(i).getExtractorInstance();
|
//videoExtractor = NewPipe.getService(i).getExtractorInstance();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -52,7 +52,7 @@ import org.schabi.newpipe.R;
|
|||||||
import org.schabi.newpipe.download.DownloadDialog;
|
import org.schabi.newpipe.download.DownloadDialog;
|
||||||
import org.schabi.newpipe.extractor.AudioStream;
|
import org.schabi.newpipe.extractor.AudioStream;
|
||||||
import org.schabi.newpipe.extractor.MediaFormat;
|
import org.schabi.newpipe.extractor.MediaFormat;
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.StreamInfo;
|
import org.schabi.newpipe.extractor.StreamInfo;
|
||||||
import org.schabi.newpipe.extractor.VideoStream;
|
import org.schabi.newpipe.extractor.VideoStream;
|
||||||
import org.schabi.newpipe.player.BackgroundPlayer;
|
import org.schabi.newpipe.player.BackgroundPlayer;
|
||||||
@ -306,7 +306,7 @@ public class VideoItemDetailFragment extends Fragment {
|
|||||||
ErrorActivity.reportError(getActivity(),
|
ErrorActivity.reportError(getActivity(),
|
||||||
failReason.getCause(), null, rootView,
|
failReason.getCause(), null, rootView,
|
||||||
ErrorActivity.ErrorInfo.make(ErrorActivity.LOAD_IMAGE,
|
ErrorActivity.ErrorInfo.make(ErrorActivity.LOAD_IMAGE,
|
||||||
ServiceList.getNameOfService(info.service_id), imageUri,
|
NewPipe.getNameOfService(info.service_id), imageUri,
|
||||||
R.string.could_not_load_thumbnails));
|
R.string.could_not_load_thumbnails));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,15 +26,13 @@ public abstract class ChannelExtractor {
|
|||||||
private int serviceId;
|
private int serviceId;
|
||||||
private String url;
|
private String url;
|
||||||
private UrlIdHandler urlIdHandler;
|
private UrlIdHandler urlIdHandler;
|
||||||
private Downloader downloader;
|
|
||||||
private StreamPreviewInfoCollector previewInfoCollector;
|
private StreamPreviewInfoCollector previewInfoCollector;
|
||||||
private int page = -1;
|
private int page = -1;
|
||||||
|
|
||||||
public ChannelExtractor(UrlIdHandler urlIdHandler, String url, int page, Downloader dl, int serviceId)
|
public ChannelExtractor(UrlIdHandler urlIdHandler, String url, int page, int serviceId)
|
||||||
throws ExtractionException, IOException {
|
throws ExtractionException, IOException {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.page = page;
|
this.page = page;
|
||||||
this.downloader = dl;
|
|
||||||
this.serviceId = serviceId;
|
this.serviceId = serviceId;
|
||||||
this.urlIdHandler = urlIdHandler;
|
this.urlIdHandler = urlIdHandler;
|
||||||
previewInfoCollector = new StreamPreviewInfoCollector(urlIdHandler, serviceId);
|
previewInfoCollector = new StreamPreviewInfoCollector(urlIdHandler, serviceId);
|
||||||
@ -42,7 +40,6 @@ public abstract class ChannelExtractor {
|
|||||||
|
|
||||||
public String getUrl() { return url; }
|
public String getUrl() { return url; }
|
||||||
public UrlIdHandler getUrlIdHandler() { return urlIdHandler; }
|
public UrlIdHandler getUrlIdHandler() { return urlIdHandler; }
|
||||||
public Downloader getDownloader() { return downloader; }
|
|
||||||
public StreamPreviewInfoCollector getStreamPreviewInfoCollector() {
|
public StreamPreviewInfoCollector getStreamPreviewInfoCollector() {
|
||||||
return previewInfoCollector;
|
return previewInfoCollector;
|
||||||
}
|
}
|
||||||
|
@ -24,11 +24,9 @@ public class ExtractionException extends Exception {
|
|||||||
public ExtractionException(String message) {
|
public ExtractionException(String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExtractionException(Throwable cause) {
|
public ExtractionException(Throwable cause) {
|
||||||
super(cause);
|
super(cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ExtractionException(String message, Throwable cause) {
|
public ExtractionException(String message, Throwable cause) {
|
||||||
super(message, cause);
|
super(message, cause);
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import org.schabi.newpipe.extractor.services.youtube.YoutubeService;
|
|||||||
* Created by Christian Schabesberger on 23.08.15.
|
* Created by Christian Schabesberger on 23.08.15.
|
||||||
*
|
*
|
||||||
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
|
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
|
||||||
* ServiceList.java is part of NewPipe.
|
* NewPipe.java is part of NewPipe.
|
||||||
*
|
*
|
||||||
* NewPipe is free software: you can redistribute it and/or modify
|
* NewPipe is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -26,20 +26,24 @@ import org.schabi.newpipe.extractor.services.youtube.YoutubeService;
|
|||||||
* Currently only Youtube until the API becomes more stable.*/
|
* Currently only Youtube until the API becomes more stable.*/
|
||||||
|
|
||||||
@SuppressWarnings("ALL")
|
@SuppressWarnings("ALL")
|
||||||
public class ServiceList {
|
public class NewPipe {
|
||||||
|
|
||||||
private ServiceList() {
|
private NewPipe() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String TAG = ServiceList.class.toString();
|
private static final String TAG = NewPipe.class.toString();
|
||||||
private static final StreamingService[] services = {
|
|
||||||
|
private static final StreamingService[] serviceList = {
|
||||||
new YoutubeService(0)
|
new YoutubeService(0)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
private static Downloader downloader = null;
|
||||||
|
|
||||||
public static StreamingService[] getServices() {
|
public static StreamingService[] getServices() {
|
||||||
return services;
|
return serviceList;
|
||||||
}
|
}
|
||||||
public static StreamingService getService(int serviceId)throws ExtractionException {
|
public static StreamingService getService(int serviceId)throws ExtractionException {
|
||||||
for(StreamingService s : services) {
|
for(StreamingService s : serviceList) {
|
||||||
if(s.getServiceId() == serviceId) {
|
if(s.getServiceId() == serviceId) {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
@ -47,7 +51,7 @@ public class ServiceList {
|
|||||||
throw new ExtractionException("Service not known: " + Integer.toString(serviceId));
|
throw new ExtractionException("Service not known: " + Integer.toString(serviceId));
|
||||||
}
|
}
|
||||||
public static StreamingService getService(String serviceName) throws ExtractionException {
|
public static StreamingService getService(String serviceName) throws ExtractionException {
|
||||||
return services[getIdOfService(serviceName)];
|
return serviceList[getIdOfService(serviceName)];
|
||||||
}
|
}
|
||||||
public static String getNameOfService(int id) {
|
public static String getNameOfService(int id) {
|
||||||
try {
|
try {
|
||||||
@ -59,11 +63,19 @@ public class ServiceList {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static int getIdOfService(String serviceName) throws ExtractionException {
|
public static int getIdOfService(String serviceName) throws ExtractionException {
|
||||||
for(int i = 0; i < services.length; i++) {
|
for(int i = 0; i < serviceList.length; i++) {
|
||||||
if(services[i].getServiceInfo().name.equals(serviceName)) {
|
if(serviceList[i].getServiceInfo().name.equals(serviceName)) {
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new ExtractionException("Error: Service " + serviceName + " not known.");
|
throw new ExtractionException("Error: Service " + serviceName + " not known.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void init(Downloader d) {
|
||||||
|
downloader = d;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Downloader getDownloader() {
|
||||||
|
return downloader;
|
||||||
|
}
|
||||||
}
|
}
|
@ -42,11 +42,11 @@ public abstract class SearchEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public abstract List<String> suggestionList(
|
public abstract List<String> suggestionList(
|
||||||
String query,String contentCountry, Downloader dl)
|
String query,String contentCountry)
|
||||||
throws ExtractionException, IOException;
|
throws ExtractionException, IOException;
|
||||||
|
|
||||||
//Result search(String query, int page);
|
//Result search(String query, int page);
|
||||||
public abstract StreamPreviewInfoSearchCollector search(
|
public abstract StreamPreviewInfoSearchCollector search(
|
||||||
String query, int page, String contentCountry, Downloader dl)
|
String query, int page, String contentCountry)
|
||||||
throws ExtractionException, IOException;
|
throws ExtractionException, IOException;
|
||||||
}
|
}
|
||||||
|
@ -26,10 +26,10 @@ import java.util.Vector;
|
|||||||
|
|
||||||
public class SearchResult {
|
public class SearchResult {
|
||||||
public static SearchResult getSearchResult(SearchEngine engine, String query,
|
public static SearchResult getSearchResult(SearchEngine engine, String query,
|
||||||
int page, String languageCode, Downloader dl)
|
int page, String languageCode)
|
||||||
throws ExtractionException, IOException {
|
throws ExtractionException, IOException {
|
||||||
|
|
||||||
SearchResult result = engine.search(query, page, languageCode, dl).getSearchResult();
|
SearchResult result = engine.search(query, page, languageCode).getSearchResult();
|
||||||
if(result.resultList.isEmpty()) {
|
if(result.resultList.isEmpty()) {
|
||||||
if(result.suggestion.isEmpty()) {
|
if(result.suggestion.isEmpty()) {
|
||||||
throw new ExtractionException("Empty result despite no error");
|
throw new ExtractionException("Empty result despite no error");
|
||||||
|
@ -31,7 +31,6 @@ public abstract class StreamExtractor {
|
|||||||
private int serviceId;
|
private int serviceId;
|
||||||
private String url;
|
private String url;
|
||||||
private UrlIdHandler urlIdHandler;
|
private UrlIdHandler urlIdHandler;
|
||||||
private Downloader downloader;
|
|
||||||
private StreamPreviewInfoCollector previewInfoCollector;
|
private StreamPreviewInfoCollector previewInfoCollector;
|
||||||
|
|
||||||
public class ExctractorInitException extends ExtractionException {
|
public class ExctractorInitException extends ExtractionException {
|
||||||
@ -55,7 +54,7 @@ public abstract class StreamExtractor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public StreamExtractor(UrlIdHandler urlIdHandler, String url, Downloader dl, int serviceId) {
|
public StreamExtractor(UrlIdHandler urlIdHandler, String url, int serviceId) {
|
||||||
this.serviceId = serviceId;
|
this.serviceId = serviceId;
|
||||||
this.urlIdHandler = urlIdHandler;
|
this.urlIdHandler = urlIdHandler;
|
||||||
previewInfoCollector = new StreamPreviewInfoCollector(urlIdHandler, serviceId);
|
previewInfoCollector = new StreamPreviewInfoCollector(urlIdHandler, serviceId);
|
||||||
@ -73,10 +72,6 @@ public abstract class StreamExtractor {
|
|||||||
return urlIdHandler;
|
return urlIdHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Downloader getDownloader() {
|
|
||||||
return downloader;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract int getTimeStamp() throws ParsingException;
|
public abstract int getTimeStamp() throws ParsingException;
|
||||||
public abstract String getTitle() throws ParsingException;
|
public abstract String getTitle() throws ParsingException;
|
||||||
public abstract String getDescription() throws ParsingException;
|
public abstract String getDescription() throws ParsingException;
|
||||||
|
@ -35,12 +35,12 @@ public abstract class StreamingService {
|
|||||||
|
|
||||||
public abstract ServiceInfo getServiceInfo();
|
public abstract ServiceInfo getServiceInfo();
|
||||||
|
|
||||||
public abstract StreamExtractor getExtractorInstance(String url, Downloader downloader)
|
public abstract StreamExtractor getExtractorInstance(String url)
|
||||||
throws IOException, ExtractionException;
|
throws IOException, ExtractionException;
|
||||||
public abstract SearchEngine getSearchEngineInstance(Downloader downloader);
|
public abstract SearchEngine getSearchEngineInstance();
|
||||||
public abstract UrlIdHandler getUrlIdHandlerInstance();
|
public abstract UrlIdHandler getUrlIdHandlerInstance();
|
||||||
public abstract UrlIdHandler getChannelUrlIdHandlerInstance();
|
public abstract UrlIdHandler getChannelUrlIdHandlerInstance();
|
||||||
public abstract ChannelExtractor getChannelExtractorInstance(String url, int page, Downloader downloader)
|
public abstract ChannelExtractor getChannelExtractorInstance(String url, int page)
|
||||||
throws ExtractionException, IOException;
|
throws ExtractionException, IOException;
|
||||||
|
|
||||||
public final int getServiceId() {
|
public final int getServiceId() {
|
||||||
|
@ -11,6 +11,7 @@ import org.schabi.newpipe.extractor.AbstractVideoInfo;
|
|||||||
import org.schabi.newpipe.extractor.ChannelExtractor;
|
import org.schabi.newpipe.extractor.ChannelExtractor;
|
||||||
import org.schabi.newpipe.extractor.Downloader;
|
import org.schabi.newpipe.extractor.Downloader;
|
||||||
import org.schabi.newpipe.extractor.ExtractionException;
|
import org.schabi.newpipe.extractor.ExtractionException;
|
||||||
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.Parser;
|
import org.schabi.newpipe.extractor.Parser;
|
||||||
import org.schabi.newpipe.extractor.ParsingException;
|
import org.schabi.newpipe.extractor.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.StreamPreviewInfoCollector;
|
import org.schabi.newpipe.extractor.StreamPreviewInfoCollector;
|
||||||
@ -46,7 +47,6 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||||||
|
|
||||||
// private CSSOMParser cssParser = new CSSOMParser(new SACParserCSS3());
|
// private CSSOMParser cssParser = new CSSOMParser(new SACParserCSS3());
|
||||||
|
|
||||||
private Downloader downloader;
|
|
||||||
private Document doc = null;
|
private Document doc = null;
|
||||||
|
|
||||||
private boolean isAjaxPage = false;
|
private boolean isAjaxPage = false;
|
||||||
@ -59,12 +59,13 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||||||
// this request url.
|
// this request url.
|
||||||
private static String nextPageUrl = "";
|
private static String nextPageUrl = "";
|
||||||
|
|
||||||
public YoutubeChannelExtractor(UrlIdHandler urlIdHandler, String url, int page, Downloader dl, int serviceId)
|
public YoutubeChannelExtractor(UrlIdHandler urlIdHandler, String url, int page, int serviceId)
|
||||||
throws ExtractionException, IOException {
|
throws ExtractionException, IOException {
|
||||||
super(urlIdHandler, url, page, dl, serviceId);
|
super(urlIdHandler, url, page, serviceId);
|
||||||
|
|
||||||
|
Downloader downloader = NewPipe.getDownloader();
|
||||||
|
|
||||||
url = urlIdHandler.cleanUrl(url) ; //+ "/video?veiw=0&flow=list&sort=dd";
|
url = urlIdHandler.cleanUrl(url) ; //+ "/video?veiw=0&flow=list&sort=dd";
|
||||||
downloader = dl;
|
|
||||||
|
|
||||||
if(page == 0) {
|
if(page == 0) {
|
||||||
if (isUserUrl(url)) {
|
if (isUserUrl(url)) {
|
||||||
|
@ -5,6 +5,7 @@ import org.jsoup.nodes.Document;
|
|||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
import org.schabi.newpipe.extractor.Downloader;
|
import org.schabi.newpipe.extractor.Downloader;
|
||||||
import org.schabi.newpipe.extractor.ExtractionException;
|
import org.schabi.newpipe.extractor.ExtractionException;
|
||||||
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.ParsingException;
|
import org.schabi.newpipe.extractor.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.SearchEngine;
|
import org.schabi.newpipe.extractor.SearchEngine;
|
||||||
import org.schabi.newpipe.extractor.StreamPreviewInfoExtractor;
|
import org.schabi.newpipe.extractor.StreamPreviewInfoExtractor;
|
||||||
@ -55,20 +56,11 @@ public class YoutubeSearchEngine extends SearchEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StreamPreviewInfoSearchCollector search(String query, int page, String languageCode, Downloader downloader)
|
public StreamPreviewInfoSearchCollector search(String query, int page, String languageCode)
|
||||||
throws IOException, ExtractionException {
|
throws IOException, ExtractionException {
|
||||||
StreamPreviewInfoSearchCollector collector = getStreamPreviewInfoSearchCollector();
|
StreamPreviewInfoSearchCollector collector = getStreamPreviewInfoSearchCollector();
|
||||||
|
|
||||||
/* Cant use Uri.Bilder since it's android code.
|
Downloader downloader = NewPipe.getDownloader();
|
||||||
// Android code is baned from the extractor side.
|
|
||||||
Uri.Builder builder = new Uri.Builder();
|
|
||||||
builder.scheme("https")
|
|
||||||
.authority("www.youtube.com")
|
|
||||||
.appendPath("results")
|
|
||||||
.appendQueryParameter("search_query", query)
|
|
||||||
.appendQueryParameter("page", Integer.toString(page))
|
|
||||||
.appendQueryParameter("filters", "video");
|
|
||||||
*/
|
|
||||||
|
|
||||||
String url = "https://www.youtube.com/results"
|
String url = "https://www.youtube.com/results"
|
||||||
+ "?search_query=" + URLEncoder.encode(query, CHARSET_UTF_8)
|
+ "?search_query=" + URLEncoder.encode(query, CHARSET_UTF_8)
|
||||||
@ -127,24 +119,13 @@ public class YoutubeSearchEngine extends SearchEngine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> suggestionList(String query, String contentCountry, Downloader dl)
|
public List<String> suggestionList(String query, String contentCountry)
|
||||||
throws IOException, ParsingException {
|
throws IOException, ParsingException {
|
||||||
|
|
||||||
List<String> suggestions = new ArrayList<>();
|
List<String> suggestions = new ArrayList<>();
|
||||||
|
|
||||||
/* Cant use Uri.Bilder since it's android code.
|
Downloader dl = NewPipe.getDownloader();
|
||||||
// Android code is baned from the extractor side.
|
|
||||||
Uri.Builder builder = new Uri.Builder();
|
|
||||||
builder.scheme("https")
|
|
||||||
.authority("suggestqueries.google.com")
|
|
||||||
.appendPath("complete")
|
|
||||||
.appendPath("search")
|
|
||||||
.appendQueryParameter("client", "")
|
|
||||||
.appendQueryParameter("output", "toolbar")
|
|
||||||
.appendQueryParameter("ds", "yt")
|
|
||||||
.appendQueryParameter("hl",contentCountry)
|
|
||||||
.appendQueryParameter("q", query);
|
|
||||||
*/
|
|
||||||
String url = "https://suggestqueries.google.com/complete/search"
|
String url = "https://suggestqueries.google.com/complete/search"
|
||||||
+ "?client=" + ""
|
+ "?client=" + ""
|
||||||
+ "&output=" + "toolbar"
|
+ "&output=" + "toolbar"
|
||||||
|
@ -44,18 +44,18 @@ public class YoutubeService extends StreamingService {
|
|||||||
return serviceInfo;
|
return serviceInfo;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public StreamExtractor getExtractorInstance(String url, Downloader downloader)
|
public StreamExtractor getExtractorInstance(String url)
|
||||||
throws ExtractionException, IOException {
|
throws ExtractionException, IOException {
|
||||||
UrlIdHandler urlIdHandler = new YoutubeStreamUrlIdHandler();
|
UrlIdHandler urlIdHandler = new YoutubeStreamUrlIdHandler();
|
||||||
if(urlIdHandler.acceptUrl(url)) {
|
if(urlIdHandler.acceptUrl(url)) {
|
||||||
return new YoutubeStreamExtractor(urlIdHandler, url, downloader, getServiceId());
|
return new YoutubeStreamExtractor(urlIdHandler, url, getServiceId());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new IllegalArgumentException("supplied String is not a valid Youtube URL");
|
throw new IllegalArgumentException("supplied String is not a valid Youtube URL");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public SearchEngine getSearchEngineInstance(Downloader downloader) {
|
public SearchEngine getSearchEngineInstance() {
|
||||||
return new YoutubeSearchEngine(getUrlIdHandlerInstance(), getServiceId());
|
return new YoutubeSearchEngine(getUrlIdHandlerInstance(), getServiceId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,8 +70,8 @@ public class YoutubeService extends StreamingService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChannelExtractor getChannelExtractorInstance(String url, int page, Downloader downloader)
|
public ChannelExtractor getChannelExtractorInstance(String url, int page)
|
||||||
throws ExtractionException, IOException {
|
throws ExtractionException, IOException {
|
||||||
return new YoutubeChannelExtractor(getChannelUrlIdHandlerInstance(), url, page, downloader, getServiceId());
|
return new YoutubeChannelExtractor(getChannelUrlIdHandlerInstance(), url, page, getServiceId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import org.schabi.newpipe.extractor.AbstractVideoInfo;
|
|||||||
import org.schabi.newpipe.extractor.AudioStream;
|
import org.schabi.newpipe.extractor.AudioStream;
|
||||||
import org.schabi.newpipe.extractor.ExtractionException;
|
import org.schabi.newpipe.extractor.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.Downloader;
|
import org.schabi.newpipe.extractor.Downloader;
|
||||||
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.Parser;
|
import org.schabi.newpipe.extractor.Parser;
|
||||||
import org.schabi.newpipe.extractor.ParsingException;
|
import org.schabi.newpipe.extractor.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.StreamInfo;
|
import org.schabi.newpipe.extractor.StreamInfo;
|
||||||
@ -185,15 +186,12 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||||||
UrlIdHandler urlidhandler = new YoutubeStreamUrlIdHandler();
|
UrlIdHandler urlidhandler = new YoutubeStreamUrlIdHandler();
|
||||||
String pageUrl = "";
|
String pageUrl = "";
|
||||||
|
|
||||||
private Downloader downloader;
|
public YoutubeStreamExtractor(UrlIdHandler urlIdHandler, String pageUrl, int serviceId)
|
||||||
|
|
||||||
public YoutubeStreamExtractor(UrlIdHandler urlIdHandler, String pageUrl,
|
|
||||||
Downloader dl, int serviceId)
|
|
||||||
throws ExtractionException, IOException {
|
throws ExtractionException, IOException {
|
||||||
super(urlIdHandler ,pageUrl, dl, serviceId);
|
super(urlIdHandler, pageUrl, serviceId);
|
||||||
//most common videoInfo fields are now set in our superclass, for all services
|
//most common videoInfo fields are now set in our superclass, for all services
|
||||||
downloader = dl;
|
|
||||||
this.pageUrl = pageUrl;
|
this.pageUrl = pageUrl;
|
||||||
|
Downloader downloader = NewPipe.getDownloader();
|
||||||
String pageContent = downloader.download(urlidhandler.cleanUrl(pageUrl));
|
String pageContent = downloader.download(urlidhandler.cleanUrl(pageUrl));
|
||||||
doc = Jsoup.parse(pageContent, pageUrl);
|
doc = Jsoup.parse(pageContent, pageUrl);
|
||||||
JSONObject ytPlayerConfig;
|
JSONObject ytPlayerConfig;
|
||||||
@ -284,6 +282,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||||||
|
|
||||||
private String getPlayerUrlFromRestrictedVideo(String pageUrl) throws ParsingException {
|
private String getPlayerUrlFromRestrictedVideo(String pageUrl) throws ParsingException {
|
||||||
try {
|
try {
|
||||||
|
Downloader downloader = NewPipe.getDownloader();
|
||||||
String playerUrl = "";
|
String playerUrl = "";
|
||||||
String videoId = urlidhandler.getId(pageUrl);
|
String videoId = urlidhandler.getId(pageUrl);
|
||||||
String embedUrl = "https://www.youtube.com/embed/" + videoId;
|
String embedUrl = "https://www.youtube.com/embed/" + videoId;
|
||||||
@ -788,6 +787,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||||||
String decryptionCode;
|
String decryptionCode;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Downloader downloader = NewPipe.getDownloader();
|
||||||
String playerCode = downloader.download(playerUrl);
|
String playerCode = downloader.download(playerUrl);
|
||||||
|
|
||||||
decryptionFuncName =
|
decryptionFuncName =
|
||||||
|
@ -18,13 +18,13 @@ import android.view.inputmethod.InputMethodManager;
|
|||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.info_list.InfoItemBuilder;
|
import org.schabi.newpipe.info_list.InfoItemBuilder;
|
||||||
import org.schabi.newpipe.report.ErrorActivity;
|
import org.schabi.newpipe.report.ErrorActivity;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.detail.VideoItemDetailActivity;
|
import org.schabi.newpipe.detail.VideoItemDetailActivity;
|
||||||
import org.schabi.newpipe.detail.VideoItemDetailFragment;
|
import org.schabi.newpipe.detail.VideoItemDetailFragment;
|
||||||
import org.schabi.newpipe.extractor.SearchResult;
|
import org.schabi.newpipe.extractor.SearchResult;
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
|
||||||
import org.schabi.newpipe.info_list.InfoListAdapter;
|
import org.schabi.newpipe.info_list.InfoListAdapter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -72,7 +72,7 @@ public class SearchInfoItemFragment extends Fragment {
|
|||||||
ErrorActivity.reportError(a, e, null,
|
ErrorActivity.reportError(a, e, null,
|
||||||
a.findViewById(android.R.id.content),
|
a.findViewById(android.R.id.content),
|
||||||
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,
|
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,
|
||||||
ServiceList.getNameOfService(streamingServiceId),
|
NewPipe.getNameOfService(streamingServiceId),
|
||||||
"Could not get widget with focus", R.string.general_error));
|
"Could not get widget with focus", R.string.general_error));
|
||||||
}
|
}
|
||||||
// clear focus
|
// clear focus
|
||||||
@ -137,13 +137,13 @@ public class SearchInfoItemFragment extends Fragment {
|
|||||||
streamingServiceId = savedInstanceState.getInt(STREAMING_SERVICE);
|
streamingServiceId = savedInstanceState.getInt(STREAMING_SERVICE);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
streamingServiceId = ServiceList.getIdOfService("Youtube");
|
streamingServiceId = NewPipe.getIdOfService("Youtube");
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
ErrorActivity.reportError(getActivity(), e, null,
|
ErrorActivity.reportError(getActivity(), e, null,
|
||||||
getActivity().findViewById(android.R.id.content),
|
getActivity().findViewById(android.R.id.content),
|
||||||
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,
|
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,
|
||||||
ServiceList.getNameOfService(streamingServiceId),
|
NewPipe.getNameOfService(streamingServiceId),
|
||||||
"", R.string.general_error));
|
"", R.string.general_error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ import org.schabi.newpipe.R;
|
|||||||
import org.schabi.newpipe.extractor.ExtractionException;
|
import org.schabi.newpipe.extractor.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.SearchEngine;
|
import org.schabi.newpipe.extractor.SearchEngine;
|
||||||
import org.schabi.newpipe.extractor.SearchResult;
|
import org.schabi.newpipe.extractor.SearchResult;
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -85,8 +85,8 @@ public class SearchWorker {
|
|||||||
SearchEngine engine = null;
|
SearchEngine engine = null;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
engine = ServiceList.getService(serviceId)
|
engine = NewPipe.getService(serviceId)
|
||||||
.getSearchEngineInstance(new Downloader());
|
.getSearchEngineInstance();
|
||||||
} catch(ExtractionException e) {
|
} catch(ExtractionException e) {
|
||||||
ErrorActivity.reportError(h, a, e, null, null,
|
ErrorActivity.reportError(h, a, e, null, null,
|
||||||
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,
|
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,
|
||||||
@ -100,8 +100,7 @@ public class SearchWorker {
|
|||||||
String searchLanguage = sp.getString(searchLanguageKey,
|
String searchLanguage = sp.getString(searchLanguageKey,
|
||||||
a.getString(R.string.default_language_value));
|
a.getString(R.string.default_language_value));
|
||||||
result = SearchResult
|
result = SearchResult
|
||||||
.getSearchResult(engine, query, page, searchLanguage, new Downloader());
|
.getSearchResult(engine, query, page, searchLanguage);
|
||||||
|
|
||||||
if(runs) {
|
if(runs) {
|
||||||
h.post(new ResultRunnable(result, requestId));
|
h.post(new ResultRunnable(result, requestId));
|
||||||
}
|
}
|
||||||
|
@ -7,11 +7,11 @@ import android.preference.PreferenceManager;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.schabi.newpipe.Downloader;
|
import org.schabi.newpipe.Downloader;
|
||||||
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.report.ErrorActivity;
|
import org.schabi.newpipe.report.ErrorActivity;
|
||||||
import org.schabi.newpipe.R;
|
import org.schabi.newpipe.R;
|
||||||
import org.schabi.newpipe.extractor.ExtractionException;
|
import org.schabi.newpipe.extractor.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.SearchEngine;
|
import org.schabi.newpipe.extractor.SearchEngine;
|
||||||
import org.schabi.newpipe.extractor.ServiceList;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -71,17 +71,17 @@ public class SuggestionSearchRunnable implements Runnable{
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
SearchEngine engine =
|
SearchEngine engine =
|
||||||
ServiceList.getService(serviceId).getSearchEngineInstance(new Downloader());
|
NewPipe.getService(serviceId).getSearchEngineInstance();
|
||||||
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(a);
|
SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(a);
|
||||||
String searchLanguageKey = a.getString(R.string.search_language_key);
|
String searchLanguageKey = a.getString(R.string.search_language_key);
|
||||||
String searchLanguage = sp.getString(searchLanguageKey,
|
String searchLanguage = sp.getString(searchLanguageKey,
|
||||||
a.getString(R.string.default_language_value));
|
a.getString(R.string.default_language_value));
|
||||||
List<String> suggestions = engine.suggestionList(query,searchLanguage,new Downloader());
|
List<String> suggestions = engine.suggestionList(query, searchLanguage);
|
||||||
h.post(new SuggestionResultRunnable(suggestions, adapter));
|
h.post(new SuggestionResultRunnable(suggestions, adapter));
|
||||||
} catch (ExtractionException e) {
|
} catch (ExtractionException e) {
|
||||||
ErrorActivity.reportError(h, a, e, null, a.findViewById(android.R.id.content),
|
ErrorActivity.reportError(h, a, e, null, a.findViewById(android.R.id.content),
|
||||||
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,
|
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,
|
||||||
ServiceList.getNameOfService(serviceId), query, R.string.parsing_error));
|
NewPipe.getNameOfService(serviceId), query, R.string.parsing_error));
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
postNewErrorToast(h, R.string.network_error);
|
postNewErrorToast(h, R.string.network_error);
|
||||||
@ -89,7 +89,7 @@ public class SuggestionSearchRunnable implements Runnable{
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ErrorActivity.reportError(h, a, e, null, a.findViewById(android.R.id.content),
|
ErrorActivity.reportError(h, a, e, null, a.findViewById(android.R.id.content),
|
||||||
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,
|
ErrorActivity.ErrorInfo.make(ErrorActivity.SEARCHED,
|
||||||
ServiceList.getNameOfService(serviceId), query, R.string.general_error));
|
NewPipe.getNameOfService(serviceId), query, R.string.general_error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user