From d6d144c927a1dda25a3a9a0d4e8a55aa5752454e Mon Sep 17 00:00:00 2001 From: Christian Schabesberger Date: Thu, 26 Nov 2015 17:29:26 +0100 Subject: [PATCH] renamed Extractor into VideoExtractor --- .../newpipe/VideoItemDetailActivity.java | 10 ++++------ .../newpipe/VideoItemDetailFragment.java | 18 +++++++++--------- .../newpipe/services/StreamingService.java | 2 +- .../{Extractor.java => VideoExtractor.java} | 6 +++--- .../services/youtube/YoutubeSearchEngine.java | 2 +- .../services/youtube/YoutubeService.java | 6 +++--- ...tractor.java => YoutubeVideoExtractor.java} | 10 +++++----- 7 files changed, 26 insertions(+), 28 deletions(-) rename app/src/main/java/org/schabi/newpipe/services/{Extractor.java => VideoExtractor.java} (96%) rename app/src/main/java/org/schabi/newpipe/services/youtube/{YoutubeExtractor.java => YoutubeVideoExtractor.java} (98%) diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemDetailActivity.java b/app/src/main/java/org/schabi/newpipe/VideoItemDetailActivity.java index 0b87b7b7f..e5b224222 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemDetailActivity.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemDetailActivity.java @@ -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, diff --git a/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java b/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java index c883e7f8d..8211962d0 100644 --- a/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java +++ b/app/src/main/java/org/schabi/newpipe/VideoItemDetailFragment.java @@ -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(); } diff --git a/app/src/main/java/org/schabi/newpipe/services/StreamingService.java b/app/src/main/java/org/schabi/newpipe/services/StreamingService.java index 4321340c6..d243ae4ad 100644 --- a/app/src/main/java/org/schabi/newpipe/services/StreamingService.java +++ b/app/src/main/java/org/schabi/newpipe/services/StreamingService.java @@ -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 diff --git a/app/src/main/java/org/schabi/newpipe/services/Extractor.java b/app/src/main/java/org/schabi/newpipe/services/VideoExtractor.java similarity index 96% rename from app/src/main/java/org/schabi/newpipe/services/Extractor.java rename to app/src/main/java/org/schabi/newpipe/services/VideoExtractor.java index a38b13f13..5aefc35d7 100644 --- a/app/src/main/java/org/schabi/newpipe/services/Extractor.java +++ b/app/src/main/java/org/schabi/newpipe/services/VideoExtractor.java @@ -4,7 +4,7 @@ package org.schabi.newpipe.services; * Created by Christian Schabesberger on 10.08.15. * * Copyright (C) Christian Schabesberger 2015 - * 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; } diff --git a/app/src/main/java/org/schabi/newpipe/services/youtube/YoutubeSearchEngine.java b/app/src/main/java/org/schabi/newpipe/services/youtube/YoutubeSearchEngine.java index d01718ed2..9074e4724 100644 --- a/app/src/main/java/org/schabi/newpipe/services/youtube/YoutubeSearchEngine.java +++ b/app/src/main/java/org/schabi/newpipe/services/youtube/YoutubeSearchEngine.java @@ -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"); diff --git a/app/src/main/java/org/schabi/newpipe/services/youtube/YoutubeService.java b/app/src/main/java/org/schabi/newpipe/services/youtube/YoutubeService.java index e606c805d..576d8c065 100644 --- a/app/src/main/java/org/schabi/newpipe/services/youtube/YoutubeService.java +++ b/app/src/main/java/org/schabi/newpipe/services/youtube/YoutubeService.java @@ -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"); diff --git a/app/src/main/java/org/schabi/newpipe/services/youtube/YoutubeExtractor.java b/app/src/main/java/org/schabi/newpipe/services/youtube/YoutubeVideoExtractor.java similarity index 98% rename from app/src/main/java/org/schabi/newpipe/services/youtube/YoutubeExtractor.java rename to app/src/main/java/org/schabi/newpipe/services/youtube/YoutubeVideoExtractor.java index cb996d2ef..2ff272bad 100644 --- a/app/src/main/java/org/schabi/newpipe/services/youtube/YoutubeExtractor.java +++ b/app/src/main/java/org/schabi/newpipe/services/youtube/YoutubeVideoExtractor.java @@ -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 - * 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 . */ -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);