Пример #1
0
        public bool Equals(OpenSubtitles other)
        {
            if (SubHash == other.SubHash)
            {
                return(true);
            }

            return(false);
        }
Пример #2
0
        public string GetMovieHash()
        {
            string hash = null;

            using (MemoryStream ms = new MemoryStream())
            {
                status = Status.BUFFERING;
                ms.Write(FileRead(0, 65536), 0, 65536);
                ms.Write(FileRead(FileSize - 65536, 65536), 0, 65536);
                ms.Position = 0;
                status      = Status.OPENED;
                hash        = Utils.ToHexadecimal(OpenSubtitles.ComputeMovieHash(ms, FileSize));
            }

            return(hash);
        }
Пример #3
0
        public int SetMediaFile(string fileName)
        {
            Log($"File Selected {fileName}");

            if (streamType == StreamType.FILE)
            {
                int ret = decoder.Open(null, "", "", "", DecoderRequestsBuffer, fileSize);
                return(ret);
            }
            else if (streamType == StreamType.TORRENT)
            {
                Pause();

                fileIndex    = torrent.file.paths.IndexOf(fileName);
                fileSize     = torrent.file.lengths[fileIndex];
                fileDistance = 0;
                for (int i = 0; i < fileIndex; i++)
                {
                    fileDistance += torrent.file.lengths[i];
                }

                if (!torrent.data.files[fileIndex].FileCreated)
                {
                    tsStream.IncludeFiles(new List <string>()
                    {
                        fileName
                    });
                }

                if (!torrent.data.files[fileIndex].FileCreated && !tsStream.isRunning)
                {
                    tsStream.Start();
                }

                status = Status.BUFFERING;

                if (sortedPaths == null)
                {
                    sortedPaths = new List <string>();
                    foreach (var path in torrent.file.paths)
                    {
                        sortedPaths.Add(path);
                    }
                    sortedPaths.Sort(new Utils.NaturalStringComparer());
                }
                downloadNextStarted = false;

                Log($"[BB OPENING]");
                int ret = decoder.Open(null, "", "", "", DecoderRequestsBuffer, fileSize);
                if (ret != 0)
                {
                    return(ret);
                }

                Log($"[DD OPENING]");
                ret = player.decoder.Open(null, "", "", "", DecoderRequests, fileSize);
                player.decoder.video.url = fileName;

                if (ret == 0 && (player.DownloadSubs == MediaRouter.DownloadSubsMode.FilesAndTorrents || player.DownloadSubs == MediaRouter.DownloadSubsMode.Torrents))
                {
                    if (!torrent.data.files[fileIndex].FileCreated)
                    {
                        while (torrent.data.progress.GetFirst0(FilePosToPiece(0), FilePosToPiece(0 + 65536)) != -1 || torrent.data.progress.GetFirst0(FilePosToPiece(fileSize - 65536), FilePosToPiece(fileSize - 65536 + 65536)) != -1)
                        {
                            CreateFocusPoint(0, 65536);
                            CreateFocusPoint(fileSize - 65536, 65536);
                            Thread.Sleep(50);
                        }
                    }

                    using (MemoryStream ms = new MemoryStream())
                    {
                        ms.Write(torrent.data.files[fileIndex].Read(0, 65536), 0, 65536);
                        ms.Write(torrent.data.files[fileIndex].Read(fileSize - 65536, 65536), 0, 65536);
                        ms.Position = 0;

                        string hash = Utils.ToHexadecimal(OpenSubtitles.ComputeMovieHash(ms, fileSize));
                        player.FindAvailableSubs(fileName, hash, fileSize);
                    }
                }
                else if (ret == 0)
                {
                    player.OpenNextAvailableSub();
                }

                status = Status.OPENED;
                DownloadNext();

                return(ret);
            }

            return(-1);
        }