You've already forked revanced-integrations
mirror of
https://github.com/revanced/revanced-integrations
synced 2025-11-21 18:35:37 +01:00
Compare commits
23 Commits
v0.98.0-de
...
v0.100.0-d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
db60d983e5 | ||
|
|
f31e3a02a0 | ||
|
|
f758b09676 | ||
|
|
3c00e58c13 | ||
|
|
0b83be989b | ||
|
|
db6ce55477 | ||
|
|
0b1b6b3682 | ||
|
|
b612cbf2c0 | ||
|
|
10fff6a0b8 | ||
|
|
e626bd08c1 | ||
|
|
476902e9ce | ||
|
|
05bfc68907 | ||
|
|
c3364226b8 | ||
|
|
0aef5e60e2 | ||
|
|
fb1a69a7ba | ||
|
|
cfc571c12c | ||
|
|
ae862cbac6 | ||
|
|
178b90b490 | ||
|
|
4b052b19a3 | ||
|
|
dce882b128 | ||
|
|
ccb5d81d46 | ||
|
|
5ed7170018 | ||
|
|
621ef63d86 |
@@ -34,7 +34,7 @@
|
|||||||
[
|
[
|
||||||
"@saithodev/semantic-release-backmerge",
|
"@saithodev/semantic-release-backmerge",
|
||||||
{
|
{
|
||||||
backmergeBranches: ["dev"],
|
backmergeBranches: [{"from": "main", "to": "dev"}],
|
||||||
clearWorkspace: true
|
clearWorkspace: true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
87
CHANGELOG.md
87
CHANGELOG.md
@@ -1,3 +1,90 @@
|
|||||||
|
# [0.100.0-dev.3](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.2...v0.100.0-dev.3) (2023-02-25)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **youtube/general-ads:** hide chapters in video description ([#326](https://github.com/revanced/revanced-integrations/issues/326)) ([f31e3a0](https://github.com/revanced/revanced-integrations/commit/f31e3a02a0965da0c1f901e9d6afcfe4f6f6b608))
|
||||||
|
|
||||||
|
# [0.100.0-dev.2](https://github.com/revanced/revanced-integrations/compare/v0.100.0-dev.1...v0.100.0-dev.2) (2023-02-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **youtube/general-ads:** do not hide components in library tab ([3c00e58](https://github.com/revanced/revanced-integrations/commit/3c00e58c13fa11da68ff21f4d76e341bc24c5737))
|
||||||
|
|
||||||
|
# [0.100.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.99.0...v0.100.0-dev.1) (2023-02-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **youtube/general-ads:** hide image shelf from search results ([db6ce55](https://github.com/revanced/revanced-integrations/commit/db6ce554779d58b23685b1794e17f89342abbd87))
|
||||||
|
|
||||||
|
# [0.99.0](https://github.com/revanced/revanced-integrations/compare/v0.98.0...v0.99.0) (2023-02-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **youtube/general-ads:** check for quick actions in path instead of component identifier ([476902e](https://github.com/revanced/revanced-integrations/commit/476902e9cedbc068a815897dd22eabdb52dee84a))
|
||||||
|
* **youtube/general-ads:** use correct setting to hide related videos in quick actions ([e626bd0](https://github.com/revanced/revanced-integrations/commit/e626bd08c1249cb5594d15c77d06cae8ae27e055))
|
||||||
|
* **youtube/general-ads:** use correct setting to hide related videos in quick actions ([05bfc68](https://github.com/revanced/revanced-integrations/commit/05bfc689078beb9a21adc6c4555afe0862e304f7))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **youtube/general-ads:** hide quick actions in fullscreen ([ae862cb](https://github.com/revanced/revanced-integrations/commit/ae862cbac6f9a9b717617469d202b48923a1d3b4))
|
||||||
|
* **youtube/general-ads:** hide related videos in quick action ([cfc571c](https://github.com/revanced/revanced-integrations/commit/cfc571c12cb012b86c8bfa8bf7df1c77b9711a21))
|
||||||
|
* **youtube/return-youtube-dislike:** support for shorts ([#312](https://github.com/revanced/revanced-integrations/issues/312)) ([0aef5e6](https://github.com/revanced/revanced-integrations/commit/0aef5e60e280b63490dac8d1b706e896fdf913a2))
|
||||||
|
* **youtube:** remove patch `open-links-directly` ([dce882b](https://github.com/revanced/revanced-integrations/commit/dce882b12809c074ae796b3551ddd82806bd084d))
|
||||||
|
|
||||||
|
# [0.99.0-dev.4](https://github.com/revanced/revanced-integrations/compare/v0.99.0-dev.3...v0.99.0-dev.4) (2023-02-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **youtube/general-ads:** check for quick actions in path instead of component identifier ([476902e](https://github.com/revanced/revanced-integrations/commit/476902e9cedbc068a815897dd22eabdb52dee84a))
|
||||||
|
* **youtube/general-ads:** use correct setting to hide related videos in quick actions ([e626bd0](https://github.com/revanced/revanced-integrations/commit/e626bd08c1249cb5594d15c77d06cae8ae27e055))
|
||||||
|
* **youtube/general-ads:** use correct setting to hide related videos in quick actions ([05bfc68](https://github.com/revanced/revanced-integrations/commit/05bfc689078beb9a21adc6c4555afe0862e304f7))
|
||||||
|
|
||||||
|
# [0.99.0-dev.3](https://github.com/revanced/revanced-integrations/compare/v0.99.0-dev.2...v0.99.0-dev.3) (2023-02-24)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **youtube/return-youtube-dislike:** support for shorts ([#312](https://github.com/revanced/revanced-integrations/issues/312)) ([0aef5e6](https://github.com/revanced/revanced-integrations/commit/0aef5e60e280b63490dac8d1b706e896fdf913a2))
|
||||||
|
|
||||||
|
# [0.99.0-dev.2](https://github.com/revanced/revanced-integrations/compare/v0.99.0-dev.1...v0.99.0-dev.2) (2023-02-23)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **youtube/general-ads:** hide quick actions in fullscreen ([ae862cb](https://github.com/revanced/revanced-integrations/commit/ae862cbac6f9a9b717617469d202b48923a1d3b4))
|
||||||
|
* **youtube/general-ads:** hide related videos in quick action ([cfc571c](https://github.com/revanced/revanced-integrations/commit/cfc571c12cb012b86c8bfa8bf7df1c77b9711a21))
|
||||||
|
|
||||||
|
# [0.99.0-dev.1](https://github.com/revanced/revanced-integrations/compare/v0.98.0...v0.99.0-dev.1) (2023-02-22)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **youtube:** remove patch `open-links-directly` ([dce882b](https://github.com/revanced/revanced-integrations/commit/dce882b12809c074ae796b3551ddd82806bd084d))
|
||||||
|
|
||||||
|
# [0.98.0](https://github.com/revanced/revanced-integrations/compare/v0.97.0...v0.98.0) (2023-02-22)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* remove nullable annotation in Kotlin code ([b5a29fd](https://github.com/revanced/revanced-integrations/commit/b5a29fdce195ab47edd61d1d684def1ac919297c))
|
||||||
|
* **twitter:** make `hide-ads` patch compatible with any version ([6655988](https://github.com/revanced/revanced-integrations/commit/665598836abfcead9c5e68ce7831a4137465df39))
|
||||||
|
* **youtube/hide-watch-in-vr:** fix descriptions ([96fcc0b](https://github.com/revanced/revanced-integrations/commit/96fcc0b1c70c277c99a99db9ca2d50f649a41a70))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **twitter:** `hide-recommended-users` patch ([96eea3d](https://github.com/revanced/revanced-integrations/commit/96eea3d4fc096f389840481b146dcf1542cb9c43))
|
||||||
|
* **youtube/general-ads:** hide channel bar ([35c4266](https://github.com/revanced/revanced-integrations/commit/35c4266e8b8ad7cf9fb5d14cf6cbc8ae65cc78df))
|
||||||
|
* **youtube/general-ads:** hide full-screen feed banner ([da1572c](https://github.com/revanced/revanced-integrations/commit/da1572c28d20e2549d0e2a68591f23bb68d8cc9c))
|
||||||
|
* **youtube/general-ads:** hide horizontal video shelf ([fd975ec](https://github.com/revanced/revanced-integrations/commit/fd975ecd2a91ea7ac713d3b7badf373c7d53ad5c))
|
||||||
|
* **youtube/open-links-directly:** skip every redirect url ([2d73b8b](https://github.com/revanced/revanced-integrations/commit/2d73b8b29b14ab9ce20fa33ea4ebfa66984c5903))
|
||||||
|
|
||||||
# [0.98.0-dev.5](https://github.com/revanced/revanced-integrations/compare/v0.98.0-dev.4...v0.98.0-dev.5) (2023-02-22)
|
# [0.98.0-dev.5](https://github.com/revanced/revanced-integrations/compare/v0.98.0-dev.4...v0.98.0-dev.5) (2023-02-22)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -35,11 +35,13 @@ public final class GeneralAdsPatch extends Filter {
|
|||||||
var channelGuidelines = new BlockRule(SettingsEnum.ADREMOVER_HIDE_CHANNEL_GUIDELINES, "channel_guidelines_entry_banner");
|
var channelGuidelines = new BlockRule(SettingsEnum.ADREMOVER_HIDE_CHANNEL_GUIDELINES, "channel_guidelines_entry_banner");
|
||||||
var artistCard = new BlockRule(SettingsEnum.HIDE_ARTIST_CARDS, "official_card");
|
var artistCard = new BlockRule(SettingsEnum.HIDE_ARTIST_CARDS, "official_card");
|
||||||
var selfSponsor = new BlockRule(SettingsEnum.ADREMOVER_SELF_SPONSOR_REMOVAL, "cta_shelf_card");
|
var selfSponsor = new BlockRule(SettingsEnum.ADREMOVER_SELF_SPONSOR_REMOVAL, "cta_shelf_card");
|
||||||
var chapterTeaser = new BlockRule(SettingsEnum.ADREMOVER_CHAPTER_TEASER_REMOVAL, "expandable_metadata");
|
var chapterTeaser = new BlockRule(SettingsEnum.ADREMOVER_CHAPTER_TEASER_REMOVAL, "expandable_metadata", "macro_markers_carousel");
|
||||||
var viewProducts = new BlockRule(SettingsEnum.ADREMOVER_VIEW_PRODUCTS, "product_item", "products_in_video");
|
var viewProducts = new BlockRule(SettingsEnum.ADREMOVER_VIEW_PRODUCTS, "product_item", "products_in_video");
|
||||||
var webLinkPanel = new BlockRule(SettingsEnum.ADREMOVER_WEB_SEARCH_RESULTS, "web_link_panel");
|
var webLinkPanel = new BlockRule(SettingsEnum.ADREMOVER_WEB_SEARCH_RESULTS, "web_link_panel");
|
||||||
var horizontalVideoShelf = new BlockRule(SettingsEnum.ADREMOVER_HORIZONTAL_VIDEO_SHELF, "horizontal_video_shelf");
|
|
||||||
var channelBar = new BlockRule(SettingsEnum.ADREMOVER_CHANNEL_BAR, "channel_bar");
|
var channelBar = new BlockRule(SettingsEnum.ADREMOVER_CHANNEL_BAR, "channel_bar");
|
||||||
|
var relatedVideos = new BlockRule(SettingsEnum.ADREMOVER_RELATED_VIDEOS, "fullscreen_related_videos");
|
||||||
|
var quickActions = new BlockRule(SettingsEnum.ADREMOVER_QUICK_ACTIONS, "quick_actions");
|
||||||
|
var imageShelf = new BlockRule(SettingsEnum.ADREMOVER_IMAGE_SHELF, "image_shelf");
|
||||||
var graySeparator = new BlockRule(SettingsEnum.ADREMOVER_GRAY_SEPARATOR,
|
var graySeparator = new BlockRule(SettingsEnum.ADREMOVER_GRAY_SEPARATOR,
|
||||||
"cell_divider" // layout residue (gray line above the buttoned ad),
|
"cell_divider" // layout residue (gray line above the buttoned ad),
|
||||||
);
|
);
|
||||||
@@ -78,6 +80,8 @@ public final class GeneralAdsPatch extends Filter {
|
|||||||
movieAds,
|
movieAds,
|
||||||
chapterTeaser,
|
chapterTeaser,
|
||||||
communityGuidelines,
|
communityGuidelines,
|
||||||
|
quickActions,
|
||||||
|
relatedVideos,
|
||||||
compactBanner,
|
compactBanner,
|
||||||
inFeedSurvey,
|
inFeedSurvey,
|
||||||
viewProducts,
|
viewProducts,
|
||||||
@@ -88,7 +92,7 @@ public final class GeneralAdsPatch extends Filter {
|
|||||||
artistCard,
|
artistCard,
|
||||||
selfSponsor,
|
selfSponsor,
|
||||||
webLinkPanel,
|
webLinkPanel,
|
||||||
horizontalVideoShelf,
|
imageShelf,
|
||||||
subscribersCommunityGuidelines,
|
subscribersCommunityGuidelines,
|
||||||
channelMemberShelf
|
channelMemberShelf
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,25 +0,0 @@
|
|||||||
package app.revanced.integrations.patches;
|
|
||||||
|
|
||||||
import android.net.Uri;
|
|
||||||
import app.revanced.integrations.settings.SettingsEnum;
|
|
||||||
|
|
||||||
public class OpenLinksDirectlyPatch {
|
|
||||||
private static final String YOUTUBE_REDIRECT_PATH = "redirect";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parses the given YouTube redirect uri by extracting the redirect query.
|
|
||||||
*
|
|
||||||
* @param uri The YouTube redirect uri.
|
|
||||||
* @return The redirect query.
|
|
||||||
*/
|
|
||||||
public static Uri parseRedirectUri(String uri) {
|
|
||||||
if (SettingsEnum.OPEN_LINKS_DIRECTLY.getBoolean()) {
|
|
||||||
final var parsed = Uri.parse(uri);
|
|
||||||
|
|
||||||
if (parsed.getPath().equals(YOUTUBE_REDIRECT_PATH))
|
|
||||||
Uri.parse(parsed.getQueryParameter("q"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return Uri.parse(uri);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,22 +1,25 @@
|
|||||||
package app.revanced.integrations.patches;
|
package app.revanced.integrations.patches;
|
||||||
|
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import android.text.Spanned;
|
||||||
|
|
||||||
import app.revanced.integrations.returnyoutubedislike.ReturnYouTubeDislike;
|
import app.revanced.integrations.returnyoutubedislike.ReturnYouTubeDislike;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by app.revanced.patches.youtube.layout.returnyoutubedislike.patch.ReturnYouTubeDislikePatch
|
* Used by app.revanced.patches.youtube.layout.returnyoutubedislike.patch.ReturnYouTubeDislikePatch
|
||||||
*/
|
*/
|
||||||
public class ReturnYouTubeDislikePatch {
|
public class ReturnYouTubeDislikePatch {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when the video id changes
|
* Injection point
|
||||||
*/
|
*/
|
||||||
public static void newVideoLoaded(String videoId) {
|
public static void newVideoLoaded(String videoId) {
|
||||||
ReturnYouTubeDislike.newVideoLoaded(videoId);
|
ReturnYouTubeDislike.newVideoLoaded(videoId);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Injection point
|
||||||
|
*
|
||||||
* Called when a litho text component is created
|
* Called when a litho text component is created
|
||||||
*/
|
*/
|
||||||
public static void onComponentCreated(Object conversionContext, AtomicReference<Object> textRef) {
|
public static void onComponentCreated(Object conversionContext, AtomicReference<Object> textRef) {
|
||||||
@@ -24,16 +27,22 @@ public class ReturnYouTubeDislikePatch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Injection point
|
||||||
|
*
|
||||||
|
* Called when a Shorts dislike Spannable is created
|
||||||
|
*/
|
||||||
|
public static Spanned onShortsComponentCreated(Spanned dislike) {
|
||||||
|
return ReturnYouTubeDislike.onShortsComponentCreated(dislike);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Injection point
|
||||||
|
*
|
||||||
* Called when the like/dislike button is clicked
|
* Called when the like/dislike button is clicked
|
||||||
*
|
*
|
||||||
* @param vote -1 (dislike), 0 (none) or 1 (like)
|
* @param vote -1 (dislike), 0 (none) or 1 (like)
|
||||||
*/
|
*/
|
||||||
public static void sendVote(int vote) {
|
public static void sendVote(int vote) {
|
||||||
for (ReturnYouTubeDislike.Vote v : ReturnYouTubeDislike.Vote.values()) {
|
ReturnYouTubeDislike.sendVote(vote);
|
||||||
if (v.value == vote) {
|
|
||||||
ReturnYouTubeDislike.sendVote(v);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,9 +1,13 @@
|
|||||||
package app.revanced.integrations.returnyoutubedislike.requests;
|
package app.revanced.integrations.returnyoutubedislike.requests;
|
||||||
|
|
||||||
|
import static app.revanced.integrations.returnyoutubedislike.ReturnYouTubeDislike.Vote;
|
||||||
|
|
||||||
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.util.Objects;
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ReturnYouTubeDislike API estimated like/dislike/view counts.
|
* ReturnYouTubeDislike API estimated like/dislike/view counts.
|
||||||
@@ -12,7 +16,7 @@ import java.util.Objects;
|
|||||||
* So these values may lag behind what YouTube shows.
|
* So these values may lag behind what YouTube shows.
|
||||||
*/
|
*/
|
||||||
public final class RYDVoteData {
|
public final class RYDVoteData {
|
||||||
|
@NonNull
|
||||||
public final String videoId;
|
public final String videoId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,46 +24,87 @@ public final class RYDVoteData {
|
|||||||
*/
|
*/
|
||||||
public final long viewCount;
|
public final long viewCount;
|
||||||
|
|
||||||
|
private final long fetchedLikeCount;
|
||||||
|
private volatile long likeCount; // read/write from different threads
|
||||||
|
private volatile float likePercentage;
|
||||||
|
|
||||||
|
private final long fetchedDislikeCount;
|
||||||
|
private volatile long dislikeCount; // read/write from different threads
|
||||||
|
private volatile float dislikePercentage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws JSONException if JSON parse error occurs, or if the values make no sense (ie: negative values)
|
||||||
|
*/
|
||||||
|
public RYDVoteData(@NonNull JSONObject json) throws JSONException {
|
||||||
|
videoId = json.getString("id");
|
||||||
|
viewCount = json.getLong("viewCount");
|
||||||
|
fetchedLikeCount = json.getLong("likes");
|
||||||
|
fetchedDislikeCount = json.getLong("dislikes");
|
||||||
|
if (viewCount < 0 || fetchedLikeCount < 0 || fetchedDislikeCount < 0) {
|
||||||
|
throw new JSONException("Unexpected JSON values: " + json);
|
||||||
|
}
|
||||||
|
likeCount = fetchedLikeCount;
|
||||||
|
dislikeCount = fetchedDislikeCount;
|
||||||
|
updatePercentages();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Estimated like count
|
* Estimated like count
|
||||||
*/
|
*/
|
||||||
public final long likeCount;
|
public long getLikeCount() {
|
||||||
|
return likeCount;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Estimated dislike count
|
* Estimated dislike count
|
||||||
*/
|
*/
|
||||||
public final long dislikeCount;
|
public long getDislikeCount() {
|
||||||
|
return dislikeCount;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Estimated percentage of likes for all votes. Value has range of [0, 1]
|
* Estimated percentage of likes for all votes. Value has range of [0, 1]
|
||||||
*
|
*
|
||||||
* A video with 400 positive votes, and 100 negative votes, has a likePercentage of 0.8
|
* A video with 400 positive votes, and 100 negative votes, has a likePercentage of 0.8
|
||||||
*/
|
*/
|
||||||
public final float likePercentage;
|
public float getLikePercentage() {
|
||||||
|
return likePercentage;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Estimated percentage of dislikes for all votes. Value has range of [0, 1]
|
* Estimated percentage of dislikes for all votes. Value has range of [0, 1]
|
||||||
*
|
*
|
||||||
* A video with 400 positive votes, and 100 negative votes, has a dislikePercentage of 0.2
|
* A video with 400 positive votes, and 100 negative votes, has a dislikePercentage of 0.2
|
||||||
*/
|
*/
|
||||||
public final float dislikePercentage;
|
public float getDislikePercentage() {
|
||||||
|
return dislikePercentage;
|
||||||
/**
|
|
||||||
* @throws JSONException if JSON parse error occurs, or if the values make no sense (ie: negative values)
|
|
||||||
*/
|
|
||||||
public RYDVoteData(JSONObject json) throws JSONException {
|
|
||||||
Objects.requireNonNull(json);
|
|
||||||
videoId = json.getString("id");
|
|
||||||
viewCount = json.getLong("viewCount");
|
|
||||||
likeCount = json.getLong("likes");
|
|
||||||
dislikeCount = json.getLong("dislikes");
|
|
||||||
if (likeCount < 0 || dislikeCount < 0 || viewCount < 0) {
|
|
||||||
throw new JSONException("Unexpected JSON values: " + json);
|
|
||||||
}
|
|
||||||
likePercentage = (likeCount == 0 ? 0 : (float)likeCount / (likeCount + dislikeCount));
|
|
||||||
dislikePercentage = (dislikeCount == 0 ? 0 : (float)dislikeCount / (likeCount + dislikeCount));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void updateUsingVote(Vote vote) {
|
||||||
|
if (vote == Vote.LIKE) {
|
||||||
|
LogHelper.printDebug(() -> "Increasing like count");
|
||||||
|
likeCount = fetchedLikeCount + 1;
|
||||||
|
dislikeCount = fetchedDislikeCount;
|
||||||
|
} else if (vote == Vote.DISLIKE) {
|
||||||
|
LogHelper.printDebug(() -> "Increasing dislike count");
|
||||||
|
likeCount = fetchedLikeCount;
|
||||||
|
dislikeCount = fetchedDislikeCount + 1;
|
||||||
|
} else if (vote == Vote.LIKE_REMOVE) {
|
||||||
|
LogHelper.printDebug(() -> "Resetting like/dislike to fetched values");
|
||||||
|
likeCount = fetchedLikeCount;
|
||||||
|
dislikeCount = fetchedDislikeCount;
|
||||||
|
} else {
|
||||||
|
throw new IllegalStateException();
|
||||||
|
}
|
||||||
|
updatePercentages();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updatePercentages() {
|
||||||
|
likePercentage = (likeCount == 0 ? 0 : (float) likeCount / (likeCount + dislikeCount));
|
||||||
|
dislikePercentage = (dislikeCount == 0 ? 0 : (float) dislikeCount / (likeCount + dislikeCount));
|
||||||
|
}
|
||||||
|
|
||||||
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "RYDVoteData{"
|
return "RYDVoteData{"
|
||||||
@@ -73,4 +118,5 @@ public final class RYDVoteData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// equals and hashcode is not implemented (currently not needed)
|
// equals and hashcode is not implemented (currently not needed)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,27 @@
|
|||||||
package app.revanced.integrations.returnyoutubedislike.requests;
|
package app.revanced.integrations.returnyoutubedislike.requests;
|
||||||
|
|
||||||
import static app.revanced.integrations.returnyoutubedislike.requests.ReturnYouTubeDislikeRoutes.getRYDConnectionFromRoute;
|
|
||||||
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
|
||||||
|
|
||||||
import android.util.Base64;
|
import android.util.Base64;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
|
import app.revanced.integrations.requests.Requester;
|
||||||
|
import app.revanced.integrations.returnyoutubedislike.ReturnYouTubeDislike;
|
||||||
|
import app.revanced.integrations.utils.LogHelper;
|
||||||
|
import app.revanced.integrations.utils.ReVancedUtils;
|
||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.ProtocolException;
|
import java.net.ProtocolException;
|
||||||
|
import java.net.SocketTimeoutException;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.security.MessageDigest;
|
import java.security.MessageDigest;
|
||||||
import java.security.NoSuchAlgorithmException;
|
import java.security.NoSuchAlgorithmException;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
import app.revanced.integrations.requests.Requester;
|
import static app.revanced.integrations.returnyoutubedislike.requests.ReturnYouTubeDislikeRoutes.getRYDConnectionFromRoute;
|
||||||
import app.revanced.integrations.returnyoutubedislike.ReturnYouTubeDislike;
|
import static app.revanced.integrations.sponsorblock.StringRef.str;
|
||||||
import app.revanced.integrations.utils.LogHelper;
|
|
||||||
import app.revanced.integrations.utils.ReVancedUtils;
|
|
||||||
|
|
||||||
public class ReturnYouTubeDislikeApi {
|
public class ReturnYouTubeDislikeApi {
|
||||||
/**
|
/**
|
||||||
@@ -48,7 +46,13 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
/**
|
/**
|
||||||
* Response code of a successful API call
|
* Response code of a successful API call
|
||||||
*/
|
*/
|
||||||
private static final int SUCCESS_HTTP_STATUS_CODE = 200;
|
private static final int HTTP_STATUS_CODE_SUCCESS = 200;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Response code indicating the video id is not for a video that can be voted for.
|
||||||
|
* (it's not a Short or a regular video, and it's likely a YouTube Story)
|
||||||
|
*/
|
||||||
|
private static final int HTTP_STATUS_CODE_NOT_FOUND = 404;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Indicates a client rate limit has been reached
|
* Indicates a client rate limit has been reached
|
||||||
@@ -57,9 +61,9 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* How long to wait until API calls are resumed, if a rate limit is hit.
|
* How long to wait until API calls are resumed, if a rate limit is hit.
|
||||||
* No clear guideline of how long to backoff. Using 60 seconds for now.
|
* No clear guideline of how long to backoff. Using 2 minutes for now.
|
||||||
*/
|
*/
|
||||||
private static final int RATE_LIMIT_BACKOFF_SECONDS = 60;
|
private static final int RATE_LIMIT_BACKOFF_SECONDS = 120;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Last time a {@link #RATE_LIMIT_HTTP_STATUS_CODE} was reached.
|
* Last time a {@link #RATE_LIMIT_HTTP_STATUS_CODE} was reached.
|
||||||
@@ -133,6 +137,7 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
*
|
*
|
||||||
* @param maximumTimeToWait maximum time to wait
|
* @param maximumTimeToWait maximum time to wait
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("UnusedReturnValue")
|
||||||
private static long randomlyWaitIfLocallyDebugging(long maximumTimeToWait) {
|
private static long randomlyWaitIfLocallyDebugging(long maximumTimeToWait) {
|
||||||
final boolean DEBUG_RANDOMLY_DELAY_NETWORK_CALLS = false; // set true to debug UI
|
final boolean DEBUG_RANDOMLY_DELAY_NETWORK_CALLS = false; // set true to debug UI
|
||||||
if (DEBUG_RANDOMLY_DELAY_NETWORK_CALLS) {
|
if (DEBUG_RANDOMLY_DELAY_NETWORK_CALLS) {
|
||||||
@@ -183,6 +188,8 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
|
|
||||||
if (httpResponseCode == RATE_LIMIT_HTTP_STATUS_CODE) {
|
if (httpResponseCode == RATE_LIMIT_HTTP_STATUS_CODE) {
|
||||||
lastTimeRateLimitWasHit = System.currentTimeMillis();
|
lastTimeRateLimitWasHit = System.currentTimeMillis();
|
||||||
|
//noinspection NonAtomicOperationOnVolatileField // don't care, field is used only as an estimate
|
||||||
|
numberOfRateLimitRequestsEncountered++;
|
||||||
LogHelper.printDebug(() -> "API rate limit was hit. Stopping API calls for the next "
|
LogHelper.printDebug(() -> "API rate limit was hit. Stopping API calls for the next "
|
||||||
+ RATE_LIMIT_BACKOFF_SECONDS + " seconds");
|
+ RATE_LIMIT_BACKOFF_SECONDS + " seconds");
|
||||||
ReVancedUtils.runOnMainThread(() -> { // must show toasts on main thread
|
ReVancedUtils.runOnMainThread(() -> { // must show toasts on main thread
|
||||||
@@ -208,7 +215,6 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
fetchCallNumberOfFailures++;
|
fetchCallNumberOfFailures++;
|
||||||
} else if (rateLimitHit) {
|
} else if (rateLimitHit) {
|
||||||
fetchCallResponseTimeLast = FETCH_CALL_RESPONSE_TIME_VALUE_RATE_LIMIT;
|
fetchCallResponseTimeLast = FETCH_CALL_RESPONSE_TIME_VALUE_RATE_LIMIT;
|
||||||
numberOfRateLimitRequestsEncountered++;
|
|
||||||
} else {
|
} else {
|
||||||
fetchCallResponseTimeLast = responseTimeOfFetchCall;
|
fetchCallResponseTimeLast = responseTimeOfFetchCall;
|
||||||
}
|
}
|
||||||
@@ -228,7 +234,6 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
LogHelper.printDebug(() -> "Fetching votes for: " + videoId);
|
LogHelper.printDebug(() -> "Fetching votes for: " + videoId);
|
||||||
final long timeNetworkCallStarted = System.currentTimeMillis();
|
final long timeNetworkCallStarted = System.currentTimeMillis();
|
||||||
|
|
||||||
String connectionErrorMessageStringKey = "revanced_ryd_failure_connection_timeout";
|
|
||||||
try {
|
try {
|
||||||
HttpURLConnection connection = getRYDConnectionFromRoute(ReturnYouTubeDislikeRoutes.GET_DISLIKES, videoId);
|
HttpURLConnection connection = getRYDConnectionFromRoute(ReturnYouTubeDislikeRoutes.GET_DISLIKES, videoId);
|
||||||
// request headers, as per https://returnyoutubedislike.com/docs/fetching
|
// request headers, as per https://returnyoutubedislike.com/docs/fetching
|
||||||
@@ -250,7 +255,7 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (responseCode == SUCCESS_HTTP_STATUS_CODE) {
|
if (responseCode == HTTP_STATUS_CODE_SUCCESS) {
|
||||||
final long timeNetworkCallEnded = System.currentTimeMillis(); // record end time before parsing
|
final long timeNetworkCallEnded = System.currentTimeMillis(); // record end time before parsing
|
||||||
// do not disconnect, the same server connection will likely be used again soon
|
// do not disconnect, the same server connection will likely be used again soon
|
||||||
JSONObject json = Requester.parseJSONObject(connection);
|
JSONObject json = Requester.parseJSONObject(connection);
|
||||||
@@ -263,13 +268,20 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
LogHelper.printException(() -> "Failed to parse video: " + videoId + " json: " + json, ex);
|
LogHelper.printException(() -> "Failed to parse video: " + videoId + " json: " + json, ex);
|
||||||
// fall thru to update statistics
|
// fall thru to update statistics
|
||||||
}
|
}
|
||||||
|
} else if (responseCode == HTTP_STATUS_CODE_NOT_FOUND) {
|
||||||
|
// normal response when viewing YouTube Stories (cannot vote for these)
|
||||||
|
LogHelper.printDebug(() -> "Video has no like/dislikes (video is a YouTube Story?): " + videoId);
|
||||||
|
return null; // do not updated connection statistics
|
||||||
} else {
|
} else {
|
||||||
LogHelper.printException(() -> "Failed to fetch votes for video: " + videoId
|
LogHelper.printException(() -> "Failed to fetch votes for video: " + videoId + " response code was: " + responseCode,
|
||||||
+ " response code was: " + responseCode, null, str(connectionErrorMessageStringKey));
|
null, str("revanced_ryd_failure_connection_status_code", responseCode));
|
||||||
connection.disconnect(); // something went wrong, might as well disconnect
|
connection.disconnect(); // something went wrong, might as well disconnect
|
||||||
}
|
}
|
||||||
} catch (Exception ex) { // connection timed out, response timeout, or some other network error
|
} catch (SocketTimeoutException ex) { // connection timed out, response timeout, or some other network error
|
||||||
LogHelper.printException(() -> "Failed to fetch votes", ex, str(connectionErrorMessageStringKey));
|
LogHelper.printException(() -> "Failed to fetch votes", ex, str("revanced_ryd_failure_connection_timeout"));
|
||||||
|
} catch (Exception ex) {
|
||||||
|
// should never happen
|
||||||
|
LogHelper.printException(() -> "Failed to fetch votes", ex, str("revanced_ryd_failure_generic", ex.getMessage()));
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStatistics(timeNetworkCallStarted, System.currentTimeMillis(), true, false);
|
updateStatistics(timeNetworkCallStarted, System.currentTimeMillis(), true, false);
|
||||||
@@ -299,7 +311,7 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
connection.disconnect(); // disconnect, as no more connections will be made for a little while
|
connection.disconnect(); // disconnect, as no more connections will be made for a little while
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (responseCode == SUCCESS_HTTP_STATUS_CODE) {
|
if (responseCode == HTTP_STATUS_CODE_SUCCESS) {
|
||||||
JSONObject json = Requester.parseJSONObject(connection);
|
JSONObject json = Requester.parseJSONObject(connection);
|
||||||
String challenge = json.getString("challenge");
|
String challenge = json.getString("challenge");
|
||||||
int difficulty = json.getInt("difficulty");
|
int difficulty = json.getInt("difficulty");
|
||||||
@@ -340,7 +352,7 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
connection.disconnect(); // disconnect, as no more connections will be made for a little while
|
connection.disconnect(); // disconnect, as no more connections will be made for a little while
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (responseCode == SUCCESS_HTTP_STATUS_CODE) {
|
if (responseCode == HTTP_STATUS_CODE_SUCCESS) {
|
||||||
String result = Requester.parseJson(connection);
|
String result = Requester.parseJson(connection);
|
||||||
if (result.equalsIgnoreCase("true")) {
|
if (result.equalsIgnoreCase("true")) {
|
||||||
LogHelper.printDebug(() -> "Registration confirmation successful for user: " + userId);
|
LogHelper.printDebug(() -> "Registration confirmation successful for user: " + userId);
|
||||||
@@ -387,7 +399,7 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
connection.disconnect(); // disconnect, as no more connections will be made for a little while
|
connection.disconnect(); // disconnect, as no more connections will be made for a little while
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (responseCode == SUCCESS_HTTP_STATUS_CODE) {
|
if (responseCode == HTTP_STATUS_CODE_SUCCESS) {
|
||||||
JSONObject json = Requester.parseJSONObject(connection);
|
JSONObject json = Requester.parseJSONObject(connection);
|
||||||
String challenge = json.getString("challenge");
|
String challenge = json.getString("challenge");
|
||||||
int difficulty = json.getInt("difficulty");
|
int difficulty = json.getInt("difficulty");
|
||||||
@@ -431,7 +443,7 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (responseCode == SUCCESS_HTTP_STATUS_CODE) {
|
if (responseCode == HTTP_STATUS_CODE_SUCCESS) {
|
||||||
String result = Requester.parseJson(connection);
|
String result = Requester.parseJson(connection);
|
||||||
if (result.equalsIgnoreCase("true")) {
|
if (result.equalsIgnoreCase("true")) {
|
||||||
LogHelper.printDebug(() -> "Vote confirm successful for video: " + videoId);
|
LogHelper.printDebug(() -> "Vote confirm successful for video: " + videoId);
|
||||||
@@ -469,9 +481,7 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
byte[] decodedChallenge = Base64.decode(challenge, Base64.NO_WRAP);
|
byte[] decodedChallenge = Base64.decode(challenge, Base64.NO_WRAP);
|
||||||
|
|
||||||
byte[] buffer = new byte[20];
|
byte[] buffer = new byte[20];
|
||||||
for (int i = 4; i < 20; i++) { // FIXME replace with System.arrayCopy
|
System.arraycopy(decodedChallenge, 0, buffer, 4, 16);
|
||||||
buffer[i] = decodedChallenge[i - 4];
|
|
||||||
}
|
|
||||||
|
|
||||||
MessageDigest md;
|
MessageDigest md;
|
||||||
try {
|
try {
|
||||||
@@ -513,9 +523,9 @@ public class ReturnYouTubeDislikeApi {
|
|||||||
|
|
||||||
private static int countLeadingZeroes(byte[] uInt8View) {
|
private static int countLeadingZeroes(byte[] uInt8View) {
|
||||||
int zeroes = 0;
|
int zeroes = 0;
|
||||||
int value = 0;
|
int value;
|
||||||
for (int i = 0; i < uInt8View.length; i++) {
|
for (byte b : uInt8View) {
|
||||||
value = uInt8View[i] & 0xFF;
|
value = b & 0xFF;
|
||||||
if (value == 0) {
|
if (value == 0) {
|
||||||
zeroes += 8;
|
zeroes += 8;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -54,8 +54,10 @@ public enum SettingsEnum {
|
|||||||
ADREMOVER_GRAY_SEPARATOR("revanced_adremover_separator", true, ReturnType.BOOLEAN),
|
ADREMOVER_GRAY_SEPARATOR("revanced_adremover_separator", true, ReturnType.BOOLEAN),
|
||||||
ADREMOVER_VIEW_PRODUCTS("revanced_adremover_view_products", true, ReturnType.BOOLEAN),
|
ADREMOVER_VIEW_PRODUCTS("revanced_adremover_view_products", true, ReturnType.BOOLEAN),
|
||||||
ADREMOVER_WEB_SEARCH_RESULTS("revanced_adremover_web_search_result", true, ReturnType.BOOLEAN),
|
ADREMOVER_WEB_SEARCH_RESULTS("revanced_adremover_web_search_result", true, ReturnType.BOOLEAN),
|
||||||
ADREMOVER_HORIZONTAL_VIDEO_SHELF("revanced_horizontal_video_shelf", true, ReturnType.BOOLEAN),
|
|
||||||
ADREMOVER_CHANNEL_BAR("revanced_hide_channel_bar", false, ReturnType.BOOLEAN),
|
ADREMOVER_CHANNEL_BAR("revanced_hide_channel_bar", false, ReturnType.BOOLEAN),
|
||||||
|
ADREMOVER_QUICK_ACTIONS("revanced_hide_quick_actions", false, ReturnType.BOOLEAN),
|
||||||
|
ADREMOVER_RELATED_VIDEOS("revanced_hide_related_videos", false, ReturnType.BOOLEAN),
|
||||||
|
ADREMOVER_IMAGE_SHELF("revanced_hide_image_shelf", true, ReturnType.BOOLEAN),
|
||||||
|
|
||||||
// Action buttons
|
// Action buttons
|
||||||
HIDE_LIKE_BUTTON("revanced_hide_like_button", false, ReturnType.BOOLEAN, false),
|
HIDE_LIKE_BUTTON("revanced_hide_like_button", false, ReturnType.BOOLEAN, false),
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import app.revanced.integrations.utils.Event
|
|||||||
*/
|
*/
|
||||||
@Suppress("unused")
|
@Suppress("unused")
|
||||||
enum class PlayerType {
|
enum class PlayerType {
|
||||||
NONE, // this also includes when shorts are playing
|
NONE, // includes Shorts playback
|
||||||
HIDDEN,
|
HIDDEN, // also includes YouTube Shorts and Stories, if a regular video is minimized and a Short/Story is then opened
|
||||||
WATCH_WHILE_MINIMIZED,
|
WATCH_WHILE_MINIMIZED,
|
||||||
WATCH_WHILE_MAXIMIZED,
|
WATCH_WHILE_MAXIMIZED,
|
||||||
WATCH_WHILE_FULLSCREEN,
|
WATCH_WHILE_FULLSCREEN,
|
||||||
@@ -42,6 +42,7 @@ enum class PlayerType {
|
|||||||
currentPlayerType = value
|
currentPlayerType = value
|
||||||
onChange(currentPlayerType)
|
onChange(currentPlayerType)
|
||||||
}
|
}
|
||||||
|
@Volatile // value is read/write from different threads
|
||||||
private var currentPlayerType = NONE
|
private var currentPlayerType = NONE
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -51,7 +52,9 @@ enum class PlayerType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Weather Shorts are being played.
|
* Check if the current player type is [NONE] or [HIDDEN]
|
||||||
|
*
|
||||||
|
* @return True, if nothing, a Short, or a Story is playing.
|
||||||
*/
|
*/
|
||||||
fun isNoneOrHidden(): Boolean {
|
fun isNoneOrHidden(): Boolean {
|
||||||
return this == NONE || this == HIDDEN
|
return this == NONE || this == HIDDEN
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
org.gradle.jvmargs = -Xmx2048m
|
org.gradle.jvmargs = -Xmx2048m
|
||||||
android.useAndroidX = true
|
android.useAndroidX = true
|
||||||
version = 0.98.0-dev.5
|
version = 0.100.0-dev.3
|
||||||
|
|||||||
Reference in New Issue
Block a user