Skip to content

Commit

Permalink
Merge pull request #10 from asdfzxcvbn/main
Browse files Browse the repository at this point in the history
fix?: randomly going back to free
  • Loading branch information
whoeevee committed Apr 24, 2024
2 parents 0c1278e + d9078f9 commit 2efecfe
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 43 deletions.
2 changes: 1 addition & 1 deletion control
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: com.eevee.spotify
Name: EeveeSpotify
Version: 1.1
Version: 1.2
Architecture: iphoneos-arm
Description: A tweak to get Spotify Premium for free, just like Spotilife
Maintainer: Eevee
Expand Down
Binary file not shown.
Binary file not shown.
3 changes: 2 additions & 1 deletion src/EVEBundleHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
@property (nonatomic, strong, readonly) NSBundle *bundle;
+ (instancetype)sharedHelper;
- (NSData *)premiumBlankData;
- (void)showPopupWithTitle:(NSString *)title message:(NSString *)msg buttonText:(NSString *)bText;
- (void)showPopupWithMessage:(NSString *)msg buttonText:(NSString *)bText;
- (NSError *)giveURL:(NSURL *)url permissions:(short)perms;
@end

@interface UITabBarButtonLabel : UILabel
Expand Down
13 changes: 10 additions & 3 deletions src/EVEBundleHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ - (instancetype)init {
}

- (NSData *)premiumBlankData {
return [NSData dataWithContentsOfURL:[self.bundle URLForResource:@"premiumblank" withExtension:@"bnk"]];
return [NSData dataWithContentsOfURL:[self.bundle URLForResource:@"premiumblankreal" withExtension:@"bnk"]];
}

- (void)showPopupWithTitle:(NSString *)title message:(NSString *)msg buttonText:(NSString *)bText {
- (void)showPopupWithMessage:(NSString *)msg buttonText:(NSString *)bText {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
dispatch_async(dispatch_get_main_queue(), ^{
UIAlertController *alert = [UIAlertController alertControllerWithTitle:title
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"EeveeSpotify"
message:msg
preferredStyle:UIAlertControllerStyleAlert];

Expand All @@ -48,4 +48,11 @@ - (void)showPopupWithTitle:(NSString *)title message:(NSString *)msg buttonText:
});
});
}

- (NSError *)giveURL:(NSURL *)url permissions:(short)perms {
NSError *err;
[[NSFileManager defaultManager] setAttributes:@{NSFilePosixPermissions: [NSNumber numberWithShort:perms]}
ofItemAtPath:url.path error:&err];
return err;
}
@end
20 changes: 0 additions & 20 deletions src/SpotifyHidePremium.x

This file was deleted.

35 changes: 17 additions & 18 deletions src/Tweak.x
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
NSLog(@"[EeveeSpotify] Not activating due to nonexistent file: %@", filePath.path);

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
[[EVEBundleHelper sharedHelper] showPopupWithTitle:@"EeveeSpotify"
message:@"An offline.bnk file was not found. Please log in and restart the app when you're done!"
[[EVEBundleHelper sharedHelper]
showPopupWithMessage:@"An offline.bnk file was not found. Please log in and restart the app when you're done!"
buttonText:@"Okay!"];
});

return YES;
};
}

NSData *fileData = [NSData dataWithContentsOfURL:filePath];
NSUInteger usernameLength = (NSUInteger)(((const char *)[fileData bytes])[8]);
Expand All @@ -39,23 +39,22 @@
[blankData replaceBytesInRange:NSMakeRange(8, 0) withBytes:(const void *)&usernameLength length:1];
[blankData replaceBytesInRange:NSMakeRange(9, 0) withBytes:[usernameData bytes] length:[usernameData length]];

[blankData writeToURL:filePath atomically:NO];
NSLog(@"[EeveeSpotify] Successfully applied");
NSError *writeError;
[[EVEBundleHelper sharedHelper] giveURL:filePath permissions:0744];
[blankData writeToURL:filePath options:0 error:&writeError];
if (writeError)
NSLog(@"[EeveeSpotify] Couldn't write: %@", writeError);
else
NSLog(@"[EeveeSpotify] Successfully applied");

// runs in background, reapplies every 20 seconds, maybe this could be useful?
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
for (;;) {
// waits 20 seconds without blocking thread
dispatch_semaphore_t semaphore = dispatch_semaphore_create(0);
dispatch_time_t delay = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(20.0 * NSEC_PER_SEC));
dispatch_after(delay, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
dispatch_semaphore_signal(semaphore);
});
dispatch_semaphore_wait(semaphore, DISPATCH_TIME_FOREVER);
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
NSError *roError = [[EVEBundleHelper sharedHelper] giveURL:filePath permissions:0444];

[blankData writeToURL:filePath atomically:NO];
NSLog(@"[EeveeSpotify] Successfully reapplied");
};
if (roError) {
NSLog(@"[EeveeSpotify] Failed to set offline.bnk as readonly: %@", roError);
} else {
NSLog(@"[EeveeSpotify] Set offline.bnk as readonly!");
}
});
} @catch (NSException *error) {
NSLog(@"[EeveeSpotify] Unable to apply tweak: %@", error);
Expand Down

0 comments on commit 2efecfe

Please sign in to comment.