private void main_timer_background_worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e) { try { DirectoryInfo torrent_download_folder = new DirectoryInfo(@"D:\Torrent Downloads"); foreach (DirectoryInfo sub_directories in torrent_download_folder.GetDirectories()) { switch (sub_directories.Name.ToLower()) { case "new folder": log(@"Folder name was ""New Folder""", msgType.message); break; case var folder_name when new Regex(@"(s\d+e\d+)|(\s+第\d+話)").IsMatch(folder_name): log(folder_name + " is for season episode", msgType.message); break; default: if (sub_directories.GetFiles("folder.ico").Length == 0) { log(sub_directories.Name + " does not have a thumbnail.", msgType.message); Task set_poster_task; switch (sub_directories.Name.ToLower()) { case var folder_name when new Regex(@"(\s+season\s+)|(\s+s\d+)").IsMatch(folder_name): set_poster_task = Task.Run(() => Poster.SetPoster(sub_directories.FullName, mediaTypes.tv)); break; case var folder_name when new Regex(@"erai-raws").IsMatch(folder_name): set_poster_task = Task.Run(() => Poster.SetPoster(sub_directories.FullName, mediaTypes.tv)); break; default: set_poster_task = Task.Run(() => Poster.SetPoster(sub_directories.FullName, mediaTypes.movie)); break; } set_poster_task.Wait(); } break; } } Task set_thumbnail_task; foreach (FileInfo files in torrent_download_folder.GetFiles()) { switch (files.Extension) { case ".mkv": if (MatroskaSerializer.Deserialize(new FileStream(files.FullName, FileMode.Open, FileAccess.Read)).Segment.Attachments.AttachedFiles.Find(x => (x.FileMimeType == "image/png" || x.FileMimeType == "image/jpg") && x.FileName.Contains("cover")) == null) { log(@"Thumbnailing """ + files.Name + @"""", msgType.message); set_thumbnail_task = Task.Run(() => Poster.SetFileThumbnail(files.FullName)); set_thumbnail_task.Wait(); } break; case ".mp4": log(@"Need to muxe """ + files.Name + @"""", msgType.message); set_thumbnail_task = Task.Run(() => Poster.SetFileThumbnail(files.FullName)); set_thumbnail_task.Wait(); break; } } } catch (Exception) { } }
private void movie_file_poster_btn_Click(object sender, EventArgs e) { Poster.SetFileThumbnail(); }