public async Task AddQueue(AddQueueDirectory dir) { // 既に追加されているファイルは除外する var ignoreSet = new HashSet <string>(queue .Where(t => t.Path == dir.DirPath) .SelectMany(t => t.Items) .Select(item => item.Path)); var items = ((dir.Targets != null) ? dir.Targets : Directory.GetFiles(dir.DirPath) .Where(s => { string lower = s.ToLower(); return(lower.EndsWith(".ts") || lower.EndsWith(".m2t") || lower.EndsWith(".mp4")); })) .Where(f => !ignoreSet.Contains(f)); if (dir.DstPath != null && Directory.Exists(dir.DstPath) == false) { await client.OnOperationResult( "出力先フォルダが存在しません:" + dir.DstPath); return; } var target = new QueueDirectory() { Path = dir.DirPath, Items = items.Select(f => new QueueItem() { Path = f }).ToList(), DstPath = (dir.DstPath != null) ? dir.DstPath : Path.Combine(dir.DirPath, "encoded") }; if (target.Items.Count == 0) { await client.OnOperationResult( "エンコード対象ファイルが見つかりません。パス:" + dir.DirPath); return; } queue.Add(target); Task task = client.OnQueueUpdate(new QueueUpdate() { Type = UpdateType.Add, Directory = target }); Task task2 = RequestFreeSpace(); if (encodePaused == false && nowEncoding == false) { await StartEncode(); } await task; await task2; }
public Task AddQueue(AddQueueDirectory dir) { return(Send(RPCMethodId.AddQueue, dir)); }