Skip to content

Commit 306d9b9

Browse files
committed
bump to 1.7.1
-Made EncryptionManager a static class -Made RipperBase an abstract class -Fixed a fatal crash bug with downloadGenericAssets -Fixed a bug with the downloading of BGs -downloadGenericAssets now has a saveFolder param -CompositeBG thumbs now download using downloadGenericAssets
1 parent f7cb1f9 commit 306d9b9

5 files changed

Lines changed: 20 additions & 36 deletions

File tree

GoAnimateRipper2/Managers/AssetManager.cs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ namespace GoAnimateRipper2
1212
public class AssetManager
1313
{
1414
MainControl mainControl;
15-
EncryptionManager encryptionManager = new EncryptionManager();
1615
HttpClient httpClient = new HttpClient();
1716

1817
List<string> pathes = new List<string>();
@@ -85,26 +84,26 @@ public async Task<bool> DownloadAsset(string path, bool isSupposedToHaveEncrypti
8584
}
8685
var data = await response.Content.ReadAsByteArrayAsync();
8786
bool keySuccessfullyMatched = true;
88-
bool isFileEncrypted = !encryptionManager.IsFlashPrefix(data);
87+
bool isFileEncrypted = !EncryptionManager.IsFlashPrefix(data);
8988
// If it's a SWF, deal with encryption jargon.
9089
if (isSwf)
9190
{
9291

9392
// If auto mode, try and figure out the key.
9493
if (isSupposedToHaveEncryption && autoMode)
9594
{
96-
key = encryptionManager.DetermineKey(data);
95+
key = EncryptionManager.DetermineKey(data);
9796
if (key == null) keySuccessfullyMatched = false;
9897
}
9998
// If the key was found, decrypt. If it isn't auto mode, it will always work.
10099
if (isSupposedToHaveEncryption && mainControl.doDecryption && keySuccessfullyMatched)
101100
{
102-
data = encryptionManager.Decrypt(key, data);
101+
data = EncryptionManager.Decrypt(key, data);
103102
}
104103
// If re-encrypt is checked and everything succeeded (or a specific edge case occured where auto mode was on and the file was supposed to be encrypted but wasn't), do re-encryption.
105104
if (mainControl.doReEncryption && isSupposedToHaveEncryption && (keySuccessfullyMatched || !isFileEncrypted))
106105
{
107-
data = encryptionManager.Decrypt(Encoding.ASCII.GetBytes(mainControl.reEncryptionKey), data);
106+
data = EncryptionManager.Decrypt(Encoding.ASCII.GetBytes(mainControl.reEncryptionKey), data);
108107
}
109108
}
110109

GoAnimateRipper2/Managers/EncryptionManager.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,8 @@ internal class EncryptionManager
1414
"g0o1a2n3i4m5a6t7e",
1515
"(auto)"
1616
};
17-
public EncryptionManager()
18-
{
19-
// Anything to put here?
20-
// I don't think you need to pass anything to this class tbh ...
21-
}
2217

23-
public byte[] Decrypt(byte[] pwd, byte[] data)
18+
static public byte[] Decrypt(byte[] pwd, byte[] data)
2419
{
2520
int a, i, j, k, tmp;
2621
int[] key, box;
@@ -61,7 +56,7 @@ public byte[] Decrypt(byte[] pwd, byte[] data)
6156
/// <summary>
6257
/// bool <c>IsFlashPrefix</c> returns if byte[] <c>data</c> has a valid SWF header.
6358
/// </summary>
64-
public bool IsFlashPrefix(byte[] data)
59+
static public bool IsFlashPrefix(byte[] data)
6560
{
6661
string prefix = Encoding.UTF8.GetString(data).Substring(0, 3);
6762
return prefix == "CWS" || prefix == "FWS";
@@ -70,7 +65,7 @@ public bool IsFlashPrefix(byte[] data)
7065
/// <summary>
7166
/// bool <c>DetermineKey</c> tries to determine the key. It returns true if it succeeds.
7267
/// </summary>
73-
public byte[] DetermineKey(byte[] data)
68+
static public byte[] DetermineKey(byte[] data)
7469
{
7570
if (!IsFlashPrefix(data))
7671
{

GoAnimateRipper2/Properties/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@
3131
// You can specify all the values or you can default the Build and Revision Numbers
3232
// by using the '*' as shown below:
3333
// [assembly: AssemblyVersion("1.0.*")]
34-
[assembly: AssemblyVersion("1.7.0")]
34+
[assembly: AssemblyVersion("1.7.1")]
3535
[assembly: AssemblyFileVersion("1.0")]

GoAnimateRipper2/Rippers/RipperBase.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
namespace GoAnimateRipper2
1212
{
13-
public class RipperBase
13+
public abstract class RipperBase
1414
{
1515
public MainControl mainControl;
1616
public AssetManager assetManager;
@@ -75,11 +75,8 @@ public void endRipper()
7575
}
7676

7777
/// <summary>
78-
/// void <c>StartRip</c> starts the ripper; Template function.
78+
/// public abstract Task <c>StartRip</c> starts the ripper; Abstract function.
7979
/// </summary>
80-
public virtual async Task StartRip()
81-
{
82-
// Bla
83-
}
80+
public abstract Task StartRip();
8481
}
8582
}

GoAnimateRipper2/Rippers/StandardRipper.cs

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,21 @@ public StandardRipper(MainControl mainControl, string themeId) : base(mainContro
2121
/// Task <c>downloadGenericAssets</c> downloads assets that get generic and predictable types of assets.
2222
///
2323
/// </summary>
24-
public async Task downloadGenericAssets(String elm, String targetProperty, String acceptFormat = null)
24+
public async Task downloadGenericAssets(String elm, String targetProperty, String acceptFormat = null, String saveFolder = null)
2525
{
26+
if (saveFolder == null)
27+
{
28+
saveFolder = elm;
29+
}
2630
var elements = xmlDoc.Elements(elm);
2731
mainControl.setProgressBarMaximum(elements.Count());
2832
mainControl.resetProgressBar();
2933
foreach (var element in elements)
3034
{
3135
var elementId = element.Attributes().Where(a => a.Name == targetProperty).Single().Value;
32-
if (elementId.Contains(acceptFormat) || acceptFormat == null)
36+
if (acceptFormat == null || elementId.Contains(acceptFormat))
3337
{
34-
fileLocation = $"{themeId}\\{elm}\\{elementId}";
38+
fileLocation = $"{themeId}\\{saveFolder}\\{elementId}";
3539
downloadSuccess = await assetManager.DownloadAsset(fileLocation, mainControl.doDecryption);
3640
if (downloadSuccess) mainControl.writeMessage($"Downloaded {elm} '{elementId}'.");
3741
}
@@ -79,7 +83,7 @@ public override async Task StartRip()
7983

8084

8185
await downloadGenericAssets("effect","id",".swf");
82-
await downloadGenericAssets("background", "id");
86+
await downloadGenericAssets("background","id",null,"bg");
8387

8488
var chars = xmlDoc.Elements("char");
8589
mainControl.setProgressBarMaximum(chars.Count());
@@ -191,18 +195,7 @@ public override async Task StartRip()
191195

192196
if (!mainControl.skipNonFlash)
193197
{
194-
var backgroundsthumb = xmlDoc.Elements("compositebg");
195-
mainControl.setProgressBarMaximum(backgroundsthumb.Count());
196-
mainControl.resetProgressBar();
197-
foreach (var compositebg in backgroundsthumb)
198-
{
199-
var bgThumb = compositebg.Attributes().Where(a => a.Name == "thumb").Single().Value;
200-
fileLocation = $"{themeId}\\bg\\{bgThumb}";
201-
202-
await assetManager.DownloadAsset(fileLocation, false);
203-
if (downloadSuccess) mainControl.writeMessage($"Downloaded background thumbnail '{bgThumb}'.");
204-
mainControl.incrementProgressBar();
205-
}
198+
await downloadGenericAssets("compositebg", "thumb", null, "bg");
206199

207200
var starters = xmlDoc.Elements("starter");
208201
mainControl.setProgressBarMaximum(starters.Count());

0 commit comments

Comments
 (0)