Example #1
0
 private static IAnonymousClient Login()
 {
     try
     {
         IAnonymousClient client = Osdb.Login("en", "SolEol 0.0.8");
         return(client);
     }
     catch (Exception ex)
     {
         errorQueue.Send(new ErrorMessage {
             Message = ex.ToString(), Time = DateTime.Now
         });
         return(null);
     }
 }
Example #2
0
        private static bool DownloadShowSub(Show show, IAnonymousClient client)
        {
            try
            {
                Subtitle         sub = null;
                IList <Subtitle> subs;

                subs = client.SearchSubtitlesFromFile("eng", show.PathToFile);
                if (!subs.Any(i => i.LanguageName.Equals("English")) && show.Episode != null && show.Season != null)
                {
                    subs = client.SearchSubtitlesFromQuery("eng", show.Name, show.Season, show.Episode);
                }

                if (subs.Any(i => i.LanguageName.Equals("English") && i.SubtitleFileName.Contains(".HI.")))
                {
                    sub = subs.FirstOrDefault(i => i.LanguageName.Equals("English") && i.SubtitleFileName.Contains(".HI.") && SubsCorrect(show, i));
                }
                else if (subs.Any(i => i.LanguageName.Equals("English")))
                {
                    sub = subs.FirstOrDefault(i => i.LanguageName.Equals("English") && SubsCorrect(show, i));
                }

                if (sub != null)
                {
                    client.DownloadSubtitleToPath(Path.GetDirectoryName(show.PathToFile), sub, $"{Path.GetFileNameWithoutExtension(show.PathToFile)}.srt");
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (FormatException ex)
            {
                ShowMessageBox($"{show.Name} --- subs currenty unfindable", "SubDownloader");
                errorQueue.Send(new ErrorMessage {
                    Message = $"{show.Name} --- {ex.ToString()}", Time = DateTime.Now
                });
                FailedMovies.Add(show);

                return(false);
            }
            catch (CookComputing.XmlRpc.XmlRpcException ex)
            {
                errorQueue.Send(new ErrorMessage {
                    Message = ex.ToString(), Time = DateTime.Now
                });
                return(false);
            }
            catch (System.Net.WebException ex)
            {
                errorQueue.Send(new ErrorMessage {
                    Message = ex.ToString(), Time = DateTime.Now
                });
                return(false);
            }
            catch (Exception ex)
            {
                errorQueue.Send(new ErrorMessage {
                    Message = ex.ToString(), Time = DateTime.Now
                });
                client = null;
                return(false);
            }
        }
Example #3
0
 public OSDBService(string clientVersionStr = "")
 {
     client = Osdb.Login("en", "opensubsearch v0.1 " + clientVersionStr);
     timer  = new Timer(OnTimeout, null, new TimeSpan(0, 14, 50), new TimeSpan(0, 14, 50));
 }
Example #4
0
        private static void DownloadShowList(ref IAnonymousClient client, ref List <Show> Shows, List <Show> DownloadedShows, MessageQueue messageQueue)
        {
            int j = 0;

            while (Shows.Count != 0)
            {
                string output   = "";
                var    messages = messageQueue.GetAllMessages();
                if (messages.Length > 0)
                {
                    output += "Added to search:\n";
                    foreach (var message in messages)
                    {
                        var temp = (Show)message.Body;
                        if (Shows.Contains(temp))
                        {
                            continue;
                        }
                        else
                        {
                            Shows.Add(temp);
                            output += Shows.Last().OutputName();
                        }
                    }
                    if (!output.Equals("Added to search:\n"))
                    {
                        ShowMessageBox(output, "SubDownloader");
                    }
                    output = "";
                }
                messageQueue.Purge();

                DownloadedShows.Clear();
                foreach (var show in Shows)
                {
                    j = 0;
                    while (client == null)
                    {
                        if (j++ > 100)
                        {
                            Thread.Sleep(new TimeSpan(0, 10, 0));
                            j = 0;
                            ShowMessageBox("Connectivity problems\nWaiting 10 minutes", "SubDownloader");
                        }
                        Thread.Sleep(500);
                        client = Login();
                    }

                    if (DownloadShowSub(show, client))
                    {
                        DownloadedShows.Add(show);
                    }
                    else if (show.Season == null && show.Episode == null)
                    {
                        FailedMovies.Add(show);
                    }
                }
                Shows = Shows.Except(DownloadedShows).ToList();
                Shows = Shows.Except(FailedMovies).ToList();

                if (DownloadedShows.Count == 0 && Shows.Count == 0 && FailedMovies.Count > 0)
                {
                    output += "Failed to find subs for:\n";
                    foreach (var s in FailedMovies)
                    {
                        output += s.OutputName();
                    }
                    ShowMessageBox(output, "SubDownloader");
                }

                if (DownloadedShows.Count > 0)
                {
                    if (FailedMovies.Count > 0)
                    {
                        output += "Failed to find subs for:\n";
                        foreach (var s in FailedMovies)
                        {
                            output += s.OutputName();
                        }
                    }
                    FailedMovies.Clear();
                    output += "Downloaded subs for:\n";
                    foreach (var s in DownloadedShows)
                    {
                        output += s.OutputName();
                    }
                    if (Shows.Count > 0)
                    {
                        output += "Still searching in the background for:\n";
                        foreach (var s in Shows)
                        {
                            output += s.OutputName();
                        }
                    }
                    ShowMessageBox(output, "SubDownloader");
                }
                if (FailedMovies.Count > 0)
                {
                    output += "Failed to find subs for:\n";
                    foreach (var s in FailedMovies)
                    {
                        output += s.OutputName();
                    }
                }
                FailedMovies.Clear();
                if (Shows.Count > 0)
                {
                    Thread.Sleep(new TimeSpan(0, 2, 0));
                }
            }
        }
 static CrowdinClient()
 {
     anonymous = new AnonymousClient(new CrowdinHelperAnonymous());
 }
 static CrowdinClient()
 {
     anonymous = new AnonymousClient(new CrowdinHelperAnonymous());
 }
 public OpenSubtitleResult(Subtitle subtitle, CultureInfo language, IAnonymousClient client)
 {
     _subtitle = subtitle;
     _language = language;
     _client = client;
 }
Example #8
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OpenSubtitlesDb"/> class.
 /// </summary>
 public OpenSubtitlesDb()
 {
     this.client = Osdb.Login("en", agent);
 }
Example #9
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OpenSubtitlesDb"/> class.
 /// </summary>
 public OpenSubtitlesDb()
 {
     this.client = Osdb.Login("en", agent);
 }