renamed Extractor into VideoExtractor

This commit is contained in:
Christian Schabesberger 2015-11-26 17:29:26 +01:00
parent 7f86872139
commit d6d144c927
7 changed files with 26 additions and 28 deletions

View file

@ -5,12 +5,11 @@ import android.os.Bundle;
import android.preference.PreferenceManager;
import android.support.v4.app.NavUtils;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.Toast;
import org.schabi.newpipe.services.Extractor;
import org.schabi.newpipe.services.VideoExtractor;
import org.schabi.newpipe.services.ServiceList;
import org.schabi.newpipe.services.StreamingService;
@ -64,14 +63,13 @@ public class VideoItemDetailActivity extends AppCompatActivity {
// this means the video was called though another app
if (getIntent().getData() != null) {
videoUrl = getIntent().getData().toString();
//Log.i(TAG, "video URL passed:\"" + videoUrl + "\"");
StreamingService[] serviceList = ServiceList.getServices();
Extractor extractor = null;
VideoExtractor videoExtractor = null;
for (int i = 0; i < serviceList.length; i++) {
if (serviceList[i].acceptUrl(videoUrl)) {
arguments.putInt(VideoItemDetailFragment.STREAMING_SERVICE, i);
currentStreamingService = i;
//extractor = ServiceList.getService(i).getExtractorInstance();
//videoExtractor = ServiceList.getService(i).getExtractorInstance();
break;
}
}
@ -80,7 +78,7 @@ public class VideoItemDetailActivity extends AppCompatActivity {
.show();
}
//arguments.putString(VideoItemDetailFragment.VIDEO_URL,
// extractor.getVideoUrl(extractor.getVideoId(videoUrl)));//cleans URL
// videoExtractor.getVideoUrl(videoExtractor.getVideoId(videoUrl)));//cleans URL
arguments.putString(VideoItemDetailFragment.VIDEO_URL, videoUrl);
arguments.putBoolean(VideoItemDetailFragment.AUTO_PLAY,

View file

@ -39,7 +39,7 @@ import java.util.Date;
import java.util.Locale;
import java.util.Vector;
import org.schabi.newpipe.services.Extractor;
import org.schabi.newpipe.services.VideoExtractor;
import org.schabi.newpipe.services.ServiceList;
import org.schabi.newpipe.services.StreamingService;
@ -79,7 +79,7 @@ public class VideoItemDetailFragment extends Fragment {
private ActionBarHandler actionBarHandler;
private boolean autoPlayEnabled = false;
private Thread extractorThread = null;
private Thread videoExtractorThread = null;
private VideoInfo currentVideoInfo = null;
private boolean showNextVideoItem = false;
@ -89,21 +89,21 @@ public class VideoItemDetailFragment extends Fragment {
private OnInvokeCreateOptionsMenuListener onInvokeCreateOptionsMenuListener = null;
private class ExtractorRunnable implements Runnable {
private class VideoExtractorRunnable implements Runnable {
private Handler h = new Handler();
private Extractor extractor;
private VideoExtractor videoExtractor;
private StreamingService service;
private String videoUrl;
public ExtractorRunnable(String videoUrl, StreamingService service, VideoItemDetailFragment f) {
public VideoExtractorRunnable(String videoUrl, StreamingService service, VideoItemDetailFragment f) {
this.service = service;
this.videoUrl = videoUrl;
}
@Override
public void run() {
try {
this.extractor = service.getExtractorInstance(videoUrl);
VideoInfo videoInfo = extractor.getVideoInfo();
this.videoExtractor = service.getExtractorInstance(videoUrl);
VideoInfo videoInfo = videoExtractor.getVideoInfo();
h.post(new VideoResultReturnedRunnable(videoInfo));
if (videoInfo.videoAvailableStatus == VideoInfo.VIDEO_AVAILABLE) {
h.post(new SetThumbnailRunnable(
@ -360,11 +360,11 @@ public class VideoItemDetailFragment extends Fragment {
try {
StreamingService streamingService = ServiceList.getService(
getArguments().getInt(STREAMING_SERVICE));
extractorThread = new Thread(new ExtractorRunnable(
videoExtractorThread = new Thread(new VideoExtractorRunnable(
getArguments().getString(VIDEO_URL), streamingService, this));
autoPlayEnabled = getArguments().getBoolean(AUTO_PLAY);
extractorThread.start();
videoExtractorThread.start();
} catch (Exception e) {
e.printStackTrace();
}

View file

@ -25,7 +25,7 @@ public interface StreamingService {
public String name = "";
}
ServiceInfo getServiceInfo();
Extractor getExtractorInstance(String url);
VideoExtractor getExtractorInstance(String url);
SearchEngine getSearchEngineInstance();
/**When a VIEW_ACTION is caught this function will test if the url delivered within the calling

View file

@ -4,7 +4,7 @@ package org.schabi.newpipe.services;
* Created by Christian Schabesberger on 10.08.15.
*
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
* Extractor.java is part of NewPipe.
* VideoExtractor.java is part of NewPipe.
*
* NewPipe is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@ -23,11 +23,11 @@ package org.schabi.newpipe.services;
import org.schabi.newpipe.VideoInfo;
/**Scrapes information from a video streaming service (eg, YouTube).*/
public abstract class Extractor {
public abstract class VideoExtractor {
public String pageUrl;
public VideoInfo videoInfo;
public Extractor(String url) {
public VideoExtractor(String url) {
this.pageUrl = url;
}

View file

@ -101,7 +101,7 @@ public class YoutubeSearchEngine implements SearchEngine {
// video item type
} else if(!((el = item.select("div[class*=\"yt-lockup-video\"").first()) == null)) {
//todo: de-duplicate this with YoutubeExtractor.getVideoPreviewInfo()
//todo: de-duplicate this with YoutubeVideoExtractor.getVideoPreviewInfo()
VideoPreviewInfo resultItem = new VideoPreviewInfo();
Element dl = el.select("h3").first().select("a").first();
resultItem.webpage_url = dl.attr("abs:href");

View file

@ -1,7 +1,7 @@
package org.schabi.newpipe.services.youtube;
import org.schabi.newpipe.services.StreamingService;
import org.schabi.newpipe.services.Extractor;
import org.schabi.newpipe.services.VideoExtractor;
import org.schabi.newpipe.services.SearchEngine;
@ -33,9 +33,9 @@ public class YoutubeService implements StreamingService {
return serviceInfo;
}
@Override
public Extractor getExtractorInstance(String url) {
public VideoExtractor getExtractorInstance(String url) {
if(acceptUrl(url)) {
return new YoutubeExtractor(url);
return new YoutubeVideoExtractor(url);
}
else {
throw new IllegalArgumentException("supplied String is not a valid Youtube URL");

View file

@ -13,7 +13,7 @@ import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.ScriptableObject;
import org.schabi.newpipe.Downloader;
import org.schabi.newpipe.services.Extractor;
import org.schabi.newpipe.services.VideoExtractor;
import org.schabi.newpipe.MediaFormat;
import org.schabi.newpipe.VideoInfo;
import org.schabi.newpipe.VideoPreviewInfo;
@ -31,7 +31,7 @@ import java.util.regex.Pattern;
* Created by Christian Schabesberger on 06.08.15.
*
* Copyright (C) Christian Schabesberger 2015 <chris.schabesberger@mailbox.org>
* YoutubeExtractor.java is part of NewPipe.
* YoutubeVideoExtractor.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
@ -47,9 +47,9 @@ import java.util.regex.Pattern;
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
*/
public class YoutubeExtractor extends Extractor {
public class YoutubeVideoExtractor extends VideoExtractor {
private static final String TAG = YoutubeExtractor.class.toString();
private static final String TAG = YoutubeVideoExtractor.class.toString();
private String pageContents;
private Document doc;
private JSONObject jsonObj;
@ -62,7 +62,7 @@ public class YoutubeExtractor extends Extractor {
private static volatile String decryptionCode = "";
public YoutubeExtractor(String pageUrl) {
public YoutubeVideoExtractor(String pageUrl) {
super(pageUrl);//most common videoInfo fields are now set in our superclass, for all services
pageContents = Downloader.download(cleanUrl(pageUrl));
doc = Jsoup.parse(pageContents, pageUrl);