Ejemplo n.º 1
0
        protected override string DoDownloadSubtitle(string fileName, SubtitleInfo si)
        {
            OPMedia.Runtime.ProTONE.NuSoap.SubtitleDownload sd = new OPMedia.Runtime.ProTONE.NuSoap.SubtitleDownload();
            int x = 0;

            int.TryParse(si.IDSubtitleFile, out x);

            sd.cod_subtitle_file = x;
            sd.movie_hash        = si.MovieHash;

            string destPath = Path.ChangeExtension(fileName, si.SubFormat);

            SubtitleArchive[] archives = _wsdl.downloadSubtitles(new OPMedia.Runtime.ProTONE.NuSoap.SubtitleDownload[] { sd });

            if (archives != null && archives.Length > 0)
            {
                byte[] decodedBytes = Convert.FromBase64String(archives[0].data);

                using (MemoryStream compressedSubtitle = new MemoryStream(decodedBytes))
                {
                    using (InflaterInputStream str = new InflaterInputStream(compressedSubtitle))
                    {
                        using (FileStream outputSubtitle = new FileStream(destPath, FileMode.Create, FileAccess.Write, FileShare.Read))
                        {
                            byte[] buffer = new byte[65536];
                            int    read   = 0;
                            do
                            {
                                read = str.Read(buffer, 0, buffer.Length);
                                if (read > 0)
                                {
                                    outputSubtitle.Write(buffer, 0, read);
                                }
                            }while (read > 0);
                        }
                    }
                }

                return(destPath);
            }

            return(string.Empty);
        }
Ejemplo n.º 2
0
 /// <remarks/>
 public void downloadSubtitlesAsync(SubtitleDownload[] subtitles, object userState)
 {
     if ((this.downloadSubtitlesOperationCompleted == null))
     {
         this.downloadSubtitlesOperationCompleted = new System.Threading.SendOrPostCallback(this.OndownloadSubtitlesOperationCompleted);
     }
     this.InvokeAsync("downloadSubtitles", new object[] {
             subtitles}, this.downloadSubtitlesOperationCompleted, userState);
 }
Ejemplo n.º 3
0
 /// <remarks/>
 public void downloadSubtitlesAsync(SubtitleDownload[] subtitles)
 {
     this.downloadSubtitlesAsync(subtitles, null);
 }
Ejemplo n.º 4
0
 public SubtitleArchive[] downloadSubtitles(SubtitleDownload[] subtitles)
 {
     object[] results = this.Invoke("downloadSubtitles", new object[] {
             subtitles});
     return ((SubtitleArchive[])(results[0]));
 }
Ejemplo n.º 5
0
        protected override string DoDownloadSubtitle(string fileName, SubtitleInfo si)
        {
            OPMedia.Runtime.ProTONE.NuSoap.SubtitleDownload sd = new OPMedia.Runtime.ProTONE.NuSoap.SubtitleDownload();
            int x = 0;
            int.TryParse(si.IDSubtitleFile, out x);

            sd.cod_subtitle_file = x;
            sd.movie_hash = si.MovieHash;

            string destPath = Path.ChangeExtension(fileName, si.SubFormat);

            SubtitleArchive[] archives = _wsdl.downloadSubtitles(new OPMedia.Runtime.ProTONE.NuSoap.SubtitleDownload[] { sd });

            if (archives != null && archives.Length > 0)
            {
                byte[] decodedBytes = Convert.FromBase64String(archives[0].data);

                using (MemoryStream compressedSubtitle = new MemoryStream(decodedBytes))
                {
                    using (InflaterInputStream str = new InflaterInputStream(compressedSubtitle))
                    {
                        using (FileStream outputSubtitle = new FileStream(destPath, FileMode.Create, FileAccess.Write, FileShare.Read))
                        {
                            byte[] buffer = new byte[65536];
                            int read = 0;
                            do
                            {
                                read = str.Read(buffer, 0, buffer.Length);
                                if (read > 0)
                                {
                                    outputSubtitle.Write(buffer, 0, read);
                                }
                            }
                            while (read > 0);
                        }
                    }
                }

                return destPath;
            }

            return string.Empty;
        }