Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compute OpenSubtitles Hash From Torrent File #702

Open
xDreamms opened this issue Oct 17, 2024 · 3 comments
Open

Compute OpenSubtitles Hash From Torrent File #702

xDreamms opened this issue Oct 17, 2024 · 3 comments

Comments

@xDreamms
Copy link

Is it possible? If so how can I do that?

@sakib1361
Copy link

Its possible. You would use the streaming output.
From the stream, you can use the following logic to compute Opensub hash.
`
//From Sample code.
var manager = await Engine.AddStreamingAsync (link, "downloads");
var stream = await manager.StreamProvider.CreateStreamAsync (largestFile, false);

private string ComputeMovieHash(Stream input, long length = -1)
{

long lhash, streamsize;
streamsize = input.Length;
lhash = length == -1 ? streamsize : length;

long i = 0;
var buffer = new byte[sizeof(long)];
while (i < 65536 / sizeof(long) && (input.Read(buffer, 0, sizeof(long)) > 0))
{
    i++;
    lhash += BitConverter.ToInt64(buffer, 0);
}

input.Position = Math.Max(0, streamsize - 65536);
i = 0;
while (i < 65536 / sizeof(long) && (input.Read(buffer, 0, sizeof(long)) > 0))
{
    i++;
    lhash += BitConverter.ToInt64(buffer, 0);
}

var result = BitConverter.GetBytes(lhash);
Array.Reverse(result);
var stringBuilder = new StringBuilder();
for (var counter = 0; counter < result.Length; counter++)
{
    _=stringBuilder.Append(result[counter].ToString("x2"));
}

return stringBuilder.ToString();

}`
N.B the code was made by me but comes with 0 testing and maybe outdated. My player uses both filename, year and hash so I can't say now which works. :)

@xDreamms
Copy link
Author

Not working application freezes

@sakib1361
Copy link

Would you please provide a sample application/repo to see what’s not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants