mirror of
https://github.com/arichornlover/uYouEnhanced.git
synced 2026-04-20 10:52:07 +00:00
Add Extractor Files
This commit is contained in:
parent
1d431bb927
commit
5a8703ef55
2 changed files with 51 additions and 0 deletions
7
Source/Extractor.h
Normal file
7
Source/Extractor.h
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
// Extractor.h was made by @LillieH1000 from https://www.github.com/LillieH1000/YouTube-Reborn
|
||||
|
||||
#import <Foundation/Foundation.h>
|
||||
|
||||
@interface Extractor : NSObject
|
||||
+ (NSDictionary *)youtubePlayerRequest :(NSString *)client :(NSString *)videoID;
|
||||
@end
|
||||
44
Source/Extractor.xm
Normal file
44
Source/Extractor.xm
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
// Extractor.xm was made by @LillieH1000 from https://www.github.com/LillieH1000/YouTube-Reborn
|
||||
|
||||
#import "Extractor.h"
|
||||
|
||||
@implementation Extractor
|
||||
|
||||
+ (NSDictionary *)youtubePlayerRequest :(NSString *)client :(NSString *)videoID {
|
||||
NSLocale *locale = [NSLocale currentLocale];
|
||||
NSString *countryCode = [locale objectForKey:NSLocaleCountryCode];
|
||||
|
||||
NSURL *requestURL;
|
||||
if ([client isEqual:@"android"]) {
|
||||
requestURL = [NSURL URLWithString:@"https://www.youtube.com/youtubei/v1/player?key=AIzaSyA8eiZmM1FaDVjRy-df2KTyQ_vz_yYM39w&prettyPrint=false"];
|
||||
} else if ([client isEqual:@"ios"]) {
|
||||
requestURL = [NSURL URLWithString:@"https://www.youtube.com/youtubei/v1/player?key=AIzaSyB-63vPrdThhKuerbB2N_l7Kwwcxj6yUAc&prettyPrint=false"];
|
||||
}
|
||||
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:requestURL];
|
||||
[request setHTTPMethod:@"POST"];
|
||||
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
|
||||
if ([client isEqual:@"android"]) {
|
||||
[request setValue:@"com.google.android.youtube/17.31.35 (Linux; U; Android 11) gzip" forHTTPHeaderField:@"User-Agent"];
|
||||
NSString *jsonBody = [NSString stringWithFormat:@"{\"context\":{\"client\":{\"hl\":\"en\",\"gl\":\"%@\",\"clientName\":\"ANDROID\",\"clientVersion\":\"17.31.35\",\"androidSdkVersion\":30}},\"contentCheckOk\":true,\"racyCheckOk\":true,\"videoId\":\"%@\"}", countryCode, videoID];
|
||||
[request setHTTPBody:[jsonBody dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]];
|
||||
} else if ([client isEqual:@"ios"]) {
|
||||
[request setValue:@"com.google.ios.youtube/17.33.2 (iPhone14,3; U; CPU iOS 15_6 like Mac OS X)" forHTTPHeaderField:@"User-Agent"];
|
||||
NSString *jsonBody = [NSString stringWithFormat:@"{\"context\":{\"client\":{\"hl\":\"en\",\"gl\":\"%@\",\"clientName\":\"IOS\",\"clientVersion\":\"17.33.2\",\"deviceModel\":\"iPhone14,3\"}},\"contentCheckOk\":true,\"racyCheckOk\":true,\"videoId\":\"%@\"}", countryCode, videoID];
|
||||
[request setHTTPBody:[jsonBody dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]];
|
||||
}
|
||||
|
||||
__block NSData *requestData;
|
||||
__block BOOL requestFinished = NO;
|
||||
[[[NSURLSession sharedSession] dataTaskWithRequest:request completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
|
||||
requestData = data;
|
||||
requestFinished = YES;
|
||||
}] resume];
|
||||
|
||||
while (!requestFinished) {
|
||||
[NSThread sleepForTimeInterval:0.02];
|
||||
}
|
||||
|
||||
return [NSJSONSerialization JSONObjectWithData:requestData options:0 error:nil];
|
||||
}
|
||||
|
||||
@end
|
||||
Loading…
Reference in a new issue