Esempio n. 1
0
        public ActionResult SubtitleInfo(FormCollection formData, SubtitleFile file)
        {
            String strComment = formData["CommentText"];

            if (!String.IsNullOrEmpty(strComment))
            {
                SubtitleComment c = new SubtitleComment();

                c.commentText = strComment;
                String strUser = System.Security.Principal.WindowsIdentity.GetCurrent().Name;

                if (!String.IsNullOrEmpty(strUser))
                {
                    int slashPos = strUser.IndexOf("\\");
                    if (slashPos != -1)
                    {
                        strUser = strUser.Substring(slashPos + 1);
                    }
                    c.SubtitleFileID = file.ID;
                    c.username       = strUser;
                    SubtitleRepository.Instance.AddComment(c);
                }
                else
                {
                    c.username = "******";
                }
                return(RedirectToAction("SubtitleInfo"));
            }
            else
            {
                ModelState.AddModelError("CommentText", "Comment text cannot be empty!");
                return(Index());
            }
        }
Esempio n. 2
0
        public static List <SubtitleFile> IndexSubtitles(string filepath)
        {
            var filename   = Path.GetFileNameWithoutExtension(filepath);
            var files      = FindFiles(Path.GetDirectoryName(filepath) !, $"*{filename}.*", "srt", "vtt");
            var uniqueSubs = new Dictionary <string, SubtitleFile>();

            foreach (var file in files)
            {
                var vtt = file.Replace(".srt", ".vtt");

                if (uniqueSubs.ContainsKey(vtt))
                {
                    continue;
                }

                if (!File.Exists(vtt))
                {
                    Utils.Srt2Vtt(file, vtt);
                }
                var language = Utils.GetSubtitleLanguage(vtt);

                var fileInfo = new FileInfo(vtt);
                uniqueSubs[vtt] = new SubtitleFile
                {
                    Path          = vtt,
                    Language      = language,
                    FileSizeBytes = fileInfo.Length,
                    LastWrite     = fileInfo.LastWriteTimeUtc
                };
            }

            return(uniqueSubs.Values.ToList());
        }
Esempio n. 3
0
        public MainWindow()
        {
            InitializeComponent();
            f = new SubtitleFile();
            s = new SelectWindow(pathFile, pathSub);
            controlPanel.Opacity = 0.1;
            media.LoadedBehavior = MediaState.Stop;
            media.Volume         = (double)volumeSlider.Value;
            text.Foreground      = Brushes.White;
            text.FontSize        = 36;
            text.TextAlignment   = TextAlignment.Center;
            text.TextWrapping    = TextWrapping.WrapWithOverflow;
            s.ShowDialog();
            if (pathSub != s.pathSubtitle && s.pathSubtitle != null)
            {
                pathSub = s.pathSubtitle;
            }
            if (pathFile != s.pathFile && s.pathFile != null)
            {
                pathFile = s.pathFile;
            }

            media.Source = new Uri(pathFile);
            f.ReadFile(pathSub);
        }
Esempio n. 4
0
 public void WriteFile(SubtitleFile file)
 {
     using (var stream = _fileWriter.OpenWrite(file.Path))
     {
         WriteStream(stream, file.SubtitleItems);
     }
 }
Esempio n. 5
0
        // The result of the Like-button
        public ActionResult UpvoteSubtitle(int subtitleFileID)
        {
            // Checks whether an upvote with the same username and SubtitleFile ID exists.
            // Return null otherwise.
            Upvote u = SubtitleRepository.Instance.GetUpvoteByID(subtitleFileID);

            // Retrieves the subtitle with the given ID.
            SubtitleFile subtitle = SubtitleRepository.Instance.GetSubtitleByID(subtitleFileID);

            // Removes the upvote if it exists
            if (u != null)
            {
                SubtitleRepository.Instance.RemoveUpvote(u);
                subtitle.upvote--;
                SubtitleRepository.Instance.Save();
            }
            // Creates a new one otherwise.
            else
            {
                SubtitleRepository.Instance.AddUpvote(new Upvote
                {
                    SubtitleFileID    = subtitleFileID,
                    applicationUserID = System.Security.Principal.WindowsIdentity.GetCurrent().Name
                });
                subtitle.upvote++;
                SubtitleRepository.Instance.Save();
            }

            return(RedirectToAction("Index"));
        }
 private void MarkSubtitlesAsSelected(SubtitleFile subtitles)
 {
     foreach (var sub in videoItem.SubtitleFiles)
     {
         sub.IsSelected = false;
     }
     subtitles.IsSelected = true;
 }
        private void SubtitleFileTapped(object item)
        {
            var file = item as FileItem;
            var subs = videoItem.SubtitleFiles.FirstOrDefault(x => x.FilePath == file.Path);

            if (subs == null)
            {
                subs = new SubtitleFile(file.Path, videoItem.VideoId);
                //string charset = "";
                //using (var fs = System.IO.File.OpenRead(file.Path))
                //{
                //    Ude.CharsetDetector cdet = new Ude.CharsetDetector();
                //    cdet.Feed(fs);
                //    cdet.DataEnd();
                //    if (cdet.Charset != null)
                //    {
                //        charset = cdet.Charset;
                //        App.DebugLog($"Charset: {cdet.Charset}, confidence: {cdet.Confidence}");
                //    }
                //    else
                //    {
                //        App.DebugLog("Detection failed.");
                //    }
                //}
                //if (charset != "")
                //{
                //    Encoding enc = Encoding.UTF8;
                //    try
                //    {
                //        enc = Encoding.GetEncoding(charset);
                //    }
                //    catch(Exception ex)
                //    {

                //    }
                //    if( enc!= Encoding.UTF8)
                //    {
                //        string fs2 = System.IO.File.ReadAllText(file.Path, enc);
                //        var cacheDir = Xamarin.Essentials.FileSystem.CacheDirectory;
                //        string filePath = System.IO.Path.Combine(cacheDir, file.Name);
                //        System.IO.File.WriteAllText(filePath, fs2);
                //        subs = new SubtitleFile(filePath, videoItem.VideoId);
                //    }
                //}
                videoItem.SubtitleFiles.Add(subs);
            }
            MarkSubtitlesAsSelected(subs);
            var config = BuildStartupConfiguration();

            vlcPlayerHelper.Reset(config);

            FilePickerVM.IsOpen = false;
        }
Esempio n. 8
0
        public static ExtraFileResource ToResource(this SubtitleFile model)
        {
            if (model == null)
            {
                return(null);
            }

            return(new ExtraFileResource
            {
                Id = model.Id,
                MovieId = model.MovieId,
                MovieFileId = model.MovieFileId,
                RelativePath = model.RelativePath,
                Extension = model.Extension,
                Type = ExtraFileType.Subtitle
            });
        }
Esempio n. 9
0
        public ActionResult AddRequest(FormCollection form)
        {
            // Values for dropdown list declared.
            List <SelectListItem> subtitleCategory = new List <SelectListItem>();

            subtitleCategory.Add(new SelectListItem {
                Text = "Velja tegund", Value = ""
            });
            subtitleCategory.Add(new SelectListItem {
                Text = "Barnaefni", Value = "Barnaefni"
            });
            subtitleCategory.Add(new SelectListItem {
                Text = "Drama", Value = "Drama"
            });
            subtitleCategory.Add(new SelectListItem {
                Text = "Gamanmyndir", Value = "Gamanmyndir"
            });
            subtitleCategory.Add(new SelectListItem {
                Text = "Hryllingsmyndir", Value = "Hryllingsmyndir"
            });
            subtitleCategory.Add(new SelectListItem {
                Text = "Rómantík", Value = "Rómantík"
            });
            subtitleCategory.Add(new SelectListItem {
                Text = "Spennumyndir", Value = "Spennumyndir"
            });
            subtitleCategory.Add(new SelectListItem {
                Text = "Ævintýramyndir", Value = "Ævintýramyndir"
            });
            subtitleCategory.Add(new SelectListItem {
                Text = "Þættir", Value = "Þættir"
            });

            ViewData["Categories"] = subtitleCategory;

            // The SubtitleFile data from view added to database.
            SubtitleFile item = new SubtitleFile();

            UpdateModel(item);
            item.state = State.Request;
            repo.AddSubtitle(item);
            repo.Save();

            // The user is redirected to the Index page when done.
            return(RedirectToAction("Index"));
        }
Esempio n. 10
0
        static void Main(string[] args)
        {
            //Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            if (args.Length >= 1)
            {
                //SubtitleFile subfile = new SubtitleFile("F:\\hdrip\\hb.sup");
                //subfile.WriteBitmap("c:\\temp\\test.png", 20);
                SubtitleFile subfile = new SubtitleFile(args[0]);
                int nb = 20;
                if (args.Length >= 2)
                    nb = Int32.Parse(args[1]);

                int spacing = 100;
                if (args.Length >= 3)
                    spacing = Int32.Parse(args[2]);

                try
                {
                    subfile.WriteBitmaps(args[0], nb, spacing);
                }
                catch (Exception e)
                {
                    Console.WriteLine("exception " + e.Message);
                }
            }
            else
            {

            #if DEBUG
                Application.Run(new MainForm());
            #else
                try
                {
                    Application.Run(new MainForm());
                }
                catch (Exception e)
                {
                    ErrorForm form = new ErrorForm(e);
                    form.ShowDialog();
                }
            #endif
            }
        }
Esempio n. 11
0
        private string SaveSubtitleFiles(SubtitlesFileUploadViewModel form)
        {
            HttpPostedFileBase fiFile = form.FinnishSubtitleFile;
            HttpPostedFileBase enFile = form.EnglishSubtitleFile;


            string fiFullPath = Path.Combine(Server.MapPath(FILE_PATH), fiFile.FileName);
            string enFullPath = Path.Combine(Server.MapPath(FILE_PATH), enFile.FileName);

            fiFile.SaveAs(fiFullPath);
            enFile.SaveAs(enFullPath);

            SubtitleFile fiSubFile = new SubtitleFile();

            fiSubFile.Filename   = fiFile.FileName;
            fiSubFile.LanguageID = FI;

            int fiID = (int)fiSubFile.Insert();

            SubtitleFile enSubFile = new SubtitleFile();

            enSubFile.Filename   = enFile.FileName;
            enSubFile.LanguageID = EN;

            int enID = (int)enSubFile.Insert();

            string subLink = "";

            {
                subLink = RandomString(5);
            } while (SubtitleCompare.Exists("WHERE Link=@0", subLink))
            {
                ;
            }

            SubtitleCompare compare = new SubtitleCompare();

            compare.Link          = subLink;
            compare.SubtitleFileA = Math.Min(fiID, enID);
            compare.SubtitleFileB = Math.Max(fiID, enID);
            compare.Title         = "Title";
            compare.Insert();

            return(subLink);
        }
Esempio n. 12
0
        public MergeResult MergeSubtitles(SubtitleFile file1, SubtitleFile file2)
        {
            _subtitleColorizer.Colorize(file1, file2);

            List <SubtitleItem> mergedSubs = _subtitleMerger.MergeSubtitles(file1.SubtitleItems, file2.SubtitleItems,
                                                                            out var totaShift, out var averageShift);

            return(new MergeResult
            {
                File = new SubtitleFile
                {
                    Path = _filenameMerger.GetMergeFilename(file1.Path),
                    SubtitleItems = mergedSubs,
                },
                AverageShift = averageShift,
                TotalShift = totaShift,
            });
        }
Esempio n. 13
0
        public void Colorize(SubtitleFile file1, SubtitleFile file2)
        {
            var fileToColorize = (file1.Lang, file2.Lang) switch
            {
                (Language.VN, Language.UNKNOWN) => file1,
                (Language.UNKNOWN, Language.VN) => file2,
                _ => file1
            };

            foreach (var item in fileToColorize.SubtitleItems)
            {
                if (!item.Lines[0].StartsWith(_openingTag))
                {
                    item.Lines[0] = _openingTag + item.Lines[0];
                    item.Lines[item.Lines.Count - 1] += "</font>";
                }
            }
        }
Esempio n. 14
0
        public ActionResult Compare(string id)
        {
            SubtitleCompare st = SubtitleCompare.SingleOrDefault("WHERE Link=@0", id);

            if (st == null || st.SubtitleFileA == 0 || st.SubtitleFileB == 0)
            {
                return(RedirectToAction("Index"));
            }

            SubtitleFile A = SubtitleFile.FirstOrDefault("WHERE ID=@0", st.SubtitleFileA);
            SubtitleFile B = SubtitleFile.FirstOrDefault("WHERE ID=@0", st.SubtitleFileB);

            SubtitleFile fiFile     = A.LanguageID == FI ? A : B;
            string       fiFullPath = Path.Combine(Server.MapPath(FILE_PATH), fiFile.Filename);
            SubtitleFile enFile     = A.LanguageID == EN ? A : B;
            string       enFullPath = Path.Combine(Server.MapPath(FILE_PATH), enFile.Filename);

            if (!System.IO.File.Exists(fiFullPath) || !System.IO.File.Exists(enFullPath))
            {
                return(HttpNotFound("File not found on server."));
            }

            string       fiFileContent = System.IO.File.ReadAllText(fiFullPath, Encoding.GetEncoding(1250));
            SubtitleList fiSubList     = srtToSubtitleList(fiFileContent);


            string       enFileContent = System.IO.File.ReadAllText(enFullPath, Encoding.GetEncoding(1250));
            SubtitleList enSubList     = srtToSubtitleList(enFileContent);

            fiSubList.CompareTo(enSubList);
            // send to 'compare'

            SubtitleCompareVM vm = new SubtitleCompareVM();

            vm.leftList  = fiSubList;
            vm.rightList = enSubList;

            return(View("Compare", vm));
        }
Esempio n. 15
0
        private void LoadSubtitleFile(string fileName)
        {
            SubtitleFile newSubFile;

            try
            {
                newSubFile = new SubtitleFile(fileName);
                //subfile.SaveXml("c:\\temp\\test.xml");
            }
            catch (SUPFileFormatException)
            {
                MessageBox.Show("Couldn't open the file\n" + fileName + ".\nMaybe it's not a BluRay .sup file?\nStandard resolution DVD and HD DVD subtitles aren't supported.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                newSubFile = null;
            }
            catch (IOException e)
            {
                MessageBox.Show("Couldn't open the file\n" + fileName + "\nbecause of \n" + e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                newSubFile = null;
            }
            catch (Exception e)
            {
                ErrorForm form = new ErrorForm(e);
                form.ShowDialog();
                newSubFile = null;
            }

            if (newSubFile != null)
            {
                //If the new file has been loaded successfully, dispose of the old one
                if (subfile != null)
                    subfile.Close();
                subfile = newSubFile;

                nextButton.Enabled = true;
                previousButton.Enabled = true;
                autoOCRButton.Enabled = true;
                ocrButton.Enabled = true;
                letterOKButton.Enabled = true;
                saveButton.Enabled = true;

                subtitleType.Text = "Bluray";
                /*else if (subfile.Type == SubtitleFile.SubtitleType.Scenarist)
                    subtitleType.Text = "Scenarist";*/

                currentNum = 0;
            #if DEBUG
                currentNum = 17;
            #endif
                currentSubtitle = LoadSubtitleImage(currentNum);
                UpdateTextBox();
                totalPages.Text = "/ " + subfile.NumSubtitles;
                UpdateBitmaps();

                // Update the window title
                Text = "SupRip " + version + " - " + fileName.Substring(fileName.LastIndexOf('\\') + 1);
            }
        }
        /// <summary>
        /// Extracts all downloaded archives and moves subtitles to the movie files with proper naming
        /// </summary>
        /// <param name="i">Index of the temporary directory in which subtitles are stored. Temp Directory PROVIDER_NAME_KEY is "TEMP"+i</param>
        public void ProcessSubtitles(int i)
        {
            string        folder     = Helper.ReadProperty(ConfigKeyConstants.LAST_DIRECTORY_KEY) + "TEMP" + i.ToString();
            List <string> extensions = new List <string>(Helper.ReadProperties(ConfigKeyConstants.SUBTITLE_FILE_EXTENSIONS_KEY, true));

            if (extensions == null)
            {
                Logger.Instance.LogMessage("No Subtitle Extensions found!", LogLevel.WARNING);
                return;
            }

            if (Directory.Exists(folder))
            {
                extractArchives(folder, extensions);
                //now that everything is extracted, try to assign subtitles to episodes
                //first, figure out episode and season numbers from filenames

                //scan for subtitle files in temp folder
                List <FileSystemInfo> Files = new List <FileSystemInfo>();
                int count = 0;
                foreach (string ex in extensions)
                {
                    List <FileSystemInfo> fsi = Helper.GetAllFilesRecursively(folder, "*." + ex, ref count, null);
                    Files.AddRange(fsi);
                }
                string[] patterns = Helper.ReadProperties(ConfigKeyConstants.EPISODE_IDENTIFIER_PATTERNS_KEY);
                foreach (FileSystemInfo file in Files)
                {
                    int Season  = -1;
                    int Episode = -1;
                    foreach (string str in patterns)
                    {
                        //replace %S and %E by proper regexps
                        string pattern = RegexConverter.toRegex(str);
                        Match  m       = Regex.Match(file.Name, pattern, RegexOptions.IgnoreCase | RegexOptions.RightToLeft);
                        if (m.Success)
                        {
                            try {
                                Season = Int32.Parse(m.Groups["Season"].Value);
                            }
                            catch (FormatException) {
                                Logger.Instance.LogMessage("Cannot parse " + m.Groups["Season"].Value + " to an integer", LogLevel.WARNING);
                            }
                            try {
                                Episode = Int32.Parse(m.Groups["Episode"].Value);
                            }
                            catch (FormatException) {
                                Logger.Instance.LogMessage("Cannot parse " + m.Groups["Episode"].Value + " to an integer", LogLevel.WARNING);
                            }
                            break;
                        }
                    }

                    //now that season and episode are known, assign the configurationFilePath to a SubtitleFile object
                    bool contains = false;
                    foreach (SubtitleFile s in this.subtitles)
                    {
                        if (Season != -1 && Episode != -1 && s.Episode == Episode && s.Season == Season)
                        {
                            s.Filenames.Add(file.Name);
                            contains = true;
                        }
                    }
                    if (!contains)
                    {
                        SubtitleFile sf = new SubtitleFile();
                        sf.Episode = Episode;
                        sf.Season  = Season;
                        sf.Filenames.Add(file.Name);
                        this.subtitles.Add(sf);
                    }
                }
                int MatchedSubtitles = 0;
                //Move subtitle files to their video files
                foreach (MediaFile ie in MediaFileManager.Instance)
                {
                    List <string> ext = new List <string>(Helper.ReadProperties(ConfigKeyConstants.VIDEO_FILE_EXTENSIONS_KEY));
                    for (int b = 0; b < ext.Count; b++)
                    {
                        ext[b] = ext[b].ToLower();
                    }
                    if (ext.Contains(Path.GetExtension(ie.Filename).Substring(1).ToLower()) && ie.ProcessingRequested && ie.EpisodeNr != -1 && ie.SeasonNr != -1)
                    {
                        foreach (SubtitleFile sf in this.subtitles)
                        {
                            if (sf.Season == ie.SeasonNr && sf.Episode == ie.EpisodeNr)
                            {
                                bool   move   = false;
                                string source = "";
                                string target = ie.FilePath.Path + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(ie.Filename) + Path.GetExtension(sf.Filenames[0]);
                                if (sf.Filenames.Count == 1)
                                {
                                    move   = true;
                                    source = folder + Path.DirectorySeparatorChar + sf.Filenames[0];
                                }
                                else
                                {
                                    FileSelector fs = new FileSelector(sf.Filenames);
                                    if (fs.ShowDialog() == DialogResult.OK)
                                    {
                                        move   = true;
                                        source = folder + Path.DirectorySeparatorChar + sf.Filenames[fs.selection];
                                    }
                                }

                                if (File.Exists(target))
                                {
                                    if (MessageBox.Show(target + " already exists. Overwrite?", "Overwrite?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes)
                                    {
                                        File.Delete(target);
                                    }
                                    else
                                    {
                                        move = false;
                                    }
                                }
                                if (move)
                                {
                                    try {
                                        File.Copy(source, target);
                                        MatchedSubtitles++;
                                    }
                                    catch (Exception ex) {
                                        Logger.Instance.LogMessage(source + " --> " + target + ": " + ex.Message, LogLevel.ERROR);
                                    }
                                }
                            }
                        }
                    }
                }
                Logger.Instance.LogMessage("Downloaded " + Files.Count + " subtitles and matched " + MatchedSubtitles + " of them.", LogLevel.INFO);
                //cleanup
                this.subtitles.Clear();
                Directory.Delete(folder, true);
                //updateCandidateFiles(true);
            }
        }
Esempio n. 17
0
        public ActionResult AddSubtitle(HttpPostedFileBase file)
        {
            // List of categories that work
            List <SelectListItem> subtitleCategory = new List <SelectListItem>();

            subtitleCategory.Add(new SelectListItem {
                Text = "Velja tegund", Value = ""
            });
            subtitleCategory.Add(new SelectListItem {
                Text = "Barnaefni", Value = "Barnaefni"
            });
            subtitleCategory.Add(new SelectListItem {
                Text = "Drama", Value = "Drama"
            });
            subtitleCategory.Add(new SelectListItem {
                Text = "Gamanmyndir", Value = "Gamanmyndir"
            });
            subtitleCategory.Add(new SelectListItem {
                Text = "Hryllingsmyndir", Value = "Hryllingsmyndir"
            });
            subtitleCategory.Add(new SelectListItem {
                Text = "Rómantík", Value = "Rómantík"
            });
            subtitleCategory.Add(new SelectListItem {
                Text = "Spennumyndir", Value = "Spennumyndir"
            });
            subtitleCategory.Add(new SelectListItem {
                Text = "Ævintýramyndir", Value = "Ævintýramyndir"
            });
            subtitleCategory.Add(new SelectListItem {
                Text = "Þættir", Value = "Þættir"
            });

            ViewData["Categories"] = subtitleCategory;
            // If the upload is valid
            if (ModelState.IsValid)
            {
                if (file == null)
                {
                    ModelState.AddModelError("File", "Vinsamlegast bættu við .srt skrá");
                }
                else if (file.ContentLength > 0)
                {
                    // If file is larger than 0, but smaller than 3 Mb.
                    int      MaxContentLength      = 1024 * 1024 * 3; //3 MB
                    string[] AllowedFileExtensions = new string[] { ".srt" };

                    if (!AllowedFileExtensions.Contains(file.FileName.Substring(file.FileName.LastIndexOf('.'))))
                    {
                        ModelState.AddModelError("File", "Vinsamlegast eingöngu skrá af gerðini: " + string.Join(", ", AllowedFileExtensions));
                    }

                    else if (file.ContentLength > MaxContentLength)
                    {
                        ModelState.AddModelError("File", "Skráin þín er of stór, vinsamlegast ekki stærri en: " + MaxContentLength + " MB");
                    }
                    else
                    {
                        //TO:DO
                        // Streamreader reads in all data from the file and puts in the variable srtContent.
                        string srtContent = null;
                        using (StreamReader sr = new StreamReader(file.InputStream, Encoding.Default, true))
                        {
                            string line;
                            while ((line = sr.ReadLine()) != null)
                            {
                                // Takes each line and adds a \n after each to create a new one.
                                srtContent += line + '\n';
                            }
                        }
                        // Creates a new instance of SubtitleFile
                        SubtitleFile item = new SubtitleFile();
                        UpdateModel(item);
                        item.state = State.Edit;
                        // Puts file into an Edit state
                        item.SubtitleText = srtContent;
                        // The table data in subtitleText is updated ti srtContent
                        item.name = char.ToUpper(item.name[0]) + item.name.Substring(1);
                        // Puts each new name of subtitle to uppercase as first letter.
                        repo.AddSubtitle(item);
                        repo.Save();
                        // Saves the repository.
                        ModelState.Clear();

                        ViewBag.Message = "Viðbæting skráar gekk eins og í sögu.";
                    }
                }
            }
            return(View());
        }
        /// <summary>
        /// Extracts all downloaded archives and moves subtitles to the movie files with proper naming
        /// </summary>
        /// <param name="i">Index of the temporary directory in which subtitles are stored. Temp Directory PROVIDER_NAME_KEY is "TEMP"+i</param>
        public void ProcessSubtitles(int i)
        {
            string folder = Helper.ReadProperty(ConfigKeyConstants.LAST_DIRECTORY_KEY) + "TEMP" + i.ToString();
            List<string> extensions = new List<string>(Helper.ReadProperties(ConfigKeyConstants.SUBTITLE_FILE_EXTENSIONS_KEY, true));
            if (extensions == null) {
                Logger.Instance.LogMessage("No Subtitle Extensions found!", LogLevel.WARNING);
                return;
            }

            if (Directory.Exists(folder)) {

                extractArchives(folder, extensions);
                //now that everything is extracted, try to assign subtitles to episodes
                //first, figure out episode and season numbers from filenames

                //scan for subtitle files in temp folder
                List<FileSystemInfo> Files = new List<FileSystemInfo>();
                int count = 0;
                foreach (string ex in extensions) {
                    List<FileSystemInfo> fsi = Helper.GetAllFilesRecursively(folder, "*." + ex, ref count, null);
                    Files.AddRange(fsi);
                }
                string[] patterns = Helper.ReadProperties(ConfigKeyConstants.EPISODE_IDENTIFIER_PATTERNS_KEY);
                foreach (FileSystemInfo file in Files) {
                    int Season = -1;
                    int Episode = -1;
                    foreach (string str in patterns) {
                        //replace %S and %E by proper regexps
                        string pattern = RegexConverter.toRegex(str);
                        Match m = Regex.Match(file.Name, pattern, RegexOptions.IgnoreCase | RegexOptions.RightToLeft);
                        if (m.Success) {

                            try {
                                Season = Int32.Parse(m.Groups["Season"].Value);
                            }
                            catch (FormatException) {
                                Logger.Instance.LogMessage("Cannot parse " + m.Groups["Season"].Value + " to an integer", LogLevel.WARNING);
                            }
                            try {
                                Episode = Int32.Parse(m.Groups["Episode"].Value);
                            }
                            catch (FormatException) {
                                Logger.Instance.LogMessage("Cannot parse " + m.Groups["Episode"].Value + " to an integer", LogLevel.WARNING);
                            }
                            break;
                        }
                    }

                    //now that season and episode are known, assign the configurationFilePath to a SubtitleFile object
                    bool contains = false;
                    foreach (SubtitleFile s in this.subtitles) {
                        if (Season != -1 && Episode != -1 && s.Episode == Episode && s.Season == Season) {
                            s.Filenames.Add(file.Name);
                            contains = true;
                        }
                    }
                    if (!contains) {
                        SubtitleFile sf = new SubtitleFile();
                        sf.Episode = Episode;
                        sf.Season = Season;
                        sf.Filenames.Add(file.Name);
                        this.subtitles.Add(sf);
                    }
                }
                int MatchedSubtitles = 0;
                //Move subtitle files to their video files
                foreach (MediaFile ie in MediaFileManager.Instance) {
                    List<string> ext = new List<string>(Helper.ReadProperties(ConfigKeyConstants.VIDEO_FILE_EXTENSIONS_KEY));
                    for (int b = 0; b < ext.Count; b++) {
                        ext[b] = ext[b].ToLower();
                    }
                    if (ext.Contains(Path.GetExtension(ie.Filename).Substring(1).ToLower()) && ie.ProcessingRequested && ie.EpisodeNr != -1 && ie.SeasonNr != -1) {
                        foreach (SubtitleFile sf in this.subtitles) {
                            if (sf.Season == ie.SeasonNr && sf.Episode == ie.EpisodeNr) {
                                bool move = false;
                                string source = "";
                                string target = ie.FilePath.Path + Path.DirectorySeparatorChar + Path.GetFileNameWithoutExtension(ie.Filename) + Path.GetExtension(sf.Filenames[0]);
                                if (sf.Filenames.Count == 1) {
                                    move = true;
                                    source = folder + Path.DirectorySeparatorChar + sf.Filenames[0];
                                }
                                else {
                                    FileSelector fs = new FileSelector(sf.Filenames);
                                    if (fs.ShowDialog() == DialogResult.OK) {
                                        move = true;
                                        source = folder + Path.DirectorySeparatorChar + sf.Filenames[fs.selection];
                                    }
                                }

                                if (File.Exists(target)) {
                                    if (MessageBox.Show(target + " already exists. Overwrite?", "Overwrite?", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) {
                                        File.Delete(target);
                                    }
                                    else {
                                        move = false;
                                    }
                                }
                                if (move) {
                                    try {
                                        File.Copy(source, target);
                                        MatchedSubtitles++;
                                    }
                                    catch (Exception ex) {
                                        Logger.Instance.LogMessage(source + " --> " + target + ": " + ex.Message, LogLevel.ERROR);
                                    }
                                }
                            }
                        }
                    }
                }
                Logger.Instance.LogMessage("Downloaded " + Files.Count + " subtitles and matched " + MatchedSubtitles + " of them.", LogLevel.INFO);
                //cleanup
                this.subtitles.Clear();
                Directory.Delete(folder, true);
                //updateCandidateFiles(true);
            }
        }