Esempio n. 1
0
        /// <summary>
        ///     synchronously prepare a youtube-dl command
        /// </summary>
        /// <param name="ydl">
        ///     The client.
        /// </param>
        /// <param name="cancellationToken">
        ///     The cancellation token
        /// </param>
        /// <returns>
        ///     The youtube-dl command that will be executed
        /// </returns>
        internal static string PrepareDownload(this YoutubeDL ydl, CancellationToken cancellationToken)
        {
            if (!ydl.Info.set)
            {
                Delegate[] originalDelegates = null;
                if (ydl.Info.propertyChangedEvent != null)
                {
                    originalDelegates = ydl.Info.propertyChangedEvent.GetInvocationList();
                }

                ydl.Info = InfoService.GetDownloadInfo(ydl, cancellationToken) ?? new DownloadInfo();

                if (originalDelegates != null)
                {
                    foreach (Delegate del in originalDelegates)
                    {
                        ydl.Info.PropertyChanged += (PropertyChangedEventHandler)del;
                    }
                }

                ydl.Info.set = true;
            }

            SetupPrepare(ydl);

            return(ydl.RunCommand);
        }
Esempio n. 2
0
        /// <summary>
        ///     synchronously prepare a youtube-dl command
        /// </summary>
        /// <param name="ydl">
        ///     The client.
        /// </param>
        /// <returns>
        ///     The youtube-dl command that will be executed
        /// </returns>
        internal static string PrepareDownload(this YoutubeDL ydl)
        {
            if (ydl.Info == null)
            {
                ydl.Info = InfoService.GetDownloadInfo(ydl) ?? new DownloadInfo();
            }

            SetupPrepare(ydl);

            return(ydl.RunCommand);
        }
Esempio n. 3
0
        /// <summary>
        ///     Asynchronously prepare a youtube-dl command
        /// </summary>
        /// <param name="ydl">
        ///     The client.
        /// </param>
        /// <returns>
        ///     The youtube-dl command that will be executed
        /// </returns>
        internal static async Task <string> PrepareDownloadAsync(this YoutubeDL ydl)
        {
            if (ydl.Info == null)
            {
                ydl.Info = await InfoService.GetDownloadInfoAsync(ydl) ?? new DownloadInfo();
            }

            SetupPrepare(ydl);

            return(ydl.RunCommand);
        }