Esempio n. 1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="PlaylistReader"/> class.
            /// </summary>
            /// <param name="url">The url<see cref="string"/></param>
            /// <param name="videos">The videos<see cref="int[]"/></param>
            /// <param name="reverse">The reverse<see cref="bool"/></param>
            public PlaylistReader(string url, int[] videos, bool reverse)
            {
                var json_dir = AppEnvironment.GetJsonDirectory();

                _playlist_id = YoutubeHelper.GetPlaylistId(url);
                var range = string.Empty;

                if (videos != null && videos.Length > 0)
                {
                    // Make sure the video indexes is sorted, otherwise reversing wont do anything
                    Array.Sort(videos);
                    range = string.Format(CmdPlaylistRange, string.Join(",", videos));
                }

                var reverseS = reverse ? CmdPlaylistReverse : string.Empty;

                _arguments = string.Format(CmdPlaylistInfo, json_dir, _playlist_id, range, reverseS, url);
                _url       = url;

                YoutubeDl.LogHeader(_arguments);

                _youtubeDl = ProcessHelper.StartProcess(YoutubeDl.YouTubeDlPath,
                                                        _arguments,
                                                        OutputReadLine,
                                                        ErrorReadLine,
                                                        null);
                _youtubeDl.Exited += delegate
                {
                    _processFinished = true;
                    YoutubeDl.LogFooter();
                };
            }