Skip to content

Commit

Permalink
* Fixed CleanUp on Quit.
Browse files Browse the repository at this point in the history
* CruncyPlugin - Dubbed shows now have the correct language (English) in the audio stream.
  • Loading branch information
maxpiva committed Sep 6, 2015
1 parent 453cf79 commit 8336733
Show file tree
Hide file tree
Showing 16 changed files with 219 additions and 488 deletions.
10 changes: 1 addition & 9 deletions ADBaseLibrary/ADBaseLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,7 @@
<Compile Include="Mp4\Mp4.cs" />
<Compile Include="DownloadPluginHandler.cs" />
<Compile Include="DownloadPluginInfo.cs" />
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
<DependentUpon>Settings.settings</DependentUpon>
</Compile>
<Compile Include="LibSettings.cs" />
<Compile Include="SessionDictionarySerializer.cs" />
<Compile Include="Settings.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down Expand Up @@ -146,10 +142,6 @@
<ItemGroup>
<None Include="app.config" />
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="AdobeHDS\FlashWrapper\DecryptForm.resx">
Expand Down
42 changes: 33 additions & 9 deletions ADBaseLibrary/BaseDownloadPlugin.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using ADBaseLibrary.Helpers;

namespace ADBaseLibrary
{
public class BaseDownloadPlugin
public abstract class BaseDownloadPlugin
{
public static string UserAgent = Properties.Settings.Default.UserAgent ?? "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36";
public static string FFMPEGArgs = Properties.Settings.Default.FFMPEGArgs ?? "-i \"{0}\" {1} -vcodec copy -acodec copy -scodec copy {4}-map 0:0 -map 0:1 -metadata:s:a:0 language={5} -metadata:s:a:0 title=\"{6}\" {2} {7} -y \"{3}\"";
public static string FFMPEGSubtitleArgs = Properties.Settings.Default.FFMPEGSubtitleArgs ?? "-map {0}:0 -metadata:s:s:{1} language={2} -metadata:s:s:{1} title=\"{3}\" ";
public static string FFMPEGEXE = Properties.Settings.Default.FFMPEGEXE ?? "ffmpeg.exe";
public static int SocketTimeout = Properties.Settings.Default.SocketTimeout==0 ? 50000 : Properties.Settings.Default.SocketTimeout;
public const string UserAgentS = "UserAgent";
public const string FFMPEGArgsS = "FFMPEGArgs";
public const string FFMPEGSubtitleArgsS = "FFMPEGSubtitleArgs";
public const string FFMPEGEXES = "FFMPEGEXE";
public const string SocketTimeoutS = "SocketTimeout";

public abstract LibSettings LibSet { get; set; }

public Dictionary<string,string> baseSettings=new Dictionary<string, string>
{
{ UserAgentS,"Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/43.0.2357.132 Safari/537.36"},
{ FFMPEGArgsS,"-i \"{0}\" {1} -vcodec copy -acodec copy -scodec copy {4}-map 0:0 -map 0:1 -metadata:s:a:0 language={5} -metadata:s:a:0 title=\"{6}\" {2} {7} -y \"{3}\"" },
{ FFMPEGSubtitleArgsS,"-map {0}:0 -metadata:s:s:{1} language={2} -metadata:s:s:{1} title=\"{3}\" "},
{ FFMPEGEXES, "ffmpeg.exe"},
{ SocketTimeoutS,"50000" }
};

public void LoadSettings(string settings)
{
baseSettings.ToList().ForEach(a=>LibSet.Add(a.Key,a.Value));
LibSet.Load(settings);
SocketTimeout = 50000;
int.TryParse(LibSet[SocketTimeoutS], out SocketTimeout);

}

public int SocketTimeout;


public string GetFFMPEGSubtitleArguments(int subtitleFileCount, int subtitileCount, string languageCode, string language)
{
return string.Format(FFMPEGSubtitleArgs, subtitleFileCount, subtitileCount, languageCode, language);
return string.Format(LibSet[FFMPEGSubtitleArgsS], subtitleFileCount, subtitileCount, languageCode, language);
}
public async Task<string> ReMux(string inputfile, string inputs, string subtileargs, Format formats,
string audiolanguagecode, string audiolanguage, double initialPercent, double percentIncrement,
Expand All @@ -39,14 +63,14 @@ public async Task<string> ReMux(string inputfile, string inputs, string subtilea
{
if ((fol & formats) == fol)
{
string ffmpegargs = string.Format(FFMPEGArgs, inputfile, inputs, subtileargs, intermediatefile, fol == Format.Mkv ? string.Empty : "-c:s mov_text ", audiolanguagecode, audiolanguage, fol == Format.Mkv ? "-f matroska" : "-f mp4");
string ffmpegargs = string.Format(LibSet[FFMPEGArgsS], inputfile, inputs, subtileargs, intermediatefile, fol == Format.Mkv ? string.Empty : "-c:s mov_text ", audiolanguagecode, audiolanguage, fol == Format.Mkv ? "-f matroska" : "-f mp4");
token.ThrowIfCancellationRequested();
dinfo.Percent = initialPercent;
initialPercent += percentIncrement;
dinfo.Status = "Muxing Video";
progress.Report(dinfo);
ShellParser ffm = new ShellParser();
await ffm.Start(FFMPEGEXE, ffmpegargs, token);
await ffm.Start(LibSet[FFMPEGEXES], ffmpegargs, token);
dinfo.Percent = initialPercent;
initialPercent += percentIncrement;
dinfo.Status = "Unique Hashing";
Expand Down
1 change: 1 addition & 0 deletions ADBaseLibrary/DownloadManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public void Delete(string id)
if (dinfo != null && (dinfo.Status == DownloadStatus.Downloading))
dinfo.Cancel();
}
_downloads.Remove(dinfo);
Save();
}

Expand Down
32 changes: 32 additions & 0 deletions ADBaseLibrary/LibSettings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ADBaseLibrary.Helpers;
using Newtonsoft.Json;

namespace ADBaseLibrary
{
public class LibSettings : Dictionary<string,string>
{
public void Load(string settings)
{
string cpath = Path.Combine(UserDataPath.Get(), settings);
if (File.Exists(cpath))
{
string str = File.ReadAllText(cpath);
JsonConvert.PopulateObject(str, this);
}
Save(settings);
}

public void Save(string settings)
{
string cpath = Path.Combine(UserDataPath.Get(), settings);
File.WriteAllText(cpath, JsonConvert.SerializeObject(this));
}

}
}
73 changes: 0 additions & 73 deletions ADBaseLibrary/Properties/Settings.Designer.cs

This file was deleted.

21 changes: 0 additions & 21 deletions ADBaseLibrary/Properties/Settings.settings

This file was deleted.

20 changes: 12 additions & 8 deletions AnimeDownloader/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,17 +126,21 @@ 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))
if (objDownloads.Objects != null)
{
DialogResult r=MessageBox.Show("Are you sure you want to quit, there is some downloads left?", "Quit?",
MessageBoxButtons.YesNo);
if (r == DialogResult.No)
List<DownloadItem> downs = objDownloads.Objects.Cast<DownloadItem>().ToList();
if (downs.Any(a => a.Status == DownloadStatus.Downloading))
{
e.Cancel = true;
return;
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);
}
butRemoveAll_Click(null, null);
}
DownloadPluginHandler.Instance.Exit();
e.Cancel = false;
Expand Down
Loading

0 comments on commit 8336733

Please sign in to comment.