Skip to content

Commit

Permalink
More bugfixing.
Browse files Browse the repository at this point in the history
  • Loading branch information
maxpiva committed Sep 5, 2015
1 parent 75131a0 commit 453cf79
Show file tree
Hide file tree
Showing 11 changed files with 61 additions and 14 deletions.
22 changes: 15 additions & 7 deletions ADBaseLibrary/AdobeHDS/FlashWrapper/DecryptForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Drawing;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using AxShockwaveFlashObjects;

Expand All @@ -15,6 +16,8 @@ public partial class DecryptForm : Form
internal AxShockwaveFlash axShock;
private static Thread thread;
private static bool _isinit = false;
private static TaskScheduler thscheduler;

public static void Init()
{
if (_isinit)
Expand All @@ -23,17 +26,19 @@ public static void Init()
thread = new Thread(CreateComponent);
thread.SetApartmentState(ApartmentState.STA);
thread.Start(null);
AppDomain.CurrentDomain.ProcessExit += (a, b) =>
{
thread?.Abort();
thread = null;
};
AppDomain.CurrentDomain.FirstChanceException += (a,b) => { };
}





public static void Kill()
{
if (thread != null)
{
Task.Factory.StartNew(Application.Exit, CancellationToken.None, TaskCreationOptions.None, thscheduler);
thread = null;
}
}

private static void CreateComponent(object obj)
{
Expand All @@ -55,6 +60,9 @@ private static void CreateComponent(object obj)
string swf = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location), "loader.swf");
if (File.Exists(swf))
form.axShock.LoadMovie(0, swf);
form.axShock.Stop();
form.axShock.Dispose();
thscheduler= TaskScheduler.FromCurrentSynchronizationContext();
Application.Run();
}
public DecryptForm()
Expand Down
1 change: 0 additions & 1 deletion ADBaseLibrary/DownloadManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ public void Delete(string id)
{
if (dinfo != null && (dinfo.Status == DownloadStatus.Downloading))
dinfo.Cancel();
_downloads.Remove(dinfo);
}
Save();
}
Expand Down
7 changes: 7 additions & 0 deletions ADBaseLibrary/DownloadPluginHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ public async Task<Response> Download(string plugin, Episode ep, string template,
return await AuthWrapper(plugin, async (plg, session) => await plg.Download(session, ep, template, downloadpath, quality, format, token, progress));
}

public void Exit()
{
foreach (IDownloadPlugin plugin in Plugins.Values)
{
plugin.Exit();
}
}


public DownloadPluginHandler()
Expand Down
7 changes: 5 additions & 2 deletions ADBaseLibrary/Follows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,11 @@ public void RemoveFollow(string showId, string pluginName)

public void AddDownload(EpisodeWithDownloadSettings d)
{
Downloads.Add(d);
Save();
if (!Downloads.Any(a => a.Id == d.Id && a.PluginName == d.PluginName && a.Quality == d.Quality && a.Format == d.Format))
{
Downloads.Add(d);
Save();
}
}
public List<EpisodeWithDownloadSettings> CheckFollows(List<Episode> upds)
{
Expand Down
1 change: 1 addition & 0 deletions ADBaseLibrary/IDownloadPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ public interface IDownloadPlugin
Task<Episodes> Episodes(ISession session, Show show);
Task<Response> Download(ISession session, Episode episode, string template, string downloadpath, Quality quality, Format format, CancellationToken token, IProgress<DownloadInfo> progress);
Task<Updates> Updates(ISession session);
void Exit();
}
}
1 change: 1 addition & 0 deletions AnimeDownloader/MainForm.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion AnimeDownloader/MainForm.Downloads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public void InitDownloadManager()
_manager = new DownloadManager(Settings.Instance.SimultaneousDownloads);
_manager.OnProgress += (a) =>
{
if (a.Status==DownloadStatus.Complete)
Follows.Instance.AddDownload(a.Episode);
objDownloads.RefreshObject(a);
if (a==objDownloads.SelectedObject)
RefreshInfo();
Expand Down Expand Up @@ -248,7 +250,7 @@ private void butRemoveCanceled_Click(object sender, EventArgs e)

private void butRemoveDownloaded_Click(object sender, EventArgs e)
{
RemoveFlagged(DownloadStatus.Downloading);
RemoveFlagged(DownloadStatus.Complete);

}

Expand Down
18 changes: 18 additions & 0 deletions AnimeDownloader/MainForm.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
Expand Down Expand Up @@ -123,5 +124,22 @@ private void objLog_FormatCell(object sender, FormatCellEventArgs e)
}
}

private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
{
List<DownloadItem> downs = objDownloads.Objects.Cast<DownloadItem>().ToList();
if (downs.Any(a => a.Status == DownloadStatus.Downloading))
{
DialogResult r=MessageBox.Show("Are you sure you want to quit, there is some downloads left?", "Quit?",
MessageBoxButtons.YesNo);
if (r == DialogResult.No)
{
e.Cancel = true;
return;
}
butRemoveAll_Click(null, null);
}
DownloadPluginHandler.Instance.Exit();
e.Cancel = false;
}
}
}
4 changes: 2 additions & 2 deletions AnimeDownloader/MainForm.resx
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAACw
BwAAAk1TRnQBSQFMAgEBBAEAAYABAwGAAQMBEgEAARIBAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFI
BwAAAk1TRnQBSQFMAgEBBAEAAYgBAwGIAQMBEgEAARIBAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAFI
AwABJAMAAQEBAAEgBQABgAEo/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A
/wD/AOkAAkcBRgGAAkcBRgGALAADKgFAAf8BnAEAAv8BnAEAAv8BnAEAAv8BnAEAAv8BnAEAAv8BnAEA
Av8BnAEAAv8BnQEAAv8BnAEAAv8BnAEAAf8DKgFALAADRwGAA0cBgCwAAyoBQAOfAf8DnwH/A58B/wOf
Expand Down Expand Up @@ -168,7 +168,7 @@
AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w
LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0
ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADe
PAAAAk1TRnQBSQFMAgEBBAEAAWABBAFgAQQBJAEAASQBAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAGQ
PAAAAk1TRnQBSQFMAgEBBAEAAWgBBAFoAQQBJAEAASQBAAT/ASEBAAj/AUIBTQE2BwABNgMAASgDAAGQ
AwABSAMAAQEBAAEgBgABov8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A
/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A
/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A/wD/AP8A
Expand Down
5 changes: 5 additions & 0 deletions Plugins/CrunchyPlugin/Crunchy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,11 @@ public async Task<Updates> Updates(ISession session)

}

public void Exit()
{

}

#endregion

#region Helpers
Expand Down
5 changes: 4 additions & 1 deletion Plugins/DaiSukiPlugin/DaiSuki.cs
Original file line number Diff line number Diff line change
Expand Up @@ -685,7 +685,10 @@ public async Task<Updates> Updates(ISession session)
}
}


public void Exit()
{
DecryptForm.Kill();
}


private KeyValuePair<Media,Quality>? BestMediaFromManifest(Manifest m, Quality q)
Expand Down

0 comments on commit 453cf79

Please sign in to comment.