Skip to content
This repository was archived by the owner on Oct 16, 2023. It is now read-only.

Youtube Multi Profile log in #757

Open
wants to merge 32 commits into
base: main-branch
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
0b2066e
Performance improvement
selectee May 9, 2020
367a8e2
Merge branch 'selectee-performance-improvement' into new-exo-player
yuliskov May 9, 2020
551d2d5
bump to 6.17.563
yuliskov May 9, 2020
c8ab284
bump to 6.17.564
yuliskov May 9, 2020
a543bdc
bump to 6.17.565
yuliskov May 9, 2020
5ad01ac
Remove multiple pattern compilation
selectee May 10, 2020
5e42714
Merge branch 'selectee-remove-patterns' into new-exo-player
yuliskov May 10, 2020
79d63de
Add state of loading scripts
selectee May 10, 2020
c492c23
Merge branch 'script-load-state' of https://github.com/selectee/Smart…
yuliskov May 10, 2020
1d08086
Merge branch 'selectee-script-load-state' into new-exo-player
yuliskov May 10, 2020
d88148d
repo sync
yuliskov May 10, 2020
dcaa5d2
Update languages.xml
WaggBR May 10, 2020
8fbdd4d
Add interceptor for filtering PNG, JPG, ICO and TTF files.
selectee May 11, 2020
318bef5
experiments icon fix
yuliskov May 12, 2020
2a62954
experiments default settings
yuliskov May 12, 2020
d7ba02b
experiments icon fix2
yuliskov May 12, 2020
c92a729
experiments icon fix: fin
yuliskov May 12, 2020
e51b0d4
bump to 6.17.566
yuliskov May 12, 2020
be2e353
bump to 6.17.568
yuliskov May 12, 2020
aebae64
pull fix
yuliskov May 11, 2020
5c5c5f6
Merge branch 'experiments' of https://github.com/selectee/SmartYouTub…
yuliskov May 11, 2020
b190976
Merge branch 'selectee-experiments' into experiments
yuliskov May 11, 2020
87fbcf3
bump to 6.17.569
yuliskov May 11, 2020
bda4790
experiments icon fix
yuliskov May 12, 2020
c489180
experiments default settings
yuliskov May 12, 2020
3e0e9a3
experiments icon fix2
yuliskov May 12, 2020
8f219db
experiments icon fix: fin
yuliskov May 12, 2020
dc36e82
bump to 6.17.566
yuliskov May 12, 2020
9901274
bump to 6.17.568
yuliskov May 12, 2020
31544fe
refactor + logging
yuliskov May 11, 2020
2df3b6e
Merge branch 'experiments' of https://github.com/WaggBR/SmartYouTubeT…
yuliskov May 12, 2020
0954e9e
Merge branch 'WaggBR-experiments' into experiments
yuliskov May 12, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Performance improvement
selectee committed May 9, 2020
commit 0b2066e47047ab03d9362007ff5b3d17b82e0b03
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.liskovsoft.smartyoutubetv.flavors.exoplayer.player.dialogs.speed;

import android.content.Context;

import com.google.android.exoplayer2.SimpleExoPlayer;
import com.liskovsoft.exoplayeractivity.R;
import com.liskovsoft.sharedutils.dialogs.GenericSelectorDialog.CombinedDialogSource;
@@ -12,31 +13,29 @@

public class SpeedDialogSource implements CombinedDialogSource {
private final Context mContext;
private final SimpleExoPlayer mPlayer;
private final ArrayList<DialogItem> mItems;
private final ExoPreferences mPrefs;
private final List<DialogItem> mItems;

public SpeedDialogSource(ExoPlayerFragment playerFragment) {
mContext = playerFragment.getActivity();
mPlayer = playerFragment.getPlayer();
mPrefs = ExoPreferences.instance(mContext);
SimpleExoPlayer player = playerFragment.getPlayer();
ExoPreferences preferences = ExoPreferences.instance(mContext);

mItems = new ArrayList<>();
mItems.add(new SaveSpeedDialogItem(mContext.getString(R.string.checkbox_save_speed), mPrefs));
mItems.add(new SpeedDialogItem("0.25", "0.25", mPlayer, mPrefs));
mItems.add(new SpeedDialogItem("0.5", "0.5", mPlayer, mPrefs));
mItems.add(new SpeedDialogItem("0.75", "0.75", mPlayer, mPrefs));
mItems.add(new SpeedDialogItem(mContext.getString(R.string.normal), "1.0", mPlayer, mPrefs));
mItems.add(new SpeedDialogItem("1.25", "1.25", mPlayer, mPrefs));
mItems.add(new SpeedDialogItem("1.5", "1.5", mPlayer, mPrefs));
mItems.add(new SpeedDialogItem("1.75", "1.75", mPlayer, mPrefs));
mItems.add(new SpeedDialogItem("2", "2.0", mPlayer, mPrefs));
mItems.add(new SpeedDialogItem("2.25", "2.25", mPlayer, mPrefs));
mItems.add(new SpeedDialogItem("2.5", "2.5", mPlayer, mPrefs));
mItems.add(new SpeedDialogItem("2.75", "2.75", mPlayer, mPrefs));

if (mPlayer != null) {
SpeedDialogItem.sCurrentSpeed = String.valueOf(mPlayer.getPlaybackParameters().speed);
mItems.add(new SaveSpeedDialogItem(mContext.getString(R.string.checkbox_save_speed), preferences));
mItems.add(new SpeedDialogItem("0.25", "0.25", player, preferences));
mItems.add(new SpeedDialogItem("0.5", "0.5", player, preferences));
mItems.add(new SpeedDialogItem("0.75", "0.75", player, preferences));
mItems.add(new SpeedDialogItem(mContext.getString(R.string.normal), "1.0", player, preferences));
mItems.add(new SpeedDialogItem("1.25", "1.25", player, preferences));
mItems.add(new SpeedDialogItem("1.5", "1.5", player, preferences));
mItems.add(new SpeedDialogItem("1.75", "1.75", player, preferences));
mItems.add(new SpeedDialogItem("2", "2.0", player, preferences));
mItems.add(new SpeedDialogItem("2.25", "2.25", player, preferences));
mItems.add(new SpeedDialogItem("2.5", "2.5", player, preferences));
mItems.add(new SpeedDialogItem("2.75", "2.75", player, preferences));

if (player != null) {
SpeedDialogItem.sCurrentSpeed = String.valueOf(player.getPlaybackParameters().speed);
}
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.liskovsoft.smartyoutubetv.flavors.exoplayer.youtubeinfoparser.parsers;

import android.net.Uri;

import com.google.gson.JsonArray;
import com.google.gson.JsonSyntaxException;
import com.jayway.jsonpath.Configuration;
@@ -15,9 +16,18 @@

import java.io.InputStream;

public class ParserUtils {
public final class ParserUtils {

private static final String TAG = ParserUtils.class.getSimpleName();

private static final Configuration JSON_PATH_CONFIGURATION = Configuration.builder()
.mappingProvider(new GsonMappingProvider())
.jsonProvider(new GsonJsonProvider())
.build();

private ParserUtils() {
}

public static String extractParam(String queryParam, String content) {
Uri videoInfo = parseUri(content);
String value = videoInfo.getQueryParameter(queryParam);
@@ -52,19 +62,13 @@ public static <T> DocumentContext createJsonInfoParser(T jsonInfo) {
throw new IllegalStateException("Can't create parser. jsonInfo == null");
}

Configuration conf = Configuration
.builder()
.mappingProvider(new GsonMappingProvider())
.jsonProvider(new GsonJsonProvider())
.build();

DocumentContext jsonPath;

try {
if (jsonInfo instanceof InputStream) {
jsonPath = JsonPath.using(conf).parse((InputStream) jsonInfo, "UTF-8");
jsonPath = JsonPath.using(JSON_PATH_CONFIGURATION).parse((InputStream) jsonInfo);
} else if (jsonInfo instanceof String) {
jsonPath = JsonPath.using(conf).parse((String) jsonInfo);
jsonPath = JsonPath.using(JSON_PATH_CONFIGURATION).parse((String) jsonInfo);
} else {
throw new IllegalStateException("Can't create parser. Unknown input type: " + jsonInfo.getClass().getSimpleName());
}
@@ -110,8 +114,8 @@ private static <T> T extractType(String jsonPath, DocumentContext parser) {

return result;
}
public static void delete(String jsonPath, DocumentContext parser) {

public static void delete(JsonPath jsonPath, DocumentContext parser) {
try {
parser.delete(jsonPath);
} catch (PathNotFoundException e) { // NOTE: exception isn't thrown in some cases
@@ -120,7 +124,7 @@ public static void delete(String jsonPath, DocumentContext parser) {
}
}

public static boolean exists(String jsonPath, DocumentContext parser) {
public static boolean exists(JsonPath jsonPath, DocumentContext parser) {
boolean result;

try {
Original file line number Diff line number Diff line change
@@ -39,7 +39,8 @@ public WebResourceResponse process(String url) {

WebResourceResponse result = null;

for (RequestInterceptor interceptor : mInterceptors) {
for (int i = 0; i < mInterceptors.size(); i++) {
RequestInterceptor interceptor = mInterceptors.get(i);
if (interceptor.test(url)) {
result = interceptor.intercept(url);

Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

import android.content.Context;
import android.webkit.WebResourceResponse;

import com.liskovsoft.sharedutils.mylogger.Log;
import com.liskovsoft.smartyoutubetv.CommonApplication;
import com.liskovsoft.smartyoutubetv.interceptors.RequestInterceptor;
@@ -29,11 +30,10 @@ public AdAwayInterceptor(Context context) {

@Override
public boolean test(String url) {
if (mClient.isAd(url)) {
return mAdBlockEnabled;
} else {
return false;
if (mAdBlockEnabled) {
return mClient.isAd(url);
}
return false;
}

@Override
Original file line number Diff line number Diff line change
@@ -3,11 +3,12 @@
import android.content.Context;
import android.webkit.WebResourceResponse;

import com.liskovsoft.m3uparser.core.utils.Strings;
import com.liskovsoft.sharedutils.helpers.AssetHelper;
import com.liskovsoft.sharedutils.helpers.Helpers;
import com.liskovsoft.sharedutils.mylogger.Log;
import com.liskovsoft.smartyoutubetv.CommonApplication;
import com.liskovsoft.smartyoutubetv.interceptors.RequestInterceptor;
import com.liskovsoft.smartyoutubetv.interceptors.ads.contentfilter.ReplacingInputStream;
import com.liskovsoft.smartyoutubetv.misc.SmartUtils;
import com.liskovsoft.smartyoutubetv.misc.UserAgentManager;
import com.liskovsoft.smartyoutubetv.prefs.SmartPreferences;
@@ -36,6 +37,7 @@ public class BrowseInterceptor extends RequestInterceptor {
private boolean mIsXWalk;
private boolean mIsAdBlockEnabled;
private boolean mIsEnableVideoMenu;
private boolean mIsCompatibleSettings;

public BrowseInterceptor(Context context) {
super(context);
@@ -44,6 +46,7 @@ public BrowseInterceptor(Context context) {
mIsXWalk = SmartUtils.isXWalk(mContext);
mIsAdBlockEnabled = mPrefs.isAdBlockEnabled();
mIsEnableVideoMenu = mPrefs.getEnableVideoMenu();
mIsCompatibleSettings = mIsEnableVideoMenu || (mIsAdBlockEnabled && !mIsXWalk);
initHeaders();
}

@@ -57,7 +60,7 @@ private void initHeaders() {

@Override
public boolean test(String url) {
return url != null && url.contains(BROWSE_URL);
return mIsCompatibleSettings && (url != null && url.contains(BROWSE_URL));
}

@Override
@@ -82,7 +85,7 @@ private WebResourceResponse filterBannerData(String url) {

String postData = mPrefs.getPostData();

if (postData == null) {
if (Strings.isNullOrEmpty(postData)) {
Log.e(TAG, "Post body is empty! Skipping url: " + url);
return null;
}
@@ -97,34 +100,16 @@ private WebResourceResponse filterBannerData(String url) {

InputStream urlData = postJsonData(url, postData, mHeaders);

WebResourceResponse response = null;

if (Log.getLogType().equals(Log.LOG_TYPE_FILE) && urlData != null) {
String content = Helpers.toString(urlData);
Log.d(TAG, "Url: " + url + ". Post Data: " + postData + ". Response: " + content);
urlData = Helpers.toStream(content);
}

if (urlData != null) {
Log.d(TAG, "Searching and removing tv masthead section...");
JsonBrowseParser browseParser = JsonBrowseParser.parse(urlData);

if (browseParser.removeMastHead()) {
Log.d(TAG, "Success. TV masthead has been removed.");
} else {
if (Log.getLogType().equals(Log.LOG_TYPE_FILE)) {
Log.d(TAG, "Oops. Response doesn't contain MustHead section. Url: " + url + ". Post Data: " + postData + ". Response: " + Helpers.toString(browseParser.toStream()));
} else {
Log.d(TAG, "Oops. Response doesn't contain MustHead section. Url: " + url + ". Post Data: " + postData);
}
}

response = createResponse("application/json", null, browseParser.toStream());
} else {
if (urlData == null) {
Log.e(TAG, "Error. Response in empty. Url: " + url + ". Post Data: " + postData);
return null;
}

return response;
Log.d(TAG, "Searching and removing tv masthead section...");

ReplacingInputStream replacingInputStream = new ReplacingInputStream(urlData, "tvMastheadRenderer", "broken-tvMastheadRend");

return createResponse("application/json", null, replacingInputStream);
}

private WebResourceResponse filterLongPressVideoMenu(String url) {
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.liskovsoft.smartyoutubetv.interceptors.ads;

import com.jayway.jsonpath.DocumentContext;
import com.jayway.jsonpath.JsonPath;
import com.liskovsoft.sharedutils.helpers.Helpers;
import com.liskovsoft.smartyoutubetv.flavors.exoplayer.youtubeinfoparser.parsers.ParserUtils;

@@ -9,7 +10,7 @@
public class JsonBrowseParser {
// All objects with property 'tvMastheadRenderer'
// ex: https://github.com/json-path/JsonPath
private static final String TV_MASTHEAD_SECTION_ANY = "$..[?(@.tvMastheadRenderer)]";
private static final JsonPath TV_MASTHEAD_SECTION_ANY = JsonPath.compile("$..[?(@.tvMastheadRenderer)]");

private final DocumentContext mParser;

Loading