Exemplo n.º 1
0
        public PlaylistReader(string url, int[] videos, bool reverse)
        {
            string json_dir = Common.GetJsonDirectory();

            _playlist_id = Helper.GetPlaylistId(url);

            string 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));
            }

            string reverseS = reverse ? CmdPlaylistReverse : string.Empty;

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

            _logger = OperationLogger.Create(OperationLogger.YTDLogFile);

            var ytd = new YoutubeDlProcess(_logger, null);

            ytd.LogHeader(_arguments);

            _youtubeDl = Helper.StartProcess(YoutubeDlProcess.YouTubeDlPath,
                                             _arguments,
                                             OutputReadLine,
                                             ErrorReadLine,
                                             null,
                                             _logger);
            _youtubeDl.Exited += delegate
            {
                _processFinished = true;
                ytd.LogFooter();
            };
        }