public void SaveSubtitleFile(Subtitle subtitle)
 {
     var dir = Path.GetDirectoryName(MediaFilename);
     var subFile = string.Format(Subtitle.FileNameFormat, Path.GetFileNameWithoutExtension(MediaFilename), subtitle.Lang);
     var fullPath = Path.Combine(dir, subFile);
     var subs = this.FetchSubtitleText(subtitle);
     if (string.IsNullOrWhiteSpace(subs))
         throw new Exception("Empty Subtitle");
     var subtitleLines = subs.Split(new[] {"\n"}, StringSplitOptions.RemoveEmptyEntries);
     File.WriteAllLines(@fullPath, subtitleLines);
 }
 private List<Subtitle> parseSubtitlesResponse(string subs)
 {
     var subList = new List<Subtitle>();
     var subtitle = new Subtitle(this);
     foreach (var line in subs.Split(new[] {"\n"}, StringSplitOptions.RemoveEmptyEntries))
     {
         if (line.StartsWith("ticket="))
         {
             LastTicket = GetValue(line);
         }
         else if (line.StartsWith("movie="))
         {
             var value = GetValue(line);
             subtitle.Movie = value.Remove(value.Length - 1);
         }
         else if (line.StartsWith("subtitle="))
         {
             subtitle.ID = int.Parse(GetValue(line));
         }
         else if (line.StartsWith("language="))
         {
             subtitle.Lang = GetValue(line);
         }
         else if (line.StartsWith("name="))
         {
             subtitle.Name = GetValue(line);
         }
         else if (line.Equals("endsubtitle"))
         {
             subList.Add(subtitle);
             subtitle = new Subtitle(this);
         }
     }
     return subList;
 }
 public string FetchSubtitleText(Subtitle subtitle)
 {
     var url = string.Format(OSDlSub, subtitle.ID, LastTicket);
     string sub = DoRequest(url);
     if (string.IsNullOrEmpty(sub))
     {
         throw new EmptyResponseException();
     }
     return sub;
 }