Merge pull request #51 from Soofe/master
Fixed some typos and removed unused imports.
This commit is contained in:
commit
173eaa8cf8
11 changed files with 58 additions and 97 deletions
|
@ -1,13 +1,11 @@
|
||||||
package org.schabi.newpipe;
|
package org.schabi.newpipe;
|
||||||
|
|
||||||
import android.app.DownloadManager;
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.DialogInterface;
|
import android.content.DialogInterface;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.preference.Preference;
|
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.view.MenuItemCompat;
|
import android.support.v4.view.MenuItemCompat;
|
||||||
import android.support.v7.app.ActionBar;
|
import android.support.v7.app.ActionBar;
|
||||||
|
@ -19,8 +17,6 @@ import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.widget.ArrayAdapter;
|
import android.widget.ArrayAdapter;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Christian Schabesberger on 18.08.15.
|
* Created by Christian Schabesberger on 18.08.15.
|
||||||
*
|
*
|
||||||
|
@ -48,7 +44,7 @@ public class ActionBarHandler {
|
||||||
private static ActionBarHandler handler = null;
|
private static ActionBarHandler handler = null;
|
||||||
|
|
||||||
private Context context = null;
|
private Context context = null;
|
||||||
private String webisteUrl = "";
|
private String websiteUrl = "";
|
||||||
private AppCompatActivity activity;
|
private AppCompatActivity activity;
|
||||||
private VideoInfo.VideoStream[] videoStreams = null;
|
private VideoInfo.VideoStream[] videoStreams = null;
|
||||||
private VideoInfo.AudioStream audioStream = null;
|
private VideoInfo.AudioStream audioStream = null;
|
||||||
|
@ -64,7 +60,7 @@ public class ActionBarHandler {
|
||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
|
|
||||||
class ForamatItemSelectListener implements ActionBar.OnNavigationListener {
|
class FormatItemSelectListener implements ActionBar.OnNavigationListener {
|
||||||
@Override
|
@Override
|
||||||
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
|
public boolean onNavigationItemSelected(int itemPosition, long itemId) {
|
||||||
selectFormatItem((int)itemId);
|
selectFormatItem((int)itemId);
|
||||||
|
@ -98,7 +94,7 @@ public class ActionBarHandler {
|
||||||
if(activity != null) {
|
if(activity != null) {
|
||||||
ActionBar ab = activity.getSupportActionBar();
|
ActionBar ab = activity.getSupportActionBar();
|
||||||
ab.setListNavigationCallbacks(itemAdapter
|
ab.setListNavigationCallbacks(itemAdapter
|
||||||
,new ForamatItemSelectListener());
|
,new FormatItemSelectListener());
|
||||||
ab.setSelectedNavigationItem(defaultResolutionPos);
|
ab.setSelectedNavigationItem(defaultResolutionPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,9 +110,9 @@ public class ActionBarHandler {
|
||||||
}
|
}
|
||||||
} else if(preferedFormat.equals("m4a")){
|
} else if(preferedFormat.equals("m4a")){
|
||||||
for(VideoInfo.AudioStream s : audioStreams) {
|
for(VideoInfo.AudioStream s : audioStreams) {
|
||||||
Log.d(TAG, VideoInfo.getMimeById(s.format) + " : " + Integer.toString(s.bandWidth));
|
Log.d(TAG, VideoInfo.getMimeById(s.format) + " : " + Integer.toString(s.bandwidth));
|
||||||
if(s.format == VideoInfo.I_M4A &&
|
if(s.format == VideoInfo.I_M4A &&
|
||||||
(audioStream == null || audioStream.bandWidth > s.bandWidth)) {
|
(audioStream == null || audioStream.bandwidth > s.bandwidth)) {
|
||||||
audioStream = s;
|
audioStream = s;
|
||||||
Log.d(TAG, "last choosen");
|
Log.d(TAG, "last choosen");
|
||||||
}
|
}
|
||||||
|
@ -162,7 +158,7 @@ public class ActionBarHandler {
|
||||||
if(!videoTitle.isEmpty()) {
|
if(!videoTitle.isEmpty()) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction(Intent.ACTION_SEND);
|
intent.setAction(Intent.ACTION_SEND);
|
||||||
intent.putExtra(Intent.EXTRA_TEXT, webisteUrl);
|
intent.putExtra(Intent.EXTRA_TEXT, websiteUrl);
|
||||||
intent.setType("text/plain");
|
intent.setType("text/plain");
|
||||||
context.startActivity(Intent.createChooser(intent, context.getString(R.string.shareDialogTitle)));
|
context.startActivity(Intent.createChooser(intent, context.getString(R.string.shareDialogTitle)));
|
||||||
}
|
}
|
||||||
|
@ -192,7 +188,7 @@ public class ActionBarHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVideoInfo(String websiteUrl, String videoTitle) {
|
public void setVideoInfo(String websiteUrl, String videoTitle) {
|
||||||
this.webisteUrl = websiteUrl;
|
this.websiteUrl = websiteUrl;
|
||||||
this.videoTitle = videoTitle;
|
this.videoTitle = videoTitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +235,7 @@ public class ActionBarHandler {
|
||||||
Intent intent = new Intent(context, PlayVideoActivity.class);
|
Intent intent = new Intent(context, PlayVideoActivity.class);
|
||||||
intent.putExtra(PlayVideoActivity.VIDEO_TITLE, videoTitle);
|
intent.putExtra(PlayVideoActivity.VIDEO_TITLE, videoTitle);
|
||||||
intent.putExtra(PlayVideoActivity.STREAM_URL, videoStreams[selectedStream].url);
|
intent.putExtra(PlayVideoActivity.STREAM_URL, videoStreams[selectedStream].url);
|
||||||
intent.putExtra(PlayVideoActivity.VIDEO_URL, webisteUrl);
|
intent.putExtra(PlayVideoActivity.VIDEO_URL, websiteUrl);
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -267,7 +263,7 @@ public class ActionBarHandler {
|
||||||
if(!videoTitle.isEmpty()) {
|
if(!videoTitle.isEmpty()) {
|
||||||
Intent intent = new Intent();
|
Intent intent = new Intent();
|
||||||
intent.setAction(Intent.ACTION_VIEW);
|
intent.setAction(Intent.ACTION_VIEW);
|
||||||
intent.setData(Uri.parse(webisteUrl));
|
intent.setData(Uri.parse(websiteUrl));
|
||||||
|
|
||||||
context.startActivity(Intent.createChooser(intent, context.getString(R.string.chooseBrowser)));
|
context.startActivity(Intent.createChooser(intent, context.getString(R.string.chooseBrowser)));
|
||||||
}
|
}
|
||||||
|
@ -278,7 +274,7 @@ public class ActionBarHandler {
|
||||||
try {
|
try {
|
||||||
Intent intent = new Intent(Intent.ACTION_VIEW);
|
Intent intent = new Intent(Intent.ACTION_VIEW);
|
||||||
intent.setPackage(KORE_PACKET);
|
intent.setPackage(KORE_PACKET);
|
||||||
intent.setData(Uri.parse(webisteUrl.replace("https", "http")));
|
intent.setData(Uri.parse(websiteUrl.replace("https", "http")));
|
||||||
context.startActivity(intent);
|
context.startActivity(intent);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package org.schabi.newpipe;
|
package org.schabi.newpipe;
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Christian Schabesberger on 10.08.15.
|
* Created by Christian Schabesberger on 10.08.15.
|
||||||
*
|
*
|
||||||
|
|
|
@ -5,7 +5,6 @@ import android.content.Intent;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
import android.content.pm.ActivityInfo;
|
import android.content.pm.ActivityInfo;
|
||||||
import android.content.res.Configuration;
|
import android.content.res.Configuration;
|
||||||
import android.content.res.Resources;
|
|
||||||
import android.media.MediaPlayer;
|
import android.media.MediaPlayer;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
@ -19,15 +18,11 @@ import android.view.Display;
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.Surface;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.widget.LinearLayout;
|
|
||||||
import android.widget.MediaController;
|
import android.widget.MediaController;
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.SeekBar;
|
|
||||||
import android.widget.VideoView;
|
import android.widget.VideoView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -84,7 +79,7 @@ public class PlayVideoActivity extends AppCompatActivity {
|
||||||
setContentView(R.layout.activity_play_video);
|
setContentView(R.layout.activity_play_video);
|
||||||
|
|
||||||
isLandscape = checkIfLandscape();
|
isLandscape = checkIfLandscape();
|
||||||
hasSoftKeys = checkIfhasSoftKeys();
|
hasSoftKeys = checkIfHasSoftKeys();
|
||||||
|
|
||||||
actionBar = getSupportActionBar();
|
actionBar = getSupportActionBar();
|
||||||
actionBar.setDisplayHomeAsUpEnabled(true);
|
actionBar.setDisplayHomeAsUpEnabled(true);
|
||||||
|
@ -203,10 +198,10 @@ public class PlayVideoActivity extends AppCompatActivity {
|
||||||
|
|
||||||
if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) {
|
||||||
isLandscape = true;
|
isLandscape = true;
|
||||||
adjustMediaControllMetrics();
|
adjustMediaControlMetrics();
|
||||||
} else if (config.orientation == Configuration.ORIENTATION_PORTRAIT){
|
} else if (config.orientation == Configuration.ORIENTATION_PORTRAIT){
|
||||||
isLandscape = false;
|
isLandscape = false;
|
||||||
adjustMediaControllMetrics();
|
adjustMediaControlMetrics();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +224,7 @@ public class PlayVideoActivity extends AppCompatActivity {
|
||||||
uiIsHidden = false;
|
uiIsHidden = false;
|
||||||
mediaController.show(100000);
|
mediaController.show(100000);
|
||||||
actionBar.show();
|
actionBar.show();
|
||||||
adjustMediaControllMetrics();
|
adjustMediaControlMetrics();
|
||||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
Handler handler = new Handler();
|
Handler handler = new Handler();
|
||||||
handler.postDelayed(new Runnable() {
|
handler.postDelayed(new Runnable() {
|
||||||
|
@ -259,7 +254,7 @@ public class PlayVideoActivity extends AppCompatActivity {
|
||||||
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
WindowManager.LayoutParams.FLAG_FULLSCREEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void adjustMediaControllMetrics() {
|
private void adjustMediaControlMetrics() {
|
||||||
MediaController.LayoutParams mediaControllerLayout
|
MediaController.LayoutParams mediaControllerLayout
|
||||||
= new MediaController.LayoutParams(MediaController.LayoutParams.MATCH_PARENT,
|
= new MediaController.LayoutParams(MediaController.LayoutParams.MATCH_PARENT,
|
||||||
MediaController.LayoutParams.WRAP_CONTENT);
|
MediaController.LayoutParams.WRAP_CONTENT);
|
||||||
|
@ -274,7 +269,7 @@ public class PlayVideoActivity extends AppCompatActivity {
|
||||||
mediaController.setLayoutParams(mediaControllerLayout);
|
mediaController.setLayoutParams(mediaControllerLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean checkIfhasSoftKeys(){
|
private boolean checkIfHasSoftKeys(){
|
||||||
if(Build.VERSION.SDK_INT >= 17) {
|
if(Build.VERSION.SDK_INT >= 17) {
|
||||||
return getNavigationBarHeight() != 0 || getNavigationBarWidth() != 0;
|
return getNavigationBarHeight() != 0 || getNavigationBarWidth() != 0;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package org.schabi.newpipe;
|
package org.schabi.newpipe;
|
||||||
|
|
||||||
import android.graphics.Bitmap;
|
|
||||||
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -110,13 +110,13 @@ public class VideoInfo {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class AudioStream {
|
public static class AudioStream {
|
||||||
public AudioStream(String url, int format, int bandWidth, int samplingRate) {
|
public AudioStream(String url, int format, int bandwidth, int samplingRate) {
|
||||||
this.url = url; this.format = format;
|
this.url = url; this.format = format;
|
||||||
this.bandWidth = bandWidth; this.samplingRate = samplingRate;
|
this.bandwidth = bandwidth; this.samplingRate = samplingRate;
|
||||||
}
|
}
|
||||||
public String url = "";
|
public String url = "";
|
||||||
public int format = -1;
|
public int format = -1;
|
||||||
public int bandWidth = -1;
|
public int bandwidth = -1;
|
||||||
public int samplingRate = -1;
|
public int samplingRate = -1;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,22 +1,13 @@
|
||||||
package org.schabi.newpipe;
|
package org.schabi.newpipe;
|
||||||
|
|
||||||
import android.content.ContentProviderOperation;
|
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.preference.PreferenceManager;
|
||||||
import android.support.v4.app.NavUtils;
|
import android.support.v4.app.NavUtils;
|
||||||
import android.util.DisplayMetrics;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.WindowManager;
|
|
||||||
|
|
||||||
import org.schabi.newpipe.youtube.YoutubeExtractor;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -3,13 +3,11 @@ package org.schabi.newpipe;
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.media.Image;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.support.design.widget.FloatingActionButton;
|
import android.support.design.widget.FloatingActionButton;
|
||||||
import android.support.v4.app.Fragment;
|
import android.support.v4.app.Fragment;
|
||||||
import android.support.v7.app.ActionBar;
|
|
||||||
import android.text.Html;
|
import android.text.Html;
|
||||||
import android.text.method.LinkMovementMethod;
|
import android.text.method.LinkMovementMethod;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
|
@ -17,14 +15,11 @@ import android.util.Log;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import android.widget.GridLayout;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
import android.widget.ListView;
|
|
||||||
import android.widget.ProgressBar;
|
import android.widget.ProgressBar;
|
||||||
import android.widget.RelativeLayout;
|
import android.widget.RelativeLayout;
|
||||||
import android.widget.TextView;
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
@ -216,7 +211,7 @@ public class VideoItemDetailFragment extends Fragment {
|
||||||
thumbnailView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.not_available_monkey));
|
thumbnailView.setImageBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.not_available_monkey));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Log.e(TAG, "Video Availeble Status not known.");
|
Log.e(TAG, "Video Available Status not known.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if(autoPlayEnabled) {
|
if(autoPlayEnabled) {
|
||||||
|
|
|
@ -2,21 +2,14 @@ package org.schabi.newpipe;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.content.res.Configuration;
|
|
||||||
import android.os.Build;
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
|
||||||
import android.preference.PreferenceManager;
|
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.util.DisplayMetrics;
|
import android.support.v7.widget.SearchView;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuInflater;
|
import android.view.MenuInflater;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
import android.support.v7.widget.SearchView;
|
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,7 +13,6 @@ import android.widget.ListView;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
|
|
||||||
|
|
||||||
|
@ -54,14 +53,14 @@ public class VideoItemListFragment extends ListFragment {
|
||||||
|
|
||||||
private class ResultRunnable implements Runnable {
|
private class ResultRunnable implements Runnable {
|
||||||
private SearchEngine.Result result;
|
private SearchEngine.Result result;
|
||||||
private int reuqestId;
|
private int requestId;
|
||||||
public ResultRunnable(SearchEngine.Result result, int requestId) {
|
public ResultRunnable(SearchEngine.Result result, int requestId) {
|
||||||
this.result = result;
|
this.result = result;
|
||||||
this.reuqestId = requestId;
|
this.requestId = requestId;
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
updateListOnResult(result, reuqestId);
|
updateListOnResult(result, requestId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +212,7 @@ public class VideoItemListFragment extends ListFragment {
|
||||||
loadThumbsThread = new Thread(loadThumbsRunnable);
|
loadThumbsThread = new Thread(loadThumbsRunnable);
|
||||||
loadThumbsThread.start();
|
loadThumbsThread.start();
|
||||||
} catch(java.lang.IllegalStateException e) {
|
} catch(java.lang.IllegalStateException e) {
|
||||||
Log.w(TAG, "Trying to set value while activity is not existing anymore.");
|
Log.w(TAG, "Trying to set value while activity doesn't exist anymore.");
|
||||||
} catch(Exception e) {
|
} catch(Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -230,7 +229,7 @@ public class VideoItemListFragment extends ListFragment {
|
||||||
}
|
}
|
||||||
if(searchThread != null) {
|
if(searchThread != null) {
|
||||||
searchRunnable.terminate();
|
searchRunnable.terminate();
|
||||||
// No need to join, since we don't realy terminate the thread. We just demand
|
// No need to join, since we don't really terminate the thread. We just demand
|
||||||
// it to post its result runnable into the gui main loop.
|
// it to post its result runnable into the gui main loop.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,30 +1,29 @@
|
||||||
package org.schabi.newpipe.youtube;
|
package org.schabi.newpipe.youtube;
|
||||||
import org.jsoup.nodes.Element;
|
|
||||||
import org.schabi.newpipe.Downloader;
|
|
||||||
import org.schabi.newpipe.Extractor;
|
|
||||||
import org.schabi.newpipe.VideoInfo;
|
|
||||||
|
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.Xml;
|
import android.util.Xml;
|
||||||
|
|
||||||
|
import org.json.JSONObject;
|
||||||
|
import org.jsoup.Jsoup;
|
||||||
|
import org.jsoup.nodes.Document;
|
||||||
|
import org.jsoup.nodes.Element;
|
||||||
|
import org.jsoup.parser.Parser;
|
||||||
|
import org.mozilla.javascript.Context;
|
||||||
|
import org.mozilla.javascript.Function;
|
||||||
|
import org.mozilla.javascript.ScriptableObject;
|
||||||
|
import org.schabi.newpipe.Downloader;
|
||||||
|
import org.schabi.newpipe.Extractor;
|
||||||
|
import org.schabi.newpipe.VideoInfo;
|
||||||
|
import org.schabi.newpipe.VideoInfoItem;
|
||||||
|
import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import org.json.JSONObject;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.jsoup.Jsoup;
|
|
||||||
import org.jsoup.nodes.Document;
|
|
||||||
import org.jsoup.parser.Parser;
|
|
||||||
|
|
||||||
import org.mozilla.javascript.Context;
|
|
||||||
import org.mozilla.javascript.Function;
|
|
||||||
import org.mozilla.javascript.ScriptableObject;
|
|
||||||
import org.schabi.newpipe.VideoInfoItem;
|
|
||||||
import org.xmlpull.v1.XmlPullParser;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Christian Schabesberger on 06.08.15.
|
* Created by Christian Schabesberger on 06.08.15.
|
||||||
|
@ -48,8 +47,6 @@ import org.xmlpull.v1.XmlPullParser;
|
||||||
|
|
||||||
public class YoutubeExtractor implements Extractor {
|
public class YoutubeExtractor implements Extractor {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private static final String TAG = YoutubeExtractor.class.toString();
|
private static final String TAG = YoutubeExtractor.class.toString();
|
||||||
|
|
||||||
// These lists only contain itag formats that are supported by the common Android Video player.
|
// These lists only contain itag formats that are supported by the common Android Video player.
|
||||||
|
@ -93,7 +90,7 @@ public class YoutubeExtractor implements Extractor {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private String decryptoinCode = "";
|
private String decryptionCode = "";
|
||||||
private static final String DECRYPTION_FUNC_NAME="decrypt";
|
private static final String DECRYPTION_FUNC_NAME="decrypt";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -189,12 +186,12 @@ public class YoutubeExtractor implements Extractor {
|
||||||
if(playerUrl.startsWith("//")) {
|
if(playerUrl.startsWith("//")) {
|
||||||
playerUrl = "https:" + playerUrl;
|
playerUrl = "https:" + playerUrl;
|
||||||
}
|
}
|
||||||
if(decryptoinCode.isEmpty()) {
|
if(decryptionCode.isEmpty()) {
|
||||||
decryptoinCode = loadDecryptioinCode(playerUrl);
|
decryptionCode = loadDecryptionCode(playerUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
// extract audio
|
// extract audio
|
||||||
videoInfo.audioStreams = parseDashManifest(dashManifest, decryptoinCode);
|
videoInfo.audioStreams = parseDashManifest(dashManifest, decryptionCode);
|
||||||
|
|
||||||
//------------------------------------
|
//------------------------------------
|
||||||
// extract video stream url
|
// extract video stream url
|
||||||
|
@ -213,10 +210,10 @@ public class YoutubeExtractor implements Extractor {
|
||||||
|
|
||||||
// if video has a signature: decrypt it and add it to the url
|
// if video has a signature: decrypt it and add it to the url
|
||||||
if(tags.get("s") != null) {
|
if(tags.get("s") != null) {
|
||||||
if(decryptoinCode.isEmpty()) {
|
if(decryptionCode.isEmpty()) {
|
||||||
decryptoinCode = loadDecryptioinCode(playerUrl);
|
decryptionCode = loadDecryptionCode(playerUrl);
|
||||||
}
|
}
|
||||||
streamUrl = streamUrl + "&signature=" + decryptSignature(tags.get("s"), decryptoinCode);
|
streamUrl = streamUrl + "&signature=" + decryptSignature(tags.get("s"), decryptionCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(resolveFormat(itag) != -1) {
|
if(resolveFormat(itag) != -1) {
|
||||||
|
@ -236,7 +233,7 @@ public class YoutubeExtractor implements Extractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
//-------------------------------
|
//-------------------------------
|
||||||
// extrating from html page
|
// extracting from html page
|
||||||
//-------------------------------
|
//-------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
@ -438,7 +435,7 @@ public class YoutubeExtractor implements Extractor {
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String loadDecryptioinCode(String playerUrl) {
|
private String loadDecryptionCode(String playerUrl) {
|
||||||
String playerCode = Downloader.download(playerUrl);
|
String playerCode = Downloader.download(playerUrl);
|
||||||
String decryptionFuncName = "";
|
String decryptionFuncName = "";
|
||||||
String decryptionFunc = "";
|
String decryptionFunc = "";
|
||||||
|
|
|
@ -1,18 +1,17 @@
|
||||||
package org.schabi.newpipe.youtube;
|
package org.schabi.newpipe.youtube;
|
||||||
|
|
||||||
import org.schabi.newpipe.Downloader;
|
|
||||||
import org.schabi.newpipe.SearchEngine;
|
|
||||||
import org.schabi.newpipe.VideoInfoItem;
|
|
||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
|
import org.schabi.newpipe.Downloader;
|
||||||
|
import org.schabi.newpipe.SearchEngine;
|
||||||
|
import org.schabi.newpipe.VideoInfoItem;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Christian Schabesberger on 09.08.15.
|
* Created by Christian Schabesberger on 09.08.15.
|
||||||
|
|
Loading…
Reference in a new issue