コード例 #1
0
        private void OnDownloadUpdate(object sender, DCCEventArgs args)
        {
            DebugHandler.TraceMessage("OnDownloadUpdate Called.", DebugSource.TASK, DebugType.ENTRY_EXIT);

            IrcClientDownloadEventArgs eventArgs = new IrcClientDownloadEventArgs()
            {
                FileName         = args.FileName,
                FileLocation     = args.FilePath,
                DownloadSpeed    = args.KBytesPerSecond.ToString(),
                FileSize         = (args.FileSize / 1048576),
                DownloadProgress = args.Progress,
                DownloadStatus   = args.Status
            };

            DebugHandler.TraceMessage(eventArgs.ToString(), DebugSource.TASK, DebugType.PARAMETERS);

            OnIrcClientDownloadEvent?.Invoke(this, eventArgs);
        }
コード例 #2
0
        private void OnIrcClientDownloadEvent(object sender, IrcClientDownloadEventArgs args)
        {
            DebugHandler.TraceMessage("OnIrcClientDownloadEvent Called.", DebugSource.TASK, DebugType.ENTRY_EXIT);
            DebugHandler.TraceMessage(args.ToString(), DebugSource.TASK, DebugType.PARAMETERS);


            if (CurrentlyDownloading != null)
            {
                if (args.DownloadStatus == "PARSING" || args.DownloadStatus == "WAITING")
                {
                    OnDownloadUpdateEvent?.Invoke(this, new DownloadUpdateEventArgs()
                    {
                        id                 = CurrentlyDownloading.id,
                        animeid            = CurrentlyDownloading.animeInfo.anime_id,
                        animeTitle         = CurrentlyDownloading.animeInfo.anime_title,
                        animeCoverSmall    = CurrentlyDownloading.animeInfo.anime_cover_small,
                        animeCoverOriginal = CurrentlyDownloading.animeInfo.anime_cover_original,
                        episodeNumber      = CurrentlyDownloading.episodeNumber,
                        bot                = CurrentlyDownloading.bot,
                        pack               = CurrentlyDownloading.pack,
                        progress           = args.DownloadProgress.ToString(),
                        speed              = args.DownloadSpeed.ToString(),
                        status             = args.DownloadStatus,
                        filename           = CurrentlyDownloading.filename,
                        filesize           = CurrentlyDownloading.filesize,
                        fullfilepath       = CurrentlyDownloading.fullfilepath,
                        downloadIndex      = CurrentlyDownloading.downloadIndex
                    });
                }
                else
                {
                    OnDownloadUpdateEvent?.Invoke(this, new DownloadUpdateEventArgs()
                    {
                        id                 = CurrentlyDownloading.id,
                        animeid            = CurrentlyDownloading.animeInfo.anime_id,
                        animeTitle         = CurrentlyDownloading.animeInfo.anime_title,
                        animeCoverSmall    = CurrentlyDownloading.animeInfo.anime_cover_small,
                        animeCoverOriginal = CurrentlyDownloading.animeInfo.anime_cover_original,
                        episodeNumber      = CurrentlyDownloading.episodeNumber,
                        bot                = CurrentlyDownloading.bot,
                        pack               = CurrentlyDownloading.pack,
                        progress           = args.DownloadProgress.ToString(),
                        speed              = args.DownloadSpeed.ToString(),
                        status             = args.DownloadStatus,
                        filename           = args.FileName,
                        filesize           = args.FileSize.ToString(),
                        fullfilepath       = args.FileLocation,
                        downloadIndex      = CurrentlyDownloading.downloadIndex
                    });
                }


                if (args.DownloadStatus.Contains("COMPLETED"))
                {
                    OnDownloadUpdateEvent?.Invoke(this, new DownloadUpdateEventArgs()
                    {
                        id                 = CurrentlyDownloading.id,
                        animeid            = CurrentlyDownloading.animeInfo.anime_id,
                        animeTitle         = CurrentlyDownloading.animeInfo.anime_title,
                        animeCoverSmall    = CurrentlyDownloading.animeInfo.anime_cover_small,
                        animeCoverOriginal = CurrentlyDownloading.animeInfo.anime_cover_original,
                        episodeNumber      = CurrentlyDownloading.episodeNumber,
                        bot                = CurrentlyDownloading.bot,
                        pack               = CurrentlyDownloading.pack,
                        progress           = args.DownloadProgress.ToString(),
                        speed              = args.DownloadSpeed.ToString(),
                        status             = args.DownloadStatus,
                        filename           = CurrentlyDownloading.filename,
                        filesize           = CurrentlyDownloading.filesize,
                        fullfilepath       = CurrentlyDownloading.fullfilepath,
                        downloadIndex      = CurrentlyDownloading.downloadIndex
                    });


                    if (CurrentlyDownloading.id != string.Empty)
                    {
                        RemoveDownload(CurrentlyDownloading.id);

                        CurrentlyDownloading = new JsonDownloadInfo();
                    }


                    DownloadProcesOnGoing = false;
                }
                else if (args.DownloadStatus.Contains("FAILED") || args.DownloadStatus.Contains("ABORTED"))
                {
                    if (CurrentlyDownloading.id != string.Empty)
                    {
                        RemoveDownload(CurrentlyDownloading.id);

                        CurrentlyDownloading = new JsonDownloadInfo();
                    }
                    DownloadProcesOnGoing = false;
                }
            }
            else
            {
                DebugHandler.TraceMessage("Got download event, but no CurrrentlyDownloading object has been set!", DebugSource.TASK, DebugType.WARNING);
            }
        }