add progress ability to extension

This commit is contained in:
Michael Nolan 2021-12-08 22:31:45 -06:00
parent dffc761970
commit be05fbb852
10 changed files with 26 additions and 4 deletions

View File

@ -1,5 +1,5 @@
<Properties StartupConfiguration="{E26F8159-6B4B-4660-A7A4-D0333DFEF0DD}|Default" NuGet.AddPackagesDialog.IncludePrerelease="True"> <Properties StartupConfiguration="{E26F8159-6B4B-4660-A7A4-D0333DFEF0DD}|Default" NuGet.AddPackagesDialog.IncludePrerelease="True">
<MonoDevelop.Ide.Workbench ActiveDocument="../../../../usr/lib/mono/msbuild/Current/bin/Microsoft.Common.CurrentVersion.targets"> <MonoDevelop.Ide.Workbench ActiveDocument="TYTD.Api/MyClass.cs">
<Files> <Files>
<File FileName="TYTD.Api/Server/Models/InfoType.cs" Line="20" Column="16" /> <File FileName="TYTD.Api/Server/Models/InfoType.cs" Line="20" Column="16" />
<File FileName="TYTD.Api/Server/Functions/Downloader.cs" Line="18" Column="1" /> <File FileName="TYTD.Api/Server/Functions/Downloader.cs" Line="18" Column="1" />
@ -8,7 +8,7 @@
<File FileName="TYTD.Api/Server/Models/InfomationQueueItem.cs" Line="125" Column="50" /> <File FileName="TYTD.Api/Server/Models/InfomationQueueItem.cs" Line="125" Column="50" />
<File FileName="TYTD.Api/Server/Functions/ffmpeg.cs" Line="5" Column="15" /> <File FileName="TYTD.Api/Server/Functions/ffmpeg.cs" Line="5" Column="15" />
<File FileName="Program.cs" Line="126" Column="26" /> <File FileName="Program.cs" Line="126" Column="26" />
<File FileName="TYTD.Api/MyClass.cs" Line="95" Column="8" /> <File FileName="TYTD.Api/MyClass.cs" Line="92" Column="6" />
<File FileName="TYTD.Api/Server/Models/SavedChannel.cs" Line="6" Column="10" /> <File FileName="TYTD.Api/Server/Models/SavedChannel.cs" Line="6" Column="10" />
<File FileName="TYTD.Api/Server/Models/SavedPlaylist.cs" Line="7" Column="1" /> <File FileName="TYTD.Api/Server/Models/SavedPlaylist.cs" Line="7" Column="1" />
<File FileName="TYTD.Api/Server/Models/VideoDownloadProgress.cs" Line="7" Column="16" /> <File FileName="TYTD.Api/Server/Models/VideoDownloadProgress.cs" Line="7" Column="16" />
@ -20,11 +20,11 @@
<State name="__root__"> <State name="__root__">
<Node name="youtube-downloader" expanded="True"> <Node name="youtube-downloader" expanded="True">
<Node name="TYTD.Api" expanded="True"> <Node name="TYTD.Api" expanded="True">
<Node name="Packages" expanded="True" />
<Node name="Server" expanded="True"> <Node name="Server" expanded="True">
<Node name="Functions" expanded="True" /> <Node name="Functions" expanded="True" />
<Node name="Models" expanded="True" /> <Node name="Models" expanded="True" />
</Node> </Node>
<Node name="MyClass.cs" selected="True" />
</Node> </Node>
<Node name="youtube-downloader" expanded="True" /> <Node name="youtube-downloader" expanded="True" />
</Node> </Node>

View File

@ -35,6 +35,10 @@ namespace TYTD
t.Interval = timespan.TotalMilliseconds; t.Interval = timespan.TotalMilliseconds;
t.Start(); t.Start();
}
public virtual void SetProgress(double progress)
{
} }
public bool TimerEnabled { get { if (t != null) { return t.Enabled; } else { return false; } } set { if (t != null) { t.Enabled = value; } } } public bool TimerEnabled { get { if (t != null) { return t.Enabled; } else { return false; } } set { if (t != null) { t.Enabled = value; } } }
public virtual IEnumerable<KeyValuePair<string, string>> GetUrls() public virtual IEnumerable<KeyValuePair<string, string>> GetUrls()
@ -90,6 +94,7 @@ namespace TYTD
public SavedVideo Video { get; set; } public SavedVideo Video { get; set; }
} }
public class DownloadInfoStartEventArgs : EventArgs public class DownloadInfoStartEventArgs : EventArgs
{ {
@ -122,6 +127,13 @@ namespace TYTD
api.SendDLComplete(sender, evt); api.SendDLComplete(sender, evt);
} }
} }
internal static void SetProgress(double progress)
{
foreach (var api in apis)
{
api.SetProgress(progress);
}
}
internal static void DownloadInfoStart(object sender, DownloadInfoStartEventArgs evt) internal static void DownloadInfoStart(object sender, DownloadInfoStartEventArgs evt)
{ {
foreach (var api in apis) foreach (var api in apis)

View File

@ -61,7 +61,17 @@ namespace TYTD.Server.Functions
static VideoDownloadProgress P = new VideoDownloadProgress(); static VideoDownloadProgress P = new VideoDownloadProgress();
const int NUM_WAITS = 5; const int NUM_WAITS = 5;
static int WAITS = 0; static int WAITS = 0;
Progress<double> DownloadP = new Progress<double>((e) => { P.Progress = (int)(e * 100.0); P.ProgressRaw = e; }); public static void SendProgress(double p)
{
WAITS++;
if (WAITS <= NUM_WAITS)
return;
WAITS = 0;
ApiLoader.SetProgress(p);
}
Progress<double> DownloadP = new Progress<double>((e) => { P.Progress = (int)(e * 100.0); P.ProgressRaw = e; SendProgress(e); });
public List<SavedVideoObject> Queue = new List<SavedVideoObject>(); public List<SavedVideoObject> Queue = new List<SavedVideoObject>();

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.