mirror of
https://github.com/faroukbmiled/RyukGram.git
synced 2026-05-31 20:51:35 +02:00
2977873932
- Profile Analyzer (beta) — follower/following scans with mutuals, non-followbacks, new/lost trackers, and profile change history; searchable lists with batch follow/unfollow - Theme settings — force dark mode, Full OLED, OLED chat theme, and keyboard theme picker - Confirm story like - Confirm story emoji reaction - Swipe down to dismiss media viewer - Manually add users to story/chat exclusion lists by username - Keep stories visually seen locally - Auto-scroll reels mode - Quality picker: audio-only and raw photo download rows - Clear cache button with optional auto-clear interval - Spanish, Russian, Korean, Arabic, and Chinese (Traditional) translations - About page with version, credits, and links - Release notes popup on first launch of a new version - Anonymous live viewing - Toggle live comments - Disappearing DM media overlay — action button, mark-as-viewed eye, and audio toggle - Hide RyukGram UI on screenshots, screen recordings, and mirroring - Open link from clipboard — long-press the search tab - Messages-only mode: optional "Hide tab bar" sub-toggle - Fake profile stats — verified badge and follower/following/post counts on your own profile - Language switcher + import/export localization from Debug - Reveal poll/slider vote counts and quiz answers on stories and reels before interacting - Force legacy Quiz sticker back into the story composer tray - Advanced experimental features menu — toggle hidden IG experiments (QuickSnap, Homecoming, Prism, Direct Notes reply types) with apply-on-restart batching and a crash-loop auto-reset - Shortcut to Advanced experimental features from the General experimental features section - Push notifications render with rich previews on sideload again - IG 426 compatibility across story audio toggle, like confirmation, seen-on-like, live comments, notes audio download - Call confirm split into separate voice-call and video-call toggles - Messages-only mode: tab swiping disabled - Settings quick-access broken in non-English languages - Story seen-receipt block restored on IG v426 - Block selected mode no longer marks listed stories as seen - Hide explore posts grid works again on recent IG versions - Hide suggested stories no longer breaks profile highlights - Hide trending searches now also hides the category chip bar - Story eye long-press menu opens next to the button - Disable video autoplay: tap-to-play now works on videos inside carousels - Disable vanish mode swipe fixed on IG 426 - "Confirm shh mode" renamed to "Confirm vanish mode" across all languages - Confirm sticker interaction split into separate story and highlight toggles - Shared link embed presets: added eeinstagram.com and vxinstagram.com - Downloaded media filenames follow `@username_context_timestamp` - Reels pause mode: optional tap-to-mute on photo reels - Backup & Restore — scope picker with live preview for Settings / Excluded lists / Analyzer data - Profile Analyzer: filter by Not verified - Settings header: tap to open a sheet with GitHub and Telegram channel links - Thanks to Furamako for the Spanish translation - Thanks to [ZomkaDEV](https://github.com/ZomkaDEV) for the Russian translation - Thanks to [@ch1tmdgus](https://github.com/ch1tmdgus) (N4C) for the Korean translation - Thanks to [@bruuhim](https://github.com/bruuhim) for the Arabic translation - Thanks to [@jaydenjcpy](https://github.com/jaydenjcpy) for the Chinese (Traditional) translation - Thanks to [@darthplagueiswise](https://github.com/darthplagueiswise) (Radan) for the experimental flag feature set - Thanks to [@asdfzxcvbn](https://github.com/asdfzxcvbn) for [zxPluginsInject](https://github.com/asdfzxcvbn/zxPluginsInject) and [ipapatch](https://github.com/asdfzxcvbn/ipapatch) - Preserved unsent messages can't be removed via "Delete for you"; pull-to-refresh clears them (warning available in settings) - "Delete for you" detection uses a ~2s window after the local action — a real unsend landing in that window may be missed (rare) - With Liquid Glass buttons + Hide UI on capture both on, the DM eye leaves an empty glass bubble in captures
361 lines
16 KiB
Objective-C
361 lines
16 KiB
Objective-C
#import "SCIDashParser.h"
|
|
#import <objc/runtime.h>
|
|
#import <objc/message.h>
|
|
|
|
@implementation SCIDashRepresentation
|
|
@end
|
|
|
|
// Resolve _fieldCache per class (walking the hierarchy). Caching the ivar
|
|
// against IGAPIStorableObject and then reading that offset from an unrelated
|
|
// class like IGVideo segfaults — ivar offsets aren't shared.
|
|
static id sciDashFieldCache(id obj, NSString *key) {
|
|
if (!obj || !key.length) return nil;
|
|
Ivar fcIvar = NULL;
|
|
@try {
|
|
for (Class c = [obj class]; c && !fcIvar; c = class_getSuperclass(c)) {
|
|
fcIvar = class_getInstanceVariable(c, "_fieldCache");
|
|
}
|
|
} @catch (__unused id e) { return nil; }
|
|
if (!fcIvar) return nil;
|
|
id fc = nil;
|
|
@try { fc = object_getIvar(obj, fcIvar); } @catch (__unused id e) { return nil; }
|
|
if (![fc isKindOfClass:[NSDictionary class]]) return nil;
|
|
id val = ((NSDictionary *)fc)[key];
|
|
if (!val || [val isKindOfClass:[NSNull class]]) return nil;
|
|
return val;
|
|
}
|
|
|
|
@implementation SCIDashParser
|
|
|
|
// Looks like XML DASH manifest or a URL to one.
|
|
static BOOL sciLooksLikeManifest(id val) {
|
|
if (![val isKindOfClass:[NSString class]]) return NO;
|
|
NSString *s = (NSString *)val;
|
|
if (s.length < 10) return NO;
|
|
NSString *head = [s substringToIndex:MIN((NSUInteger)16, s.length)];
|
|
return [head containsString:@"<MPD"] || [head containsString:@"<?xml"]
|
|
|| [head hasPrefix:@"http"];
|
|
}
|
|
|
|
// Walk a fieldCache dict looking for any key containing "dash" or "manifest".
|
|
static NSString *sciScanDictForManifest(NSDictionary *dict, NSString *path, int depth) {
|
|
if (depth > 3 || ![dict isKindOfClass:[NSDictionary class]]) return nil;
|
|
for (NSString *k in dict) {
|
|
id v = dict[k];
|
|
NSString *lk = k.lowercaseString;
|
|
if (([lk containsString:@"dash"] || [lk containsString:@"manifest"]) && sciLooksLikeManifest(v)) {
|
|
NSLog(@"[SCInsta][Dash] hit %@/%@ (len=%lu)", path, k, (unsigned long)[(NSString *)v length]);
|
|
return v;
|
|
}
|
|
if ([v isKindOfClass:[NSDictionary class]]) {
|
|
NSString *found = sciScanDictForManifest(v, [NSString stringWithFormat:@"%@/%@", path, k], depth + 1);
|
|
if (found) return found;
|
|
} else if ([v isKindOfClass:[NSArray class]]) {
|
|
for (id item in (NSArray *)v) {
|
|
if ([item isKindOfClass:[NSDictionary class]]) {
|
|
NSString *found = sciScanDictForManifest(item, [NSString stringWithFormat:@"%@/%@[]", path, k], depth + 1);
|
|
if (found) return found;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return nil;
|
|
}
|
|
|
|
static NSDictionary *sciFieldCacheDict(id obj) {
|
|
if (!obj) return nil;
|
|
Ivar fcIvar = NULL;
|
|
@try {
|
|
for (Class c = [obj class]; c && !fcIvar; c = class_getSuperclass(c)) {
|
|
fcIvar = class_getInstanceVariable(c, "_fieldCache");
|
|
}
|
|
} @catch (__unused id e) { return nil; }
|
|
if (!fcIvar) return nil;
|
|
id fc = nil;
|
|
@try { fc = object_getIvar(obj, fcIvar); } @catch (__unused id e) { return nil; }
|
|
return [fc isKindOfClass:[NSDictionary class]] ? fc : nil;
|
|
}
|
|
|
|
// Coerce an arbitrary object (NSString or NSData) into a manifest string.
|
|
static NSString *sciToManifestString(id val) {
|
|
if ([val isKindOfClass:[NSString class]] && [(NSString *)val length] > 10) return val;
|
|
if ([val isKindOfClass:[NSData class]] && [(NSData *)val length] > 10) {
|
|
NSString *s = [[NSString alloc] initWithData:(NSData *)val encoding:NSUTF8StringEncoding];
|
|
if (s.length > 10) return s;
|
|
}
|
|
return nil;
|
|
}
|
|
|
|
+ (NSString *)dashManifestForMedia:(id)media {
|
|
if (!media) return nil;
|
|
|
|
NSArray *keys = @[@"video_dash_manifest", @"dash_manifest",
|
|
@"video_dash_manifest_url", @"dash_manifest_url"];
|
|
|
|
// Direct hits on the media's fieldCache (older builds).
|
|
for (NSString *key in keys) {
|
|
id val = sciDashFieldCache(media, key);
|
|
if (sciLooksLikeManifest(val)) return val;
|
|
}
|
|
|
|
// IGBaseMedia -videoDashManifest (used through IG v440ish).
|
|
@try {
|
|
if ([media respondsToSelector:@selector(videoDashManifest)]) {
|
|
id val = ((id(*)(id, SEL))objc_msgSend)(media, @selector(videoDashManifest));
|
|
NSString *str = sciToManifestString(val);
|
|
if (sciLooksLikeManifest(str)) return str;
|
|
}
|
|
} @catch (__unused id e) {}
|
|
|
|
// Nested IGVideo — both fieldCache + the new -dashManifestData NSData getter.
|
|
id video = nil;
|
|
@try {
|
|
if ([media respondsToSelector:@selector(video)]) {
|
|
video = ((id(*)(id, SEL))objc_msgSend)(media, @selector(video));
|
|
}
|
|
} @catch (__unused id e) { video = nil; }
|
|
if (video) {
|
|
for (NSString *key in keys) {
|
|
id val = sciDashFieldCache(video, key);
|
|
if (sciLooksLikeManifest(val)) return val;
|
|
}
|
|
@try {
|
|
if ([video respondsToSelector:@selector(dashManifestData)]) {
|
|
id val = ((id(*)(id, SEL))objc_msgSend)(video, @selector(dashManifestData));
|
|
NSString *str = sciToManifestString(val);
|
|
if (sciLooksLikeManifest(str)) return str;
|
|
}
|
|
} @catch (__unused id e) {}
|
|
// Direct ivar read as last resort (handles future property removals).
|
|
@try {
|
|
Ivar iv = NULL;
|
|
for (Class c = [video class]; c && !iv; c = class_getSuperclass(c))
|
|
iv = class_getInstanceVariable(c, "_dashManifestData");
|
|
if (iv) {
|
|
id val = object_getIvar(video, iv);
|
|
NSString *str = sciToManifestString(val);
|
|
if (sciLooksLikeManifest(str)) return str;
|
|
}
|
|
} @catch (__unused id e) {}
|
|
}
|
|
|
|
// Wider scan: walk the fieldCache dict recursively for any key containing
|
|
// "dash" or "manifest".
|
|
NSDictionary *fc = sciFieldCacheDict(media);
|
|
if (fc) {
|
|
NSString *found = sciScanDictForManifest(fc, @"fieldCache", 0);
|
|
if (found) return found;
|
|
|
|
// Last-ditch manifest hunt + dump via iterative stack (no recursion,
|
|
// no block self-capture).
|
|
NSMutableArray *stack = [NSMutableArray arrayWithObject:@[fc, @"fieldCache", @(0)]];
|
|
NSString *bigManifest = nil;
|
|
NSString *bigManifestPath = nil;
|
|
NSMutableArray *longStrings = [NSMutableArray array];
|
|
while (stack.count) {
|
|
NSArray *frame = stack.lastObject; [stack removeLastObject];
|
|
id obj = frame[0];
|
|
NSString *path = frame[1];
|
|
int depth = [frame[2] intValue];
|
|
if (depth > 4) continue;
|
|
if ([obj isKindOfClass:[NSDictionary class]]) {
|
|
for (NSString *k in obj) {
|
|
[stack addObject:@[obj[k], [NSString stringWithFormat:@"%@/%@", path, k], @(depth + 1)]];
|
|
}
|
|
} else if ([obj isKindOfClass:[NSArray class]]) {
|
|
NSUInteger i = 0;
|
|
for (id item in obj) {
|
|
[stack addObject:@[item, [NSString stringWithFormat:@"%@[%lu]", path, (unsigned long)i++], @(depth + 1)]];
|
|
}
|
|
} else if ([obj isKindOfClass:[NSString class]]) {
|
|
NSString *s = obj;
|
|
if (s.length > 300) {
|
|
NSString *head = [s substringToIndex:MIN((NSUInteger)32, s.length)];
|
|
if (!bigManifest && ([head containsString:@"<MPD"] || [head containsString:@"<?xml"])) {
|
|
bigManifest = s;
|
|
bigManifestPath = path;
|
|
}
|
|
if (s.length > 200) [longStrings addObject:@[path, @(s.length), [s substringToIndex:MIN((NSUInteger)120, s.length)]]];
|
|
}
|
|
}
|
|
}
|
|
if (bigManifest) {
|
|
NSLog(@"[SCInsta][Dash] found manifest at %@ (len=%lu)", bigManifestPath, (unsigned long)bigManifest.length);
|
|
return bigManifest;
|
|
}
|
|
|
|
static dispatch_once_t once;
|
|
dispatch_once(&once, ^{
|
|
NSLog(@"[SCInsta][Dash] no manifest found; top-level keys=%@", [[fc allKeys] componentsJoinedByString:@","]);
|
|
for (NSArray *row in longStrings) {
|
|
NSLog(@"[SCInsta][Dash] long-str %@ (len=%@) head=%@", row[0], row[1], row[2]);
|
|
}
|
|
});
|
|
}
|
|
|
|
return nil;
|
|
}
|
|
|
|
+ (NSArray<SCIDashRepresentation *> *)parseManifest:(NSString *)xmlString {
|
|
if (!xmlString.length) return @[];
|
|
|
|
NSMutableArray<SCIDashRepresentation *> *results = [NSMutableArray array];
|
|
|
|
NSError *err = nil;
|
|
|
|
// AdaptationSet blocks (handles both contentType= and mimeType= patterns)
|
|
NSRegularExpression *adaptRE = [NSRegularExpression
|
|
regularExpressionWithPattern:@"(<AdaptationSet[^>]*>)(.*?)</AdaptationSet>"
|
|
options:NSRegularExpressionDotMatchesLineSeparators error:&err];
|
|
if (err) return @[];
|
|
|
|
NSRegularExpression *ctRE = [NSRegularExpression
|
|
regularExpressionWithPattern:@"contentType=\"(video|audio)\"" options:NSRegularExpressionCaseInsensitive error:nil];
|
|
NSRegularExpression *mtRE = [NSRegularExpression
|
|
regularExpressionWithPattern:@"mimeType=\"(video|audio)/[^\"]*\"" options:NSRegularExpressionCaseInsensitive error:nil];
|
|
|
|
NSRegularExpression *repRE = [NSRegularExpression
|
|
regularExpressionWithPattern:@"<Representation[^>]*>"
|
|
options:0 error:nil];
|
|
|
|
NSRegularExpression *baseURLRE = [NSRegularExpression
|
|
regularExpressionWithPattern:@"<BaseURL>(.*?)</BaseURL>"
|
|
options:0 error:nil];
|
|
|
|
NSRegularExpression *bwRE = [NSRegularExpression
|
|
regularExpressionWithPattern:@"bandwidth=\"(\\d+)\"" options:0 error:nil];
|
|
NSRegularExpression *widthRE = [NSRegularExpression
|
|
regularExpressionWithPattern:@"(?:^|\\s)width=\"(\\d+)\"" options:0 error:nil];
|
|
NSRegularExpression *heightRE = [NSRegularExpression
|
|
regularExpressionWithPattern:@"(?:^|\\s)height=\"(\\d+)\"" options:0 error:nil];
|
|
NSRegularExpression *labelRE = [NSRegularExpression
|
|
regularExpressionWithPattern:@"FBQualityLabel=\"([^\"]+)\"" options:0 error:nil];
|
|
NSRegularExpression *fpsRE = [NSRegularExpression
|
|
regularExpressionWithPattern:@"frameRate=\"([0-9./]+)\"" options:0 error:nil];
|
|
NSRegularExpression *codecsRE = [NSRegularExpression
|
|
regularExpressionWithPattern:@"codecs=\"([^\"]+)\"" options:0 error:nil];
|
|
|
|
[adaptRE enumerateMatchesInString:xmlString options:0
|
|
range:NSMakeRange(0, xmlString.length)
|
|
usingBlock:^(NSTextCheckingResult *adaptMatch, __unused NSMatchingFlags flags, __unused BOOL *stop) {
|
|
|
|
NSString *adaptTag = [xmlString substringWithRange:[adaptMatch rangeAtIndex:1]];
|
|
NSString *adaptBody = [xmlString substringWithRange:[adaptMatch rangeAtIndex:2]];
|
|
|
|
NSString *contentType = nil;
|
|
NSTextCheckingResult *ctMatch = [ctRE firstMatchInString:adaptTag options:0
|
|
range:NSMakeRange(0, adaptTag.length)];
|
|
if (ctMatch) {
|
|
contentType = [[adaptTag substringWithRange:[ctMatch rangeAtIndex:1]] lowercaseString];
|
|
} else {
|
|
NSTextCheckingResult *mtMatch = [mtRE firstMatchInString:adaptTag options:0
|
|
range:NSMakeRange(0, adaptTag.length)];
|
|
if (mtMatch) {
|
|
contentType = [[adaptTag substringWithRange:[mtMatch rangeAtIndex:1]] lowercaseString];
|
|
}
|
|
}
|
|
if (!contentType) return;
|
|
|
|
NSArray<NSTextCheckingResult *> *repMatches =
|
|
[repRE matchesInString:adaptBody options:0 range:NSMakeRange(0, adaptBody.length)];
|
|
NSArray<NSTextCheckingResult *> *urlMatches =
|
|
[baseURLRE matchesInString:adaptBody options:0 range:NSMakeRange(0, adaptBody.length)];
|
|
|
|
for (NSUInteger i = 0; i < repMatches.count && i < urlMatches.count; i++) {
|
|
NSString *repTag = [adaptBody substringWithRange:repMatches[i].range];
|
|
NSString *baseURL = [adaptBody substringWithRange:[urlMatches[i] rangeAtIndex:1]];
|
|
|
|
if (!baseURL.length) continue;
|
|
|
|
baseURL = [baseURL stringByReplacingOccurrencesOfString:@"&" withString:@"&"];
|
|
|
|
SCIDashRepresentation *rep = [SCIDashRepresentation new];
|
|
rep.url = [NSURL URLWithString:baseURL];
|
|
rep.contentType = contentType;
|
|
|
|
NSTextCheckingResult *bwMatch = [bwRE firstMatchInString:repTag options:0
|
|
range:NSMakeRange(0, repTag.length)];
|
|
if (bwMatch) rep.bandwidth = [[repTag substringWithRange:[bwMatch rangeAtIndex:1]] integerValue];
|
|
|
|
NSTextCheckingResult *wMatch = [widthRE firstMatchInString:repTag options:0
|
|
range:NSMakeRange(0, repTag.length)];
|
|
if (wMatch) rep.width = [[repTag substringWithRange:[wMatch rangeAtIndex:1]] integerValue];
|
|
|
|
NSTextCheckingResult *hMatch = [heightRE firstMatchInString:repTag options:0
|
|
range:NSMakeRange(0, repTag.length)];
|
|
if (hMatch) rep.height = [[repTag substringWithRange:[hMatch rangeAtIndex:1]] integerValue];
|
|
|
|
NSTextCheckingResult *fpsMatch = [fpsRE firstMatchInString:repTag options:0
|
|
range:NSMakeRange(0, repTag.length)];
|
|
if (fpsMatch) {
|
|
NSString *raw = [repTag substringWithRange:[fpsMatch rangeAtIndex:1]];
|
|
NSArray *parts = [raw componentsSeparatedByString:@"/"];
|
|
if (parts.count == 2) {
|
|
float num = [parts[0] floatValue], den = [parts[1] floatValue];
|
|
if (den > 0) rep.frameRate = num / den;
|
|
} else {
|
|
rep.frameRate = [raw floatValue];
|
|
}
|
|
}
|
|
NSTextCheckingResult *codecsMatch = [codecsRE firstMatchInString:repTag options:0
|
|
range:NSMakeRange(0, repTag.length)];
|
|
if (codecsMatch) rep.codecs = [repTag substringWithRange:[codecsMatch rangeAtIndex:1]];
|
|
|
|
// Quality label from shorter dimension (1080x1920 → "1080p")
|
|
if (rep.width > 0 && rep.height > 0) {
|
|
NSInteger shortSide = MIN(rep.width, rep.height);
|
|
rep.qualityLabel = [NSString stringWithFormat:@"%ldp", (long)shortSide];
|
|
} else if (rep.height > 0) {
|
|
rep.qualityLabel = [NSString stringWithFormat:@"%ldp", (long)rep.height];
|
|
} else {
|
|
NSTextCheckingResult *lMatch = [labelRE firstMatchInString:repTag options:0
|
|
range:NSMakeRange(0, repTag.length)];
|
|
if (lMatch) rep.qualityLabel = [repTag substringWithRange:[lMatch rangeAtIndex:1]];
|
|
}
|
|
|
|
if (rep.url) [results addObject:rep];
|
|
}
|
|
}];
|
|
|
|
return [results copy];
|
|
}
|
|
|
|
+ (SCIDashRepresentation *)bestVideoFromRepresentations:(NSArray<SCIDashRepresentation *> *)reps {
|
|
return [[self videoRepresentations:reps] firstObject];
|
|
}
|
|
|
|
+ (SCIDashRepresentation *)bestAudioFromRepresentations:(NSArray<SCIDashRepresentation *> *)reps {
|
|
SCIDashRepresentation *best = nil;
|
|
for (SCIDashRepresentation *r in reps) {
|
|
if (![r.contentType isEqualToString:@"audio"]) continue;
|
|
if (!best || r.bandwidth > best.bandwidth) best = r;
|
|
}
|
|
return best;
|
|
}
|
|
|
|
+ (NSArray<SCIDashRepresentation *> *)videoRepresentations:(NSArray<SCIDashRepresentation *> *)reps {
|
|
NSMutableArray *videos = [NSMutableArray array];
|
|
for (SCIDashRepresentation *r in reps) {
|
|
if ([r.contentType isEqualToString:@"video"]) [videos addObject:r];
|
|
}
|
|
return [videos sortedArrayUsingComparator:^NSComparisonResult(SCIDashRepresentation *a, SCIDashRepresentation *b) {
|
|
return [@(b.bandwidth) compare:@(a.bandwidth)]; // descending
|
|
}];
|
|
}
|
|
|
|
+ (SCIDashRepresentation *)representationForQuality:(SCIVideoQuality)quality
|
|
fromRepresentations:(NSArray<SCIDashRepresentation *> *)reps {
|
|
NSArray *sorted = [self videoRepresentations:reps];
|
|
if (!sorted.count) return nil;
|
|
|
|
switch (quality) {
|
|
case SCIVideoQualityHighest: return sorted.firstObject;
|
|
case SCIVideoQualityLowest: return sorted.lastObject;
|
|
case SCIVideoQualityMedium: return sorted[sorted.count / 2];
|
|
case SCIVideoQualityAsk: return sorted.firstObject; // caller handles the picker
|
|
}
|
|
return sorted.firstObject;
|
|
}
|
|
|
|
@end
|