mirror of
https://github.com/revanced/revanced-integrations.git
synced 2024-12-01 00:02:55 +01:00
Small fixes and changes
- Added versionName fetching - Reduced RYD API spam for Shorts - Fixes and additions to strings - YT API Key from local.properties
This commit is contained in:
parent
8d2a84b066
commit
7c71435e5d
@ -5,12 +5,19 @@ android {
|
|||||||
buildToolsVersion "30.0.2"
|
buildToolsVersion "30.0.2"
|
||||||
|
|
||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "pl.jakubweg"
|
applicationId "vanced.integrations"
|
||||||
minSdkVersion 21
|
minSdkVersion 21
|
||||||
targetSdkVersion 30
|
targetSdkVersion 30
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
multiDexEnabled false
|
multiDexEnabled false
|
||||||
|
|
||||||
|
Properties properties = new Properties()
|
||||||
|
if (rootProject.file("local.properties").exists()) {
|
||||||
|
properties.load(rootProject.file("local.properties").newDataInputStream())
|
||||||
|
}
|
||||||
|
|
||||||
|
buildConfigField "String", "YT_API_KEY", "\"${properties.getProperty("youtubeAPIKey", "")}\""
|
||||||
}
|
}
|
||||||
|
|
||||||
buildTypes {
|
buildTypes {
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
package="pl.jakubweg">
|
package="vanced.integrations">
|
||||||
</manifest>
|
</manifest>
|
@ -10,22 +10,29 @@ public class VideoInformation {
|
|||||||
private static final String TAG = "VI - VideoInfo";
|
private static final String TAG = "VI - VideoInfo";
|
||||||
|
|
||||||
public static String currentVideoId;
|
public static String currentVideoId;
|
||||||
public static Integer dislikeCount = null;
|
public static Integer dislikeCount;
|
||||||
public static String channelName = null;
|
public static String channelName;
|
||||||
public static long lastKnownVideoTime = -1L;
|
public static long lastKnownVideoTime = -1L;
|
||||||
|
|
||||||
|
private static boolean tempInfoSaved = false;
|
||||||
|
private static String tempVideoId;
|
||||||
|
private static Integer tempDislikeCount;
|
||||||
|
|
||||||
// Call hook in the YT code when the video changes
|
// Call hook in the YT code when the video changes
|
||||||
public static void setCurrentVideoId(final String videoId) {
|
public static void setCurrentVideoId(final String videoId) {
|
||||||
if (videoId == null) {
|
if (videoId == null) {
|
||||||
if (debug) {
|
if (debug) {
|
||||||
Log.d(TAG, "setCurrentVideoId - new id was null - currentVideoId was" + currentVideoId);
|
Log.d(TAG, "setCurrentVideoId - new id was null - currentVideoId was" + currentVideoId);
|
||||||
}
|
}
|
||||||
currentVideoId = null;
|
clearInformation();
|
||||||
dislikeCount = null;
|
|
||||||
channelName = null;
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Restore temporary information that was stored from the last watched video
|
||||||
|
if (tempInfoSaved) {
|
||||||
|
restoreTempInformation();
|
||||||
|
}
|
||||||
|
|
||||||
if (videoId.equals(currentVideoId)) {
|
if (videoId.equals(currentVideoId)) {
|
||||||
if (debug) {
|
if (debug) {
|
||||||
Log.d(TAG, "setCurrentVideoId - new and current video were equal - " + videoId);
|
Log.d(TAG, "setCurrentVideoId - new and current video were equal - " + videoId);
|
||||||
@ -42,4 +49,36 @@ public class VideoInformation {
|
|||||||
// New video
|
// New video
|
||||||
ReturnYouTubeDislikes.newVideoLoaded(videoId);
|
ReturnYouTubeDislikes.newVideoLoaded(videoId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Call hook in the YT code when the video ends
|
||||||
|
public static void videoEnded() {
|
||||||
|
saveTempInformation();
|
||||||
|
clearInformation();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Information is cleared once a video ends
|
||||||
|
// It's cleared because the setCurrentVideoId isn't called for Shorts
|
||||||
|
// so Shorts would otherwise use the information from the last watched video
|
||||||
|
private static void clearInformation() {
|
||||||
|
currentVideoId = null;
|
||||||
|
dislikeCount = null;
|
||||||
|
channelName = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Temporary information is saved once a video ends
|
||||||
|
// so that if the user watches the same video again,
|
||||||
|
// the information can be restored without having to fetch again
|
||||||
|
private static void saveTempInformation() {
|
||||||
|
tempVideoId = currentVideoId;
|
||||||
|
tempDislikeCount = dislikeCount;
|
||||||
|
tempInfoSaved = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void restoreTempInformation() {
|
||||||
|
currentVideoId = tempVideoId;
|
||||||
|
dislikeCount = tempDislikeCount;
|
||||||
|
tempVideoId = null;
|
||||||
|
tempDislikeCount = null;
|
||||||
|
tempInfoSaved = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,8 +22,10 @@ import java.nio.charset.StandardCharsets;
|
|||||||
import fi.vanced.libraries.youtube.player.ChannelModel;
|
import fi.vanced.libraries.youtube.player.ChannelModel;
|
||||||
import fi.vanced.libraries.youtube.whitelisting.Whitelist;
|
import fi.vanced.libraries.youtube.whitelisting.Whitelist;
|
||||||
import fi.vanced.libraries.youtube.whitelisting.WhitelistType;
|
import fi.vanced.libraries.youtube.whitelisting.WhitelistType;
|
||||||
|
import fi.vanced.utils.VancedUtils;
|
||||||
import fi.vanced.utils.requests.Requester;
|
import fi.vanced.utils.requests.Requester;
|
||||||
import fi.vanced.utils.requests.Route;
|
import fi.vanced.utils.requests.Route;
|
||||||
|
import vanced.integrations.BuildConfig;
|
||||||
|
|
||||||
public class WhitelistRequester {
|
public class WhitelistRequester {
|
||||||
private static final String YT_API_URL = "https://www.youtube.com/youtubei/v1/";
|
private static final String YT_API_URL = "https://www.youtube.com/youtubei/v1/";
|
||||||
@ -32,14 +34,14 @@ public class WhitelistRequester {
|
|||||||
|
|
||||||
public static void addChannelToWhitelist(WhitelistType whitelistType, View view, ImageView buttonIcon, Context context) {
|
public static void addChannelToWhitelist(WhitelistType whitelistType, View view, ImageView buttonIcon, Context context) {
|
||||||
try {
|
try {
|
||||||
HttpURLConnection connection = getConnectionFromRoute(WhitelistRoutes.GET_CHANNEL_DETAILS, "replaceMeWithTheYouTubeAPIKey");
|
HttpURLConnection connection = getConnectionFromRoute(WhitelistRoutes.GET_CHANNEL_DETAILS, BuildConfig.YT_API_KEY);
|
||||||
connection.setRequestProperty("Content-Type", "application/json; utf-8");
|
connection.setRequestProperty("Content-Type", "application/json; utf-8");
|
||||||
connection.setRequestProperty("Accept", "application/json");
|
connection.setRequestProperty("Accept", "application/json");
|
||||||
connection.setDoOutput(true);
|
connection.setDoOutput(true);
|
||||||
connection.setConnectTimeout(2 * 1000);
|
connection.setConnectTimeout(2 * 1000);
|
||||||
|
|
||||||
// TODO: Actually fetch the version
|
String versionName = VancedUtils.getVersionName(context);
|
||||||
String jsonInputString = "{\"context\": {\"client\": { \"clientName\": \"Android\", \"clientVersion\": \"16.49.37\" } }, \"videoId\": \"" + currentVideoId + "\"}";
|
String jsonInputString = "{\"context\": {\"client\": { \"clientName\": \"Android\", \"clientVersion\": \"" + versionName + "\" } }, \"videoId\": \"" + currentVideoId + "\"}";
|
||||||
try(OutputStream os = connection.getOutputStream()) {
|
try(OutputStream os = connection.getOutputStream()) {
|
||||||
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
byte[] input = jsonInputString.getBytes(StandardCharsets.UTF_8);
|
||||||
os.write(input, 0, input.length);
|
os.write(input, 0, input.length);
|
||||||
|
@ -2,6 +2,8 @@ package fi.vanced.utils;
|
|||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.SharedPreferences;
|
import android.content.SharedPreferences;
|
||||||
|
import android.content.pm.PackageInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import android.os.Looper;
|
import android.os.Looper;
|
||||||
|
|
||||||
@ -43,6 +45,18 @@ public class VancedUtils {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String getVersionName(Context context) {
|
||||||
|
try {
|
||||||
|
PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
|
||||||
|
String version = pInfo.versionName;
|
||||||
|
return (version);
|
||||||
|
} catch (PackageManager.NameNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ("17.03.35");
|
||||||
|
}
|
||||||
|
|
||||||
public static void runOnMainThread(Runnable runnable) {
|
public static void runOnMainThread(Runnable runnable) {
|
||||||
new Handler(Looper.getMainLooper()).post(runnable);
|
new Handler(Looper.getMainLooper()).post(runnable);
|
||||||
}
|
}
|
||||||
|
@ -320,9 +320,9 @@
|
|||||||
<string name="stats">Stats</string>
|
<string name="stats">Stats</string>
|
||||||
<string name="stats_loading">Loading..</string>
|
<string name="stats_loading">Loading..</string>
|
||||||
<string name="stats_sb_disabled">SponsorBlock is disabled</string>
|
<string name="stats_sb_disabled">SponsorBlock is disabled</string>
|
||||||
<string name="stats_username">Your username: <b>%s</b></string>
|
<string name="stats_username" formatted="false">Your username: <b>%s</b></string>
|
||||||
<string name="stats_username_change">Click to change your username</string>
|
<string name="stats_username_change">Click to change your username</string>
|
||||||
<string name="stats_username_change_unknown_error">Unable to change username: Status: %d %s</string>
|
<string name="stats_username_change_unknown_error" formatted="false">Unable to change username: Status: %d %s</string>
|
||||||
<string name="stats_username_changed">Username successfully changed</string>
|
<string name="stats_username_changed">Username successfully changed</string>
|
||||||
<string name="stats_submissions">Submissions: <b>%s</b></string>
|
<string name="stats_submissions">Submissions: <b>%s</b></string>
|
||||||
<string name="stats_saved">You\'ve saved people from <b>%s</b> segments.</string>
|
<string name="stats_saved">You\'ve saved people from <b>%s</b> segments.</string>
|
||||||
@ -339,8 +339,8 @@
|
|||||||
<string name="change">Change</string>
|
<string name="change">Change</string>
|
||||||
<string name="reset">Reset</string>
|
<string name="reset">Reset</string>
|
||||||
|
|
||||||
<string name="action_copy">Copy</string>
|
<string name="action_copy">Copy link</string>
|
||||||
<string name="action_tcopy">TCopy</string>
|
<string name="action_tcopy">Timestamp</string>
|
||||||
<string name="action_ads">Ads</string>
|
<string name="action_ads">Ads</string>
|
||||||
<string name="action_segments">Segments</string>
|
<string name="action_segments">Segments</string>
|
||||||
|
|
||||||
@ -359,10 +359,14 @@
|
|||||||
<string name="vanced_button_location_entry_player">In player</string>
|
<string name="vanced_button_location_entry_player">In player</string>
|
||||||
<string name="vanced_button_location_entry_buttoncontainer">Under player</string>
|
<string name="vanced_button_location_entry_buttoncontainer">Under player</string>
|
||||||
<string name="vanced_button_location_entry_both">Both</string>
|
<string name="vanced_button_location_entry_both">Both</string>
|
||||||
<string name="vanced_ryd_settings_title">RYD settings</string>
|
<string name="vanced_ryd_settings_title">Return YouTube Dislike settings</string>
|
||||||
<string name="vanced_ryd_settings_summary">Uses the RYD API</string>
|
<string name="vanced_ryd_settings_summary">Uses the RYD API</string>
|
||||||
<string name="vanced_ryd_title">Enable RYD</string>
|
<string name="vanced_ryd_title">Enable RYD</string>
|
||||||
<string name="vanced_ryd_summary">Switch this on to see the dislike counts again</string>
|
<string name="vanced_ryd_summary">Switch this on to see the dislike counts again</string>
|
||||||
<string name="vanced_ryd_attribution_title">Return YouTube Dislike Integration</string>
|
<string name="vanced_ryd_attribution_title">Return YouTube Dislike Integration</string>
|
||||||
<string name="vanced_ryd_attribution_summary">This integration uses the RYD API from https://returnyoutubedislike.com. Tap to learn more</string>
|
<string name="vanced_ryd_attribution_summary">This integration uses the RYD API from https://returnyoutubedislike.com. Tap to learn more</string>
|
||||||
|
|
||||||
|
<string name="xfile_xfenster_tablet_title">Tablet style</string>
|
||||||
|
<string name="xfile_xfenster_tablet_summary_on">Tablet style is turned on. For example suggested videos are only partially working</string>
|
||||||
|
<string name="xfile_xfenster_tablet_summary_off">Tablet style is turned off</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user